@dedot/contracts 0.17.1-next.db98ff20.1 → 0.18.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 +2 -2
- package/ContractDeployer.d.ts +2 -2
- package/SolRegistry.js +1 -1
- package/TypinkRegistry.js +1 -1
- package/cjs/SolRegistry.js +1 -1
- package/cjs/TypinkRegistry.js +1 -1
- 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/SolRegistry.js
CHANGED
|
@@ -57,7 +57,7 @@ export class SolRegistry {
|
|
|
57
57
|
if (contractAddress) {
|
|
58
58
|
// @ts-ignore
|
|
59
59
|
const emittedContract = event.palletEvent.data?.contract;
|
|
60
|
-
return emittedContract === contractAddress;
|
|
60
|
+
return emittedContract?.toLowerCase() === contractAddress.toLowerCase();
|
|
61
61
|
}
|
|
62
62
|
return true;
|
|
63
63
|
}
|
package/TypinkRegistry.js
CHANGED
|
@@ -129,7 +129,7 @@ export class TypinkRegistry extends TypeRegistry {
|
|
|
129
129
|
// @ts-ignore
|
|
130
130
|
const emittedContract = event.palletEvent.data?.contract;
|
|
131
131
|
if (this.isRevive()) {
|
|
132
|
-
return emittedContract === contractAddress;
|
|
132
|
+
return emittedContract?.toLowerCase() === contractAddress.toLowerCase();
|
|
133
133
|
}
|
|
134
134
|
else if (emittedContract instanceof AccountId32) {
|
|
135
135
|
return emittedContract.eq(contractAddress);
|
package/cjs/SolRegistry.js
CHANGED
|
@@ -60,7 +60,7 @@ class SolRegistry {
|
|
|
60
60
|
if (contractAddress) {
|
|
61
61
|
// @ts-ignore
|
|
62
62
|
const emittedContract = event.palletEvent.data?.contract;
|
|
63
|
-
return emittedContract === contractAddress;
|
|
63
|
+
return emittedContract?.toLowerCase() === contractAddress.toLowerCase();
|
|
64
64
|
}
|
|
65
65
|
return true;
|
|
66
66
|
}
|
package/cjs/TypinkRegistry.js
CHANGED
|
@@ -155,7 +155,7 @@ class TypinkRegistry extends codecs_1.TypeRegistry {
|
|
|
155
155
|
// @ts-ignore
|
|
156
156
|
const emittedContract = event.palletEvent.data?.contract;
|
|
157
157
|
if (this.isRevive()) {
|
|
158
|
-
return emittedContract === contractAddress;
|
|
158
|
+
return emittedContract?.toLowerCase() === contractAddress.toLowerCase();
|
|
159
159
|
}
|
|
160
160
|
else if (emittedContract instanceof codecs_1.AccountId32) {
|
|
161
161
|
return emittedContract.eq(contractAddress);
|
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.
|
|
3
|
+
"version": "0.18.1",
|
|
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.
|
|
22
|
-
"@dedot/codecs": "0.
|
|
23
|
-
"@dedot/types": "0.
|
|
24
|
-
"@dedot/utils": "0.
|
|
21
|
+
"@dedot/api": "0.18.1",
|
|
22
|
+
"@dedot/codecs": "0.18.1",
|
|
23
|
+
"@dedot/types": "0.18.1",
|
|
24
|
+
"@dedot/utils": "0.18.1",
|
|
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": "3ffda568232b50a3993d13c6ccac2894b0759dd7",
|
|
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);
|