@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.
- package/Contract.d.ts +4 -4
- package/Contract.js +41 -6
- package/ContractDeployer.d.ts +2 -2
- package/ContractDeployer.js +8 -6
- package/TypinkRegistry.d.ts +29 -6
- package/TypinkRegistry.js +144 -24
- package/cjs/Contract.js +44 -9
- package/cjs/ContractDeployer.js +10 -8
- package/cjs/TypinkRegistry.js +144 -24
- package/cjs/errors.js +3 -3
- package/cjs/executor/ConstructorQueryExecutor.js +49 -9
- package/cjs/executor/ConstructorTxExecutor.js +17 -6
- package/cjs/executor/QueryExecutor.js +30 -5
- package/cjs/executor/TxExecutor.js +10 -1
- package/cjs/executor/abstract/ContractExecutor.js +4 -5
- package/cjs/executor/abstract/DeployerExecutor.js +2 -2
- package/cjs/index.js +1 -1
- package/cjs/storage/BaseLazyObject.js +25 -0
- package/cjs/storage/LazyMapping.js +22 -0
- package/cjs/storage/LazyObject.js +18 -0
- package/cjs/storage/LazyStorageVec.js +54 -0
- package/cjs/storage/index.js +19 -0
- package/cjs/types/index.js +3 -0
- package/cjs/types/v6.js +2 -0
- package/cjs/utils/address.js +67 -0
- package/cjs/utils/ensure.js +68 -0
- package/cjs/utils/index.js +21 -0
- package/cjs/utils/proxy.js +11 -0
- package/cjs/utils/storage.js +44 -0
- package/cjs/{utils.js → utils/types.js} +31 -34
- package/errors.js +2 -2
- package/executor/ConstructorQueryExecutor.js +47 -7
- package/executor/ConstructorTxExecutor.js +18 -7
- package/executor/QueryExecutor.js +27 -2
- package/executor/TxExecutor.js +11 -2
- package/executor/abstract/ContractExecutor.d.ts +3 -4
- package/executor/abstract/ContractExecutor.js +2 -3
- package/executor/abstract/DeployerExecutor.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +7 -6
- package/storage/BaseLazyObject.d.ts +10 -0
- package/storage/BaseLazyObject.js +21 -0
- package/storage/LazyMapping.d.ts +4 -0
- package/storage/LazyMapping.js +18 -0
- package/storage/LazyObject.d.ts +4 -0
- package/storage/LazyObject.js +14 -0
- package/storage/LazyStorageVec.d.ts +5 -0
- package/storage/LazyStorageVec.js +27 -0
- package/storage/index.d.ts +3 -0
- package/storage/index.js +3 -0
- package/types/index.d.ts +73 -11
- package/types/index.js +3 -0
- package/types/shared.d.ts +6 -18
- package/types/v4.d.ts +47 -3
- package/types/v5.d.ts +43 -4
- package/types/v6.d.ts +13 -0
- package/types/v6.js +1 -0
- package/utils/address.d.ts +30 -0
- package/utils/address.js +61 -0
- package/utils/ensure.d.ts +12 -0
- package/utils/ensure.js +59 -0
- package/utils/index.d.ts +5 -0
- package/utils/index.js +5 -0
- package/utils/proxy.d.ts +3 -0
- package/utils/proxy.js +7 -0
- package/utils/storage.d.ts +2 -0
- package/utils/storage.js +40 -0
- package/utils/types.d.ts +17 -0
- package/{utils.js → utils/types.js} +29 -30
- 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;
|