@fangorn-network/sdk 2026.4.7 → 2026.4.15
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/README.md +137 -150
- package/lib/cli/cli.js +134 -226
- package/lib/cli/index.d.ts +170 -170
- package/lib/config.d.ts +260 -257
- package/lib/config.js +7 -5
- package/lib/fangorn.d.ts +3 -20
- package/lib/fangorn.js +15 -52
- package/lib/index.d.ts +3 -7
- package/lib/index.js +4 -7
- package/lib/modules/encryption/aes.d.ts +3 -3
- package/lib/modules/encryption/index.d.ts +1 -28
- package/lib/modules/encryption/index.js +1 -3
- package/lib/modules/encryption/types.d.ts +1 -48
- package/lib/providers/storage/index.d.ts +4 -21
- package/lib/providers/storage/index.js +3 -2
- package/lib/providers/storage/pinata.d.ts +14 -0
- package/lib/providers/storage/pinata.js +32 -0
- package/lib/providers/storage/types.d.ts +37 -0
- package/lib/providers/storage/utils.d.ts +12 -0
- package/lib/providers/storage/utils.js +50 -0
- package/lib/registries/datasource-registry/abi.d.ts +116 -43
- package/lib/registries/datasource-registry/abi.js +190 -12
- package/lib/registries/datasource-registry/index.d.ts +12 -6
- package/lib/registries/datasource-registry/index.js +96 -20
- package/lib/registries/index.js +1 -1
- package/lib/registries/schema-registry/abi.d.ts +157 -66
- package/lib/registries/schema-registry/abi.js +242 -15
- package/lib/registries/schema-registry/index.d.ts +8 -3
- package/lib/registries/schema-registry/index.js +82 -17
- package/lib/registries/settlement-registry/abi.d.ts +199 -145
- package/lib/registries/settlement-registry/abi.js +331 -25
- package/lib/registries/settlement-registry/index.d.ts +36 -39
- package/lib/registries/settlement-registry/index.js +125 -91
- package/lib/registries/settlement-registry/types.d.ts +6 -3
- package/lib/roles/consumer/index.d.ts +17 -42
- package/lib/roles/consumer/index.js +87 -58
- package/lib/roles/consumer/types.d.ts +15 -34
- package/lib/roles/publisher/index.d.ts +22 -40
- package/lib/roles/publisher/index.js +69 -113
- package/lib/roles/publisher/types.d.ts +40 -41
- package/lib/roles/schema/index.d.ts +4 -30
- package/lib/roles/schema/index.js +7 -60
- package/lib/roles/schema/types.d.ts +16 -2
- package/lib/test/testbed.d.ts +12 -36
- package/lib/test/testbed.js +35 -68
- package/lib/types/index.d.ts +14 -57
- package/package.json +1 -6
- package/lib/modules/encryption/lit.d.ts +0 -21
- package/lib/modules/encryption/lit.js +0 -127
- package/lib/modules/gadgets/index.d.ts +0 -2
- package/lib/modules/gadgets/index.js +0 -1
- package/lib/modules/gadgets/settledGadget.d.ts +0 -31
- package/lib/modules/gadgets/settledGadget.js +0 -75
- package/lib/modules/gadgets/types.d.ts +0 -27
- package/lib/providers/storage/pinata/index.d.ts +0 -13
- package/lib/providers/storage/pinata/index.js +0 -41
- package/lib/providers/storage/storacha/index.d.ts +0 -13
- package/lib/providers/storage/storacha/index.js +0 -49
- package/lib/providers/storage/storacha/readOnly.d.ts +0 -8
- package/lib/providers/storage/storacha/readOnly.js +0 -16
- /package/lib/{modules/gadgets → providers/storage}/types.js +0 -0
|
@@ -1,83 +1,156 @@
|
|
|
1
1
|
//#region src/registries/datasource-registry/abi.d.ts
|
|
2
2
|
declare const DS_REGISTRY_ABI: readonly [{
|
|
3
|
-
readonly
|
|
4
|
-
readonly
|
|
5
|
-
readonly
|
|
3
|
+
readonly inputs: readonly [];
|
|
4
|
+
readonly name: "DataSourceNotFound";
|
|
5
|
+
readonly type: "error";
|
|
6
|
+
}, {
|
|
7
|
+
readonly inputs: readonly [];
|
|
8
|
+
readonly name: "NameRequired";
|
|
9
|
+
readonly type: "error";
|
|
10
|
+
}, {
|
|
11
|
+
readonly inputs: readonly [];
|
|
12
|
+
readonly name: "ResourceSetupFailed";
|
|
13
|
+
readonly type: "error";
|
|
14
|
+
}, {
|
|
15
|
+
readonly inputs: readonly [];
|
|
16
|
+
readonly name: "SchemaNotFound";
|
|
17
|
+
readonly type: "error";
|
|
18
|
+
}, {
|
|
19
|
+
readonly inputs: readonly [];
|
|
20
|
+
readonly name: "SchemaRequired";
|
|
21
|
+
readonly type: "error";
|
|
22
|
+
}, {
|
|
6
23
|
readonly inputs: readonly [{
|
|
24
|
+
readonly internalType: "address";
|
|
25
|
+
readonly name: "owner";
|
|
7
26
|
readonly type: "address";
|
|
8
|
-
|
|
27
|
+
}, {
|
|
28
|
+
readonly internalType: "bytes32";
|
|
29
|
+
readonly name: "schema_id";
|
|
30
|
+
readonly type: "bytes32";
|
|
31
|
+
}, {
|
|
32
|
+
readonly internalType: "string";
|
|
33
|
+
readonly name: "name";
|
|
34
|
+
readonly type: "string";
|
|
9
35
|
}];
|
|
10
|
-
readonly
|
|
11
|
-
|
|
12
|
-
|
|
36
|
+
readonly name: "get";
|
|
37
|
+
readonly outputs: readonly [{
|
|
38
|
+
readonly internalType: "string";
|
|
39
|
+
readonly name: "";
|
|
40
|
+
readonly type: "string";
|
|
41
|
+
}];
|
|
42
|
+
readonly stateMutability: "view";
|
|
13
43
|
readonly type: "function";
|
|
14
|
-
|
|
44
|
+
}, {
|
|
15
45
|
readonly inputs: readonly [{
|
|
16
|
-
readonly
|
|
17
|
-
readonly name: "
|
|
46
|
+
readonly internalType: "address";
|
|
47
|
+
readonly name: "owner";
|
|
48
|
+
readonly type: "address";
|
|
18
49
|
}, {
|
|
19
|
-
readonly
|
|
50
|
+
readonly internalType: "bytes32";
|
|
20
51
|
readonly name: "schema_id";
|
|
52
|
+
readonly type: "bytes32";
|
|
53
|
+
}, {
|
|
54
|
+
readonly internalType: "bytes32";
|
|
55
|
+
readonly name: "name_hash";
|
|
56
|
+
readonly type: "bytes32";
|
|
57
|
+
}];
|
|
58
|
+
readonly name: "getByHash";
|
|
59
|
+
readonly outputs: readonly [{
|
|
60
|
+
readonly internalType: "string";
|
|
61
|
+
readonly name: "";
|
|
62
|
+
readonly type: "string";
|
|
21
63
|
}];
|
|
22
|
-
readonly outputs: readonly [];
|
|
23
|
-
}, {
|
|
24
|
-
readonly name: "getManifest";
|
|
25
|
-
readonly type: "function";
|
|
26
64
|
readonly stateMutability: "view";
|
|
65
|
+
readonly type: "function";
|
|
66
|
+
}, {
|
|
27
67
|
readonly inputs: readonly [{
|
|
28
|
-
readonly
|
|
68
|
+
readonly internalType: "address";
|
|
29
69
|
readonly name: "owner";
|
|
70
|
+
readonly type: "address";
|
|
30
71
|
}, {
|
|
31
|
-
readonly
|
|
72
|
+
readonly internalType: "bytes32";
|
|
32
73
|
readonly name: "schema_id";
|
|
74
|
+
readonly type: "bytes32";
|
|
75
|
+
}, {
|
|
76
|
+
readonly internalType: "bytes32";
|
|
77
|
+
readonly name: "name_hash";
|
|
78
|
+
readonly type: "bytes32";
|
|
33
79
|
}];
|
|
80
|
+
readonly name: "getName";
|
|
34
81
|
readonly outputs: readonly [{
|
|
82
|
+
readonly internalType: "string";
|
|
83
|
+
readonly name: "";
|
|
35
84
|
readonly type: "string";
|
|
36
85
|
}];
|
|
37
|
-
}, {
|
|
38
|
-
readonly name: "getVersion";
|
|
39
|
-
readonly type: "function";
|
|
40
86
|
readonly stateMutability: "view";
|
|
87
|
+
readonly type: "function";
|
|
88
|
+
}, {
|
|
41
89
|
readonly inputs: readonly [{
|
|
42
|
-
readonly
|
|
90
|
+
readonly internalType: "address";
|
|
43
91
|
readonly name: "owner";
|
|
92
|
+
readonly type: "address";
|
|
44
93
|
}, {
|
|
45
|
-
readonly
|
|
94
|
+
readonly internalType: "bytes32";
|
|
46
95
|
readonly name: "schema_id";
|
|
96
|
+
readonly type: "bytes32";
|
|
97
|
+
}, {
|
|
98
|
+
readonly internalType: "string";
|
|
99
|
+
readonly name: "name";
|
|
100
|
+
readonly type: "string";
|
|
47
101
|
}];
|
|
102
|
+
readonly name: "getVersion";
|
|
48
103
|
readonly outputs: readonly [{
|
|
104
|
+
readonly internalType: "uint64";
|
|
105
|
+
readonly name: "";
|
|
49
106
|
readonly type: "uint64";
|
|
50
107
|
}];
|
|
108
|
+
readonly stateMutability: "view";
|
|
109
|
+
readonly type: "function";
|
|
51
110
|
}, {
|
|
52
|
-
readonly name: "ManifestPublished";
|
|
53
|
-
readonly type: "event";
|
|
54
111
|
readonly inputs: readonly [{
|
|
55
|
-
readonly
|
|
56
|
-
readonly name: "
|
|
57
|
-
readonly
|
|
112
|
+
readonly internalType: "string";
|
|
113
|
+
readonly name: "manifest_cid";
|
|
114
|
+
readonly type: "string";
|
|
58
115
|
}, {
|
|
59
|
-
readonly
|
|
116
|
+
readonly internalType: "bytes32";
|
|
60
117
|
readonly name: "schema_id";
|
|
61
|
-
readonly
|
|
118
|
+
readonly type: "bytes32";
|
|
62
119
|
}, {
|
|
120
|
+
readonly internalType: "string";
|
|
121
|
+
readonly name: "name";
|
|
63
122
|
readonly type: "string";
|
|
64
|
-
readonly name: "manifest_cid";
|
|
65
123
|
}, {
|
|
66
|
-
readonly
|
|
67
|
-
readonly name: "
|
|
124
|
+
readonly internalType: "uint256";
|
|
125
|
+
readonly name: "price";
|
|
126
|
+
readonly type: "uint256";
|
|
68
127
|
}];
|
|
128
|
+
readonly name: "publish";
|
|
129
|
+
readonly outputs: readonly [];
|
|
130
|
+
readonly stateMutability: "nonpayable";
|
|
131
|
+
readonly type: "function";
|
|
69
132
|
}, {
|
|
70
|
-
readonly
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
133
|
+
readonly inputs: readonly [{
|
|
134
|
+
readonly internalType: "address";
|
|
135
|
+
readonly name: "owner";
|
|
136
|
+
readonly type: "address";
|
|
137
|
+
}, {
|
|
138
|
+
readonly internalType: "bytes32";
|
|
139
|
+
readonly name: "schema_id";
|
|
140
|
+
readonly type: "bytes32";
|
|
141
|
+
}, {
|
|
142
|
+
readonly internalType: "string";
|
|
143
|
+
readonly name: "name";
|
|
144
|
+
readonly type: "string";
|
|
145
|
+
}];
|
|
146
|
+
readonly name: "resourceId";
|
|
147
|
+
readonly outputs: readonly [{
|
|
148
|
+
readonly internalType: "bytes32";
|
|
149
|
+
readonly name: "";
|
|
150
|
+
readonly type: "bytes32";
|
|
151
|
+
}];
|
|
152
|
+
readonly stateMutability: "view";
|
|
153
|
+
readonly type: "function";
|
|
81
154
|
}];
|
|
82
155
|
//#endregion
|
|
83
156
|
export { DS_REGISTRY_ABI };
|
|
@@ -1,16 +1,194 @@
|
|
|
1
|
-
import { parseAbi } from "viem";
|
|
2
|
-
|
|
3
1
|
//#region src/registries/datasource-registry/abi.ts
|
|
4
|
-
const DS_REGISTRY_ABI =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
const DS_REGISTRY_ABI = [
|
|
3
|
+
{
|
|
4
|
+
"inputs": [],
|
|
5
|
+
"name": "DataSourceNotFound",
|
|
6
|
+
"type": "error"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"inputs": [],
|
|
10
|
+
"name": "NameRequired",
|
|
11
|
+
"type": "error"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"inputs": [],
|
|
15
|
+
"name": "ResourceSetupFailed",
|
|
16
|
+
"type": "error"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"inputs": [],
|
|
20
|
+
"name": "SchemaNotFound",
|
|
21
|
+
"type": "error"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"inputs": [],
|
|
25
|
+
"name": "SchemaRequired",
|
|
26
|
+
"type": "error"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"inputs": [
|
|
30
|
+
{
|
|
31
|
+
"internalType": "address",
|
|
32
|
+
"name": "owner",
|
|
33
|
+
"type": "address"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"internalType": "bytes32",
|
|
37
|
+
"name": "schema_id",
|
|
38
|
+
"type": "bytes32"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"internalType": "string",
|
|
42
|
+
"name": "name",
|
|
43
|
+
"type": "string"
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"name": "get",
|
|
47
|
+
"outputs": [{
|
|
48
|
+
"internalType": "string",
|
|
49
|
+
"name": "",
|
|
50
|
+
"type": "string"
|
|
51
|
+
}],
|
|
52
|
+
"stateMutability": "view",
|
|
53
|
+
"type": "function"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"inputs": [
|
|
57
|
+
{
|
|
58
|
+
"internalType": "address",
|
|
59
|
+
"name": "owner",
|
|
60
|
+
"type": "address"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"internalType": "bytes32",
|
|
64
|
+
"name": "schema_id",
|
|
65
|
+
"type": "bytes32"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"internalType": "bytes32",
|
|
69
|
+
"name": "name_hash",
|
|
70
|
+
"type": "bytes32"
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
"name": "getByHash",
|
|
74
|
+
"outputs": [{
|
|
75
|
+
"internalType": "string",
|
|
76
|
+
"name": "",
|
|
77
|
+
"type": "string"
|
|
78
|
+
}],
|
|
79
|
+
"stateMutability": "view",
|
|
80
|
+
"type": "function"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"inputs": [
|
|
84
|
+
{
|
|
85
|
+
"internalType": "address",
|
|
86
|
+
"name": "owner",
|
|
87
|
+
"type": "address"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"internalType": "bytes32",
|
|
91
|
+
"name": "schema_id",
|
|
92
|
+
"type": "bytes32"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"internalType": "bytes32",
|
|
96
|
+
"name": "name_hash",
|
|
97
|
+
"type": "bytes32"
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
"name": "getName",
|
|
101
|
+
"outputs": [{
|
|
102
|
+
"internalType": "string",
|
|
103
|
+
"name": "",
|
|
104
|
+
"type": "string"
|
|
105
|
+
}],
|
|
106
|
+
"stateMutability": "view",
|
|
107
|
+
"type": "function"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"inputs": [
|
|
111
|
+
{
|
|
112
|
+
"internalType": "address",
|
|
113
|
+
"name": "owner",
|
|
114
|
+
"type": "address"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"internalType": "bytes32",
|
|
118
|
+
"name": "schema_id",
|
|
119
|
+
"type": "bytes32"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"internalType": "string",
|
|
123
|
+
"name": "name",
|
|
124
|
+
"type": "string"
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
"name": "getVersion",
|
|
128
|
+
"outputs": [{
|
|
129
|
+
"internalType": "uint64",
|
|
130
|
+
"name": "",
|
|
131
|
+
"type": "uint64"
|
|
132
|
+
}],
|
|
133
|
+
"stateMutability": "view",
|
|
134
|
+
"type": "function"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"inputs": [
|
|
138
|
+
{
|
|
139
|
+
"internalType": "string",
|
|
140
|
+
"name": "manifest_cid",
|
|
141
|
+
"type": "string"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"internalType": "bytes32",
|
|
145
|
+
"name": "schema_id",
|
|
146
|
+
"type": "bytes32"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"internalType": "string",
|
|
150
|
+
"name": "name",
|
|
151
|
+
"type": "string"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"internalType": "uint256",
|
|
155
|
+
"name": "price",
|
|
156
|
+
"type": "uint256"
|
|
157
|
+
}
|
|
158
|
+
],
|
|
159
|
+
"name": "publish",
|
|
160
|
+
"outputs": [],
|
|
161
|
+
"stateMutability": "nonpayable",
|
|
162
|
+
"type": "function"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"inputs": [
|
|
166
|
+
{
|
|
167
|
+
"internalType": "address",
|
|
168
|
+
"name": "owner",
|
|
169
|
+
"type": "address"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"internalType": "bytes32",
|
|
173
|
+
"name": "schema_id",
|
|
174
|
+
"type": "bytes32"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"internalType": "string",
|
|
178
|
+
"name": "name",
|
|
179
|
+
"type": "string"
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
"name": "resourceId",
|
|
183
|
+
"outputs": [{
|
|
184
|
+
"internalType": "bytes32",
|
|
185
|
+
"name": "",
|
|
186
|
+
"type": "bytes32"
|
|
187
|
+
}],
|
|
188
|
+
"stateMutability": "view",
|
|
189
|
+
"type": "function"
|
|
190
|
+
}
|
|
191
|
+
];
|
|
14
192
|
|
|
15
193
|
//#endregion
|
|
16
194
|
export { DS_REGISTRY_ABI };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as viem173 from "viem";
|
|
2
2
|
import { Address, Hash, Hex, PublicClient, WalletClient } from "viem";
|
|
3
3
|
|
|
4
4
|
//#region src/registries/datasource-registry/index.d.ts
|
|
5
5
|
interface DataSource {
|
|
6
6
|
manifestCid: string;
|
|
7
|
+
name: string;
|
|
7
8
|
schemaId: Hex;
|
|
8
9
|
version: bigint;
|
|
9
10
|
}
|
|
@@ -14,11 +15,16 @@ declare class DataSourceRegistry {
|
|
|
14
15
|
constructor(contractAddress: Address, publicClient: PublicClient, walletClient: WalletClient);
|
|
15
16
|
private getWriteConfig;
|
|
16
17
|
getContractAddress(): `0x${string}`;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
publish(manifestCid: string, schemaId: Hex, name: string, price: bigint, gas?: bigint): Promise<Hash>;
|
|
19
|
+
get(owner: Address, schemaId: Hex, name: string): Promise<DataSource>;
|
|
20
|
+
getByHash(owner: Address, schemaId: Hex, nameHash: Hex): Promise<string>;
|
|
21
|
+
getName(owner: Address, schemaId: Hex, nameHash: Hex): Promise<string>;
|
|
22
|
+
getVersion(owner: Address, schemaId: Hex, name: string): Promise<bigint>;
|
|
23
|
+
resourceId(owner: Address, schemaId: Hex, name: string): Promise<Hex>;
|
|
24
|
+
static resourceIdLocal(owner: Address, schemaId: Hex, name: string): Hex;
|
|
25
|
+
hashName(name: string): Hex;
|
|
26
|
+
waitForTransaction(hash: Hash): Promise<viem173.TransactionReceipt>;
|
|
27
|
+
private estimateGas;
|
|
22
28
|
}
|
|
23
29
|
//#endregion
|
|
24
30
|
export { DataSource, DataSourceRegistry };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DS_REGISTRY_ABI } from "./abi.js";
|
|
2
|
+
import { encodePacked, keccak256 } from "viem";
|
|
2
3
|
|
|
3
4
|
//#region src/registries/datasource-registry/index.ts
|
|
4
5
|
var DataSourceRegistry = class {
|
|
@@ -21,61 +22,136 @@ var DataSourceRegistry = class {
|
|
|
21
22
|
getContractAddress() {
|
|
22
23
|
return this.contractAddress;
|
|
23
24
|
}
|
|
24
|
-
async
|
|
25
|
+
async publish(manifestCid, schemaId, name, price, gas) {
|
|
25
26
|
const { chain, account } = this.getWriteConfig();
|
|
26
|
-
const
|
|
27
|
+
const gasLimit = await this.estimateGas(() => this.publicClient.estimateContractGas({
|
|
27
28
|
address: this.contractAddress,
|
|
28
29
|
abi: DS_REGISTRY_ABI,
|
|
29
|
-
functionName: "
|
|
30
|
-
args: [
|
|
31
|
-
|
|
30
|
+
functionName: "publish",
|
|
31
|
+
args: [
|
|
32
|
+
manifestCid,
|
|
33
|
+
schemaId,
|
|
34
|
+
name,
|
|
35
|
+
price
|
|
36
|
+
],
|
|
32
37
|
account
|
|
33
|
-
});
|
|
34
|
-
await this.
|
|
35
|
-
return hash;
|
|
36
|
-
}
|
|
37
|
-
async publishManifest(manifestCid, schemaId) {
|
|
38
|
-
const { chain, account } = this.getWriteConfig();
|
|
38
|
+
}), gas);
|
|
39
|
+
const fees = await this.publicClient.estimateFeesPerGas();
|
|
39
40
|
const hash = await this.walletClient.writeContract({
|
|
40
41
|
address: this.contractAddress,
|
|
41
42
|
abi: DS_REGISTRY_ABI,
|
|
42
|
-
functionName: "
|
|
43
|
-
args: [
|
|
43
|
+
functionName: "publish",
|
|
44
|
+
args: [
|
|
45
|
+
manifestCid,
|
|
46
|
+
schemaId,
|
|
47
|
+
name,
|
|
48
|
+
price
|
|
49
|
+
],
|
|
44
50
|
chain,
|
|
45
|
-
account
|
|
51
|
+
account,
|
|
52
|
+
gas: gasLimit,
|
|
53
|
+
maxFeePerGas: fees.maxFeePerGas * 3n,
|
|
54
|
+
maxPriorityFeePerGas: fees.maxPriorityFeePerGas
|
|
46
55
|
});
|
|
47
56
|
await this.waitForTransaction(hash);
|
|
48
57
|
return hash;
|
|
49
58
|
}
|
|
50
|
-
async
|
|
59
|
+
async get(owner, schemaId, name) {
|
|
51
60
|
const [manifestCid, version] = await Promise.all([this.publicClient.readContract({
|
|
52
61
|
address: this.contractAddress,
|
|
53
62
|
abi: DS_REGISTRY_ABI,
|
|
54
|
-
functionName: "
|
|
55
|
-
args: [
|
|
63
|
+
functionName: "get",
|
|
64
|
+
args: [
|
|
65
|
+
owner,
|
|
66
|
+
schemaId,
|
|
67
|
+
name
|
|
68
|
+
]
|
|
56
69
|
}), this.publicClient.readContract({
|
|
57
70
|
address: this.contractAddress,
|
|
58
71
|
abi: DS_REGISTRY_ABI,
|
|
59
72
|
functionName: "getVersion",
|
|
60
|
-
args: [
|
|
73
|
+
args: [
|
|
74
|
+
owner,
|
|
75
|
+
schemaId,
|
|
76
|
+
name
|
|
77
|
+
]
|
|
61
78
|
})]);
|
|
62
79
|
return {
|
|
63
80
|
manifestCid,
|
|
81
|
+
name,
|
|
64
82
|
schemaId,
|
|
65
83
|
version
|
|
66
84
|
};
|
|
67
85
|
}
|
|
68
|
-
async
|
|
86
|
+
async getByHash(owner, schemaId, nameHash) {
|
|
87
|
+
return this.publicClient.readContract({
|
|
88
|
+
address: this.contractAddress,
|
|
89
|
+
abi: DS_REGISTRY_ABI,
|
|
90
|
+
functionName: "getByHash",
|
|
91
|
+
args: [
|
|
92
|
+
owner,
|
|
93
|
+
schemaId,
|
|
94
|
+
nameHash
|
|
95
|
+
]
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
async getName(owner, schemaId, nameHash) {
|
|
99
|
+
return this.publicClient.readContract({
|
|
100
|
+
address: this.contractAddress,
|
|
101
|
+
abi: DS_REGISTRY_ABI,
|
|
102
|
+
functionName: "getName",
|
|
103
|
+
args: [
|
|
104
|
+
owner,
|
|
105
|
+
schemaId,
|
|
106
|
+
nameHash
|
|
107
|
+
]
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
async getVersion(owner, schemaId, name) {
|
|
69
111
|
return this.publicClient.readContract({
|
|
70
112
|
address: this.contractAddress,
|
|
71
113
|
abi: DS_REGISTRY_ABI,
|
|
72
114
|
functionName: "getVersion",
|
|
73
|
-
args: [
|
|
115
|
+
args: [
|
|
116
|
+
owner,
|
|
117
|
+
schemaId,
|
|
118
|
+
name
|
|
119
|
+
]
|
|
74
120
|
});
|
|
75
121
|
}
|
|
122
|
+
async resourceId(owner, schemaId, name) {
|
|
123
|
+
return this.publicClient.readContract({
|
|
124
|
+
address: this.contractAddress,
|
|
125
|
+
abi: DS_REGISTRY_ABI,
|
|
126
|
+
functionName: "resourceId",
|
|
127
|
+
args: [
|
|
128
|
+
owner,
|
|
129
|
+
schemaId,
|
|
130
|
+
name
|
|
131
|
+
]
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
static resourceIdLocal(owner, schemaId, name) {
|
|
135
|
+
return keccak256(encodePacked([
|
|
136
|
+
"address",
|
|
137
|
+
"bytes32",
|
|
138
|
+
"bytes32"
|
|
139
|
+
], [
|
|
140
|
+
owner,
|
|
141
|
+
schemaId,
|
|
142
|
+
keccak256(new TextEncoder().encode(name))
|
|
143
|
+
]));
|
|
144
|
+
}
|
|
145
|
+
hashName(name) {
|
|
146
|
+
return keccak256(new TextEncoder().encode(name));
|
|
147
|
+
}
|
|
76
148
|
async waitForTransaction(hash) {
|
|
77
149
|
return this.publicClient.waitForTransactionReceipt({ hash });
|
|
78
150
|
}
|
|
151
|
+
async estimateGas(fn, override) {
|
|
152
|
+
if (override !== void 0) return override;
|
|
153
|
+
return await fn() * 130n / 100n;
|
|
154
|
+
}
|
|
79
155
|
};
|
|
80
156
|
|
|
81
157
|
//#endregion
|
package/lib/registries/index.js
CHANGED