@cofhe/sdk 0.6.0 → 0.7.0

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.
Files changed (114) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/acps/acp.ts +411 -0
  3. package/acps/index.ts +70 -0
  4. package/{permits → acps}/onchain-utils.ts +49 -24
  5. package/acps/sealing.ts +90 -0
  6. package/acps/signature.ts +89 -0
  7. package/acps/store.ts +172 -0
  8. package/acps/test/acp.test.ts +615 -0
  9. package/acps/test/localstorage.test.ts +105 -0
  10. package/acps/test/sealing.test.ts +77 -0
  11. package/acps/test/store.test.ts +88 -0
  12. package/acps/test/validation.test.ts +361 -0
  13. package/acps/test-utils.ts +32 -0
  14. package/acps/types.ts +252 -0
  15. package/acps/validation.ts +392 -0
  16. package/adapters/test/ethers5.test.ts +4 -1
  17. package/adapters/test/ethers6.test.ts +4 -1
  18. package/adapters/test/wagmi.test.ts +5 -2
  19. package/chains/chains/stagingCofhe.ts +21 -0
  20. package/chains/index.ts +3 -1
  21. package/chains/test/chains.test.ts +2 -1
  22. package/core/acps.ts +625 -0
  23. package/core/client.ts +136 -39
  24. package/core/clientTypes.ts +52 -41
  25. package/core/config.ts +66 -5
  26. package/core/debug.ts +72 -0
  27. package/core/decrypt/MockThresholdNetworkAbi.ts +20 -11
  28. package/core/decrypt/apiError.ts +104 -0
  29. package/core/decrypt/cofheMocksDecryptForTx.ts +11 -11
  30. package/core/decrypt/cofheMocksDecryptForView.ts +7 -7
  31. package/core/decrypt/decryptForTxBuilder.ts +102 -102
  32. package/core/decrypt/decryptForViewBuilder.ts +90 -90
  33. package/core/decrypt/submitRetry.ts +38 -30
  34. package/core/decrypt/tnDecryptV1.ts +5 -5
  35. package/core/decrypt/tnDecryptV2.ts +45 -34
  36. package/core/decrypt/tnSealOutputV1.ts +4 -3
  37. package/core/decrypt/tnSealOutputV2.ts +44 -31
  38. package/core/encrypt/cofheMocksZkVerifySign.ts +59 -74
  39. package/core/encrypt/encryptInputsBuilder.ts +86 -52
  40. package/core/encrypt/zkPackProveVerify.ts +25 -18
  41. package/core/error.ts +34 -6
  42. package/core/index.ts +14 -14
  43. package/core/test/acpDefaults.test.ts +52 -0
  44. package/core/test/acps.test.ts +596 -0
  45. package/core/test/apiError.test.ts +130 -0
  46. package/core/test/client.test.ts +22 -19
  47. package/core/test/config.test.ts +25 -5
  48. package/core/test/decrypt.test.ts +40 -35
  49. package/core/test/decryptBuilders.test.ts +68 -68
  50. package/core/test/decryptErrorCodes.test.ts +217 -0
  51. package/core/test/encryptInputsBuilder.test.ts +72 -41
  52. package/core/test/pollCallbacks.test.ts +89 -18
  53. package/core/test/stagingRedirect.ts +18 -0
  54. package/core/test/submitRetry.test.ts +182 -0
  55. package/core/types.ts +9 -69
  56. package/dist/acp-Wi6isVQI.d.cts +407 -0
  57. package/dist/acp-Wi6isVQI.d.ts +407 -0
  58. package/dist/acps.cjs +1081 -0
  59. package/dist/acps.d.cts +480 -0
  60. package/dist/acps.d.ts +480 -0
  61. package/dist/acps.js +2 -0
  62. package/dist/chains.cjs +14 -1
  63. package/dist/chains.d.cts +30 -1
  64. package/dist/chains.d.ts +30 -1
  65. package/dist/chains.js +1 -1
  66. package/dist/{chunk-PE5V5CCV.js → chunk-43USWPEH.js} +1000 -604
  67. package/dist/{chunk-MTRAXQXC.js → chunk-N6IDQRRU.js} +14 -2
  68. package/dist/chunk-Q7CBWGQX.js +1029 -0
  69. package/dist/{clientTypes-CyUvRRzA.d.ts → clientTypes-BN3nbzYM.d.ts} +342 -165
  70. package/dist/{clientTypes-BDy1qIBu.d.cts → clientTypes-CYZjFznO.d.cts} +342 -165
  71. package/dist/core.cjs +1431 -1026
  72. package/dist/core.d.cts +55 -10
  73. package/dist/core.d.ts +55 -10
  74. package/dist/core.js +3 -3
  75. package/dist/node.cjs +1356 -976
  76. package/dist/node.d.cts +2 -2
  77. package/dist/node.d.ts +2 -2
  78. package/dist/node.js +3 -3
  79. package/dist/web.cjs +1356 -976
  80. package/dist/web.d.cts +2 -2
  81. package/dist/web.d.ts +2 -2
  82. package/dist/web.js +3 -3
  83. package/node/test/inherited.test.ts +75 -65
  84. package/node/test/tfheinit.test.ts +23 -8
  85. package/package.json +6 -6
  86. package/web/test/client.web.test.ts +5 -1
  87. package/web/test/inherited.web.test.ts +75 -65
  88. package/web/test/tfheinit.web.test.ts +14 -5
  89. package/web/test/worker.config.web.test.ts +38 -23
  90. package/web/test/worker.output.web.test.ts +25 -24
  91. package/core/encrypt/encryptUtils.ts +0 -67
  92. package/core/permits.ts +0 -206
  93. package/core/test/permits.test.ts +0 -534
  94. package/dist/chunk-VB62WYPL.js +0 -978
  95. package/dist/permit-DnVMDT5h.d.cts +0 -376
  96. package/dist/permit-DnVMDT5h.d.ts +0 -376
  97. package/dist/permits.cjs +0 -1026
  98. package/dist/permits.d.cts +0 -353
  99. package/dist/permits.d.ts +0 -353
  100. package/dist/permits.js +0 -2
  101. package/permits/index.ts +0 -68
  102. package/permits/permit.ts +0 -385
  103. package/permits/sealing.ts +0 -131
  104. package/permits/signature.ts +0 -79
  105. package/permits/store.ts +0 -157
  106. package/permits/test/localstorage.test.ts +0 -113
  107. package/permits/test/permit.test.ts +0 -557
  108. package/permits/test/sealing.test.ts +0 -84
  109. package/permits/test/store.test.ts +0 -88
  110. package/permits/test/validation.test.ts +0 -361
  111. package/permits/test-utils.ts +0 -28
  112. package/permits/types.ts +0 -204
  113. package/permits/validation.ts +0 -327
  114. /package/{permits → acps}/utils.ts +0 -0
