fangorn-sdk 0.0.4 → 0.0.5

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 CHANGED
@@ -1,58 +1,55 @@
1
1
  # Fangorn
2
2
 
3
+ Programmable data.
4
+
3
5
  ## Overview
4
6
 
5
- Fangorn lets you publish encrypted data under public conditions, or predicates, such that it can only be decrypted if you meet the condition. Heavily inspired by witness encryption, Fangorn is 'practical' witness encryption built on top of threshold encryption and, for now, TEE-based computations (in the future: purely zkps).
7
+ Fangorn is a programmable data framework that lets you **register datasources** and **publish encrypted data** under public conditions, or predicates, such that it can only be decrypted if you meet the condition.
8
+
9
+ ## Supported Networks
10
+
11
+ Fangorn can be deployed on any EVM chain that has a brige to Lit protocol. Currently, contracts are deployed to both Arbitrum Sepolia and Base Sepolia. See the [contracts](#contracts) section for more info.
6
12
 
7
13
  ## Build
8
14
 
9
- To build this project, navigate to the root directory and run `pnpm i`.
15
+ `pnpm i`.
10
16
 
11
17
  ### Usage
12
18
 
13
19
  Fangorn is a programmable data framework. It provides tools to register data sources that can be accessed based on owner-defined conditions, like payment.
14
20
 
15
- ## Supported Networks
16
-
17
- - arbitrum sepolia
18
- - base sepolia
19
-
20
- ### Encryption
21
-
22
- The library is modular and can support various key management systems. We recommend, and use by default, Lit protocol as the main KMS, or in this case, DKMS.
23
-
24
- Each datasource points to the content identifier (CID) of a "manifest" stored in IPFS. Each manifest stores a complete record of (encrypted) content, descriptions, and prices inserted by the data owner.
25
-
26
21
  #### Quickstart
27
22
 
28
- Coming soon ;)
29
-
30
23
  ```js
31
- # TODO
24
+ # Coming soon
32
25
  ```
33
26
 
34
27
  #### Full Guide
35
28
 
29
+ #### Setup
30
+
36
31
  ```js
37
- // initialize a new fangorn client
38
-
39
- // setup config
40
- const config: AppConfig = {
41
- litActionCid: litActionCid,
42
- dataSourceRegistryContractAddress: dataSourceRegistryContractAddress,
43
- usdcContractAddress,
44
- chainName: "arbitrum",
45
- rpcUrl: rpcUrl,
46
- };
47
-
48
- // setup the Lit client
49
- // client to interact with LIT proto
32
+ // provide the account, rpcurl, and chain externally
33
+ // Initalize a wallet client
34
+ const walletClient = createWalletClient({
35
+ account,,
36
+ transport: http(rpcUrl),
37
+ chain,
38
+ });
39
+
40
+ // For ArbSep, also supports BaseSepolia (wallet client must match)
41
+ const config: AppConfig = FangornConfig.ArbitrumSepolia;
42
+
43
+ // setup the Lit client (for encryption)
50
44
  const litClient = await createLitClient({
51
45
  network: nagaDev,
52
46
  });
47
+ // and the encryption service
48
+ const encryptionService = new LitEncryptionService(delegateeLitClient, {
49
+ chainName: chain,
50
+ });
53
51
 
54
- // setup the storage client (jwt and gateway must be provided)
55
- // storage via Pinata
52
+ // setup the storage client
56
53
  const pinata = new PinataSDK({
57
54
  pinataJwt: jwt,
58
55
  pinataGateway: gateway,
@@ -61,85 +58,94 @@ const pinata = new PinataSDK({
61
58
  const storage = new PinataStorage(pinata);
62
59
 
63
60
  // the domain/webserver where Fangorn is used
64
- const domain = "localhost:3000";
61
+ const domain = "localhost";
65
62
 
66
63
  const fangorn = await Fangorn.init(
67
- delegatorAccount,
64
+ walletClient,
68
65
  storage,
69
- client,
66
+ encryptionService,
70
67
  domain,
71
68
  config,
72
69
  );
70
+ ```
73
71
 
