@dedot/contracts 0.12.1-next.f19f185a.2 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/Contract.d.ts +4 -4
  2. package/Contract.js +41 -6
  3. package/ContractDeployer.d.ts +2 -2
  4. package/ContractDeployer.js +8 -6
  5. package/TypinkRegistry.d.ts +29 -6
  6. package/TypinkRegistry.js +144 -24
  7. package/cjs/Contract.js +44 -9
  8. package/cjs/ContractDeployer.js +10 -8
  9. package/cjs/TypinkRegistry.js +144 -24
  10. package/cjs/errors.js +3 -3
  11. package/cjs/executor/ConstructorQueryExecutor.js +49 -9
  12. package/cjs/executor/ConstructorTxExecutor.js +17 -6
  13. package/cjs/executor/QueryExecutor.js +30 -5
  14. package/cjs/executor/TxExecutor.js +10 -1
  15. package/cjs/executor/abstract/ContractExecutor.js +4 -5
  16. package/cjs/executor/abstract/DeployerExecutor.js +2 -2
  17. package/cjs/index.js +1 -1
  18. package/cjs/storage/BaseLazyObject.js +25 -0
  19. package/cjs/storage/LazyMapping.js +22 -0
  20. package/cjs/storage/LazyObject.js +18 -0
  21. package/cjs/storage/LazyStorageVec.js +54 -0
  22. package/cjs/storage/index.js +19 -0
  23. package/cjs/types/index.js +3 -0
  24. package/cjs/types/v6.js +2 -0
  25. package/cjs/utils/address.js +67 -0
  26. package/cjs/utils/ensure.js +68 -0
  27. package/cjs/utils/index.js +21 -0
  28. package/cjs/utils/proxy.js +11 -0
  29. package/cjs/utils/storage.js +44 -0
  30. package/cjs/{utils.js → utils/types.js} +31 -34
  31. package/errors.js +2 -2
  32. package/executor/ConstructorQueryExecutor.js +47 -7
  33. package/executor/ConstructorTxExecutor.js +18 -7
  34. package/executor/QueryExecutor.js +27 -2
  35. package/executor/TxExecutor.js +11 -2
  36. package/executor/abstract/ContractExecutor.d.ts +3 -4
  37. package/executor/abstract/ContractExecutor.js +2 -3
  38. package/executor/abstract/DeployerExecutor.js +1 -1
  39. package/index.d.ts +1 -1
  40. package/index.js +1 -1
  41. package/package.json +7 -6
  42. package/storage/BaseLazyObject.d.ts +10 -0
  43. package/storage/BaseLazyObject.js +21 -0
  44. package/storage/LazyMapping.d.ts +4 -0
  45. package/storage/LazyMapping.js +18 -0
  46. package/storage/LazyObject.d.ts +4 -0
  47. package/storage/LazyObject.js +14 -0
  48. package/storage/LazyStorageVec.d.ts +5 -0
  49. package/storage/LazyStorageVec.js +27 -0
  50. package/storage/index.d.ts +3 -0
  51. package/storage/index.js +3 -0
  52. package/types/index.d.ts +73 -11
  53. package/types/index.js +3 -0
  54. package/types/shared.d.ts +6 -18
  55. package/types/v4.d.ts +47 -3
  56. package/types/v5.d.ts +43 -4
  57. package/types/v6.d.ts +13 -0
  58. package/types/v6.js +1 -0
  59. package/utils/address.d.ts +30 -0
  60. package/utils/address.js +61 -0
  61. package/utils/ensure.d.ts +12 -0
  62. package/utils/ensure.js +59 -0
  63. package/utils/index.d.ts +5 -0
  64. package/utils/index.js +5 -0
  65. package/utils/proxy.d.ts +3 -0
  66. package/utils/proxy.js +7 -0
  67. package/utils/storage.d.ts +2 -0
  68. package/utils/storage.js +40 -0
  69. package/utils/types.d.ts +17 -0
  70. package/{utils.js → utils/types.js} +29 -30
  71. package/utils.d.ts +0 -13
@@ -75,36 +75,6 @@ export const normalizeContractTypeDef = (def) => {
75
75
  }
76
76
  return { type, value };
77
77
  };
