@dedot/contracts 0.17.1-next.6d398d60.0 → 0.17.1-next.9d03d21b.3
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 +2 -2
- package/ContractDeployer.d.ts +2 -2
- package/cjs/utils/ensure.js +9 -3
- package/package.json +6 -6
- package/types/index.d.ts +4 -0
- package/utils/ensure.js +9 -3
package/Contract.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { ISubstrateClient } from '@dedot/api';
|
|
|
2
2
|
import { IEventRecord } from '@dedot/types';
|
|
3
3
|
import { SolRegistry } from './SolRegistry.js';
|
|
4
4
|
import { TypinkRegistry } from './TypinkRegistry.js';
|
|
5
|
-
import { AB, ContractAddress, ContractEvent, ContractMetadata, ExecutionOptions, GenericContractApi, LooseContractMetadata, SolAbi } from './types/index.js';
|
|
5
|
+
import { AB, ContractAddress, ContractEvent, ContractMetadata, ExecutionOptions, GenericContractApi, LooseContractMetadata, LooseSolAbi, SolAbi } from './types/index.js';
|
|
6
6
|
export declare class Contract<ContractApi extends GenericContractApi = GenericContractApi> {
|
|
7
7
|
#private;
|
|
8
8
|
readonly client: ISubstrateClient<ContractApi['types']['ChainApi']>;
|
|
9
|
-
constructor(client: ISubstrateClient<ContractApi['types']['ChainApi']>, metadata: LooseContractMetadata |
|
|
9
|
+
constructor(client: ISubstrateClient<ContractApi['types']['ChainApi']>, metadata: LooseContractMetadata | LooseSolAbi | string, address: ContractAddress, options?: ExecutionOptions);
|
|
10
10
|
decodeEvent(eventRecord: IEventRecord): ContractEvent;
|
|
11
11
|
decodeEvents(eventRecords: IEventRecord[]): ContractEvent[];
|
|
12
12
|
get address(): ContractAddress;
|
package/ContractDeployer.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { ISubstrateClient } from '@dedot/api';
|
|
|
2
2
|
import { Hash } from '@dedot/codecs';
|
|
3
3
|
import { SolRegistry } from './SolRegistry.js';
|
|
4
4
|
import { TypinkRegistry } from './TypinkRegistry.js';
|
|
5
|
-
import { AB, ContractMetadata, ExecutionOptions, GenericContractApi, LooseContractMetadata, SolAbi } from './types/index.js';
|
|
5
|
+
import { AB, ContractMetadata, ExecutionOptions, GenericContractApi, LooseContractMetadata, LooseSolAbi, SolAbi } from './types/index.js';
|
|
6
6
|
export declare class ContractDeployer<ContractApi extends GenericContractApi = GenericContractApi> {
|
|
7
7
|
#private;
|
|
8
8
|
readonly client: ISubstrateClient<ContractApi['types']['ChainApi']>;
|
|
9
|
-
constructor(client: ISubstrateClient<ContractApi['types']['ChainApi']>, metadata: AB<ContractApi['metadataType'], LooseContractMetadata,
|
|
9
|
+
constructor(client: ISubstrateClient<ContractApi['types']['ChainApi']>, metadata: AB<ContractApi['metadataType'], LooseContractMetadata, LooseSolAbi> | string, codeHashOrCode: Hash | Uint8Array | string, options?: ExecutionOptions);
|
|
10
10
|
get metadata(): AB<ContractApi['metadataType'], ContractMetadata, SolAbi>;
|
|
11
11
|
get registry(): AB<ContractApi['metadataType'], TypinkRegistry, SolRegistry>;
|
|
12
12
|
get tx(): ContractApi['constructorTx'];
|
package/cjs/utils/ensure.js
CHANGED
|
@@ -38,10 +38,16 @@ async function ensureContractPresence(client, isRevive, address, cache) {
|
|
|
38
38
|
}
|
|
39
39
|
const contractInfo = await (async () => {
|
|
40
40
|
if (isRevive) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
try {
|
|
42
|
+
const accountInfo = await client.query.revive.accountInfoOf(address);
|
|
43
|
+
if (accountInfo?.accountType && accountInfo?.accountType?.type === 'Contract') {
|
|
44
|
+
return accountInfo.accountType.value;
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
44
47
|
}
|
|
48
|
+
catch { }
|
|
49
|
+
// Fallback to contractInfoOf for older versions of pallet-revive
|
|
50
|
+
return client.query.revive.contractInfoOf(address);
|
|
45
51
|
}
|
|
46
52
|
else {
|
|
47
53
|
return client.query.contracts.contractInfoOf(address);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dedot/contracts",
|
|
3
|
-
"version": "0.17.1-next.
|
|
3
|
+
"version": "0.17.1-next.9d03d21b.3+9d03d21b",
|
|
4
4
|
"description": "Delightful ink! Contract APIs",
|
|
5
5
|
"author": "Tung Vu <tung@dedot.dev>",
|
|
6
6
|
"homepage": "https://dedot.dev",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"test": "npx vitest --watch=false"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dedot/api": "0.17.1-next.
|
|
22
|
-
"@dedot/codecs": "0.17.1-next.
|
|
23
|
-
"@dedot/types": "0.17.1-next.
|
|
24
|
-
"@dedot/utils": "0.17.1-next.
|
|
21
|
+
"@dedot/api": "0.17.1-next.9d03d21b.3+9d03d21b",
|
|
22
|
+
"@dedot/codecs": "0.17.1-next.9d03d21b.3+9d03d21b",
|
|
23
|
+
"@dedot/types": "0.17.1-next.9d03d21b.3+9d03d21b",
|
|
24
|
+
"@dedot/utils": "0.17.1-next.9d03d21b.3+9d03d21b",
|
|
25
25
|
"viem": "^2.37.7"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"node": ">=18"
|
|
33
33
|
},
|
|
34
34
|
"license": "Apache-2.0",
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "9d03d21b0b652b14222301b64682940047514172",
|
|
36
36
|
"module": "./index.js",
|
|
37
37
|
"types": "./index.d.ts",
|
|
38
38
|
"exports": {
|
package/types/index.d.ts
CHANGED
|
@@ -25,6 +25,10 @@ export interface LooseContractMetadata {
|
|
|
25
25
|
version: number | string;
|
|
26
26
|
[prop: string]: any;
|
|
27
27
|
}
|
|
28
|
+
export type LooseSolAbi = Array<{
|
|
29
|
+
type: string;
|
|
30
|
+
[prop: string]: any;
|
|
31
|
+
}>;
|
|
28
32
|
export type GenericContractQueryCall<ChainApi extends GenericSubstrateApi, F extends AsyncMethod = (...args: any[]) => Promise<GenericContractCallResult<any, ContractCallResult<ChainApi>>>, Type extends MetadataType = MetadataType> = F & {
|
|
29
33
|
meta: Type extends 'ink' ? ContractCallMessage : SolAbiFunction;
|
|
30
34
|
};
|
package/utils/ensure.js
CHANGED
|
@@ -33,10 +33,16 @@ export async function ensureContractPresence(client, isRevive, address, cache) {
|
|
|
33
33
|
}
|
|
34
34
|
const contractInfo = await (async () => {
|
|
35
35
|
if (isRevive) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
try {
|
|
37
|
+
const accountInfo = await client.query.revive.accountInfoOf(address);
|
|
38
|
+
if (accountInfo?.accountType && accountInfo?.accountType?.type === 'Contract') {
|
|
39
|
+
return accountInfo.accountType.value;
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
39
42
|
}
|
|
43
|
+
catch { }
|
|
44
|
+
// Fallback to contractInfoOf for older versions of pallet-revive
|
|
45
|
+
return client.query.revive.contractInfoOf(address);
|
|
40
46
|
}
|
|
41
47
|
else {
|
|
42
48
|
return client.query.contracts.contractInfoOf(address);
|