@dedot/contracts 0.0.1-next.a5b1d2fb.22 → 0.0.1-next.b6596712.6
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 +1 -1
- package/Contract.js +1 -1
- package/cjs/Contract.js +1 -1
- package/cjs/utils.js +4 -4
- package/executor/Executor.d.ts +2 -2
- package/package.json +6 -6
- package/types/index.d.ts +8 -8
- package/types/shared.d.ts +3 -3
- package/types/v4.d.ts +2 -2
package/Contract.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { TypinkRegistry } from './TypinkRegistry.js';
|
|
|
4
4
|
import { ContractMetadata, GenericContractApi } from './types/index.js';
|
|
5
5
|
export declare class Contract<ContractApi extends GenericContractApi = GenericContractApi> {
|
|
6
6
|
#private;
|
|
7
|
-
constructor(api: ISubstrateClient,
|
|
7
|
+
constructor(api: ISubstrateClient, metadata: ContractMetadata | string, address: AccountId32Like);
|
|
8
8
|
get metadata(): ContractMetadata;
|
|
9
9
|
get address(): AccountId32;
|
|
10
10
|
get registry(): TypinkRegistry;
|
package/Contract.js
CHANGED
package/cjs/Contract.js
CHANGED
|
@@ -10,7 +10,7 @@ class Contract {
|
|
|
10
10
|
#registry;
|
|
11
11
|
#address;
|
|
12
12
|
#metadata;
|
|
13
|
-
constructor(api,
|
|
13
|
+
constructor(api, metadata, address) {
|
|
14
14
|
(0, utils_js_1.ensureSupportContractsPallet)(api);
|
|
15
15
|
this.#api = api;
|
|
16
16
|
this.#address = new codecs_1.AccountId32(address);
|
package/cjs/utils.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseRawMetadata = exports.normalizeContractTypeDef = exports.extractContractTypes = void 0;
|
|
4
|
-
exports.newProxyChain = newProxyChain;
|
|
5
|
-
exports.ensureSupportContractsPallet = ensureSupportContractsPallet;
|
|
6
|
-
exports.normalizeLabel = normalizeLabel;
|
|
3
|
+
exports.normalizeLabel = exports.ensureSupportContractsPallet = exports.newProxyChain = exports.parseRawMetadata = exports.normalizeContractTypeDef = exports.extractContractTypes = void 0;
|
|
7
4
|
const utils_1 = require("@dedot/utils");
|
|
8
5
|
const extractContractTypes = (contractMetadata) => {
|
|
9
6
|
const { types } = contractMetadata;
|
|
@@ -93,6 +90,7 @@ function newProxyChain(carrier) {
|
|
|
93
90
|
},
|
|
94
91
|
});
|
|
95
92
|
}
|
|
93
|
+
exports.newProxyChain = newProxyChain;
|
|
96
94
|
function ensureSupportContractsPallet(api) {
|
|
97
95
|
try {
|
|
98
96
|
!!api.call.contractsApi.call.meta && !!api.tx.contracts.call.meta;
|
|
@@ -101,8 +99,10 @@ function ensureSupportContractsPallet(api) {
|
|
|
101
99
|
throw new Error('Contracts pallet is not available');
|
|
102
100
|
}
|
|
103
101
|
}
|
|
102
|
+
exports.ensureSupportContractsPallet = ensureSupportContractsPallet;
|
|
104
103
|
function normalizeLabel(label) {
|
|
105
104
|
if (!label)
|
|
106
105
|
return '';
|
|
107
106
|
return (0, utils_1.stringCamelCase)(label.replaceAll('::', '_'));
|
|
108
107
|
}
|
|
108
|
+
exports.normalizeLabel = normalizeLabel;
|
package/executor/Executor.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { SubstrateApi } from '@dedot/api/chaintypes';
|
|
|
3
3
|
import { AccountId32 } from '@dedot/codecs';
|
|
4
4
|
import { GenericSubstrateApi, RpcVersion } from '@dedot/types';
|
|
5
5
|
import { TypinkRegistry } from '../TypinkRegistry.js';
|
|
6
|
-
import { ContractMessageArg,
|
|
6
|
+
import { ContractMessageArg, ContractCallMessage } from '../types/index.js';
|
|
7
7
|
import { ContractMetadata } from '../types/index.js';
|
|
8
8
|
export declare abstract class Executor<ChainApi extends GenericSubstrateApi = SubstrateApi[RpcVersion]> {
|
|
9
9
|
#private;
|
|
@@ -14,5 +14,5 @@ export declare abstract class Executor<ChainApi extends GenericSubstrateApi = Su
|
|
|
14
14
|
get registry(): TypinkRegistry;
|
|
15
15
|
abstract doExecute(...paths: string[]): unknown;
|
|
16
16
|
tryEncode(param: ContractMessageArg, value: any): Uint8Array;
|
|
17
|
-
tryDecode(meta:
|
|
17
|
+
tryDecode(meta: ContractCallMessage, raw: any): unknown;
|
|
18
18
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dedot/contracts",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.b6596712.6+b659671",
|
|
4
4
|
"description": "Delightful ink! Contract APIs",
|
|
5
5
|
"author": "Tung Vu <tung@coongcrafts.io>",
|
|
6
6
|
"main": "./cjs/index.js",
|
|
@@ -12,17 +12,17 @@
|
|
|
12
12
|
"test": "vitest --watch=false"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@dedot/api": "0.0.1-next.
|
|
16
|
-
"@dedot/codecs": "0.0.1-next.
|
|
17
|
-
"@dedot/types": "0.0.1-next.
|
|
18
|
-
"@dedot/utils": "0.0.1-next.
|
|
15
|
+
"@dedot/api": "0.0.1-next.b6596712.6+b659671",
|
|
16
|
+
"@dedot/codecs": "0.0.1-next.b6596712.6+b659671",
|
|
17
|
+
"@dedot/types": "0.0.1-next.b6596712.6+b659671",
|
|
18
|
+
"@dedot/utils": "0.0.1-next.b6596712.6+b659671"
|
|
19
19
|
},
|
|
20
20
|
"publishConfig": {
|
|
21
21
|
"access": "public",
|
|
22
22
|
"directory": "dist"
|
|
23
23
|
},
|
|
24
24
|
"license": "Apache-2.0",
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "b6596712119e3812b8af54d50f23371a3d556ad4",
|
|
26
26
|
"module": "./index.js",
|
|
27
27
|
"types": "./index.d.ts",
|
|
28
28
|
"exports": {
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SubstrateApi } from '@dedot/api/chaintypes';
|
|
2
2
|
import { AccountId32Like, BytesLike, DispatchError, Weight } from '@dedot/codecs';
|
|
3
3
|
import { AnyFunc, AsyncMethod, GenericSubstrateApi, RpcVersion, VersionedGenericSubstrateApi } from '@dedot/types';
|
|
4
|
-
import {
|
|
4
|
+
import { ContractCallMessage, ContractConstructorMessage } from './shared.js';
|
|
5
5
|
import { ContractMetadataV4 } from './v4.js';
|
|
6
6
|
import { ContractMetadataV5 } from './v5.js';
|
|
7
7
|
export * from './shared.js';
|
|
@@ -41,10 +41,10 @@ export type ContractTxOptions = CallOptions & {
|
|
|
41
41
|
gasLimit: Weight;
|
|
42
42
|
};
|
|
43
43
|
export type GenericContractQueryCall<ChainApi extends GenericSubstrateApi, F extends AsyncMethod = (...args: any[]) => Promise<GenericContractCallResult<any, ContractCallResult<ChainApi>>>> = F & {
|
|
44
|
-
meta:
|
|
44
|
+
meta: ContractCallMessage;
|
|
45
45
|
};
|
|
46
46
|
export type GenericContractTxCall<ChainApi extends GenericSubstrateApi, F extends AnyFunc = (...args: any[]) => ContractSubmittableExtrinsic<ChainApi>> = F & {
|
|
47
|
-
meta:
|
|
47
|
+
meta: ContractCallMessage;
|
|
48
48
|
};
|
|
49
49
|
export type GenericConstructorQueryCall<ChainApi extends GenericSubstrateApi, F extends AsyncMethod = (...args: any[]) => Promise<ContractInstantiateResult<ChainApi>>> = F & {
|
|
50
50
|
meta: ContractConstructorMessage;
|
|
@@ -64,9 +64,9 @@ export interface GenericConstructorQuery<ChainApi extends GenericSubstrateApi> {
|
|
|
64
64
|
export interface GenericConstructorTx<ChainApi extends GenericSubstrateApi> {
|
|
65
65
|
[method: string]: GenericConstructorTxCall<ChainApi>;
|
|
66
66
|
}
|
|
67
|
-
export interface GenericContractApi<ChainApi extends VersionedGenericSubstrateApi = SubstrateApi> {
|
|
68
|
-
query: GenericContractQuery<ChainApi[
|
|
69
|
-
tx: GenericContractTx<ChainApi[
|
|
70
|
-
constructorQuery: GenericConstructorQuery<ChainApi[
|
|
71
|
-
constructorTx: GenericConstructorTx<ChainApi[
|
|
67
|
+
export interface GenericContractApi<Rv extends RpcVersion = RpcVersion, ChainApi extends VersionedGenericSubstrateApi = SubstrateApi> {
|
|
68
|
+
query: GenericContractQuery<ChainApi[Rv]>;
|
|
69
|
+
tx: GenericContractTx<ChainApi[Rv]>;
|
|
70
|
+
constructorQuery: GenericConstructorQuery<ChainApi[Rv]>;
|
|
71
|
+
constructorTx: GenericConstructorTx<ChainApi[Rv]>;
|
|
72
72
|
}
|
package/types/shared.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export interface ContractTypeInfo {
|
|
|
28
28
|
displayName: string[];
|
|
29
29
|
type: number;
|
|
30
30
|
}
|
|
31
|
-
export interface
|
|
31
|
+
export interface ContractMessage {
|
|
32
32
|
args: ContractMessageArg[];
|
|
33
33
|
default: boolean;
|
|
34
34
|
docs: string[];
|
|
@@ -37,9 +37,9 @@ export interface Message {
|
|
|
37
37
|
returnType: ContractTypeInfo;
|
|
38
38
|
selector: string;
|
|
39
39
|
}
|
|
40
|
-
export interface ContractConstructorMessage extends
|
|
40
|
+
export interface ContractConstructorMessage extends ContractMessage {
|
|
41
41
|
}
|
|
42
|
-
export interface
|
|
42
|
+
export interface ContractCallMessage extends ContractMessage {
|
|
43
43
|
mutates: boolean;
|
|
44
44
|
}
|
|
45
45
|
export interface ContractType {
|
package/types/v4.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContractConstructorMessage, ContractInformation,
|
|
1
|
+
import { ContractConstructorMessage, ContractInformation, ContractCallMessage, ContractSource, ContractStorage, ContractType, ContractTypeInfo } from './shared.js';
|
|
2
2
|
export interface ContractMetadataV4 {
|
|
3
3
|
source: ContractSource;
|
|
4
4
|
contract: ContractInformation;
|
|
@@ -13,7 +13,7 @@ export interface ContractSpecV4 {
|
|
|
13
13
|
environment: ContractEnvironmentV4;
|
|
14
14
|
events: ContractEventV4[];
|
|
15
15
|
lang_error: ContractTypeInfo;
|
|
16
|
-
messages:
|
|
16
|
+
messages: ContractCallMessage[];
|
|
17
17
|
}
|
|
18
18
|
export interface ContractEventV4 {
|
|
19
19
|
args: unknown[];
|