package/dist/web.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { I as IStorage, C as CofheInputConfig, a as CofheConfig, b as CofheClient, E as EncryptableItem } from './clientTypes-BDy1qIBu.cjs';
1
+ import { I as IStorage, C as CofheInputConfig, a as CofheConfig, b as CofheClient, E as EncryptableItem } from './clientTypes-CYZjFznO.cjs';
2
2
  import 'viem';
3
3
  import './types-C07FK-cL.cjs';
4
4
  import 'zod';
5
- import './permit-DnVMDT5h.cjs';
5
+ import './acp-Wi6isVQI.cjs';
6
6
  import 'zustand/vanilla';
7
7
 
8
8
  declare function createSsrStorage(): IStorage;
package/dist/web.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { I as IStorage, C as CofheInputConfig, a as CofheConfig, b as CofheClient, E as EncryptableItem } from './clientTypes-CyUvRRzA.js';
1
+ import { I as IStorage, C as CofheInputConfig, a as CofheConfig, b as CofheClient, E as EncryptableItem } from './clientTypes-BN3nbzYM.js';
2
2
  import 'viem';
3
3
  import './types-C07FK-cL.js';
4
4
  import 'zod';
5
- import './permit-DnVMDT5h.js';
5
+ import './acp-Wi6isVQI.js';
6
6
  import 'zustand/vanilla';
