@fangorn-network/sdk 2026.4.7-0 → 2026.4.10
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 +30 -26
- package/lib/cli/cli.js +115 -153
- package/lib/config.d.ts +241 -241
- package/lib/config.js +3 -3
- package/lib/fangorn.d.ts +5 -0
- package/lib/fangorn.js +13 -8
- package/lib/index.js +1 -2
- package/lib/modules/encryption/lit.d.ts +0 -1
- package/lib/modules/encryption/lit.js +1 -7
- package/lib/modules/gadgets/settledGadget.d.ts +1 -8
- package/lib/modules/gadgets/settledGadget.js +1 -13
- package/lib/providers/storage/index.d.ts +1 -1
- package/lib/providers/storage/index.js +3 -1
- package/lib/providers/storage/pinata.js +1 -1
- 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 +11 -6
- package/lib/registries/datasource-registry/index.js +89 -25
- 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 +35 -38
- 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 +6 -5
- package/lib/roles/consumer/index.js +21 -20
- package/lib/roles/consumer/types.d.ts +4 -4
- package/lib/roles/publisher/index.d.ts +22 -19
- package/lib/roles/publisher/index.js +63 -59
- package/lib/roles/publisher/types.d.ts +3 -3
- package/lib/roles/schema/index.d.ts +1 -7
- package/lib/roles/schema/index.js +4 -34
- package/lib/test/testbed.d.ts +7 -32
- package/lib/test/testbed.js +20 -43
- 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: "0xdb82c131a9d51f6e7695e744bb2bd7774cbb224c",
|
|
30
|
+
schemaRegistryContractAddress: "0x35b67934f9c75bfef6ff3f4d61ff406d81420066",
|
|
31
|
+
settlementRegistryContractAddress: "0x6aff8212e126ed3232958fd228bc58a202b8f590",
|
|
32
32
|
chainName: "arbitrumSepolia",
|
|
33
33
|
chain: arbitrumSepolia,
|
|
34
34
|
rpcUrl: "https://sepolia-rollup.arbitrum.io/rpc",
|
package/lib/fangorn.d.ts
CHANGED
|
@@ -27,6 +27,11 @@ declare class Fangorn {
|
|
|
27
27
|
* Consumer: purchase, claim, and decrypt data.
|
|
28
28
|
*/
|
|
29
29
|
get consumer(): ConsumerRole;
|
|
30
|
+
/**
|
|
31
|
+
* Create a new Fangorn instance
|
|
32
|
+
* @param options
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
30
35
|
static create(options: FangornCreateOptions): Promise<Fangorn>;
|
|
31
36
|
getConfig(): AppConfig;
|
|
32
37
|
getSchemaRegistry(): SchemaRegistry;
|
package/lib/fangorn.js
CHANGED
|
@@ -4,26 +4,26 @@ import "./modules/encryption/index.js";
|
|
|
4
4
|
import { PinataStorage } from "./providers/storage/pinata.js";
|
|
5
5
|
import "./providers/storage/index.js";
|
|
6
6
|
import { SchemaRole } from "./roles/schema/index.js";
|
|
7
|
-
import {
|
|
7
|
+
import { DataSourceRegistry } from "./registries/datasource-registry/index.js";
|
|
8
8
|
import { PublisherRole } from "./roles/publisher/index.js";
|
|
9
9
|
import { ConsumerRole } from "./roles/consumer/index.js";
|
|
10
10
|
import { SchemaRegistry } from "./registries/schema-registry/index.js";
|
|
11
|
-
import {
|
|
11
|
+
import { SettlementRegistry } from "./registries/settlement-registry/index.js";
|
|
12
12
|
import { createPublicClient, createWalletClient, http } from "viem";
|
|
13
13
|
import { privateKeyToAccount } from "viem/accounts";
|
|
14
14
|
|
|
15
15
|
//#region src/fangorn.ts
|
|
16
|
-
const DEFAULT_IPFS_GATEWAY = "https://
|
|
16
|
+
const DEFAULT_IPFS_GATEWAY = "https://ipfs.io";
|
|
17
17
|
function isEncryptionService(e) {
|
|
18
18
|
return typeof e.encrypt === "function";
|
|
19
19
|
}
|
|
20
20
|
function isPinataConfig(s) {
|
|
21
21
|
return "pinata" in s;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
function resolveStorage(storage) {
|
|
24
24
|
if (!storage) return void 0;
|
|
25
25
|
if (isPinataConfig(storage)) return new PinataStorage(storage.pinata.jwt, storage.pinata.gateway);
|
|
26
|
-
throw new Error(
|
|
26
|
+
throw new Error(`Invalid storage config: must be { pinata: { jwt, gateway } }, but was ${JSON.stringify(storage)}`);
|
|
27
27
|
}
|
|
28
28
|
var Fangorn = class Fangorn {
|
|
29
29
|
ctx;
|
|
@@ -38,14 +38,14 @@ var Fangorn = class Fangorn {
|
|
|
38
38
|
*/
|
|
39
39
|
get schema() {
|
|
40
40
|
if (!this.ctx.storage) throw new Error("fangorn.schema requires storage. Pass { pinata: { ... } } to Fangorn.create()");
|
|
41
|
-
return this._schema ??= new SchemaRole(this.ctx.schemaRegistry, this.ctx.storage, this.ctx.walletClient, this.ctx.ipfsGateway
|
|
41
|
+
return this._schema ??= new SchemaRole(this.ctx.schemaRegistry, this.ctx.storage, this.ctx.walletClient, this.ctx.ipfsGateway);
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* Publisher: encrypt, stage, and commit data under a schema.
|
|
45
45
|
*/
|
|
46
46
|
get publisher() {
|
|
47
47
|
if (!this.ctx.storage) throw new Error("fangorn.publisher requires storage. Pass { pinata: { ... } } to Fangorn.create()");
|
|
48
|
-
return this._publisher ??= new PublisherRole(this.ctx.dataSourceRegistry, this.ctx.
|
|
48
|
+
return this._publisher ??= new PublisherRole(this.ctx.dataSourceRegistry, this.ctx.schemaRegistry, this.ctx.storage, this.ctx.encryption, this.ctx.walletClient, this.ctx.config);
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* Consumer: purchase, claim, and decrypt data.
|
|
@@ -53,6 +53,11 @@ var Fangorn = class Fangorn {
|
|
|
53
53
|
get consumer() {
|
|
54
54
|
return this._consumer ??= new ConsumerRole(this.ctx.dataSourceRegistry, this.ctx.settlementRegistry, this.ctx.encryption, this.ctx.domain, this.ctx.ipfsGateway);
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Create a new Fangorn instance
|
|
58
|
+
* @param options
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
56
61
|
static async create(options) {
|
|
57
62
|
if (!options.privateKey && !options.walletClient) throw new Error("Either privateKey or walletClient must be provided");
|
|
58
63
|
const resolvedConfig = options.config ?? FangornConfig.ArbitrumSepolia;
|
|
@@ -61,7 +66,7 @@ var Fangorn = class Fangorn {
|
|
|
61
66
|
chain: resolvedConfig.chain,
|
|
62
67
|
transport: http(resolvedConfig.rpcUrl)
|
|
63
68
|
});
|
|
64
|
-
const storage =
|
|
69
|
+
const storage = resolveStorage(options.storage);
|
|
65
70
|
const encryption = isEncryptionService(options.encryption) ? options.encryption : await LitEncryptionService.init(resolvedConfig.chainName);
|
|
66
71
|
const domain = options.domain ?? new URL(resolvedConfig.rpcUrl).hostname;
|
|
67
72
|
const ipfsGateway = options.ipfsGateway ?? DEFAULT_IPFS_GATEWAY;
|
package/lib/index.js
CHANGED
|
@@ -3,10 +3,9 @@ import { LitEncryptionService } from "./modules/encryption/lit.js";
|
|
|
3
3
|
import "./modules/encryption/index.js";
|
|
4
4
|
import { PinataStorage } from "./providers/storage/pinata.js";
|
|
5
5
|
import { deserialize, retrieveByCid, serialize } from "./providers/storage/index.js";
|
|
6
|
-
import { SETTLEMENT_REGISTRY_ABI } from "./registries/settlement-registry/abi.js";
|
|
7
6
|
import { DS_REGISTRY_ABI } from "./registries/datasource-registry/abi.js";
|
|
7
|
+
import { SETTLEMENT_REGISTRY_ABI } from "./registries/settlement-registry/abi.js";
|
|
8
8
|
import { Fangorn } from "./fangorn.js";
|
|
9
|
-
import "./registries/index.js";
|
|
10
9
|
import { addressToBytes32Array, computeSchemaId, fieldToHex, hexToBytes32Array, hexToField, stringToBytes32Array } from "./utils/index.js";
|
|
11
10
|
|
|
12
11
|
export { DS_REGISTRY_ABI, Fangorn, FangornConfig, LitEncryptionService, PinataStorage, SETTLEMENT_REGISTRY_ABI, SupportedNetworks, addressToBytes32Array, computeSchemaId, deserialize, fieldToHex, hexToBytes32Array, hexToField, retrieveByCid, serialize, stringToBytes32Array };
|
|
@@ -15,7 +15,6 @@ declare class LitEncryptionService implements EncryptionService {
|
|
|
15
15
|
decrypt(payload: EncryptedPayload, authContext: AuthContextWrapper): Promise<DecryptedPayload>;
|
|
16
16
|
createAuthContext(walletClient: WalletClient, domain: string): Promise<AuthContextWrapper>;
|
|
17
17
|
private createAuthSig;
|
|
18
|
-
private parseKeyResponse;
|
|
19
18
|
}
|
|
20
19
|
//#endregion
|
|
21
20
|
export { LitEncryptionService };
|
|
@@ -47,7 +47,7 @@ var LitEncryptionService = class LitEncryptionService {
|
|
|
47
47
|
}
|
|
48
48
|
async createAuthContext(walletClient, domain) {
|
|
49
49
|
const isNode = typeof window === "undefined";
|
|
50
|
-
const account =
|
|
50
|
+
const account = walletClient.account;
|
|
51
51
|
if (!account) throw new Error("No account found in wallet client");
|
|
52
52
|
if (!walletClient.chain) throw new Error("No chain found in wallet client");
|
|
53
53
|
const sessionContext = await (isNode ? createAuthManager({ storage: storagePlugins.localStorageNode({
|
|
@@ -115,12 +115,6 @@ var LitEncryptionService = class LitEncryptionService {
|
|
|
115
115
|
address: account.address
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
|
-
parseKeyResponse(response) {
|
|
119
|
-
return Uint8Array.from(response.replace(/^[^\d]+/, "").split(","), (entry) => {
|
|
120
|
-
const val = parseInt(entry.trim(), 10);
|
|
121
|
-
return isNaN(val) ? 0 : val;
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
118
|
};
|
|
125
119
|
|
|
126
120
|
//#endregion
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AppConfig } from "../../config.js";
|
|
2
1
|
import { Gadget, GadgetDescriptor } from "./types.js";
|
|
3
2
|
import { Address, Hex } from "viem";
|
|
4
3
|
import { UnifiedAccessControlCondition } from "@lit-protocol/access-control-conditions";
|
|
@@ -12,12 +11,6 @@ interface SettledGadgetParams {
|
|
|
12
11
|
/** "arbitrumSepolia" | "baseSepolia" */
|
|
13
12
|
chainName: string;
|
|
14
13
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Build a new default gadget from the given config
|
|
17
|
-
* @param config : AppConfig
|
|
18
|
-
* @returns the configured gadget
|
|
19
|
-
*/
|
|
20
|
-
declare function makeSettledGadgetFactory(config: AppConfig): (resourceId: Hex) => SettledGadget;
|
|
21
14
|
declare class SettledGadget implements Gadget {
|
|
22
15
|
private readonly params;
|
|
23
16
|
readonly type = "settled";
|
|
@@ -28,4 +21,4 @@ declare class SettledGadget implements Gadget {
|
|
|
28
21
|
toDescriptor(): GadgetDescriptor;
|
|
29
22
|
}
|
|
30
23
|
//#endregion
|
|
31
|
-
export { SettledGadget, SettledGadgetParams
|
|
24
|
+
export { SettledGadget, SettledGadgetParams };
|
|
@@ -2,18 +2,6 @@ import { zeroAddress } from "viem";
|
|
|
2
2
|
import { createAccBuilder } from "@lit-protocol/access-control-conditions";
|
|
3
3
|
|
|
4
4
|
//#region src/modules/gadgets/settledGadget.ts
|
|
5
|
-
/**
|
|
6
|
-
* Build a new default gadget from the given config
|
|
7
|
-
* @param config : AppConfig
|
|
8
|
-
* @returns the configured gadget
|
|
9
|
-
*/
|
|
10
|
-
function makeSettledGadgetFactory(config) {
|
|
11
|
-
return (resourceId) => new SettledGadget({
|
|
12
|
-
resourceId,
|
|
13
|
-
settlementRegistryAddress: config.settlementRegistryContractAddress,
|
|
14
|
-
chainName: config.chainName
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
5
|
var SettledGadget = class {
|
|
18
6
|
type = "settled";
|
|
19
7
|
constructor(params) {
|
|
@@ -72,4 +60,4 @@ var SettledGadget = class {
|
|
|
72
60
|
};
|
|
73
61
|
|
|
74
62
|
//#endregion
|
|
75
|
-
export { SettledGadget
|
|
63
|
+
export { SettledGadget };
|
|
@@ -11,7 +11,7 @@ interface PinningService {
|
|
|
11
11
|
delete(cid: string): Promise<void>;
|
|
12
12
|
}
|
|
13
13
|
declare function serialize(data: unknown): string;
|
|
14
|
-
declare function deserialize
|
|
14
|
+
declare function deserialize(text: string): unknown;
|
|
15
15
|
/**
|
|
16
16
|
* Fetch any content by CID from a public IPFS gateway.
|
|
17
17
|
* No auth required — all Fangorn content is public; privacy is cryptographic.
|
|
@@ -31,7 +31,9 @@ function deserialize(text) {
|
|
|
31
31
|
async function retrieveByCid(cid, gateway = "https://ipfs.io") {
|
|
32
32
|
const url = `${gateway.replace(/\/$/, "")}/ipfs/${cid}`;
|
|
33
33
|
const controller = new AbortController();
|
|
34
|
-
const timeout = setTimeout(() =>
|
|
34
|
+
const timeout = setTimeout(() => {
|
|
35
|
+
controller.abort();
|
|
36
|
+
}, 1e4);
|
|
35
37
|
try {
|
|
36
38
|
const res = await fetch(url, { signal: controller.signal });
|
|
37
39
|
if (!res.ok) throw new Error(`Failed to retrieve ${cid}: ${res.statusText}`);
|
|
@@ -12,7 +12,7 @@ var PinataStorage = class {
|
|
|
12
12
|
}
|
|
13
13
|
async store(data, metadata) {
|
|
14
14
|
const content = serialize(data);
|
|
15
|
-
const file = new File([content], metadata
|
|
15
|
+
const file = new File([content], (metadata ?? { name: "file" }).name, { type: "text/plain" });
|
|
16
16
|
return (await this.pinata.upload.public.file(file, { metadata })).cid;
|
|
17
17
|
}
|
|
18
18
|
async delete(cid) {
|
|
@@ -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 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
|
|
5
5
|
interface DataSource {
|
|
6
6
|
manifestCid: string;
|
|
7
|
+
name: string;
|
|
7
8
|
schemaId: Hex;
|
|
8
9
|
version: bigint;
|
|
9
10
|
}
|
|
@@ -14,11 +15,15 @@ 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<viem0.TransactionReceipt>;
|
|
22
27
|
private estimateGas;
|
|
23
28
|
}
|
|
24
29
|
//#endregion
|