74
- // create a new named vault
75
- const vaultName = "myvault-001";
76
- const vaultId = await fangorn.registerDataSource(vaultName);
72
+ ##### Datasource Registration
77
73
 
78
- // upload files to the vault, specifying price
74
+ Now that you have a Fangorn client, you can create a _datasource_. A datasource is an on-chain asset that stores a commitment to its storage root along with an optional `agentId` field for associating the datasource with an ERC-8004 identity.
75
+
76
+ ```js
77
+ const name = "demo";
78
+ // id = sha256(name || owner), agentId = ""
79
+ const id = await this.delegatorFangorn.registerDataSource(name, "");
80
+ ```
81
+
82
+ ##### Encryption
83
+
84
+ Once a datasource exists, the owner can update its storage root to point it to data. Fangorn leverages Lit protocol for encryption and access control.
85
+
86
+ Encryption works by specifying a [gadget](./src/modules/gadgets/README.md), code that represents a logical statement that you want to encrypt under. The gadgets framework is extensible and customizable, allowing for easy custom implementations. For now, we have three gadgets:
87
+
88
+ - empty wallet: must have an empty wallet to decrypt
89
+ - identity: must have a specific identity to decrypt
90
+ - payment: must submit a specific payment to decrypt
91
+
92
+ ```js
93
+ // configure data using a json array, note that all data in this array will be encrypted under the same condition
94
+ // each entry has as (tag, data, extension, fileTpe)
79
95
  let filedata = [
80
96
  {
81
97
  tag: "test0",
82
98
  data: "content0",
83
99
  extension: ".txt",
84
100
  fileType: "text/plain",
85
- price: "0.0001",
86
101
  },
87
102
  {
88
103
  tag: "test1",
89
104
  data: "content1",
90
105
  extension: ".png",
91
106
  fileType: "image/png",
92
- price: "0.15",
93
107
  },
94
108
  ];
95
- await fangorn.upload(vaultId, filedata);
96
109
 
97
- // easily add more files to the vault
98
- let filedata = [
99
- {
100
- tag: "test2",
101
- data: "content2",
102
- extension: ".mp4",
103
- fileType: "video/mp4",
104
- price: "0.091",
105
- },
106
- ];
107
- await fangorn.upload(vaultId, filedata);
108
-
109
- // overwrite a vault
110
- let filedata = [
111
- {
112
- tag: "test3",
113
- data: "content3",
114
- extension: ".js",
115
- fileType: "text/javascript",
116
- },
117
- ];
118
- await fangorn.upload(vaultId, filedata, true);
110
+ // this encrypts the file under a USDC payment condition, useful for x402
111
+ await fangorn.upload(datasourceName, filedata, async (file) => {
112
+ const commitment = await computeTagCommitment(
113
+ this.delegatorAddress,
114
+ datasourceName,
115
+ file.tag,
116
+ usdcPrice,
117
+ );
118
+ return new PaymentGadget({
119
+ commitment: fieldToHex(commitment),
120
+ chainName: this.config.chainName,
121
+ settlementTrackerContractAddress,
122
+ usdcPrice,
123
+ });
124
+ });
119
125
  ```
120
126
 
121
127
  ### Decryption
122
128
 
123
- Decryption works by providing a vault id, tag, and the valid password to unlock the data. Proof generation is handled by the Fangorn SDK.
129
+ Decryption mandates that the caller has met the condition specified by the ciphertext. If unknown, the condition can be decoded by fetching the entry from storage (pinata) in which we store a `gadgetDescriptor`, providing pertinent information about the gadget used to encrypt the plaintext and how to satisfy it.
124
130
 