78
- const UNSUPPORTED_VERSIONS = ['V3', 'V2', 'V1'];
79
- const SUPPORTED_VERSIONS = [5, '4'];
80
- export const parseRawMetadata = (rawMetadata) => {
81
- const metadata = JSON.parse(rawMetadata);
82
- // This is for V1, V2, V3
83
- const unsupportedVersion = UNSUPPORTED_VERSIONS.find((o) => metadata[o]);
84
- if (unsupportedVersion) {
85
- throw new Error(`Unsupported metadata version: ${unsupportedVersion}`);
86
- }
87
- // This is for V4, V5
88
- if (!SUPPORTED_VERSIONS.includes(metadata.version)) {
89
- throw new Error(`Unsupported metadata version: ${metadata.version}`);
90
- }
91
- return metadata;
92
- };
93
- export function newProxyChain(carrier) {
94
- return new Proxy(carrier, {
95
- get(target, property) {
96
- return target.doExecute(property.toString());
97
- },
98
- });
99
- }
100
- export function ensureSupportContractsPallet(client) {
101
- try {
102
- !!client.call.contractsApi.call.meta && !!client.tx.contracts.call.meta;
103
- }
104
- catch {
105
- throw new Error('Contracts pallet is not available');
106
- }
107
- }
108
78
  export function normalizeLabel(label) {
109
79
  if (!label)
110
80
  return '';
@@ -118,3 +88,32 @@ export function toReturnFlags(bits) {
118
88
  revert: bits === REVERT_FLAG,
119
89
  };
120
90
  }
91
+ const KNOWN_LAZY_TYPES = {
92
+ LAZY: ['ink_storage', 'lazy', 'Lazy'].join('::'),
93
+ MAPPING: ['ink_storage', 'lazy', 'mapping', 'Mapping'].join('::'),
94
+ STORAGE_VEC: ['ink_storage', 'lazy', 'vec', 'StorageVec'].join('::'),
95
+ };
96
+ export var KnownLazyType;
97
+ (function (KnownLazyType) {
98
+ KnownLazyType["LAZY"] = "LAZY";
99
+ KnownLazyType["MAPPING"] = "MAPPING";
100
+ KnownLazyType["STORAGE_VEC"] = "STORAGE_VEC";
101
+ })(KnownLazyType || (KnownLazyType = {}));
102
+ /**
103
+ * Check if a type is lazy/non-packed storage
104
+ *
105
+ * @param typePath
106
+ */
107
+ export function isLazyType(typePath) {
108
+ if (!typePath)
109
+ return;
110
+ if (Array.isArray(typePath)) {
111
+ typePath = typePath.join('::');
112
+ }
113
+ if (typePath === KNOWN_LAZY_TYPES.LAZY)
114
+ return KnownLazyType.LAZY;
115
+ if (typePath === KNOWN_LAZY_TYPES.MAPPING)
116
+ return KnownLazyType.MAPPING;
117
+ if (typePath === KNOWN_LAZY_TYPES.STORAGE_VEC)
118
+ return KnownLazyType.STORAGE_VEC;
119
+ }
package/utils.d.ts DELETED
@@ -1,13 +0,0 @@
1
- import { ISubstrateClient } from '@dedot/api';
2
- import { SubstrateApi } from '@dedot/api/chaintypes';
3
- import { PortableType, TypeDef } from '@dedot/codecs';
4
- import { GenericSubstrateApi, RpcVersion } from '@dedot/types';
5
- import { Executor } from './executor/index.js';
6
- import { ContractMetadata, ContractTypeDef, ReturnFlags } from './types/index.js';
7
- export declare const extractContractTypes: (contractMetadata: ContractMetadata) => PortableType[];
8
- export declare const normalizeContractTypeDef: (def: ContractTypeDef) => TypeDef;
9
- export declare const parseRawMetadata: (rawMetadata: string) => ContractMetadata;
10
- export declare function newProxyChain<ChainApi extends GenericSubstrateApi>(carrier: Executor<ChainApi>): unknown;
11
- export declare function ensureSupportContractsPallet(client: ISubstrateClient<SubstrateApi[RpcVersion]>): void;
12
- export declare function normalizeLabel(label?: string): string;
13
- export declare function toReturnFlags(bits: number): ReturnFlags;