@dedot/contracts 0.17.0 → 0.17.1-next.db98ff20.1
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 +5 -4
- package/Contract.js +42 -15
- package/ContractDeployer.d.ts +5 -4
- package/ContractDeployer.js +27 -10
- package/SolRegistry.d.ts +22 -0
- package/SolRegistry.js +64 -0
- package/TypinkRegistry.d.ts +2 -1
- package/TypinkRegistry.js +3 -1
- package/cjs/Contract.js +43 -16
- package/cjs/ContractDeployer.js +25 -8
- package/cjs/SolRegistry.js +68 -0
- package/cjs/TypinkRegistry.js +2 -0
- package/cjs/errors.js +75 -1
- package/cjs/executor/index.js +2 -5
- package/cjs/executor/{ConstructorQueryExecutor.js → ink/ConstructorQueryExecutor.js} +3 -2
- package/cjs/executor/{ConstructorTxExecutor.js → ink/ConstructorTxExecutor.js} +4 -3
- package/cjs/executor/{QueryExecutor.js → ink/QueryExecutor.js} +4 -3
- package/cjs/executor/{TxExecutor.js → ink/TxExecutor.js} +1 -1
- package/cjs/executor/{abstract → ink/abstract}/ContractExecutor.js +1 -1
- package/cjs/executor/{abstract → ink/abstract}/DeployerExecutor.js +1 -1
- package/cjs/executor/ink/index.js +22 -0
- package/cjs/executor/sol/SolConstructorQueryExecutor.js +81 -0
- package/cjs/executor/sol/SolConstructorTxExecutor.js +123 -0
- package/cjs/executor/sol/SolEventExecutor.js +57 -0
- package/cjs/executor/sol/SolQueryExecutor.js +83 -0
- package/cjs/executor/sol/SolTxExecutor.js +62 -0
- package/cjs/executor/sol/abstract/SolContractExecutor.js +12 -0
- package/cjs/executor/sol/abstract/SolDeployerExecutor.js +12 -0
- package/cjs/executor/sol/abstract/SolExecutor.js +17 -0
- package/cjs/executor/sol/abstract/index.js +19 -0
- package/cjs/executor/sol/index.js +22 -0
- package/cjs/types/index.js +2 -3
- package/cjs/types/ink/index.js +20 -0
- package/cjs/types/ink/v6.js +2 -0
- package/cjs/types/sol/abi.js +2 -0
- package/cjs/types/sol/index.js +17 -0
- package/cjs/utils/address.js +2 -2
- package/cjs/utils/ensure.js +40 -23
- package/cjs/utils/types.js +21 -1
- package/errors.d.ts +64 -5
- package/errors.js +70 -0
- package/executor/index.d.ts +2 -5
- package/executor/index.js +2 -5
- package/executor/{ConstructorQueryExecutor.d.ts → ink/ConstructorQueryExecutor.d.ts} +1 -2
- package/executor/{ConstructorQueryExecutor.js → ink/ConstructorQueryExecutor.js} +3 -2
- package/executor/{ConstructorTxExecutor.d.ts → ink/ConstructorTxExecutor.d.ts} +1 -2
- package/executor/{ConstructorTxExecutor.js → ink/ConstructorTxExecutor.js} +4 -3
- package/executor/{EventExecutor.d.ts → ink/EventExecutor.d.ts} +2 -2
- package/executor/{QueryExecutor.d.ts → ink/QueryExecutor.d.ts} +1 -2
- package/executor/{QueryExecutor.js → ink/QueryExecutor.js} +4 -3
- package/executor/{TxExecutor.d.ts → ink/TxExecutor.d.ts} +1 -2
- package/executor/{TxExecutor.js → ink/TxExecutor.js} +1 -1
- package/executor/{abstract → ink/abstract}/ContractExecutor.d.ts +2 -2
- package/executor/{abstract → ink/abstract}/ContractExecutor.js +1 -1
- package/executor/{abstract → ink/abstract}/DeployerExecutor.d.ts +2 -2
- package/executor/{abstract → ink/abstract}/DeployerExecutor.js +1 -1
- package/executor/{abstract → ink/abstract}/Executor.d.ts +2 -2
- package/executor/ink/index.d.ts +6 -0
- package/executor/ink/index.js +6 -0
- package/executor/sol/SolConstructorQueryExecutor.d.ts +5 -0
- package/executor/sol/SolConstructorQueryExecutor.js +77 -0
- package/executor/sol/SolConstructorTxExecutor.d.ts +5 -0
- package/executor/sol/SolConstructorTxExecutor.js +119 -0
- package/executor/sol/SolEventExecutor.d.ts +6 -0
- package/executor/sol/SolEventExecutor.js +53 -0
- package/executor/sol/SolQueryExecutor.d.ts +5 -0
- package/executor/sol/SolQueryExecutor.js +79 -0
- package/executor/sol/SolTxExecutor.d.ts +5 -0
- package/executor/sol/SolTxExecutor.js +58 -0
- package/executor/sol/abstract/SolContractExecutor.d.ts +9 -0
- package/executor/sol/abstract/SolContractExecutor.js +8 -0
- package/executor/sol/abstract/SolDeployerExecutor.d.ts +11 -0
- package/executor/sol/abstract/SolDeployerExecutor.js +8 -0
- package/executor/sol/abstract/SolExecutor.d.ts +13 -0
- package/executor/sol/abstract/SolExecutor.js +13 -0
- package/executor/sol/abstract/index.d.ts +3 -0
- package/executor/sol/abstract/index.js +3 -0
- package/executor/sol/index.d.ts +6 -0
- package/executor/sol/index.js +6 -0
- package/package.json +7 -7
- package/storage/BaseLazyObject.d.ts +1 -1
- package/types/index.d.ts +44 -121
- package/types/index.js +2 -3
- package/types/ink/index.d.ts +9 -0
- package/types/ink/index.js +4 -0
- package/types/ink/shared.d.ts +100 -0
- package/types/ink/v6.js +1 -0
- package/types/shared.d.ts +80 -99
- package/types/sol/abi.d.ts +45 -0
- package/types/sol/abi.js +1 -0
- package/types/sol/index.d.ts +1 -0
- package/types/sol/index.js +1 -0
- package/utils/address.js +2 -2
- package/utils/ensure.d.ts +8 -7
- package/utils/ensure.js +38 -22
- package/utils/types.d.ts +20 -2
- package/utils/types.js +18 -0
- /package/cjs/executor/{EventExecutor.js → ink/EventExecutor.js} +0 -0
- /package/cjs/executor/{abstract → ink/abstract}/Executor.js +0 -0
- /package/cjs/executor/{abstract → ink/abstract}/index.js +0 -0
- /package/cjs/types/{v4.js → ink/shared.js} +0 -0
- /package/cjs/types/{v5.js → ink/v4.js} +0 -0
- /package/cjs/types/{v6.js → ink/v5.js} +0 -0
- /package/executor/{EventExecutor.js → ink/EventExecutor.js} +0 -0
- /package/executor/{abstract → ink/abstract}/Executor.js +0 -0
- /package/executor/{abstract → ink/abstract}/index.d.ts +0 -0
- /package/executor/{abstract → ink/abstract}/index.js +0 -0
- /package/types/{v4.js → ink/shared.js} +0 -0
- /package/types/{v4.d.ts → ink/v4.d.ts} +0 -0
- /package/types/{v5.js → ink/v4.js} +0 -0
- /package/types/{v5.d.ts → ink/v5.d.ts} +0 -0
- /package/types/{v6.js → ink/v5.js} +0 -0
- /package/types/{v6.d.ts → ink/v6.d.ts} +0 -0
package/types/index.d.ts
CHANGED
|
@@ -1,75 +1,15 @@
|
|
|
1
1
|
import { SubstrateApi } from '@dedot/api/chaintypes';
|
|
2
|
-
import {
|
|
2
|
+
import { Extrinsic } from '@dedot/codecs';
|
|
3
3
|
import { AnyFunc, AsyncMethod, GenericSubstrateApi, IEventRecord, ISubmittableExtrinsic, ISubmittableResult, RpcVersion, Unsub, VersionedGenericSubstrateApi } from '@dedot/types';
|
|
4
4
|
import { Contract } from '../Contract.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
5
|
+
import { ContractCallMessage, ContractConstructorMessage, ContractEventMeta } from './ink/index.js';
|
|
6
|
+
import { ContractCallResult, ContractInstantiateResult, ExecutionOptions, GenericConstructorCallResult, GenericContractCallResult, ContractAddress } from './shared.js';
|
|
7
|
+
import { SolAbiConstructor, SolAbiEvent, SolAbiFunction } from './sol/index.js';
|
|
8
|
+
export * from './ink/index.js';
|
|
9
|
+
export * from './sol/index.js';
|
|
9
10
|
export * from './shared.js';
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
export * from './v6.js';
|
|
13
|
-
export type ContractEventMeta = ContractEventV4 | ContractEventV5;
|
|
14
|
-
/**
|
|
15
|
-
* Flags used by a contract to customize exit behaviour.
|
|
16
|
-
* Ref: https://github.com/paritytech/polkadot-sdk/blob/d2fd53645654d3b8e12cbf735b67b93078d70113/substrate/frame/contracts/uapi/src/flags.rs#L23-L26
|
|
17
|
-
*/
|
|
18
|
-
export type ReturnFlags = {
|
|
19
|
-
bits: number;
|
|
20
|
-
revert: boolean;
|
|
21
|
-
};
|
|
22
|
-
export interface GenericContractCallResult<DecodedData = any, ContractResult = any> {
|
|
23
|
-
data: DecodedData;
|
|
24
|
-
raw: ContractResult;
|
|
25
|
-
flags: ReturnFlags;
|
|
26
|
-
inputData: Bytes;
|
|
27
|
-
}
|
|
28
|
-
export interface GenericConstructorCallResult<DecodedData = any, ContractResult = any> extends GenericContractCallResult<DecodedData, ContractResult> {
|
|
29
|
-
address: ContractAddress;
|
|
30
|
-
}
|
|
31
|
-
export type ContractCode = {
|
|
32
|
-
type: 'Upload';
|
|
33
|
-
value: Bytes;
|
|
34
|
-
} | {
|
|
35
|
-
type: 'Existing';
|
|
36
|
-
value: H256;
|
|
37
|
-
};
|
|
38
|
-
export type WeightV2 = {
|
|
39
|
-
refTime: bigint;
|
|
40
|
-
proofSize: bigint;
|
|
41
|
-
};
|
|
42
|
-
export type StorageDeposit = {
|
|
43
|
-
type: 'Refund';
|
|
44
|
-
value: bigint;
|
|
45
|
-
} | {
|
|
46
|
-
type: 'Charge';
|
|
47
|
-
value: bigint;
|
|
48
|
-
};
|
|
49
|
-
export type ExecReturnValue = {
|
|
50
|
-
flags: {
|
|
51
|
-
bits: number;
|
|
52
|
-
};
|
|
53
|
-
data: Bytes;
|
|
54
|
-
};
|
|
55
|
-
export type InstantiateReturnValue = {
|
|
56
|
-
result: ExecReturnValue;
|
|
57
|
-
address: ContractAddress;
|
|
58
|
-
};
|
|
59
|
-
export type ContractCallResult<_ extends GenericSubstrateApi> = {
|
|
60
|
-
gasConsumed: WeightV2;
|
|
61
|
-
gasRequired: WeightV2;
|
|
62
|
-
storageDeposit: StorageDeposit;
|
|
63
|
-
debugMessage?: Bytes;
|
|
64
|
-
result: Result<ExecReturnValue, DispatchError>;
|
|
65
|
-
};
|
|
66
|
-
export type ContractInstantiateResult<_ extends GenericSubstrateApi> = {
|
|
67
|
-
gasConsumed: WeightV2;
|
|
68
|
-
gasRequired: WeightV2;
|
|
69
|
-
storageDeposit: StorageDeposit;
|
|
70
|
-
debugMessage?: Bytes;
|
|
71
|
-
result: Result<InstantiateReturnValue, DispatchError>;
|
|
72
|
-
};
|
|
11
|
+
type SubmittableExtrinsic<R extends ISubmittableResult> = ISubmittableExtrinsic<R> & Extrinsic;
|
|
12
|
+
export type ContractSubmittableExtrinsic<_ extends GenericSubstrateApi> = SubmittableExtrinsic<ISubmittableResult>;
|
|
73
13
|
export interface IContractInstantiateSubmittableResult<ContractApi extends GenericContractApi = GenericContractApi> extends ISubmittableResult {
|
|
74
14
|
/**
|
|
75
15
|
* Get deployed contract address
|
|
@@ -80,53 +20,34 @@ export interface IContractInstantiateSubmittableResult<ContractApi extends Gener
|
|
|
80
20
|
*/
|
|
81
21
|
contract(options?: ExecutionOptions): Promise<Contract<ContractApi>>;
|
|
82
22
|
}
|
|
83
|
-
type SubmittableExtrinsic<R extends ISubmittableResult> = ISubmittableExtrinsic<R> & Extrinsic;
|
|
84
|
-
export type ContractSubmittableExtrinsic<_ extends GenericSubstrateApi> = SubmittableExtrinsic<ISubmittableResult>;
|
|
85
23
|
export type GenericInstantiateSubmittableExtrinsic<_ extends GenericSubstrateApi, ContractApi extends GenericContractApi = GenericContractApi> = SubmittableExtrinsic<IContractInstantiateSubmittableResult<ContractApi>>;
|
|
86
|
-
export type ContractMetadata = ContractMetadataV4 | ContractMetadataV5 | ContractMetadataV6;
|
|
87
24
|
export interface LooseContractMetadata {
|
|
88
25
|
version: number | string;
|
|
89
26
|
[prop: string]: any;
|
|
90
27
|
}
|
|
91
|
-
export type
|
|
92
|
-
|
|
93
|
-
gasLimit?: Weight | undefined;
|
|
94
|
-
storageDepositLimit?: bigint | undefined;
|
|
95
|
-
};
|
|
96
|
-
export type ConstructorCallOptions = CallOptions & {
|
|
97
|
-
salt?: BytesLike;
|
|
98
|
-
caller?: AccountId32Like;
|
|
99
|
-
};
|
|
100
|
-
export type ConstructorTxOptions = CallOptions & {
|
|
101
|
-
salt?: BytesLike;
|
|
102
|
-
};
|
|
103
|
-
export type ContractCallOptions = CallOptions & {
|
|
104
|
-
caller?: AccountId32Like;
|
|
28
|
+
export type GenericContractQueryCall<ChainApi extends GenericSubstrateApi, F extends AsyncMethod = (...args: any[]) => Promise<GenericContractCallResult<any, ContractCallResult<ChainApi>>>, Type extends MetadataType = MetadataType> = F & {
|
|
29
|
+
meta: Type extends 'ink' ? ContractCallMessage : SolAbiFunction;
|
|
105
30
|
};
|
|
106
|
-
export type
|
|
107
|
-
|
|
108
|
-
meta: ContractCallMessage;
|
|
31
|
+
export type GenericContractTxCall<ChainApi extends GenericSubstrateApi, F extends AnyFunc = (...args: any[]) => ContractSubmittableExtrinsic<ChainApi>, Type extends MetadataType = MetadataType> = F & {
|
|
32
|
+
meta: Type extends 'ink' ? ContractCallMessage : SolAbiFunction;
|
|
109
33
|
};
|
|
110
|
-
export type
|
|
111
|
-
meta:
|
|
34
|
+
export type GenericConstructorQueryCall<ChainApi extends GenericSubstrateApi, F extends AsyncMethod = (...args: any[]) => Promise<GenericConstructorCallResult<any, ContractInstantiateResult<ChainApi>>>, Type extends MetadataType = MetadataType> = F & {
|
|
35
|
+
meta: Type extends 'ink' ? ContractConstructorMessage : SolAbiConstructor;
|
|
112
36
|
};
|
|
113
|
-
export type
|
|
114
|
-
meta: ContractConstructorMessage;
|
|
37
|
+
export type GenericConstructorTxCall<ChainApi extends GenericSubstrateApi, F extends AnyFunc = (...args: any[]) => GenericInstantiateSubmittableExtrinsic<ChainApi>, Type extends MetadataType = MetadataType> = F & {
|
|
38
|
+
meta: Type extends 'ink' ? ContractConstructorMessage : SolAbiConstructor;
|
|
115
39
|
};
|
|
116
|
-
export
|
|
117
|
-
|
|
118
|
-
};
|
|
119
|
-
export interface GenericContractQuery<ChainApi extends GenericSubstrateApi> {
|
|
120
|
-
[method: string]: GenericContractQueryCall<ChainApi>;
|
|
40
|
+
export interface GenericContractQuery<ChainApi extends GenericSubstrateApi, Type extends MetadataType = MetadataType> {
|
|
41
|
+
[method: string]: GenericContractQueryCall<ChainApi, (...args: any[]) => Promise<GenericContractCallResult<any, ContractCallResult<ChainApi>>>, Type>;
|
|
121
42
|
}
|
|
122
|
-
export interface GenericContractTx<ChainApi extends GenericSubstrateApi> {
|
|
123
|
-
[method: string]: GenericContractTxCall<ChainApi>;
|
|
43
|
+
export interface GenericContractTx<ChainApi extends GenericSubstrateApi, Type extends MetadataType = MetadataType> {
|
|
44
|
+
[method: string]: GenericContractTxCall<ChainApi, (...args: any[]) => ContractSubmittableExtrinsic<ChainApi>, Type>;
|
|
124
45
|
}
|
|
125
|
-
export interface GenericConstructorQuery<ChainApi extends GenericSubstrateApi> {
|
|
126
|
-
[method: string]: GenericConstructorQueryCall<ChainApi>;
|
|
46
|
+
export interface GenericConstructorQuery<ChainApi extends GenericSubstrateApi, Type extends MetadataType = MetadataType> {
|
|
47
|
+
[method: string]: GenericConstructorQueryCall<ChainApi, (...args: any[]) => Promise<GenericConstructorCallResult<any, ContractInstantiateResult<ChainApi>>>, Type>;
|
|
127
48
|
}
|
|
128
|
-
export interface GenericConstructorTx<ChainApi extends GenericSubstrateApi> {
|
|
129
|
-
[method: string]: GenericConstructorTxCall<ChainApi>;
|
|
49
|
+
export interface GenericConstructorTx<ChainApi extends GenericSubstrateApi, Type extends MetadataType = MetadataType> {
|
|
50
|
+
[method: string]: GenericConstructorTxCall<ChainApi, (...args: any[]) => GenericInstantiateSubmittableExtrinsic<ChainApi>, Type>;
|
|
130
51
|
}
|
|
131
52
|
export type ContractEvent<EventName extends string = string, Data extends any = any> = Data extends undefined ? {
|
|
132
53
|
name: EventName;
|
|
@@ -134,42 +55,44 @@ export type ContractEvent<EventName extends string = string, Data extends any =
|
|
|
134
55
|
name: EventName;
|
|
135
56
|
data: Data;
|
|
136
57
|
};
|
|
137
|
-
export interface GenericContractEvent<EventName extends string = string, Data extends any = any> {
|
|
58
|
+
export interface GenericContractEvent<EventName extends string = string, Data extends any = any, Type extends MetadataType = MetadataType> {
|
|
138
59
|
is: (event: IEventRecord | ContractEvent) => event is ContractEvent<EventName, Data>;
|
|
139
60
|
find: (events: IEventRecord[] | ContractEvent[]) => ContractEvent<EventName, Data> | undefined;
|
|
140
61
|
filter: (events: IEventRecord[] | ContractEvent[]) => ContractEvent<EventName, Data>[];
|
|
141
62
|
watch: (callback: (events: ContractEvent<EventName, Data>[]) => void) => Promise<Unsub>;
|
|
142
|
-
meta: ContractEventMeta;
|
|
63
|
+
meta: Type extends 'ink' ? ContractEventMeta : SolAbiEvent;
|
|
143
64
|
}
|
|
144
|
-
export interface GenericContractEvents<_ extends GenericSubstrateApi> {
|
|
145
|
-
[event: string]: GenericContractEvent
|
|
65
|
+
export interface GenericContractEvents<_ extends GenericSubstrateApi, Type extends MetadataType = MetadataType> {
|
|
66
|
+
[event: string]: GenericContractEvent<string, any, Type>;
|
|
146
67
|
}
|
|
147
68
|
export type GenericInkLangError = 'CouldNotReadInput' | any;
|
|
148
69
|
export type GenericRootStorage = any;
|
|
149
70
|
export type GenericLazyStorage = any;
|
|
150
|
-
export
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
71
|
+
export type MetadataType = 'ink' | 'sol';
|
|
72
|
+
export type AB<Type extends MetadataType, A, B> = Type extends 'ink' ? A : B;
|
|
73
|
+
export interface GenericContractApi<Rv extends RpcVersion = RpcVersion, ChainApi extends VersionedGenericSubstrateApi = SubstrateApi, Type extends MetadataType = MetadataType> {
|
|
74
|
+
metadataType: Type;
|
|
75
|
+
query: GenericContractQuery<ChainApi[Rv], Type>;
|
|
76
|
+
tx: GenericContractTx<ChainApi[Rv], Type>;
|
|
77
|
+
constructorQuery: GenericConstructorQuery<ChainApi[Rv], Type>;
|
|
78
|
+
constructorTx: GenericConstructorTx<ChainApi[Rv], Type>;
|
|
79
|
+
events: GenericContractEvents<ChainApi[Rv], Type>;
|
|
80
|
+
storage: AB<Type, {
|
|
157
81
|
root(): Promise<GenericRootStorage>;
|
|
158
82
|
lazy(): GenericLazyStorage;
|
|
159
|
-
}
|
|
83
|
+
}, undefined>;
|
|
160
84
|
types: {
|
|
161
|
-
RootStorage: GenericRootStorage;
|
|
162
|
-
LazyStorage: GenericLazyStorage;
|
|
163
|
-
LangError: GenericInkLangError;
|
|
164
85
|
ChainApi: ChainApi[Rv];
|
|
86
|
+
[TypeName: string]: any;
|
|
165
87
|
};
|
|
166
88
|
}
|
|
167
|
-
export interface ExecutionOptions {
|
|
168
|
-
defaultCaller?: AccountId32Like;
|
|
169
|
-
}
|
|
170
89
|
type HasGetter<T> = T extends {
|
|
171
90
|
get: (...args: any[]) => any;
|
|
172
91
|
} ? true : false;
|
|
173
92
|
export type WithLazyStorage<T> = {
|
|
174
93
|
[K in keyof T as HasGetter<T[K]> extends true ? K : T[K] extends object ? keyof WithLazyStorage<T[K]> extends never ? never : K : never]: T[K] extends object ? HasGetter<T[K]> extends true ? T[K] : WithLazyStorage<T[K]> : never;
|
|
175
94
|
};
|
|
95
|
+
export interface InkGenericContractApi<Rv extends RpcVersion = RpcVersion, ChainApi extends VersionedGenericSubstrateApi = SubstrateApi> extends GenericContractApi<Rv, ChainApi, 'ink'> {
|
|
96
|
+
}
|
|
97
|
+
export interface SolGenericContractApi<Rv extends RpcVersion = RpcVersion, ChainApi extends VersionedGenericSubstrateApi = SubstrateApi> extends GenericContractApi<Rv, ChainApi, 'sol'> {
|
|
98
|
+
}
|
package/types/index.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ContractEventV4, ContractMetadataV4 } from './v4.js';
|
|
2
|
+
import { ContractEventV5, ContractMetadataV5 } from './v5.js';
|
|
3
|
+
import { ContractMetadataV6 } from './v6.js';
|
|
4
|
+
export * from './shared.js';
|
|
5
|
+
export * from './v4.js';
|
|
6
|
+
export * from './v5.js';
|
|
7
|
+
export * from './v6.js';
|
|
8
|
+
export type ContractEventMeta = ContractEventV4 | ContractEventV5;
|
|
9
|
+
export type ContractMetadata = ContractMetadataV4 | ContractMetadataV5 | ContractMetadataV6;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export interface ContractInformation {
|
|
2
|
+
name: string;
|
|
3
|
+
version: string;
|
|
4
|
+
authors: string[];
|
|
5
|
+
}
|
|
6
|
+
export interface ContractSource {
|
|
7
|
+
hash: string;
|
|
8
|
+
language: string;
|
|
9
|
+
compiler: string;
|
|
10
|
+
build_info: BuildInfo;
|
|
11
|
+
}
|
|
12
|
+
export interface BuildInfo {
|
|
13
|
+
build_mode: string;
|
|
14
|
+
cargo_contract_version: string;
|
|
15
|
+
rust_toolchain: string;
|
|
16
|
+
}
|
|
17
|
+
export interface WasmOptSettings {
|
|
18
|
+
keep_debug_symbols: boolean;
|
|
19
|
+
optimization_passes: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ContractMessageArg {
|
|
22
|
+
label: string;
|
|
23
|
+
type: ContractTypeInfo;
|
|
24
|
+
}
|
|
25
|
+
export interface ContractTypeInfo {
|
|
26
|
+
displayName: string[];
|
|
27
|
+
type: number;
|
|
28
|
+
}
|
|
29
|
+
export interface ContractMessage {
|
|
30
|
+
args: ContractMessageArg[];
|
|
31
|
+
default: boolean;
|
|
32
|
+
docs: string[];
|
|
33
|
+
label: string;
|
|
34
|
+
payable: boolean;
|
|
35
|
+
returnType: ContractTypeInfo;
|
|
36
|
+
selector: string;
|
|
37
|
+
}
|
|
38
|
+
export interface ContractConstructorMessage extends ContractMessage {
|
|
39
|
+
}
|
|
40
|
+
export interface ContractCallMessage extends ContractMessage {
|
|
41
|
+
mutates: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface ContractType {
|
|
44
|
+
id: number;
|
|
45
|
+
type: {
|
|
46
|
+
def: ContractTypeDef;
|
|
47
|
+
path?: string[];
|
|
48
|
+
params?: ParamInfo[];
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export interface ContractTypeDef {
|
|
52
|
+
composite?: CompositeType;
|
|
53
|
+
array?: ArrayType;
|
|
54
|
+
primitive?: string;
|
|
55
|
+
sequence?: SequenceType;
|
|
56
|
+
variant?: VariantType;
|
|
57
|
+
tuple?: number[];
|
|
58
|
+
compact?: CompactType;
|
|
59
|
+
bitsequence?: BitSequenceType;
|
|
60
|
+
}
|
|
61
|
+
export interface BitSequenceType {
|
|
62
|
+
bit_order_type: number;
|
|
63
|
+
bit_store_type: number;
|
|
64
|
+
}
|
|
65
|
+
export interface CompactType {
|
|
66
|
+
type: number;
|
|
67
|
+
}
|
|
68
|
+
export interface CompositeType {
|
|
69
|
+
fields?: {
|
|
70
|
+
type: number;
|
|
71
|
+
typeName: string;
|
|
72
|
+
name?: string;
|
|
73
|
+
}[];
|
|
74
|
+
}
|
|
75
|
+
export interface ArrayType {
|
|
76
|
+
len: number;
|
|
77
|
+
type: number;
|
|
78
|
+
}
|
|
79
|
+
export interface SequenceType {
|
|
80
|
+
type: number;
|
|
81
|
+
}
|
|
82
|
+
export interface VariantType {
|
|
83
|
+
variants?: {
|
|
84
|
+
index: number;
|
|
85
|
+
name: string;
|
|
86
|
+
fields?: {
|
|
87
|
+
type: number;
|
|
88
|
+
typeName?: string;
|
|
89
|
+
name?: string;
|
|
90
|
+
}[];
|
|
91
|
+
}[];
|
|
92
|
+
}
|
|
93
|
+
export interface ParamInfo {
|
|
94
|
+
name: string;
|
|
95
|
+
type: number;
|
|
96
|
+
}
|
|
97
|
+
export interface ContractEventArg extends ContractMessageArg {
|
|
98
|
+
docs: string[];
|
|
99
|
+
indexed: boolean;
|
|
100
|
+
}
|
package/types/ink/v6.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/types/shared.d.ts
CHANGED
|
@@ -1,101 +1,82 @@
|
|
|
1
|
+
import { AccountId32Like, Bytes, BytesLike, DispatchError, H256, Weight } from '@dedot/codecs';
|
|
2
|
+
import { Result } from '@dedot/shape';
|
|
3
|
+
import { GenericSubstrateApi } from '@dedot/types';
|
|
1
4
|
export type ContractAddress = string;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
export
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
export interface ContractCallMessage extends ContractMessage {
|
|
42
|
-
mutates: boolean;
|
|
43
|
-
}
|
|
44
|
-
export interface ContractType {
|
|
45
|
-
id: number;
|
|
46
|
-
type: {
|
|
47
|
-
def: ContractTypeDef;
|
|
48
|
-
path?: string[];
|
|
49
|
-
params?: ParamInfo[];
|
|
5
|
+
/**
|
|
6
|
+
* Flags used by a contract to customize exit behaviour.
|
|
7
|
+
* Ref: https://github.com/paritytech/polkadot-sdk/blob/d2fd53645654d3b8e12cbf735b67b93078d70113/substrate/frame/contracts/uapi/src/flags.rs#L23-L26
|
|
8
|
+
*/
|
|
9
|
+
export type ReturnFlags = {
|
|
10
|
+
bits: number;
|
|
11
|
+
revert: boolean;
|
|
12
|
+
};
|
|
13
|
+
export interface GenericContractCallResult<DecodedData = any, ContractResult = any> {
|
|
14
|
+
data: DecodedData;
|
|
15
|
+
raw: ContractResult;
|
|
16
|
+
flags: ReturnFlags;
|
|
17
|
+
inputData: Bytes;
|
|
18
|
+
}
|
|
19
|
+
export interface GenericConstructorCallResult<DecodedData = any, ContractResult = any> extends GenericContractCallResult<DecodedData, ContractResult> {
|
|
20
|
+
address: ContractAddress;
|
|
21
|
+
}
|
|
22
|
+
export type ContractCode = {
|
|
23
|
+
type: 'Upload';
|
|
24
|
+
value: Bytes;
|
|
25
|
+
} | {
|
|
26
|
+
type: 'Existing';
|
|
27
|
+
value: H256;
|
|
28
|
+
};
|
|
29
|
+
export type WeightV2 = {
|
|
30
|
+
refTime: bigint;
|
|
31
|
+
proofSize: bigint;
|
|
32
|
+
};
|
|
33
|
+
export type StorageDeposit = {
|
|
34
|
+
type: 'Refund';
|
|
35
|
+
value: bigint;
|
|
36
|
+
} | {
|
|
37
|
+
type: 'Charge';
|
|
38
|
+
value: bigint;
|
|
39
|
+
};
|
|
40
|
+
export type ExecReturnValue = {
|
|
41
|
+
flags: {
|
|
42
|
+
bits: number;
|
|
50
43
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
export
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
name?: string;
|
|
91
|
-
}[];
|
|
92
|
-
}[];
|
|
93
|
-
}
|
|
94
|
-
export interface ParamInfo {
|
|
95
|
-
name: string;
|
|
96
|
-
type: number;
|
|
97
|
-
}
|
|
98
|
-
export interface ContractEventArg extends ContractMessageArg {
|
|
99
|
-
docs: string[];
|
|
100
|
-
indexed: boolean;
|
|
101
|
-
}
|
|
44
|
+
data: Bytes;
|
|
45
|
+
};
|
|
46
|
+
export type InstantiateReturnValue = {
|
|
47
|
+
result: ExecReturnValue;
|
|
48
|
+
address: ContractAddress;
|
|
49
|
+
};
|
|
50
|
+
export type ContractCallResult<_ extends GenericSubstrateApi> = {
|
|
51
|
+
gasConsumed: WeightV2;
|
|
52
|
+
gasRequired: WeightV2;
|
|
53
|
+
storageDeposit: StorageDeposit;
|
|
54
|
+
debugMessage?: Bytes;
|
|
55
|
+
result: Result<ExecReturnValue, DispatchError>;
|
|
56
|
+
};
|
|
57
|
+
export type ContractInstantiateResult<_ extends GenericSubstrateApi> = {
|
|
58
|
+
gasConsumed: WeightV2;
|
|
59
|
+
gasRequired: WeightV2;
|
|
60
|
+
storageDeposit: StorageDeposit;
|
|
61
|
+
debugMessage?: Bytes;
|
|
62
|
+
result: Result<InstantiateReturnValue, DispatchError>;
|
|
63
|
+
};
|
|
64
|
+
export interface ExecutionOptions {
|
|
65
|
+
defaultCaller?: AccountId32Like;
|
|
66
|
+
}
|
|
67
|
+
export type CallOptions = {
|
|
68
|
+
value?: bigint;
|
|
69
|
+
gasLimit?: Weight | undefined;
|
|
70
|
+
storageDepositLimit?: bigint | undefined;
|
|
71
|
+
};
|
|
72
|
+
export type ConstructorCallOptions = CallOptions & {
|
|
73
|
+
salt?: BytesLike;
|
|
74
|
+
caller?: AccountId32Like;
|
|
75
|
+
};
|
|
76
|
+
export type ConstructorTxOptions = CallOptions & {
|
|
77
|
+
salt?: BytesLike;
|
|
78
|
+
};
|
|
79
|
+
export type ContractCallOptions = CallOptions & {
|
|
80
|
+
caller?: AccountId32Like;
|
|
81
|
+
};
|
|
82
|
+
export type ContractTxOptions = CallOptions;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface SolAbiTypeDef {
|
|
2
|
+
internalType?: string;
|
|
3
|
+
components?: SolAbiTypeDef[];
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SolAbiInput extends SolAbiTypeDef {
|
|
8
|
+
}
|
|
9
|
+
export interface SolAbiOutput extends SolAbiTypeDef {
|
|
10
|
+
}
|
|
11
|
+
export interface SolAbiFunction {
|
|
12
|
+
inputs: SolAbiInput[];
|
|
13
|
+
name: string;
|
|
14
|
+
outputs: SolAbiOutput[];
|
|
15
|
+
stateMutability: 'pure' | 'view' | 'nonpayable' | 'payable';
|
|
16
|
+
type: 'function';
|
|
17
|
+
}
|
|
18
|
+
export interface SolAbiConstructor {
|
|
19
|
+
inputs: SolAbiInput[];
|
|
20
|
+
stateMutability: 'nonpayable' | 'payable';
|
|
21
|
+
type: 'constructor';
|
|
22
|
+
}
|
|
23
|
+
export interface SolAbiEvent {
|
|
24
|
+
anonymous?: boolean;
|
|
25
|
+
inputs: (SolAbiInput & {
|
|
26
|
+
indexed?: boolean;
|
|
27
|
+
})[];
|
|
28
|
+
name: string;
|
|
29
|
+
type: 'event';
|
|
30
|
+
}
|
|
31
|
+
export interface SolAbiError {
|
|
32
|
+
inputs: SolAbiInput[];
|
|
33
|
+
name: string;
|
|
34
|
+
type: 'error';
|
|
35
|
+
}
|
|
36
|
+
export interface SolAbiFallback {
|
|
37
|
+
type: 'fallback';
|
|
38
|
+
stateMutability: 'nonpayable' | 'payable';
|
|
39
|
+
}
|
|
40
|
+
export interface SolAbiReceive {
|
|
41
|
+
type: 'receive';
|
|
42
|
+
stateMutability: 'payable';
|
|
43
|
+
}
|
|
44
|
+
export type SolAbiItem = SolAbiFunction | SolAbiConstructor | SolAbiEvent | SolAbiError | SolAbiFallback | SolAbiReceive;
|
|
45
|
+
export type SolAbi = SolAbiItem[];
|
package/types/sol/abi.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './abi.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './abi.js';
|
package/utils/address.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AccountId20, AccountId32 } from '@dedot/codecs';
|
|
2
2
|
import { concatU8a, hexToU8a, keccakAsU8a, toHex, toU8a, u8aToHex } from '@dedot/utils';
|
|
3
|
-
import {
|
|
3
|
+
import { toRlp } from 'viem/utils';
|
|
4
4
|
/**
|
|
5
5
|
* Calculate new contract's address is based on the deployer's address and a nonce
|
|
6
6
|
*
|
|
@@ -10,7 +10,7 @@ import { RLP } from '@ethereumjs/rlp';
|
|
|
10
10
|
* @param nonce
|
|
11
11
|
*/
|
|
12
12
|
export function CREATE1(deployer, nonce) {
|
|
13
|
-
const encodedData =
|
|
13
|
+
const encodedData = toRlp([new AccountId20(deployer).raw, toHex(nonce)]);
|
|
14
14
|
const hash = keccakAsU8a(encodedData);
|
|
15
15
|
return u8aToHex(hash.subarray(12));
|
|
16
16
|
}
|
package/utils/ensure.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { ISubstrateClient } from '@dedot/api';
|
|
2
2
|
import { SubstrateApi } from '@dedot/api/chaintypes';
|
|
3
|
-
import { Hash } from '@dedot/codecs';
|
|
3
|
+
import { AccountId32Like, Hash } from '@dedot/codecs';
|
|
4
4
|
import { RpcVersion } from '@dedot/types';
|
|
5
|
-
import {
|
|
6
|
-
import { ContractAddress, LooseContractMetadata } from '
|
|
5
|
+
import { LRUCache } from '@dedot/utils';
|
|
6
|
+
import { ContractAddress, LooseContractMetadata } from '../types/index.js';
|
|
7
7
|
export declare const ensureStorageApiSupports: (version: string | number) => void;
|
|
8
|
-
export declare function ensurePalletPresence(client: ISubstrateClient<SubstrateApi[RpcVersion]>,
|
|
9
|
-
export declare function ensureContractPresence(client: ISubstrateClient<SubstrateApi[RpcVersion]>,
|
|
10
|
-
export declare function ensureValidContractAddress(address: ContractAddress,
|
|
11
|
-
export declare function
|
|
8
|
+
export declare function ensurePalletPresence(client: ISubstrateClient<SubstrateApi[RpcVersion]>, isRevive: boolean): void;
|
|
9
|
+
export declare function ensureContractPresence(client: ISubstrateClient<SubstrateApi[RpcVersion]>, isRevive: boolean, address: ContractAddress, cache?: LRUCache): Promise<void>;
|
|
10
|
+
export declare function ensureValidContractAddress(address: ContractAddress, isRevive: boolean): void;
|
|
11
|
+
export declare function ensureValidAccountId32Address(address: AccountId32Like, customErrorMessage?: string): void;
|
|
12
|
+
export declare function ensureValidCodeHashOrCode(codeHashOrCode: Hash | Uint8Array | string, isRevive: boolean): void;
|
|
12
13
|
export declare function ensureSupportedContractMetadataVersion(metadata: LooseContractMetadata): void;
|
|
13
14
|
export declare function ensureParamsLength(expectedArgsLength: number, actualParamsLength: number): void;
|