125
131
  ```js
126
- // The tag associated with the data we want to decrypt
127
- const taxTag = "tax-2025";
128
- const password = "test";
129
-
130
- const domain = "localhost:3000";
131
- const fangorn = await Fangorn.init(delegateeAccount, jwt, gateway, domain);
132
- // try to recover plaintext
133
- const plaintext = await fangorn.decryptFile(vaultId, taxTag, password);
134
-
135
- console.log("we got the plaintext " + plaintext);
132
+ // the address of the owner of the datasource
133
+ const owner = "0xabc123...";
134
+ // the name of the datasource
135
+ const name = "demo";
136
+ // the tag of the data we want to fetch
137
+ const tag = "test0";
138
+
139
+ const plaintext = await fangorn.decryptFile(owner, name, tag);
140
+ const outputAsString = new TextDecoder().decode(output);
141
+ console.log("we got the plaintext " + outputAsString);
136
142
  ```
137
143
 
138
144
  ## Testing
139
145
 
140
146
  ### Unit Tests
141
147
 
142
- Run the tests with
148
+ Run the tests with:
143
149
 
144
150
  ```sh
145
151
  pnpm test
@@ -149,7 +155,7 @@ pnpm test
149
155
 
150
156
  #### Setup
151
157
 
152
- The e2e test suite requires various environment variables that must be manually configured.
158
+ The e2e test suite requires various environment variables that must be manually configured. In addition, it must be executed on an actual testnet in order to establish comms with Lit protocol.
153
159
 
154
160
  Testnet tokens (ETH on Base Sepolia) can be obtained from Coinbase's official faucet https://portal.cdp.coinbase.com/
155
161
 
@@ -159,19 +165,46 @@ Testnet tokens (ETH on Base Sepolia) can be obtained from Coinbase's official fa
159
165
  - Needs to have a balance of test ETH to send transactions
160
166
  - `DELEGATEE_ETH_PRIVATE_KEY`: The private key of the delegatee account
161
167
  - Needs to have a balance of test ETH to send transactions
162
- - `CHAIN_RPC_URL`: The RPC URL of the ERC20 chain
163
- - Expected to be Base sepolia testnet: https://base-sepolia-public.nodies.app
164
- - It does not currently support other networks (would require modifying the lit action, which we will do in the future)
165
- - `PINATA_JWT`: The JWT for Pinata
166
- - Can be obtained from: https://app.pinata.cloud/developers/api-keys
167
- - `PINATA_GATEWAY`: The gateway for Pinata
168
- - Can use your own gateway or the default 'https://gateway.pinata.cloud'
169
- - `LIT_ACTION_CID`: The CID of the lit action for access control checks
170
- - Can be deployed by the test script, else use "QmcDkeo7YnJbuyYnXfxcnB65UCkjFhLDG5qa3hknMmrDmQ"
171
- - `VERIFIER_CONTRACT_ADDR`: The Barretenberg verifier contract address
172
- - Can be deployed by the test script, else use "0xb88e05a06bb2a2a424c1740515b5a46c0d181639"
173
- - `ZK_GATE_ADDR`: The ZkGate.sol contract address
174
- - Can be deployed by the test script, else use "0xec2b41e50ca1b9fc3262b9fd6ad9744c64f135a6"
168
+
169
+ - `PINATA_JWT`: The JWT for Pinata
170
+ - Can be obtained from: https://app.pinata.cloud/developers/api-keys
171
+ - `PINATA_GATEWAY`: The gateway for Pinata
172
+ - Can use your own gateway or the default 'https://gateway.pinata.cloud'
173
+ - `CHAIN_NAME`: arbitrumSepolia or baseSepolia
174
+ - `CAIP2`: The CAIP-2 identifier for the network.
175
+ - 421614 for Arbitrum Sepolia, 84532 for Base Sepolia
176
+ - `CHAIN_RPC_URL`: The RPC URL of the chain
177
+ - Expected to be Base sepolia testnet: https://base-sepolia-public.nodies.app or Arbitrum Sepolia: https://sepolia-rollup.arbitrum.io/rpc
178
+ - `USDC_CONTRACT_ADDRESS`: The address of the deployed USDC contract
179
+ - 0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d for Arbitrum Sepolia 0x036CbD53842c5426634e7929541eC2318f3dCF7e for Base Sepolia
180
+ - `DS_REGISTRY_ADDR`: The address of the deployed data registry contract
181
+ - Can be deployed by the test script, else use 0x5bd547ce3b5964c2fc0325f523679f66de391d6f for Arbitrum Sepolia and 0x6fd0e50073dbd8169bcaf066bb4a4991bfa48eeb on Base Sepolia
182
+ - `SETTLEMENT_TRACKER_ADDR`: The address of the deployed settlement tracker contract address. This is only needed if you plan to run tests using the payment gadget.
183
+ - Can be deployed by the test script, else use 0x7c6ae9eb3398234eb69b2f3acfae69065505ff69 for Arbitrum Sepolia
184
+
185
+ Sample:
186
+
187
+ For Arbitrum Sepolia
188
+
189
+ ```sh
190
+ CHAIN_NAME=arbitrumSepolia
191
+ CAIP2=421614
192
+ CHAIN_RPC_URL=https://sepolia-rollup.arbitrum.io/rpc
193
+ USDC_CONTRACT_ADDRESS=0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d
194
+ DS_REGISTRY_ADDR=0x602aedafe1096004d4db591b6537bc39d7ac71a6
195
+ SETTLEMENT_TRACKER_ADDR=0x7c6ae9eb3398234eb69b2f3acfae69065505ff69
196
+ ```
197
+
198
+ For Base Sepolia
199
+
200
+ ```sh
201
+ CHAIN_NAME=baseSepolia
202
+ CAIP2=84532
203
+ CHAIN_RPC_URL=https://base-sepolia-public.nodies.app
204
+ USDC_CONTRACT_ADDRESS=0x036CbD53842c5426634e7929541eC2318f3dCF7e
205
+ DS_REGISTRY_ADDR=0x6fd0e50073dbd8169bcaf066bb4a4991bfa48eeb
206
+ SETTLEMENT_TRACKER_ADDR=0x708751829f5f5f584da4142b62cd5cc9235c8a18
207
+ ```
175
208
 
176
209
  ### Running the tests
177
210
 
@@ -182,6 +215,15 @@ The tests will:
182
215
  1. Build and deploy the solidity verifier to base sepolia (unless it is defined in .env)
183
216
  2. Upload the Lit Action to IPFS (unless it is defined in .env)
184
217
 
218
+ ## Contracts
219
+
220
+ | | Arbitrum Sepolia | Base Sepolia |
221
+ | -------------------------------------- | ------------------------------------------------------------ | -------------------------------------------------------------- |
222
+ | Datsource Registry Contract Deployment | 0x602aedafe1096004d4db591b6537bc39d7ac71a6 | 0x6fd0e50073dbd8169bcaf066bb4a4991bfa48eeb |
223
+ | Datsource Registry Contract Code | [lib.rs](./contracts/arbitrum/DatasourceRegistry/src/lib.rs) | [DSRegistry.sol](./contracts/src/DSRegistry.sol) |
224
+ | Settlement Tracker Contract Deployment | 0x7c6ae9eb3398234eb69b2f3acfae69065505ff69 | 0x708751829f5f5f584da4142b62cd5cc9235c8a18 |
225
+ | Settlement Tracker Contract Code | [lib.rs](./contracts/arbitrum/SettlementTracker//src/lib.rs) | [SettlementTracker.sol](./contracts/src/SettlementTracker.sol) |
226
+
185
227
  ## CLI
186
228
 
187
229
  To install locally:
@@ -191,21 +233,22 @@ chmod +x update_clci.sh
191
233
  ./update_cli.sh
192
234
  ```
