@fangorn-network/sdk 2026.4.22 → 2026.4.23
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 +3 -3
- package/lib/cli/index.d.ts +170 -170
- package/lib/config.d.ts +257 -257
- package/lib/config.js +3 -3
- package/lib/registries/datasource-registry/index.d.ts +2 -2
- package/lib/registries/schema-registry/index.d.ts +2 -2
- package/lib/registries/settlement-registry/abi.d.ts +11 -75
- package/lib/registries/settlement-registry/abi.js +12 -88
- package/lib/registries/settlement-registry/index.d.ts +3 -9
- package/lib/registries/settlement-registry/index.js +4 -29
- package/package.json +1 -1
package/lib/config.js
CHANGED
|
@@ -26,9 +26,9 @@ function getNetwork(name) {
|
|
|
26
26
|
}
|
|
27
27
|
const FangornConfig = {
|
|
28
28
|
ArbitrumSepolia: {
|
|
29
|
-
dataSourceRegistryContractAddress: "
|
|
30
|
-
schemaRegistryContractAddress: "
|
|
31
|
-
settlementRegistryContractAddress: "
|
|
29
|
+
dataSourceRegistryContractAddress: "0x14cff4b583cabde7066d12f04bf9eaba408a426f",
|
|
30
|
+
schemaRegistryContractAddress: "0xfe63c0748cc992c7258dc3c92b44247f44f88577",
|
|
31
|
+
settlementRegistryContractAddress: "0x282915f5c6f6c9b15c131fa379916da47754fbef",
|
|
32
32
|
chainName: "arbitrumSepolia",
|
|
33
33
|
chain: arbitrumSepolia,
|
|
34
34
|
rpcUrl: "https://sepolia-rollup.arbitrum.io/rpc",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as viem0 from "viem";
|
|
2
2
|
import { Address, Hash, Hex, PublicClient, WalletClient } from "viem";
|
|
3
3
|
|
|
4
4
|
//#region src/registries/datasource-registry/index.d.ts
|
|
@@ -23,7 +23,7 @@ declare class DataSourceRegistry {
|
|
|
23
23
|
resourceId(owner: Address, schemaId: Hex, name: string): Promise<Hex>;
|
|
24
24
|
static resourceIdLocal(owner: Address, schemaId: Hex, name: string): Hex;
|
|
25
25
|
hashName(name: string): Hex;
|
|
26
|
-
waitForTransaction(hash: Hash): Promise<
|
|
26
|
+
waitForTransaction(hash: Hash): Promise<viem0.TransactionReceipt>;
|
|
27
27
|
private estimateGas;
|
|
28
28
|
}
|
|
29
29
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as viem0 from "viem";
|
|
2
2
|
import { Address, Hash, Hex, PublicClient, WalletClient } from "viem";
|
|
3
3
|
|
|
4
4
|
//#region src/registries/schema-registry/index.d.ts
|
|
@@ -27,7 +27,7 @@ declare class SchemaRegistry {
|
|
|
27
27
|
hasPublishers(nameOrId: string): Promise<boolean>;
|
|
28
28
|
isPublisher(nameOrId: string, publisher: Address): Promise<boolean>;
|
|
29
29
|
getPublisherCount(nameOrId: string): Promise<bigint>;
|
|
30
|
-
waitForTransaction(hash: Hash): Promise<
|
|
30
|
+
waitForTransaction(hash: Hash): Promise<viem0.TransactionReceipt>;
|
|
31
31
|
private resolveId;
|
|
32
32
|
}
|
|
33
33
|
//#endregion
|
|
@@ -1,47 +1,11 @@
|
|
|
1
1
|
//#region src/registries/settlement-registry/abi.d.ts
|
|
2
2
|
declare const SETTLEMENT_REGISTRY_ABI: readonly [{
|
|
3
|
-
readonly inputs: readonly [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
readonly name: "
|
|
9
|
-
readonly type: "error";
|
|
10
|
-
}, {
|
|
11
|
-
readonly inputs: readonly [];
|
|
12
|
-
readonly name: "GroupCreationFailed";
|
|
13
|
-
readonly type: "error";
|
|
14
|
-
}, {
|
|
15
|
-
readonly inputs: readonly [];
|
|
16
|
-
readonly name: "HookFailed";
|
|
17
|
-
readonly type: "error";
|
|
18
|
-
}, {
|
|
19
|
-
readonly inputs: readonly [];
|
|
20
|
-
readonly name: "IncorrectPaymentAmount";
|
|
21
|
-
readonly type: "error";
|
|
22
|
-
}, {
|
|
23
|
-
readonly inputs: readonly [];
|
|
24
|
-
readonly name: "NotAdmin";
|
|
25
|
-
readonly type: "error";
|
|
26
|
-
}, {
|
|
27
|
-
readonly inputs: readonly [];
|
|
28
|
-
readonly name: "NotAuthorizedRegistry";
|
|
29
|
-
readonly type: "error";
|
|
30
|
-
}, {
|
|
31
|
-
readonly inputs: readonly [];
|
|
32
|
-
readonly name: "NotResourceOwner";
|
|
33
|
-
readonly type: "error";
|
|
34
|
-
}, {
|
|
35
|
-
readonly inputs: readonly [];
|
|
36
|
-
readonly name: "ResourceNotFound";
|
|
37
|
-
readonly type: "error";
|
|
38
|
-
}, {
|
|
39
|
-
readonly inputs: readonly [];
|
|
40
|
-
readonly name: "TransferFailed";
|
|
41
|
-
readonly type: "error";
|
|
42
|
-
}, {
|
|
43
|
-
readonly inputs: readonly [];
|
|
44
|
-
readonly name: "VerificationFailed";
|
|
3
|
+
readonly inputs: readonly [{
|
|
4
|
+
readonly internalType: "uint8";
|
|
5
|
+
readonly name: "";
|
|
6
|
+
readonly type: "uint8";
|
|
7
|
+
}];
|
|
8
|
+
readonly name: "ErrCode";
|
|
45
9
|
readonly type: "error";
|
|
46
10
|
}, {
|
|
47
11
|
readonly inputs: readonly [{
|
|
@@ -79,20 +43,6 @@ declare const SETTLEMENT_REGISTRY_ABI: readonly [{
|
|
|
79
43
|
}];
|
|
80
44
|
readonly stateMutability: "view";
|
|
81
45
|
readonly type: "function";
|
|
82
|
-
}, {
|
|
83
|
-
readonly inputs: readonly [{
|
|
84
|
-
readonly internalType: "bytes32";
|
|
85
|
-
readonly name: "resource_id";
|
|
86
|
-
readonly type: "bytes32";
|
|
87
|
-
}];
|
|
88
|
-
readonly name: "getOwner";
|
|
89
|
-
readonly outputs: readonly [{
|
|
90
|
-
readonly internalType: "address";
|
|
91
|
-
readonly name: "";
|
|
92
|
-
readonly type: "address";
|
|
93
|
-
}];
|
|
94
|
-
readonly stateMutability: "view";
|
|
95
|
-
readonly type: "function";
|
|
96
46
|
}, {
|
|
97
47
|
readonly inputs: readonly [{
|
|
98
48
|
readonly internalType: "bytes32";
|
|
@@ -193,20 +143,6 @@ declare const SETTLEMENT_REGISTRY_ABI: readonly [{
|
|
|
193
143
|
readonly outputs: readonly [];
|
|
194
144
|
readonly stateMutability: "payable";
|
|
195
145
|
readonly type: "function";
|
|
196
|
-
}, {
|
|
197
|
-
readonly inputs: readonly [{
|
|
198
|
-
readonly internalType: "bytes32";
|
|
199
|
-
readonly name: "resource_id";
|
|
200
|
-
readonly type: "bytes32";
|
|
201
|
-
}, {
|
|
202
|
-
readonly internalType: "address";
|
|
203
|
-
readonly name: "hook";
|
|
204
|
-
readonly type: "address";
|
|
205
|
-
}];
|
|
206
|
-
readonly name: "registerHook";
|
|
207
|
-
readonly outputs: readonly [];
|
|
208
|
-
readonly stateMutability: "nonpayable";
|
|
209
|
-
readonly type: "function";
|
|
210
146
|
}, {
|
|
211
147
|
readonly inputs: readonly [{
|
|
212
148
|
readonly internalType: "address";
|
|
@@ -264,16 +200,16 @@ declare const SETTLEMENT_REGISTRY_ABI: readonly [{
|
|
|
264
200
|
readonly internalType: "bytes32";
|
|
265
201
|
readonly name: "resource_id";
|
|
266
202
|
readonly type: "bytes32";
|
|
203
|
+
}, {
|
|
204
|
+
readonly internalType: "address";
|
|
205
|
+
readonly name: "hook";
|
|
206
|
+
readonly type: "address";
|
|
267
207
|
}, {
|
|
268
208
|
readonly internalType: "uint256";
|
|
269
209
|
readonly name: "price";
|
|
270
210
|
readonly type: "uint256";
|
|
271
|
-
}, {
|
|
272
|
-
readonly internalType: "address";
|
|
273
|
-
readonly name: "owner";
|
|
274
|
-
readonly type: "address";
|
|
275
211
|
}];
|
|
276
|
-
readonly name: "
|
|
212
|
+
readonly name: "updateResource";
|
|
277
213
|
readonly outputs: readonly [];
|
|
278
214
|
readonly stateMutability: "nonpayable";
|
|
279
215
|
readonly type: "function";
|
|
@@ -1,58 +1,12 @@
|
|
|
1
1
|
//#region src/registries/settlement-registry/abi.ts
|
|
2
2
|
const SETTLEMENT_REGISTRY_ABI = [
|
|
3
3
|
{
|
|
4
|
-
"inputs": [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"name": "AlreadySettled",
|
|
11
|
-
"type": "error"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"inputs": [],
|
|
15
|
-
"name": "GroupCreationFailed",
|
|
16
|
-
"type": "error"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"inputs": [],
|
|
20
|
-
"name": "HookFailed",
|
|
21
|
-
"type": "error"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"inputs": [],
|
|
25
|
-
"name": "IncorrectPaymentAmount",
|
|
26
|
-
"type": "error"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"inputs": [],
|
|
30
|
-
"name": "NotAdmin",
|
|
31
|
-
"type": "error"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"inputs": [],
|
|
35
|
-
"name": "NotAuthorizedRegistry",
|
|
36
|
-
"type": "error"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"inputs": [],
|
|
40
|
-
"name": "NotResourceOwner",
|
|
41
|
-
"type": "error"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"inputs": [],
|
|
45
|
-
"name": "ResourceNotFound",
|
|
46
|
-
"type": "error"
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
"inputs": [],
|
|
50
|
-
"name": "TransferFailed",
|
|
51
|
-
"type": "error"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"inputs": [],
|
|
55
|
-
"name": "VerificationFailed",
|
|
4
|
+
"inputs": [{
|
|
5
|
+
"internalType": "uint8",
|
|
6
|
+
"name": "",
|
|
7
|
+
"type": "uint8"
|
|
8
|
+
}],
|
|
9
|
+
"name": "ErrCode",
|
|
56
10
|
"type": "error"
|
|
57
11
|
},
|
|
58
12
|
{
|
|
@@ -97,21 +51,6 @@ const SETTLEMENT_REGISTRY_ABI = [
|
|
|
97
51
|
"stateMutability": "view",
|
|
98
52
|
"type": "function"
|
|
99
53
|
},
|
|
100
|
-
{
|
|
101
|
-
"inputs": [{
|
|
102
|
-
"internalType": "bytes32",
|
|
103
|
-
"name": "resource_id",
|
|
104
|
-
"type": "bytes32"
|
|
105
|
-
}],
|
|
106
|
-
"name": "getOwner",
|
|
107
|
-
"outputs": [{
|
|
108
|
-
"internalType": "address",
|
|
109
|
-
"name": "",
|
|
110
|
-
"type": "address"
|
|
111
|
-
}],
|
|
112
|
-
"stateMutability": "view",
|
|
113
|
-
"type": "function"
|
|
114
|
-
},
|
|
115
54
|
{
|
|
116
55
|
"inputs": [{
|
|
117
56
|
"internalType": "bytes32",
|
|
@@ -228,21 +167,6 @@ const SETTLEMENT_REGISTRY_ABI = [
|
|
|
228
167
|
"stateMutability": "payable",
|
|
229
168
|
"type": "function"
|
|
230
169
|
},
|
|
231
|
-
{
|
|
232
|
-
"inputs": [{
|
|
233
|
-
"internalType": "bytes32",
|
|
234
|
-
"name": "resource_id",
|
|
235
|
-
"type": "bytes32"
|
|
236
|
-
}, {
|
|
237
|
-
"internalType": "address",
|
|
238
|
-
"name": "hook",
|
|
239
|
-
"type": "address"
|
|
240
|
-
}],
|
|
241
|
-
"name": "registerHook",
|
|
242
|
-
"outputs": [],
|
|
243
|
-
"stateMutability": "nonpayable",
|
|
244
|
-
"type": "function"
|
|
245
|
-
},
|
|
246
170
|
{
|
|
247
171
|
"inputs": [{
|
|
248
172
|
"internalType": "address",
|
|
@@ -313,18 +237,18 @@ const SETTLEMENT_REGISTRY_ABI = [
|
|
|
313
237
|
"name": "resource_id",
|
|
314
238
|
"type": "bytes32"
|
|
315
239
|
},
|
|
240
|
+
{
|
|
241
|
+
"internalType": "address",
|
|
242
|
+
"name": "hook",
|
|
243
|
+
"type": "address"
|
|
244
|
+
},
|
|
316
245
|
{
|
|
317
246
|
"internalType": "uint256",
|
|
318
247
|
"name": "price",
|
|
319
248
|
"type": "uint256"
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
"internalType": "address",
|
|
323
|
-
"name": "owner",
|
|
324
|
-
"type": "address"
|
|
325
249
|
}
|
|
326
250
|
],
|
|
327
|
-
"name": "
|
|
251
|
+
"name": "updateResource",
|
|
328
252
|
"outputs": [],
|
|
329
253
|
"stateMutability": "nonpayable",
|
|
330
254
|
"type": "function"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PrepareSettleParams, PrepareSettleResult, RegisterParams, SettleParams, TransferWithAuthParams, TransferWithAuthPayload } from "./types.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as viem1 from "viem";
|
|
3
3
|
import { Address, Hex, PublicClient, WalletClient } from "viem";
|
|
4
4
|
|
|
5
5
|
//#region src/registries/settlement-registry/index.d.ts
|
|
@@ -26,12 +26,7 @@ declare class SettlementRegistry {
|
|
|
26
26
|
* Update the price for a resource.
|
|
27
27
|
* In production this is called by the DataSourceRegistry.
|
|
28
28
|
*/
|
|
29
|
-
updatePrice(resourceId: Hex,
|
|
30
|
-
/**
|
|
31
|
-
* Register a hook contract for a resource.
|
|
32
|
-
* Called directly by the publisher wallet (msg.sender must be resource owner).
|
|
33
|
-
*/
|
|
34
|
-
registerHook(resourceId: Hex, hook: Address): Promise<Hex>;
|
|
29
|
+
updatePrice(resourceId: Hex, hook: Address, price: bigint): Promise<Hex>;
|
|
35
30
|
/**
|
|
36
31
|
* Prepare the EIP-3009 transferWithAuthorization signature.
|
|
37
32
|
*/
|
|
@@ -58,8 +53,7 @@ declare class SettlementRegistry {
|
|
|
58
53
|
isRegistered(resourceId: Hex, identityCommitment: bigint): Promise<boolean>;
|
|
59
54
|
getGroupId(resourceId: Hex): Promise<bigint>;
|
|
60
55
|
getPrice(resourceId: Hex): Promise<bigint>;
|
|
61
|
-
|
|
62
|
-
waitForTransaction(hash: Hex): Promise<viem431.TransactionReceipt>;
|
|
56
|
+
waitForTransaction(hash: Hex): Promise<viem1.TransactionReceipt>;
|
|
63
57
|
/**
|
|
64
58
|
* Reconstruct the Semaphore group from MemberRegistered events.
|
|
65
59
|
*/
|
|
@@ -65,16 +65,16 @@ var SettlementRegistry = class {
|
|
|
65
65
|
* Update the price for a resource.
|
|
66
66
|
* In production this is called by the DataSourceRegistry.
|
|
67
67
|
*/
|
|
68
|
-
async updatePrice(resourceId,
|
|
68
|
+
async updatePrice(resourceId, hook, price) {
|
|
69
69
|
const account = this.getAccount();
|
|
70
70
|
const hash = await this.walletClient.writeContract({
|
|
71
71
|
address: this.contractAddress,
|
|
72
72
|
abi: SETTLEMENT_REGISTRY_ABI,
|
|
73
|
-
functionName: "
|
|
73
|
+
functionName: "updateResource",
|
|
74
74
|
args: [
|
|
75
75
|
resourceId,
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
hook,
|
|
77
|
+
price
|
|
78
78
|
],
|
|
79
79
|
chain: this.getChain(),
|
|
80
80
|
account
|
|
@@ -83,23 +83,6 @@ var SettlementRegistry = class {
|
|
|
83
83
|
return hash;
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
|
-
* Register a hook contract for a resource.
|
|
87
|
-
* Called directly by the publisher wallet (msg.sender must be resource owner).
|
|
88
|
-
*/
|
|
89
|
-
async registerHook(resourceId, hook) {
|
|
90
|
-
const account = this.getAccount();
|
|
91
|
-
const hash = await this.walletClient.writeContract({
|
|
92
|
-
address: this.contractAddress,
|
|
93
|
-
abi: SETTLEMENT_REGISTRY_ABI,
|
|
94
|
-
functionName: "registerHook",
|
|
95
|
-
args: [resourceId, hook],
|
|
96
|
-
chain: this.getChain(),
|
|
97
|
-
account
|
|
98
|
-
});
|
|
99
|
-
await this.publicClient.waitForTransactionReceipt({ hash });
|
|
100
|
-
return hash;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
86
|
* Prepare the EIP-3009 transferWithAuthorization signature.
|
|
104
87
|
*/
|
|
105
88
|
async prepareTransferWithAuth(params) {
|
|
@@ -300,14 +283,6 @@ var SettlementRegistry = class {
|
|
|
300
283
|
args: [resourceId]
|
|
301
284
|
});
|
|
302
285
|
}
|
|
303
|
-
async getOwner(resourceId) {
|
|
304
|
-
return this.publicClient.readContract({
|
|
305
|
-
address: this.contractAddress,
|
|
306
|
-
abi: SETTLEMENT_REGISTRY_ABI,
|
|
307
|
-
functionName: "getOwner",
|
|
308
|
-
args: [resourceId]
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
286
|
async waitForTransaction(hash) {
|
|
312
287
|
return this.publicClient.waitForTransactionReceipt({ hash });
|
|
313
288
|
}
|