7
7
 
8
8
  declare function createSsrStorage(): IStorage;
package/dist/web.js CHANGED
@@ -1,6 +1,6 @@
1
- import { createCofheConfigBase, createCofheClientBase, fheTypeToString } from './chunk-PE5V5CCV.js';
2
- import './chunk-MTRAXQXC.js';
3
- import './chunk-VB62WYPL.js';
1
+ import { createCofheConfigBase, createCofheClientBase, fheTypeToString } from './chunk-43USWPEH.js';
2
+ import './chunk-N6IDQRRU.js';
3
+ import './chunk-Q7CBWGQX.js';
4
4
  import { TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT } from './chunk-ESMZCFJY.js';
5
5
  import { constructClient } from 'iframe-shared-storage';
6
6
 
@@ -1,9 +1,11 @@
1
+ import { STAGING_TESTS, stagingViemChain } from '../../core/test/stagingRedirect';
1
2
  import { Encryptable, FheTypes, type CofheClient } from '@/core';
2
- import { arbSepolia as cofheArbSepolia, getChainById } from '@/chains';
3
+ import { arbSepolia as cofheArbSepolia, getChainById, stagingCofhe } from '@/chains';
3
4
  import {
4
5
  TEST_PRIVATE_KEY,
5
6
  PRIMARY_TEST_CHAIN,
6
7
  primaryTestChainRegistry,
8
+ stagingTestChainRegistry,
7
9
  isPrimaryTestChainReady,
8
10
  } from '@cofhe/test-setup';
9
11
 
@@ -27,6 +29,9 @@ const VIEM_CHAINS: Record<number, Chain> = {
27
29
  11155111: sepolia,
28
30
  };
29
31
 
