@dedot/contracts 0.18.8 → 1.0.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/errors.d.ts +10 -10
- package/executor/ink/ConstructorQueryExecutor.d.ts +1 -2
- package/executor/ink/ConstructorTxExecutor.d.ts +1 -2
- package/executor/ink/EventExecutor.d.ts +1 -2
- package/executor/ink/QueryExecutor.d.ts +1 -2
- package/executor/ink/TxExecutor.d.ts +1 -2
- package/executor/ink/abstract/ContractExecutor.d.ts +2 -3
- package/executor/ink/abstract/DeployerExecutor.d.ts +2 -3
- package/executor/ink/abstract/Executor.d.ts +4 -6
- package/executor/sol/SolConstructorQueryExecutor.d.ts +1 -2
- package/executor/sol/SolConstructorTxExecutor.d.ts +1 -2
- package/executor/sol/SolEventExecutor.d.ts +1 -2
- package/executor/sol/SolQueryExecutor.d.ts +1 -2
- package/executor/sol/SolTxExecutor.d.ts +1 -2
- package/executor/sol/abstract/SolContractExecutor.d.ts +2 -3
- package/executor/sol/abstract/SolDeployerExecutor.d.ts +2 -3
- package/executor/sol/abstract/SolExecutor.d.ts +3 -5
- package/package.json +7 -7
- package/types/index.d.ts +25 -26
- package/types/shared.d.ts +2 -3
- package/utils/ensure.d.ts +2 -4
- package/utils/proxy.d.ts +1 -1
package/errors.d.ts
CHANGED
|
@@ -14,13 +14,13 @@ export declare class ContractInstantiateError<ContractApi extends GenericContrac
|
|
|
14
14
|
/**
|
|
15
15
|
* The raw result of the contract instantiation.
|
|
16
16
|
*/
|
|
17
|
-
raw: ContractInstantiateResult
|
|
17
|
+
raw: ContractInstantiateResult;
|
|
18
18
|
/**
|
|
19
19
|
* Constructs a new `ContractInstantiateError` instance.
|
|
20
20
|
*
|
|
21
21
|
* @param raw - The raw result of the contract instantiation.
|
|
22
22
|
*/
|
|
23
|
-
constructor(raw: ContractInstantiateResult
|
|
23
|
+
constructor(raw: ContractInstantiateResult);
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Represents an error that occurred during the dispatch phase of contract instantiation.
|
|
@@ -47,7 +47,7 @@ export declare class ContractInstantiateDispatchError<ContractApi extends Generi
|
|
|
47
47
|
* @param raw - The raw result of the contract instantiation.
|
|
48
48
|
* @param moduleError - The decoded module error, if any.
|
|
49
49
|
*/
|
|
50
|
-
constructor(err: DispatchError, raw: ContractInstantiateResult
|
|
50
|
+
constructor(err: DispatchError, raw: ContractInstantiateResult, moduleError?: PalletErrorMetadataLatest);
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* Represents an error that occurred during the instantiation of a smart contract due to a language-specific error.
|
|
@@ -75,7 +75,7 @@ export declare class ContractInstantiateLangError<ContractApi extends InkGeneric
|
|
|
75
75
|
* @param err - The `LangError` that occurred during the instantiation phase.
|
|
76
76
|
* @param raw - The raw result of the contract instantiation.
|
|
77
77
|
*/
|
|
78
|
-
constructor(err: ContractApi['types']['LangError'], raw: ContractInstantiateResult
|
|
78
|
+
constructor(err: ContractApi['types']['LangError'], raw: ContractInstantiateResult);
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
81
|
* Represents an error that occurred during the execution of a smart contract call.
|
|
@@ -90,13 +90,13 @@ export declare class ContractExecutionError<ContractApi extends GenericContractA
|
|
|
90
90
|
/**
|
|
91
91
|
* The raw result of the contract call.
|
|
92
92
|
*/
|
|
93
|
-
raw: ContractCallResult
|
|
93
|
+
raw: ContractCallResult;
|
|
94
94
|
/**
|
|
95
95
|
* Constructs a new `ContractExecutionError` instance.
|
|
96
96
|
*
|
|
97
97
|
* @param raw - The raw result of the contract call.
|
|
98
98
|
*/
|
|
99
|
-
constructor(raw: ContractCallResult
|
|
99
|
+
constructor(raw: ContractCallResult);
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
102
|
* Represents an error that occurred during the execution of a smart contract call due to a dispatch error.
|
|
@@ -123,7 +123,7 @@ export declare class ContractDispatchError<ContractApi extends GenericContractAp
|
|
|
123
123
|
* @param raw - The raw result of the contract call.
|
|
124
124
|
* @param moduleError - The decoded module error, if any.
|
|
125
125
|
*/
|
|
126
|
-
constructor(err: DispatchError, raw: ContractCallResult
|
|
126
|
+
constructor(err: DispatchError, raw: ContractCallResult, moduleError?: PalletErrorMetadataLatest);
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
129
|
* Represents an error that occurred during the execution of a smart contract call due to a language-specific error.
|
|
@@ -151,7 +151,7 @@ export declare class ContractLangError<ContractApi extends InkGenericContractApi
|
|
|
151
151
|
* @param err - The `LangError` that occurred during the execution phase.
|
|
152
152
|
* @param raw - The raw result of the contract call.
|
|
153
153
|
*/
|
|
154
|
-
constructor(err: ContractApi['types']['LangError'], raw: ContractCallResult
|
|
154
|
+
constructor(err: ContractApi['types']['LangError'], raw: ContractCallResult);
|
|
155
155
|
}
|
|
156
156
|
export type SolErrorResult = {
|
|
157
157
|
abiItem: SolAbiError;
|
|
@@ -169,7 +169,7 @@ export type SolErrorResult = {
|
|
|
169
169
|
export declare class SolContractInstantiateError<ContractApi extends SolGenericContractApi = SolGenericContractApi> extends ContractInstantiateError {
|
|
170
170
|
name: string;
|
|
171
171
|
details?: SolErrorResult;
|
|
172
|
-
constructor(raw: ContractInstantiateResult
|
|
172
|
+
constructor(raw: ContractInstantiateResult, { details, message }: {
|
|
173
173
|
details?: SolErrorResult;
|
|
174
174
|
message?: string;
|
|
175
175
|
});
|
|
@@ -185,7 +185,7 @@ export declare class SolContractInstantiateError<ContractApi extends SolGenericC
|
|
|
185
185
|
export declare class SolContractExecutionError<ContractApi extends SolGenericContractApi = SolGenericContractApi> extends ContractExecutionError {
|
|
186
186
|
name: string;
|
|
187
187
|
details?: SolErrorResult;
|
|
188
|
-
constructor(raw: ContractCallResult
|
|
188
|
+
constructor(raw: ContractCallResult, { details, message }: {
|
|
189
189
|
details?: SolErrorResult;
|
|
190
190
|
message?: string;
|
|
191
191
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { GenericSubstrateApi } from '@dedot/types';
|
|
2
1
|
import { DeployerExecutor } from './abstract/index.js';
|
|
3
|
-
export declare class ConstructorQueryExecutor
|
|
2
|
+
export declare class ConstructorQueryExecutor extends DeployerExecutor {
|
|
4
3
|
doExecute(constructor: string): any;
|
|
5
4
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { GenericSubstrateApi } from '@dedot/types';
|
|
2
1
|
import { DeployerExecutor } from './abstract/index.js';
|
|
3
|
-
export declare class ConstructorTxExecutor
|
|
2
|
+
export declare class ConstructorTxExecutor extends DeployerExecutor {
|
|
4
3
|
doExecute(constructor: string): any;
|
|
5
4
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { GenericSubstrateApi } from '@dedot/types';
|
|
2
1
|
import { GenericContractEvent } from '../../types/index.js';
|
|
3
2
|
import { ContractExecutor } from './abstract/index.js';
|
|
4
|
-
export declare class EventExecutor
|
|
3
|
+
export declare class EventExecutor extends ContractExecutor {
|
|
5
4
|
#private;
|
|
6
5
|
doExecute(eventName: string): GenericContractEvent<string, any, 'ink'>;
|
|
7
6
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { GenericSubstrateApi } from '@dedot/types';
|
|
2
1
|
import { ContractExecutor } from './abstract/index.js';
|
|
3
|
-
export declare class QueryExecutor
|
|
2
|
+
export declare class QueryExecutor extends ContractExecutor {
|
|
4
3
|
doExecute(message: string): any;
|
|
5
4
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { GenericSubstrateApi } from '@dedot/types';
|
|
2
1
|
import { ContractExecutor } from './abstract/index.js';
|
|
3
|
-
export declare class TxExecutor
|
|
2
|
+
export declare class TxExecutor extends ContractExecutor {
|
|
4
3
|
doExecute(message: string): any;
|
|
5
4
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { ISubstrateClient } from '@dedot/api';
|
|
2
|
-
import { GenericSubstrateApi } from '@dedot/types';
|
|
3
2
|
import { TypinkRegistry } from '../../../TypinkRegistry.js';
|
|
4
3
|
import { ContractAddress, ContractCallMessage, ExecutionOptions } from '../../../types/index.js';
|
|
5
4
|
import { Executor } from './Executor.js';
|
|
6
|
-
export declare abstract class ContractExecutor
|
|
5
|
+
export declare abstract class ContractExecutor extends Executor {
|
|
7
6
|
readonly address: ContractAddress;
|
|
8
|
-
constructor(client: ISubstrateClient
|
|
7
|
+
constructor(client: ISubstrateClient, registry: TypinkRegistry, address: ContractAddress, options?: ExecutionOptions);
|
|
9
8
|
protected findMessage(message: string): ContractCallMessage | undefined;
|
|
10
9
|
protected findTxMessage(message: string): ContractCallMessage | undefined;
|
|
11
10
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { ISubstrateClient } from '@dedot/api';
|
|
2
2
|
import { Hash } from '@dedot/codecs';
|
|
3
|
-
import { GenericSubstrateApi } from '@dedot/types';
|
|
4
3
|
import { HexString } from '@dedot/utils';
|
|
5
4
|
import { TypinkRegistry } from '../../../TypinkRegistry.js';
|
|
6
5
|
import { ContractConstructorMessage, ExecutionOptions } from '../../../types/index.js';
|
|
7
6
|
import { Executor } from './Executor.js';
|
|
8
|
-
export declare abstract class DeployerExecutor
|
|
7
|
+
export declare abstract class DeployerExecutor extends Executor {
|
|
9
8
|
readonly code: Hash | Uint8Array | HexString | string;
|
|
10
|
-
constructor(client: ISubstrateClient
|
|
9
|
+
constructor(client: ISubstrateClient, registry: TypinkRegistry, code: Hash | Uint8Array | HexString | string, options?: ExecutionOptions);
|
|
11
10
|
protected findConstructorMeta(constructor: string): ContractConstructorMessage | undefined;
|
|
12
11
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { ISubstrateClient } from '@dedot/api';
|
|
2
|
-
import { SubstrateApi } from '@dedot/api/chaintypes';
|
|
3
|
-
import { GenericSubstrateApi, RpcVersion } from '@dedot/types';
|
|
4
2
|
import { TypinkRegistry } from '../../../TypinkRegistry.js';
|
|
5
|
-
import { ContractMessageArg,
|
|
6
|
-
export declare abstract class Executor
|
|
7
|
-
readonly client: ISubstrateClient
|
|
3
|
+
import { ContractMessage, ContractMessageArg, ContractMetadata, ExecutionOptions } from '../../../types/index.js';
|
|
4
|
+
export declare abstract class Executor {
|
|
5
|
+
readonly client: ISubstrateClient;
|
|
8
6
|
readonly registry: TypinkRegistry;
|
|
9
7
|
readonly options: ExecutionOptions;
|
|
10
|
-
constructor(client: ISubstrateClient
|
|
8
|
+
constructor(client: ISubstrateClient, registry: TypinkRegistry, options?: ExecutionOptions);
|
|
11
9
|
get metadata(): ContractMetadata;
|
|
12
10
|
abstract doExecute(...paths: string[]): unknown;
|
|
13
11
|
tryEncode(param: ContractMessageArg, value: any): Uint8Array;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { GenericSubstrateApi } from '@dedot/types';
|
|
2
1
|
import { SolDeployerExecutor } from './abstract/index.js';
|
|
3
|
-
export declare class SolConstructorQueryExecutor
|
|
2
|
+
export declare class SolConstructorQueryExecutor extends SolDeployerExecutor {
|
|
4
3
|
doExecute(_: string): any;
|
|
5
4
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { GenericSubstrateApi } from '@dedot/types';
|
|
2
1
|
import { SolDeployerExecutor } from './abstract/index.js';
|
|
3
|
-
export declare class SolConstructorTxExecutor
|
|
2
|
+
export declare class SolConstructorTxExecutor extends SolDeployerExecutor {
|
|
4
3
|
doExecute(_: string): any;
|
|
5
4
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { GenericSubstrateApi } from '@dedot/types';
|
|
2
1
|
import { GenericContractEvent } from '../../types/index.js';
|
|
3
2
|
import { SolContractExecutor } from './abstract/index.js';
|
|
4
|
-
export declare class SolEventExecutor
|
|
3
|
+
export declare class SolEventExecutor extends SolContractExecutor {
|
|
5
4
|
doExecute(eventName: string): GenericContractEvent<string, any, 'sol'>;
|
|
6
5
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { GenericSubstrateApi } from '@dedot/types';
|
|
2
1
|
import { SolContractExecutor } from './abstract/SolContractExecutor.js';
|
|
3
|
-
export declare class SolQueryExecutor
|
|
2
|
+
export declare class SolQueryExecutor extends SolContractExecutor {
|
|
4
3
|
doExecute(name: string): any;
|
|
5
4
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { GenericSubstrateApi } from '@dedot/types';
|
|
2
1
|
import { SolContractExecutor } from './abstract/SolContractExecutor.js';
|
|
3
|
-
export declare class SolTxExecutor
|
|
2
|
+
export declare class SolTxExecutor extends SolContractExecutor {
|
|
4
3
|
doExecute(name: string): any;
|
|
5
4
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ISubstrateClient } from '@dedot/api';
|
|
2
|
-
import { GenericSubstrateApi } from '@dedot/types';
|
|
3
2
|
import { SolRegistry } from '../../../SolRegistry.js';
|
|
4
3
|
import { ContractAddress, ExecutionOptions } from '../../../types/index.js';
|
|
5
4
|
import { SolExecutor } from './SolExecutor.js';
|
|
6
|
-
export declare abstract class SolContractExecutor
|
|
5
|
+
export declare abstract class SolContractExecutor extends SolExecutor {
|
|
7
6
|
readonly address: ContractAddress;
|
|
8
|
-
constructor(client: ISubstrateClient
|
|
7
|
+
constructor(client: ISubstrateClient, registry: SolRegistry, address: ContractAddress, options?: ExecutionOptions);
|
|
9
8
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { ISubstrateClient } from '@dedot/api';
|
|
2
2
|
import { Hash } from '@dedot/codecs';
|
|
3
|
-
import { GenericSubstrateApi } from '@dedot/types';
|
|
4
3
|
import { HexString } from '@dedot/utils';
|
|
5
4
|
import { SolRegistry } from '../../../SolRegistry.js';
|
|
6
5
|
import { ExecutionOptions } from '../../../types/index.js';
|
|
7
6
|
import { SolExecutor } from './SolExecutor.js';
|
|
8
|
-
export declare abstract class SolDeployerExecutor
|
|
7
|
+
export declare abstract class SolDeployerExecutor extends SolExecutor {
|
|
9
8
|
readonly code: Hash | Uint8Array | HexString | string;
|
|
10
|
-
constructor(client: ISubstrateClient
|
|
9
|
+
constructor(client: ISubstrateClient, registry: SolRegistry, code: Hash | Uint8Array | HexString | string, options?: ExecutionOptions);
|
|
11
10
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { ISubstrateClient } from '@dedot/api';
|
|
2
|
-
import { SubstrateApi } from '@dedot/api/chaintypes';
|
|
3
|
-
import { GenericSubstrateApi, RpcVersion } from '@dedot/types';
|
|
4
2
|
import { SolRegistry } from '../../../SolRegistry.js';
|
|
5
3
|
import { ExecutionOptions, SolAbi } from '../../../types/index.js';
|
|
6
|
-
export declare abstract class SolExecutor
|
|
7
|
-
readonly client: ISubstrateClient
|
|
4
|
+
export declare abstract class SolExecutor {
|
|
5
|
+
readonly client: ISubstrateClient;
|
|
8
6
|
readonly registry: SolRegistry;
|
|
9
7
|
readonly options: ExecutionOptions;
|
|
10
|
-
protected constructor(client: ISubstrateClient
|
|
8
|
+
protected constructor(client: ISubstrateClient, registry: SolRegistry, options?: ExecutionOptions);
|
|
11
9
|
get abi(): SolAbi;
|
|
12
10
|
abstract doExecute(...paths: string[]): unknown;
|
|
13
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dedot/contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Delightful ink! Contract APIs",
|
|
5
5
|
"author": "Tung Vu <tung@dedot.dev>",
|
|
6
6
|
"homepage": "https://dedot.dev",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"test": "npx vitest --watch=false"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dedot/api": "0.
|
|
22
|
-
"@dedot/codecs": "0.
|
|
23
|
-
"@dedot/types": "0.
|
|
24
|
-
"@dedot/utils": "0.
|
|
25
|
-
"viem": "^2.
|
|
21
|
+
"@dedot/api": "1.0.0",
|
|
22
|
+
"@dedot/codecs": "1.0.0",
|
|
23
|
+
"@dedot/types": "1.0.0",
|
|
24
|
+
"@dedot/utils": "1.0.0",
|
|
25
|
+
"viem": "^2.40.3"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"node": ">=18"
|
|
33
33
|
},
|
|
34
34
|
"license": "Apache-2.0",
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "7767062a2188b4ac90561c5ad3cc3f06ac608a24",
|
|
36
36
|
"module": "./index.js",
|
|
37
37
|
"types": "./index.d.ts",
|
|
38
38
|
"exports": {
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SubstrateApi } from '@dedot/api/chaintypes';
|
|
2
2
|
import { Extrinsic } from '@dedot/codecs';
|
|
3
|
-
import { AnyFunc, AsyncMethod, GenericSubstrateApi, IEventRecord, ISubmittableExtrinsic, ISubmittableResult,
|
|
3
|
+
import { AnyFunc, AsyncMethod, GenericSubstrateApi, IEventRecord, ISubmittableExtrinsic, ISubmittableResult, Unsub } from '@dedot/types';
|
|
4
4
|
import { Contract } from '../Contract.js';
|
|
5
5
|
import { ContractCallMessage, ContractConstructorMessage, ContractEventMeta } from './ink/index.js';
|
|
6
6
|
import { ContractCallResult, ContractInstantiateResult, ExecutionOptions, GenericConstructorCallResult, GenericContractCallResult, ContractAddress } from './shared.js';
|
|
@@ -8,8 +8,7 @@ import { SolAbiConstructor, SolAbiEvent, SolAbiFunction } from './sol/index.js';
|
|
|
8
8
|
export * from './ink/index.js';
|
|
9
9
|
export * from './sol/index.js';
|
|
10
10
|
export * from './shared.js';
|
|
11
|
-
type
|
|
12
|
-
export type ContractSubmittableExtrinsic<_ extends GenericSubstrateApi> = SubmittableExtrinsic<ISubmittableResult>;
|
|
11
|
+
export type ContractSubmittableExtrinsic<R extends ISubmittableResult = ISubmittableResult> = ISubmittableExtrinsic<R> & Extrinsic;
|
|
13
12
|
export interface IContractInstantiateSubmittableResult<ContractApi extends GenericContractApi = GenericContractApi> extends ISubmittableResult {
|
|
14
13
|
/**
|
|
15
14
|
* Get deployed contract address
|
|
@@ -20,7 +19,7 @@ export interface IContractInstantiateSubmittableResult<ContractApi extends Gener
|
|
|
20
19
|
*/
|
|
21
20
|
contract(options?: ExecutionOptions): Promise<Contract<ContractApi>>;
|
|
22
21
|
}
|
|
23
|
-
export type GenericInstantiateSubmittableExtrinsic<
|
|
22
|
+
export type GenericInstantiateSubmittableExtrinsic<ContractApi extends GenericContractApi = GenericContractApi> = ContractSubmittableExtrinsic<IContractInstantiateSubmittableResult<ContractApi>>;
|
|
24
23
|
export interface LooseContractMetadata {
|
|
25
24
|
version: number | string;
|
|
26
25
|
[prop: string]: any;
|
|
@@ -29,29 +28,29 @@ export type LooseSolAbi = Array<{
|
|
|
29
28
|
type: string;
|
|
30
29
|
[prop: string]: any;
|
|
31
30
|
}>;
|
|
32
|
-
export type GenericContractQueryCall<
|
|
31
|
+
export type GenericContractQueryCall<F extends AsyncMethod = (...args: any[]) => Promise<GenericContractCallResult<any, ContractCallResult>>, Type extends MetadataType = MetadataType> = F & {
|
|
33
32
|
meta: Type extends 'ink' ? ContractCallMessage : SolAbiFunction;
|
|
34
33
|
};
|
|
35
|
-
export type GenericContractTxCall<
|
|
34
|
+
export type GenericContractTxCall<F extends AnyFunc = (...args: any[]) => ContractSubmittableExtrinsic, Type extends MetadataType = MetadataType> = F & {
|
|
36
35
|
meta: Type extends 'ink' ? ContractCallMessage : SolAbiFunction;
|
|
37
36
|
};
|
|
38
|
-
export type GenericConstructorQueryCall<
|
|
37
|
+
export type GenericConstructorQueryCall<F extends AsyncMethod = (...args: any[]) => Promise<GenericConstructorCallResult<any, ContractInstantiateResult>>, Type extends MetadataType = MetadataType> = F & {
|
|
39
38
|
meta: Type extends 'ink' ? ContractConstructorMessage : SolAbiConstructor;
|
|
40
39
|
};
|
|
41
|
-
export type GenericConstructorTxCall<
|
|
40
|
+
export type GenericConstructorTxCall<F extends AnyFunc = (...args: any[]) => GenericInstantiateSubmittableExtrinsic, Type extends MetadataType = MetadataType> = F & {
|
|
42
41
|
meta: Type extends 'ink' ? ContractConstructorMessage : SolAbiConstructor;
|
|
43
42
|
};
|
|
44
|
-
export interface GenericContractQuery<
|
|
45
|
-
[method: string]: GenericContractQueryCall<
|
|
43
|
+
export interface GenericContractQuery<Type extends MetadataType = MetadataType> {
|
|
44
|
+
[method: string]: GenericContractQueryCall<(...args: any[]) => Promise<GenericContractCallResult<any, ContractCallResult>>, Type>;
|
|
46
45
|
}
|
|
47
|
-
export interface GenericContractTx<
|
|
48
|
-
[method: string]: GenericContractTxCall<
|
|
46
|
+
export interface GenericContractTx<Type extends MetadataType = MetadataType> {
|
|
47
|
+
[method: string]: GenericContractTxCall<(...args: any[]) => ContractSubmittableExtrinsic, Type>;
|
|
49
48
|
}
|
|
50
|
-
export interface GenericConstructorQuery<
|
|
51
|
-
[method: string]: GenericConstructorQueryCall<
|
|
49
|
+
export interface GenericConstructorQuery<Type extends MetadataType = MetadataType> {
|
|
50
|
+
[method: string]: GenericConstructorQueryCall<(...args: any[]) => Promise<GenericConstructorCallResult<any, ContractInstantiateResult>>, Type>;
|
|
52
51
|
}
|
|
53
|
-
export interface GenericConstructorTx<
|
|
54
|
-
[method: string]: GenericConstructorTxCall<
|
|
52
|
+
export interface GenericConstructorTx<Type extends MetadataType = MetadataType> {
|
|
53
|
+
[method: string]: GenericConstructorTxCall<(...args: any[]) => GenericInstantiateSubmittableExtrinsic, Type>;
|
|
55
54
|
}
|
|
56
55
|
export type ContractEvent<EventName extends string = string, Data extends any = any> = Data extends undefined ? {
|
|
57
56
|
name: EventName;
|
|
@@ -66,7 +65,7 @@ export interface GenericContractEvent<EventName extends string = string, Data ex
|
|
|
66
65
|
watch: (callback: (events: ContractEvent<EventName, Data>[]) => void) => Promise<Unsub>;
|
|
67
66
|
meta: Type extends 'ink' ? ContractEventMeta : SolAbiEvent;
|
|
68
67
|
}
|
|
69
|
-
export interface GenericContractEvents<
|
|
68
|
+
export interface GenericContractEvents<Type extends MetadataType = MetadataType> {
|
|
70
69
|
[event: string]: GenericContractEvent<string, any, Type>;
|
|
71
70
|
}
|
|
72
71
|
export type GenericInkLangError = 'CouldNotReadInput' | any;
|
|
@@ -74,19 +73,19 @@ export type GenericRootStorage = any;
|
|
|
74
73
|
export type GenericLazyStorage = any;
|
|
75
74
|
export type MetadataType = 'ink' | 'sol';
|
|
76
75
|
export type AB<Type extends MetadataType, A, B> = Type extends 'ink' ? A : B;
|
|
77
|
-
export interface GenericContractApi<
|
|
76
|
+
export interface GenericContractApi<ChainApi extends GenericSubstrateApi = SubstrateApi, Type extends MetadataType = MetadataType> {
|
|
78
77
|
metadataType: Type;
|
|
79
|
-
query: GenericContractQuery<
|
|
80
|
-
tx: GenericContractTx<
|
|
81
|
-
constructorQuery: GenericConstructorQuery<
|
|
82
|
-
constructorTx: GenericConstructorTx<
|
|
83
|
-
events: GenericContractEvents<
|
|
78
|
+
query: GenericContractQuery<Type>;
|
|
79
|
+
tx: GenericContractTx<Type>;
|
|
80
|
+
constructorQuery: GenericConstructorQuery<Type>;
|
|
81
|
+
constructorTx: GenericConstructorTx<Type>;
|
|
82
|
+
events: GenericContractEvents<Type>;
|
|
84
83
|
storage: AB<Type, {
|
|
85
84
|
root(): Promise<GenericRootStorage>;
|
|
86
85
|
lazy(): GenericLazyStorage;
|
|
87
86
|
}, undefined>;
|
|
88
87
|
types: {
|
|
89
|
-
ChainApi: ChainApi
|
|
88
|
+
ChainApi: ChainApi;
|
|
90
89
|
[TypeName: string]: any;
|
|
91
90
|
};
|
|
92
91
|
}
|
|
@@ -96,7 +95,7 @@ type HasGetter<T> = T extends {
|
|
|
96
95
|
export type WithLazyStorage<T> = {
|
|
97
96
|
[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;
|
|
98
97
|
};
|
|
99
|
-
export interface InkGenericContractApi<
|
|
98
|
+
export interface InkGenericContractApi<ChainApi extends GenericSubstrateApi = SubstrateApi> extends GenericContractApi<ChainApi, 'ink'> {
|
|
100
99
|
}
|
|
101
|
-
export interface SolGenericContractApi<
|
|
100
|
+
export interface SolGenericContractApi<ChainApi extends GenericSubstrateApi = SubstrateApi> extends GenericContractApi<ChainApi, 'sol'> {
|
|
102
101
|
}
|
package/types/shared.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AccountId32Like, Bytes, BytesLike, DispatchError, H256, Weight } from '@dedot/codecs';
|
|
2
2
|
import { Result } from '@dedot/shape';
|
|
3
|
-
import { GenericSubstrateApi } from '@dedot/types';
|
|
4
3
|
export type ContractAddress = string;
|
|
5
4
|
/**
|
|
6
5
|
* Flags used by a contract to customize exit behaviour.
|
|
@@ -47,14 +46,14 @@ export type InstantiateReturnValue = {
|
|
|
47
46
|
result: ExecReturnValue;
|
|
48
47
|
address: ContractAddress;
|
|
49
48
|
};
|
|
50
|
-
export type ContractCallResult
|
|
49
|
+
export type ContractCallResult = {
|
|
51
50
|
gasConsumed: WeightV2;
|
|
52
51
|
gasRequired: WeightV2;
|
|
53
52
|
storageDeposit: StorageDeposit;
|
|
54
53
|
debugMessage?: Bytes;
|
|
55
54
|
result: Result<ExecReturnValue, DispatchError>;
|
|
56
55
|
};
|
|
57
|
-
export type ContractInstantiateResult
|
|
56
|
+
export type ContractInstantiateResult = {
|
|
58
57
|
gasConsumed: WeightV2;
|
|
59
58
|
gasRequired: WeightV2;
|
|
60
59
|
storageDeposit: StorageDeposit;
|
package/utils/ensure.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { ISubstrateClient } from '@dedot/api';
|
|
2
|
-
import { SubstrateApi } from '@dedot/api/chaintypes';
|
|
3
2
|
import { AccountId32Like, Hash } from '@dedot/codecs';
|
|
4
|
-
import { RpcVersion } from '@dedot/types';
|
|
5
3
|
import { LRUCache } from '@dedot/utils';
|
|
6
4
|
import { ContractAddress, LooseContractMetadata } from '../types/index.js';
|
|
7
5
|
export declare const ensureStorageApiSupports: (version: string | number) => void;
|
|
8
|
-
export declare function ensurePalletPresence(client: ISubstrateClient
|
|
9
|
-
export declare function ensureContractPresence(client: ISubstrateClient
|
|
6
|
+
export declare function ensurePalletPresence(client: ISubstrateClient, isRevive: boolean): void;
|
|
7
|
+
export declare function ensureContractPresence(client: ISubstrateClient, isRevive: boolean, address: ContractAddress, cache?: LRUCache): Promise<void>;
|
|
10
8
|
export declare function ensureValidContractAddress(address: ContractAddress, isRevive: boolean): void;
|
|
11
9
|
export declare function ensureValidAccountId32Address(address: AccountId32Like, customErrorMessage?: string): void;
|
|
12
10
|
export declare function ensureValidCodeHashOrCode(codeHashOrCode: Hash | Uint8Array | string, isRevive: boolean): void;
|
package/utils/proxy.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { GenericSubstrateApi } from '@dedot/types';
|
|
2
2
|
import { Executor } from 'src/executor';
|
|
3
|
-
export declare function newProxyChain<ChainApi extends GenericSubstrateApi>(carrier: Executor
|
|
3
|
+
export declare function newProxyChain<ChainApi extends GenericSubstrateApi>(carrier: Executor): unknown;
|