193
235
 
194
- ```
236
+ ```sh
195
237
  Usage: Fangorn [options] [command]
196
238
 
197
239
  CLI for Fangorn
198
240
 
199
241
  Options:
200
- -V, --version output the version number
201
- -h, --help display help for command
242
+ -V, --version output the version number
243
+ -h, --help display help for command
202
244
 
203
245
  Commands:
204
- register [options] <name> Register a new data source
205
- upload [options] <name> <files...> Upload file(s) to a data source
206
- list [options] <name> List contents (index) of a data source
207
- info [options] <name> Get data source info from contract
208
- decrypt [options] <name> <tag> Decrypt a file from a vault
209
- entry [options] <name> <tag> Get info about a specific vault entry
210
- help [command] display help for command
246
+ register [options] <name> Register a new datasource as an agent.
247
+ upload [options] <name> <files...> Upload file(s) to a data source
248
+ decrypt [options] <owner> <name> <tag> Decrypt a file from a vault
249
+ help [command] display help for command
211
250
  ```
251
+
252
+ ## License
253
+
254
+ MIT
package/lib/cli.js CHANGED
@@ -326,7 +326,7 @@ program.command("register").description("Register a new datasource as an agent."
326
326
  if (agentsList.length > 0) datasourceAgentId = agentsList[0].agentId;
327
327
  else throw new Error(`Agent with name ${name} was not found on the ERC-8004 on ${chain.name}`);
328
328
  }
329
- note(`Data source ${name} registered with id = ${await (await getFangorn(chain)).registerDataSource(datasourceAgentId)}`);
329
+ note(`Data source ${name} registered with id = ${await (await getFangorn(chain)).registerDataSource(name, datasourceAgentId)}`);
330
330
  }
331
331
  process.exit(0);
332
332
  } catch (err) {
@@ -351,10 +351,8 @@ program.command("upload").description("Upload file(s) to a data source").argumen
351
351
  };
352
352
  });
353
353
  const cid = await fangorn.upload(name, filedata, async (file) => {
354
- const commitment = await computeTagCommitment(owner, name, file.tag, options.price);
355
- console.log("using commitment " + fieldToHex(commitment));
356
354
  return new PaymentGadget({
357
- commitment: fieldToHex(commitment),
355
+ commitment: fieldToHex(await computeTagCommitment(owner, name, file.tag, options.price)),
358
356
  chainName: "arbitrumSepolia",
359
357
  settlementTrackerContractAddress: "0xb32ed201896ba765e6aa118a5c18c263f559474e",
360
358
  usdcPrice: options.price
package/lib/config.d.ts CHANGED
@@ -713,7 +713,6 @@ interface AppConfig {
713
713
  chainName: string;
714
714
  chain: Chain;
715
715
  rpcUrl: string;
716
- usdcContractAddress: Hex;
717
716
  caip2: number;
718
717
  }
719
718
  declare namespace FangornConfig {
package/lib/config.js CHANGED
@@ -27,16 +27,14 @@ function getNetwork(name) {
27
27
  let FangornConfig;
28
28
  (function(_FangornConfig) {
29
29
  _FangornConfig.ArbitrumSepolia = {
30
- usdcContractAddress: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d",
31
- dataSourceRegistryContractAddress: "0x4bd96b4d274bdc845dccd06bb886ecdc0d708bdb",
30
+ dataSourceRegistryContractAddress: "0x602aedafe1096004d4db591b6537bc39d7ac71a6",
32
31
  chainName: "arbitrumSepolia",
33
32
  chain: arbitrumSepolia,
34
33
  rpcUrl: "https://sepolia-rollup.arbitrum.io/rpc",
35
34
  caip2: 421614
36
35
  };
37
36
  _FangornConfig.BaseSepolia = {
38
- usdcContractAddress: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
39
- dataSourceRegistryContractAddress: "0x4e7c79e79da6d98e3747b72147c0bfd9330c95a6",
37
+ dataSourceRegistryContractAddress: "0x6fd0e50073dbd8169bcaf066bb4a4991bfa48eeb",
40
38
  chainName: "baseSepolia",
41
39
  chain: baseSepolia,
42
40
  rpcUrl: "https://sepolia.base.org",
package/lib/fangorn.d.ts CHANGED
@@ -23,7 +23,7 @@ declare class Fangorn {
23
23
  /**
24
24
  * Register a new named data source owned by the current wallet.
25
25
  */
26
- registerDataSource(name: string): Promise<Hex>;
26
+ registerDataSource(name: string, agentId?: string): Promise<Hex>;
27
27
  /**
28
28
  * Upload files to a vault with the given gadget for access control.
29
29
  */
package/lib/fangorn.js CHANGED
@@ -23,8 +23,8 @@ var Fangorn = class Fangorn {
23
23
  /**
24
24
  * Register a new named data source owned by the current wallet.
25
25
  */
26
- async registerDataSource(name) {
27
- return await this.dataSourceRegistry.registerDataSource(name);
26
+ async registerDataSource(name, agentId) {
27
+ return await this.dataSourceRegistry.registerDataSource(name, agentId || "");
28
28
  }
29
29
  /**
30
30
  * Upload files to a vault with the given gadget for access control.
@@ -6,6 +6,9 @@ declare const DS_REGISTRY_ABI: readonly [{
6
6
  readonly inputs: readonly [{
7
7
  readonly name: "name";
8
8
  readonly type: "string";
9
+ }, {
10
+ readonly name: "agentId";
11
+ readonly type: "string";
9
12
  }];
10
13
  readonly outputs: readonly [{
11
14
  readonly name: "id";
@@ -7,6 +7,9 @@ const DS_REGISTRY_ABI = [
7
7
  inputs: [{
8
8
  name: "name",
9
9
  type: "string"
10
+ }, {
11
+ name: "agentId",
12
+ type: "string"
10
13
  }],
11
14
  outputs: [{
12
15
  name: "id",
@@ -16,7 +16,7 @@ declare class DataSourceRegistry {
16
16
  getContractAddress(): `0x${string}`;
17
17
  getDataSource(owner: Address, name: string): Promise<Vault>;
18
18
  getOwnedDataSources(address: Address): Promise<Hex[]>;
19
- registerDataSource(name: string): Promise<Hex>;
19
+ registerDataSource(name: string, agentId: string): Promise<Hex>;
20
20
  updateDataSource(name: string, newManifestCid: string): Promise<Hash>;
21
21
  waitForTransaction(hash: Hash): Promise<viem143.TransactionReceipt>;
22
22
  }
@@ -42,13 +42,13 @@ var DataSourceRegistry = class {
42
42
  args: [address]
43
43
  });
44
44
  }
45
- async registerDataSource(name) {
45
+ async registerDataSource(name, agentId) {
46
46
  const { chain, account } = this.getWriteConfig();
47
47
  const hash = await this.walletClient.writeContract({
48
48
  address: this.contractAddress,
49
49
  abi: DS_REGISTRY_ABI,
50
50
  functionName: "registerDataSource",
51
- args: [name],
51
+ args: [name, agentId],
52
52
  chain,
53
53
  account
54
54
  });
@@ -11,10 +11,11 @@ declare class TestBed {
11
11
  private delegateeFangorn;
12
12
  private delegatorAddress;
13
13
  private storage;
14
+ private usdcContractAddress;
14
15
  private vaultIds;
15
16
  private config;
16
17
  private litChain;
17
- constructor(delegatorAddress: Address, delegatorFangorn: Fangorn, delegateeFangorn: Fangorn, storage: PinataStorage, config: AppConfig, litChain: EvmChain);
18
+ constructor(delegatorAddress: Address, delegatorFangorn: Fangorn, delegateeFangorn: Fangorn, storage: PinataStorage, config: AppConfig, litChain: EvmChain, usdcContractAddress: Address);
18
19
  static init(delegatorWalletClient: WalletClient, delegateeWalletClient: WalletClient, jwt: string, gateway: string, dataSourceRegistryContractAddress: Hex, usdcContractAddress: Hex, rpcUrl: string, chain: string, litChain: EvmChain, caip2: number): Promise<TestBed>;
19
20
  registerDatasource(name: string): Promise<Hex>;
20
21
  /**
@@ -17,10 +17,11 @@ var TestBed = class TestBed {
17
17
  delegateeFangorn;
18
18
  delegatorAddress;
19
19
  storage;
20
+ usdcContractAddress;
20
21
  vaultIds;
21
22
  config;
22
23
  litChain;
23
- constructor(delegatorAddress, delegatorFangorn, delegateeFangorn, storage, config, litChain) {
24
+ constructor(delegatorAddress, delegatorFangorn, delegateeFangorn, storage, config, litChain, usdcContractAddress) {
24
25
  this.delegatorAddress = delegatorAddress;
25
26
  this.delegatorFangorn = delegatorFangorn;
26
27
  this.delegateeFangorn = delegateeFangorn;
@@ -28,13 +29,13 @@ var TestBed = class TestBed {
28
29
  this.config = config;
29
30
  this.litChain = litChain;
30
31
  this.storage = storage;
32
+ this.usdcContractAddress = usdcContractAddress;
31
33
  }
32
34
  static async init(delegatorWalletClient, delegateeWalletClient, jwt, gateway, dataSourceRegistryContractAddress, usdcContractAddress, rpcUrl, chain, litChain, caip2) {
33
35
  let chainImpl = arbitrumSepolia;
34
36
  if (chain === "baseSepolia") chainImpl = baseSepolia;
35
37
  const config = {
36
38
  dataSourceRegistryContractAddress,
37
- usdcContractAddress,
38
39
  chainName: chain,
39
40
  chain: chainImpl,
40
41
  rpcUrl,
@@ -53,12 +54,12 @@ var TestBed = class TestBed {
53
54
  const domain = "localhost";
54
55
  const delegatorFangorn = await Fangorn.init(delegatorWalletClient, delegatorStorage, delegatorEncryption, domain, config);
55
56
  const delegateeFangorn = await Fangorn.init(delegateeWalletClient, delegateeStorage, delegateeEncryption, domain, config);
56
- return new TestBed(delegatorWalletClient.account.address, delegatorFangorn, delegateeFangorn, delegatorStorage, config, litChain);
57
+ return new TestBed(delegatorWalletClient.account.address, delegatorFangorn, delegateeFangorn, delegatorStorage, config, litChain, usdcContractAddress);
57
58
  }
58
59
  async registerDatasource(name) {
59
60
  const existing = this.vaultIds.get(name);
60
61
  if (existing) return existing;
61
- const id = await this.delegatorFangorn.registerDataSource(name);
62
+ const id = await this.delegatorFangorn.registerDataSource(name, "");
62
63
  this.vaultIds.set(name, id);
63
64
  return id;
64
65
  }
@@ -153,7 +154,7 @@ var TestBed = class TestBed {
153
154
  };
154
155
  }
155
156
  async payForFile(owner, name, tag, amount, usdcDomainName, settlementTrackerAddress, walletClient, rpcUrl) {
156
- const auth = await this.buildUsdcAuthorization(this.delegatorAddress, amount, this.config.caip2, usdcDomainName, this.config.usdcContractAddress);
157
+ const auth = await this.buildUsdcAuthorization(this.delegatorAddress, amount, this.config.caip2, usdcDomainName, this.usdcContractAddress);
157
158
  const commitmentHex = fieldToHex(await computeTagCommitment(owner, name, tag, amount));
158
159
  await new SettlementTracker(settlementTrackerAddress, createPublicClient({ transport: http(rpcUrl) }), walletClient).pay({
159
160
  commitment: commitmentHex,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fangorn-sdk",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "A zero-knowledge conditional access control framework",
5
5
  "repository": {
6
6
  "type": "git",