32
+ const testViemChain = STAGING_TESTS ? stagingViemChain : arbitrumSepolia;
33
+ const testCofheChain = STAGING_TESTS ? stagingCofhe : cofheArbSepolia;
34
+
30
35
  describe('@cofhe/node - Inherited Client Tests', () => {
31
36
  let cofheClient: CofheClient;
32
37
  let publicClient: PublicClient;
@@ -35,18 +40,18 @@ describe('@cofhe/node - Inherited Client Tests', () => {
35
40
 
36
41
  beforeAll(() => {
37
42
  publicClient = createPublicClient({
38
- chain: arbitrumSepolia,
43
+ chain: testViemChain,
39
44
  transport: http(),
40
45
  });
41
46
 
42
47
  bobWalletClient = createWalletClient({
43
- chain: arbitrumSepolia,
48
+ chain: testViemChain,
44
49
  transport: http(),
45
50
  account: bobAccount,
46
51
  });
47
52
 
48
53
  aliceWalletClient = createWalletClient({
49
- chain: arbitrumSepolia,
54
+ chain: testViemChain,
50
55
  transport: http(),
51
56
  account: aliceAccount,
52
57
  });
@@ -54,7 +59,7 @@ describe('@cofhe/node - Inherited Client Tests', () => {
54
59
 
55
60
  beforeEach(() => {
56
61
  const config = createCofheConfig({
57
- supportedChains: [cofheArbSepolia],
62
+ supportedChains: [testCofheChain],
58
63
  });
59
64
  cofheClient = createCofheClient(config);
60
65
  });
@@ -71,7 +76,7 @@ describe('@cofhe/node - Inherited Client Tests', () => {
71
76
  expect(typeof cofheClient.decryptForTx).toBe('function');
72
77
  expect(typeof cofheClient.getSnapshot).toBe('function');
73
78
  expect(typeof cofheClient.subscribe).toBe('function');
74
- expect(cofheClient.permits).toBeDefined();
79
+ expect(cofheClient.acp).toBeDefined();
75
80
  });
76
81
  });
77
82
 
@@ -83,7 +88,7 @@ describe('@cofhe/node - Inherited Client Tests', () => {
83
88
 
84
89
  const snapshot = cofheClient.getSnapshot();
85
90
  expect(snapshot.connected).toBe(true);
86
- expect(snapshot.chainId).toBe(cofheArbSepolia.id);
91
+ expect(snapshot.chainId).toBe(testCofheChain.id);
87
92
  expect(snapshot.account).toBe(bobAccount.address);
88
93
  }, 30000);
89
94
  });
@@ -92,81 +97,85 @@ describe('@cofhe/node - Inherited Client Tests', () => {
92
97
  it('should encrypt a uint128 value', async () => {
93
98
  await cofheClient.connect(publicClient, bobWalletClient);
94
99
 
95
- const encrypted = await cofheClient.encryptInputs([Encryptable.uint128(100n)]).execute();
100
+ const encrypted = await cofheClient
101
+ .encryptInputs([Encryptable.uint128(100n)])
102
+ .setConsumingContract(bobAccount.address)
103
+ .execute();
96
104
 
105
+ // [hash, signature] - one hash per input, followed by the shared batch signature.
97
106
  expect(encrypted).toBeDefined();
98
- expect(encrypted.length).toBe(1);
99
- expect(encrypted[0].utype).toBe(FheTypes.Uint128);
100
- expect(encrypted[0].ctHash).toBeDefined();
101
- expect(typeof encrypted[0].ctHash).toBe('bigint');
102
- expect(encrypted[0].signature).toBeDefined();
103
- expect(typeof encrypted[0].signature).toBe('string');
104
- expect(encrypted[0].securityZone).toBe(0);
105
- }, 60000);
107
+ expect(encrypted.length).toBe(2);
108
+
109
+ const [hash, signature] = encrypted;
110
+ expect(typeof hash).toBe('string');
111
+ expect(hash).toMatch(/^0x[0-9a-fA-F]+$/);
112
+ expect(typeof signature).toBe('string');
113
+ expect(signature).toMatch(/^0x[0-9a-fA-F]+$/);
114
+ }, 120000);
106
115
  });
107
116
 
108
- describe('Self Permit', () => {
109
- it('should create a self permit', async () => {
117
+ describe('Self ACP', () => {
118
+ it('should create a self acp', async () => {
110
119
  await cofheClient.connect(publicClient, bobWalletClient);
111
120
 
112
- const permit = await cofheClient.permits.createSelf({
121
+ const acp = await cofheClient.acp.createSelf({
113
122
  issuer: bobAccount.address,
114
- name: 'Test Self Permit',
123
+ name: 'Test Self ACP',
115
124
  });
116
125
 
117
- expect(permit).toBeDefined();
118
- expect(permit.type).toBe('self');
119
- expect(permit.name).toBe('Test Self Permit');
120
- expect(permit.issuer).toBe(bobAccount.address);
121
- expect(permit.issuerSignature).not.toBe('0x');
122
- expect(permit.sealingPair).toBeDefined();
123
- expect(permit.sealingPair.publicKey).toBeDefined();
124
-
125
- const activePermit = cofheClient.permits.getActivePermit();
126
- expect(activePermit).toBeDefined();
127
- expect(activePermit!.hash).toBe(permit.hash);
126
+ expect(acp).toBeDefined();
127
+ expect(acp.type).toBe('self');
128
+ expect(acp.name).toBe('Test Self ACP');
129
+ expect(acp.issuer).toBe(bobAccount.address);
130
+ expect(acp.issuerSignature).not.toBe('0x');
131
+ expect(acp.sealingPrivateKey).toBeDefined();
132
+ expect(acp.sealingKey).toBeDefined();
133
+
134
+ const activeACP = cofheClient.acp.getActiveACP();
135
+ expect(activeACP).toBeDefined();
136
+ expect(activeACP!.hash).toBe(acp.hash);
128
137
  }, 30000);
129
138
  });
130
139
 
131
- describe('Sharing Permit', () => {
132
- it('should create a sharing permit, export it, and import it as another user', async () => {
140
+ describe('Sharing ACP', () => {
141
+ it('should create a sharing acp, export it, and import it as another user', async () => {
133
142
  await cofheClient.connect(publicClient, bobWalletClient);
134
143
 
135
- const sharingPermit = await cofheClient.permits.createSharing({
144
+ const sharingACP = await cofheClient.acp.createSharing({
136
145
  issuer: bobAccount.address,
137
146
  recipient: aliceAccount.address,
138
- name: 'Test Sharing Permit',
147
+ name: 'Test Sharing ACP',
139
148
  });
140
149
 
141
- expect(sharingPermit).toBeDefined();
142
- expect(sharingPermit.type).toBe('sharing');
143
- expect(sharingPermit.issuer).toBe(bobAccount.address);
144
- expect(sharingPermit.recipient).toBe(aliceAccount.address);
145
- expect(sharingPermit.issuerSignature).not.toBe('0x');
150
+ expect(sharingACP).toBeDefined();
151
+ expect(sharingACP.type).toBe('sharing');
152
+ expect(sharingACP.issuer).toBe(bobAccount.address);
153
+ expect(sharingACP.recipient).toBe(aliceAccount.address);
154
+ expect(sharingACP.issuerSignature).not.toBe('0x');
146
155
 
147
- const exported = cofheClient.permits.export(sharingPermit);
156
+ const exported = cofheClient.acp.export(sharingACP);
148
157
  expect(exported).toBeDefined();
149
158
  const parsed = JSON.parse(exported);
150
159
  expect(parsed.type).toBe('sharing');
151
160
  expect(parsed.issuer).toBe(bobAccount.address);
152
161
  expect(parsed.recipient).toBe(aliceAccount.address);
153
162
  expect(parsed.issuerSignature).toBeDefined();
154
- expect(parsed).not.toHaveProperty('sealingPair');
163
+ expect(parsed).not.toHaveProperty('sealingPrivateKey');
155
164
 
156
165
  const aliceConfig = createCofheConfig({
157
- supportedChains: [cofheArbSepolia],
166
+ supportedChains: [testCofheChain],
158
167
  });
159
168
  const aliceClient = createCofheClient(aliceConfig);
160
169
  await aliceClient.connect(publicClient, aliceWalletClient);
161
170
 
162
- const importedPermit = await aliceClient.permits.importShared(exported);
171
+ const importedACP = await aliceClient.acp.importShared(exported);
163
172
 
164
- expect(importedPermit).toBeDefined();
165
- expect(importedPermit.type).toBe('recipient');
166
- expect(importedPermit.issuer).toBe(bobAccount.address);
167
- expect(importedPermit.recipient).toBe(aliceAccount.address);
168
- expect(importedPermit.recipientSignature).not.toBe('0x');
169
- expect(importedPermit.sealingPair).toBeDefined();
173
+ expect(importedACP).toBeDefined();
174
+ expect(importedACP.type).toBe('recipient');
175
+ expect(importedACP.issuer).toBe(bobAccount.address);
176
+ expect(importedACP.recipient).toBe(aliceAccount.address);
177
+ expect(importedACP.recipientSignature).not.toBe('0x');
178
+ expect(importedACP.sealingPrivateKey).toBeDefined();
170
179
  }, 30000);
171
180
  });
172
181
 
@@ -181,15 +190,16 @@ describe('@cofhe/node - Inherited Client Tests', () => {
181
190
  let publicValue: bigint;
182
191
 
183
192
  beforeAll(() => {
184
- if (!isPrimaryTestChainReady(primaryTestChainRegistry)) {
185
- throw new Error('Primary test chain registry not initialized. Run `pnpm test:setup` first.');
193
+ const reg = STAGING_TESTS
194
+ ? (stagingTestChainRegistry as typeof primaryTestChainRegistry)
195
+ : primaryTestChainRegistry;
196
+ if (!isPrimaryTestChainReady(reg)) {
197
+ throw new Error('Test chain registry not initialized. Run `pnpm test:setup` first.');
186
198
  }
187
-
188
- const reg = primaryTestChainRegistry;
189
- const viemChain = VIEM_CHAINS[reg.chainId];
199
+ const viemChain = STAGING_TESTS ? stagingViemChain : VIEM_CHAINS[reg.chainId];
190
200
  if (!viemChain) throw new Error(`No viem chain mapping for chain ${reg.chainId}`);
191
201
 
192
- const cofheChain = getChainById(reg.chainId);
202
+ const cofheChain = STAGING_TESTS ? stagingCofhe : getChainById(reg.chainId);
193
203
  if (!cofheChain) throw new Error(`No cofhe chain config for chain ${reg.chainId}`);
194
204
 
195
205
  privateCtHash = reg.privateValue.ctHash as `0x${string}`;
@@ -204,37 +214,37 @@ describe('@cofhe/node - Inherited Client Tests', () => {
204
214
  decryptClient = createCofheClient(config);
205
215
  });
206
216
 
207
- it('decryptForView — private value with permit', async () => {
217
+ it('decryptForView — private value with acp', async () => {
208
218
  await decryptClient.connect(decryptPublicClient, decryptWalletClient);
209
219
 
210
- await decryptClient.permits.createSelf({
220
+ await decryptClient.acp.createSelf({
211
221
  issuer: bobAccount.address,
212
- name: 'Decrypt View Permit',
222
+ name: 'Decrypt View ACP',
213
223
  });
214
224
 
215
225
  const result = await decryptClient.decryptForView(privateCtHash, FheTypes.Uint32).execute();
216
226
  expect(result).toBe(privateValue);
217
227
  }, 180000);
218
228
 
219
- it('decryptForTx — public value without permit', async () => {
229
+ it('decryptForTx — public value without acp', async () => {
220
230
  await decryptClient.connect(decryptPublicClient, decryptWalletClient);
221
231
 
222
- const result = await decryptClient.decryptForTx(publicCtHash).withoutPermit().execute();
232
+ const result = await decryptClient.decryptForTx(publicCtHash).withoutACP().execute();
223
233
 
224
234
  expect(BigInt(result.ctHash)).toBe(BigInt(publicCtHash));
225
235
  expect(result.decryptedValue).toBe(publicValue);
226
236
  expect(result.signature).toMatch(/^0x[0-9a-fA-F]+$/);
227
237
  }, 180000);
228
238
 
229
- it('decryptForTx — private value with permit', async () => {
239
+ it('decryptForTx — private value with acp', async () => {
230
240
  await decryptClient.connect(decryptPublicClient, decryptWalletClient);
231
241
 
232
- const permit = await decryptClient.permits.createSelf({
242
+ const acp = await decryptClient.acp.createSelf({
233
243
  issuer: bobAccount.address,
234
- name: 'Decrypt Tx Permit',
244
+ name: 'Decrypt Tx ACP',
235
245
  });
236
246
 
237
- const result = await decryptClient.decryptForTx(privateCtHash).withPermit(permit).execute();
247
+ const result = await decryptClient.decryptForTx(privateCtHash).withACP(acp).execute();
238
248
 
239
249
  expect(BigInt(result.ctHash)).toBe(BigInt(privateCtHash));
240
250
  expect(result.decryptedValue).toBe(privateValue);
@@ -1,5 +1,6 @@
1
+ import { STAGING_TESTS, stagingViemChain } from '../../core/test/stagingRedirect';
1
2
  import { Encryptable, type CofheClient } from '@/core';
2
- import { arbSepolia as cofheArbSepolia } from '@/chains';
3
+ import { arbSepolia as cofheArbSepolia, stagingCofhe } from '@/chains';
3
4
 
4
5
  import { describe, it, expect, beforeAll, beforeEach } from 'vitest';
5
6
  import type { PublicClient, WalletClient } from 'viem';
@@ -10,28 +11,33 @@ import { createCofheClient, createCofheConfig } from '../index.js';
10
11
 
11
12
  const TEST_PRIVATE_KEY = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80';
12
13
 
14
+ const testViemChain = STAGING_TESTS ? stagingViemChain : viemArbitrumSepolia;
15
+ const testCofheChain = STAGING_TESTS ? stagingCofhe : cofheArbSepolia;
16
+
13
17
  describe('@cofhe/node - TFHE Initialization Tests', () => {
14
18
  let cofheClient: CofheClient;
15
19
  let publicClient: PublicClient;
16
20
  let walletClient: WalletClient;
21
+ let consumingContract: `0x${string}`;
17
22
 
18
23
  beforeAll(() => {
19
24
  publicClient = createPublicClient({
20
- chain: viemArbitrumSepolia,
25
+ chain: testViemChain,
21
26
  transport: http(),
22
27
  });
23
28
 
24
29
  const account = privateKeyToAccount(TEST_PRIVATE_KEY);
25
30
  walletClient = createWalletClient({
26
- chain: viemArbitrumSepolia,
31
+ chain: testViemChain,
27
32
  transport: http(),
28
33
  account,
29
34
  });
35
+ consumingContract = account.address;
30
36
  });
31
37
 
32
38
  beforeEach(() => {
33
39
  const config = createCofheConfig({
34
- supportedChains: [cofheArbSepolia],
40
+ supportedChains: [testCofheChain],
35
41
  });
36
42
  cofheClient = createCofheClient(config);
37
43
  });
@@ -40,17 +46,26 @@ describe('@cofhe/node - TFHE Initialization Tests', () => {
40
46
  it('should initialize node-tfhe on first encryption', async () => {
41
47
  await cofheClient.connect(publicClient, walletClient);
42
48
 
43
- const result = await cofheClient.encryptInputs([Encryptable.uint128(100n)]).execute();
49
+ const result = await cofheClient
50
+ .encryptInputs([Encryptable.uint128(100n)])
51
+ .setConsumingContract(consumingContract)
52
+ .execute();
44
53
 
45
54
  expect(result).toBeDefined();
46
- }, 60000);
55
+ }, 120000);
47
56
 
48
57
  it('should handle multiple encryptions without re-initializing', async () => {
49
58
  await cofheClient.connect(publicClient, walletClient);
50
59
 
51
- await cofheClient.encryptInputs([Encryptable.uint128(100n)]).execute();
60
+ await cofheClient
61
+ .encryptInputs([Encryptable.uint128(100n)])
62
+ .setConsumingContract(consumingContract)
63
+ .execute();
52
64
 
53
- await cofheClient.encryptInputs([Encryptable.uint64(50n)]).execute();
65
+ await cofheClient
66
+ .encryptInputs([Encryptable.uint64(50n)])
67
+ .setConsumingContract(consumingContract)
68
+ .execute();
54
69
  }, 120000);
55
70
  });
56
71
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cofhe/sdk",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "description": "SDK for Fhenix COFHE coprocessor interaction",
6
6
  "main": "./dist/core.cjs",
@@ -23,10 +23,10 @@
23
23
  "require": "./dist/chains.cjs",
24
24
  "types": "./dist/chains.d.ts"
25
25
  },
26
- "./permits": {
27
- "import": "./dist/permits.js",
28
- "require": "./dist/permits.cjs",
29
- "types": "./dist/permits.d.ts"
26
+ "./acps": {
27
+ "import": "./dist/acps.js",
28
+ "require": "./dist/acps.cjs",
29
+ "types": "./dist/acps.d.ts"
30
30
  },
31
31
  "./node": {
32
32
  "import": "./dist/node.js",
@@ -51,7 +51,7 @@
51
51
  "core/**",
52
52
  "adapters/**",
53
53
  "chains/**",
54
- "permits/**",
54
+ "acps/**",
55
55
  "node/**",
56
56
  "web/**",
57
57
  "CHANGELOG.md"
@@ -130,7 +130,11 @@ describe('@cofhe/web - Client', () => {
130
130
  expect(typeof builder.setChainId).toBe('function');
131
131
  expect(typeof builder.setAccount).toBe('function');
132
132
  expect(typeof builder.setSecurityZone).toBe('function');
133
- expect(typeof builder.execute).toBe('function');
133
+ expect(typeof builder.setConsumingContract).toBe('function');
134
+ // execute() only exists once a consuming contract has been committed to.
135
+ expect(typeof builder.setConsumingContract('0xbeefbeefbeefbeefbeefbeefbeefbeefbeefbeef').execute).toBe(
136
+ 'function'
137
+ );
134
138
  }, 30000);
135
139
 
136
140
  it('should create decrypt builder after connection', async () => {