@shodai-network/agreements-protocol-evm 0.1.4

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 (110) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +6 -0
  3. package/README.md +102 -0
  4. package/dist/cjs/AgreementEngine.d.ts +219 -0
  5. package/dist/cjs/AgreementEngine.d.ts.map +1 -0
  6. package/dist/cjs/AgreementEngine.js +454 -0
  7. package/dist/cjs/AgreementEngine.js.map +1 -0
  8. package/dist/cjs/AgreementFactory.d.ts +186 -0
  9. package/dist/cjs/AgreementFactory.d.ts.map +1 -0
  10. package/dist/cjs/AgreementFactory.js +541 -0
  11. package/dist/cjs/AgreementFactory.js.map +1 -0
  12. package/dist/cjs/deployments.d.ts +37 -0
  13. package/dist/cjs/deployments.d.ts.map +1 -0
  14. package/dist/cjs/deployments.js +90 -0
  15. package/dist/cjs/deployments.js.map +1 -0
  16. package/dist/cjs/generated/AgreementEngineAbi.d.ts +651 -0
  17. package/dist/cjs/generated/AgreementEngineAbi.d.ts.map +1 -0
  18. package/dist/cjs/generated/AgreementEngineAbi.js +842 -0
  19. package/dist/cjs/generated/AgreementEngineAbi.js.map +1 -0
  20. package/dist/cjs/generated/AgreementFactoryAbi.d.ts +861 -0
  21. package/dist/cjs/generated/AgreementFactoryAbi.d.ts.map +1 -0
  22. package/dist/cjs/generated/AgreementFactoryAbi.js +1117 -0
  23. package/dist/cjs/generated/AgreementFactoryAbi.js.map +1 -0
  24. package/dist/cjs/generated/DeploymentsRegistry.d.ts +50 -0
  25. package/dist/cjs/generated/DeploymentsRegistry.d.ts.map +1 -0
  26. package/dist/cjs/generated/DeploymentsRegistry.js +54 -0
  27. package/dist/cjs/generated/DeploymentsRegistry.js.map +1 -0
  28. package/dist/cjs/index.d.ts +15 -0
  29. package/dist/cjs/index.d.ts.map +1 -0
  30. package/dist/cjs/index.js +32 -0
  31. package/dist/cjs/index.js.map +1 -0
  32. package/dist/cjs/package.json +3 -0
  33. package/dist/cjs/payload-builder.d.ts +122 -0
  34. package/dist/cjs/payload-builder.d.ts.map +1 -0
  35. package/dist/cjs/payload-builder.js +186 -0
  36. package/dist/cjs/payload-builder.js.map +1 -0
  37. package/dist/cjs/rpc-transport.d.ts +3 -0
  38. package/dist/cjs/rpc-transport.d.ts.map +1 -0
  39. package/dist/cjs/rpc-transport.js +87 -0
  40. package/dist/cjs/rpc-transport.js.map +1 -0
  41. package/dist/cjs/telemetry.d.ts +5 -0
  42. package/dist/cjs/telemetry.d.ts.map +1 -0
  43. package/dist/cjs/telemetry.js +54 -0
  44. package/dist/cjs/telemetry.js.map +1 -0
  45. package/dist/cjs/transactions.d.ts +25 -0
  46. package/dist/cjs/transactions.d.ts.map +1 -0
  47. package/dist/cjs/transactions.js +40 -0
  48. package/dist/cjs/transactions.js.map +1 -0
  49. package/dist/cjs/transformer.d.ts +112 -0
  50. package/dist/cjs/transformer.d.ts.map +1 -0
  51. package/dist/cjs/transformer.js +498 -0
  52. package/dist/cjs/transformer.js.map +1 -0
  53. package/dist/cjs/types.d.ts +311 -0
  54. package/dist/cjs/types.d.ts.map +1 -0
  55. package/dist/cjs/types.js +48 -0
  56. package/dist/cjs/types.js.map +1 -0
  57. package/dist/esm/AgreementEngine.d.ts +219 -0
  58. package/dist/esm/AgreementEngine.d.ts.map +1 -0
  59. package/dist/esm/AgreementEngine.js +450 -0
  60. package/dist/esm/AgreementEngine.js.map +1 -0
  61. package/dist/esm/AgreementFactory.d.ts +186 -0
  62. package/dist/esm/AgreementFactory.d.ts.map +1 -0
  63. package/dist/esm/AgreementFactory.js +537 -0
  64. package/dist/esm/AgreementFactory.js.map +1 -0
  65. package/dist/esm/deployments.d.ts +37 -0
  66. package/dist/esm/deployments.d.ts.map +1 -0
  67. package/dist/esm/deployments.js +82 -0
  68. package/dist/esm/deployments.js.map +1 -0
  69. package/dist/esm/generated/AgreementEngineAbi.d.ts +651 -0
  70. package/dist/esm/generated/AgreementEngineAbi.d.ts.map +1 -0
  71. package/dist/esm/generated/AgreementEngineAbi.js +839 -0
  72. package/dist/esm/generated/AgreementEngineAbi.js.map +1 -0
  73. package/dist/esm/generated/AgreementFactoryAbi.d.ts +861 -0
  74. package/dist/esm/generated/AgreementFactoryAbi.d.ts.map +1 -0
  75. package/dist/esm/generated/AgreementFactoryAbi.js +1114 -0
  76. package/dist/esm/generated/AgreementFactoryAbi.js.map +1 -0
  77. package/dist/esm/generated/DeploymentsRegistry.d.ts +50 -0
  78. package/dist/esm/generated/DeploymentsRegistry.d.ts.map +1 -0
  79. package/dist/esm/generated/DeploymentsRegistry.js +51 -0
  80. package/dist/esm/generated/DeploymentsRegistry.js.map +1 -0
  81. package/dist/esm/index.d.ts +15 -0
  82. package/dist/esm/index.d.ts.map +1 -0
  83. package/dist/esm/index.js +16 -0
  84. package/dist/esm/index.js.map +1 -0
  85. package/dist/esm/package.json +3 -0
  86. package/dist/esm/payload-builder.d.ts +122 -0
  87. package/dist/esm/payload-builder.d.ts.map +1 -0
  88. package/dist/esm/payload-builder.js +173 -0
  89. package/dist/esm/payload-builder.js.map +1 -0
  90. package/dist/esm/rpc-transport.d.ts +3 -0
  91. package/dist/esm/rpc-transport.d.ts.map +1 -0
  92. package/dist/esm/rpc-transport.js +84 -0
  93. package/dist/esm/rpc-transport.js.map +1 -0
  94. package/dist/esm/telemetry.d.ts +5 -0
  95. package/dist/esm/telemetry.d.ts.map +1 -0
  96. package/dist/esm/telemetry.js +51 -0
  97. package/dist/esm/telemetry.js.map +1 -0
  98. package/dist/esm/transactions.d.ts +25 -0
  99. package/dist/esm/transactions.d.ts.map +1 -0
  100. package/dist/esm/transactions.js +36 -0
  101. package/dist/esm/transactions.js.map +1 -0
  102. package/dist/esm/transformer.d.ts +112 -0
  103. package/dist/esm/transformer.d.ts.map +1 -0
  104. package/dist/esm/transformer.js +480 -0
  105. package/dist/esm/transformer.js.map +1 -0
  106. package/dist/esm/types.d.ts +311 -0
  107. package/dist/esm/types.d.ts.map +1 -0
  108. package/dist/esm/types.js +45 -0
  109. package/dist/esm/types.js.map +1 -0
  110. package/package.json +56 -0
@@ -0,0 +1,454 @@
1
+ "use strict";
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.AgreementEngine = void 0;
5
+ const transactions_js_1 = require("./transactions.js");
6
+ const payload_builder_js_1 = require("./payload-builder.js");
7
+ const transformer_js_1 = require("./transformer.js");
8
+ const telemetry_js_1 = require("./telemetry.js");
9
+ const AgreementEngineAbi_js_1 = require("./generated/AgreementEngineAbi.js");
10
+ // Use inlined ABI data (works in both Node.js and browser)
11
+ // ABI is extracted directly from contract artifacts as an array
12
+ const engineAbi = AgreementEngineAbi_js_1.AgreementEngineABI;
13
+ /**
14
+ * Agreement instance for interacting with a specific on-chain agreement
15
+ *
16
+ * Each agreement is a separate clone contract. This class provides
17
+ * methods to interact with a specific agreement instance.
18
+ */
19
+ class AgreementEngine {
20
+ /**
21
+ * Create a new Agreement instance
22
+ *
23
+ * @param address - The agreement contract address (clone address)
24
+ * @param publicClient - viem PublicClient for read-only operations
25
+ * @param walletClient - Optional viem WalletClient for submitting inputs
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * // Read-only agreement
30
+ * const agreement = new Agreement("0x...", provider);
31
+ * const state = await agreement.getCurrentState();
32
+ *
33
+ * // Agreement with signer (can submit inputs)
34
+ * const agreement = new Agreement("0x...", signer);
35
+ * await agreement.submitInput(agreementJson, "grantorData", { ... });
36
+ * ```
37
+ */
38
+ constructor(address, publicClient, walletClient) {
39
+ this.address = address;
40
+ this.publicClient = publicClient;
41
+ this.walletClient = walletClient;
42
+ }
43
+ /**
44
+ * Get all on-chain agreement data
45
+ *
46
+ * @returns Complete on-chain agreement information
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const agreement = new Agreement("0x...", provider);
51
+ * const data = await agreement.getData();
52
+ * console.log(`Current state: ${data.currentState}`);
53
+ * console.log(`Owner: ${data.owner}`);
54
+ * ```
55
+ */
56
+ async getData() {
57
+ return await (0, telemetry_js_1.withSdkSpan)("agreement_engine.get_data", {
58
+ "blockchain.chain_id": this.publicClient.chain?.id,
59
+ "agreement.address": this.address,
60
+ }, async () => {
61
+ const [docUri, docHash, initialState, currentState, owner] = await Promise.all([
62
+ (0, transactions_js_1.readContractResult)(this.publicClient, {
63
+ address: this.address,
64
+ abi: engineAbi,
65
+ functionName: 'docUri',
66
+ args: [],
67
+ }),
68
+ (0, transactions_js_1.readContractResult)(this.publicClient, {
69
+ address: this.address,
70
+ abi: engineAbi,
71
+ functionName: 'docHash',
72
+ args: [],
73
+ }),
74
+ (0, transactions_js_1.readContractResult)(this.publicClient, {
75
+ address: this.address,
76
+ abi: engineAbi,
77
+ functionName: 'initialState',
78
+ args: [],
79
+ }),
80
+ (0, transactions_js_1.readContractResult)(this.publicClient, {
81
+ address: this.address,
82
+ abi: engineAbi,
83
+ functionName: 'currentState',
84
+ args: [],
85
+ }),
86
+ (0, transactions_js_1.readContractResult)(this.publicClient, {
87
+ address: this.address,
88
+ abi: engineAbi,
89
+ functionName: 'owner',
90
+ args: [],
91
+ }),
92
+ ]);
93
+ return {
94
+ address: this.address,
95
+ docUri,
96
+ docHash: docHash,
97
+ initialState: initialState,
98
+ currentState: currentState,
99
+ owner: owner,
100
+ };
101
+ });
102
+ }
103
+ /**
104
+ * Get the current state of the agreement
105
+ *
106
+ * @param agreementJson - Optional agreement JSON. If provided, returns the state name string instead of bytes32
107
+ * @returns The current state as bytes32, or state name string if agreementJson is provided
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * // Get bytes32 state
112
+ * const agreement = new Agreement("0x...", provider);
113
+ * const stateBytes32 = await agreement.getCurrentState();
114
+ *
115
+ * // Get state name string
116
+ * const stateName = await agreement.getCurrentState(agreementJson);
117
+ * ```
118
+ */
119
+ async getCurrentState(agreementJson) {
120
+ return await (0, telemetry_js_1.withSdkSpan)("agreement_engine.get_current_state", {
121
+ "blockchain.chain_id": this.publicClient.chain?.id,
122
+ "agreement.address": this.address,
123
+ }, async () => {
124
+ const state = await (0, transactions_js_1.readContractResult)(this.publicClient, {
125
+ address: this.address,
126
+ abi: engineAbi,
127
+ functionName: 'currentState',
128
+ args: [],
129
+ });
130
+ const stateHex = state;
131
+ if (agreementJson) {
132
+ // Look up state name by comparing bytes32 values
133
+ const states = Object.keys(agreementJson.execution.states);
134
+ for (const stateName of states) {
135
+ if ((0, transformer_js_1.stateToBytes32)(stateName).toLowerCase() === stateHex.toLowerCase()) {
136
+ return stateName;
137
+ }
138
+ }
139
+ throw new Error(`State ${stateHex} not found in agreement states`);
140
+ }
141
+ return stateHex;
142
+ });
143
+ }
144
+ /**
145
+ * Get the initial state of the agreement
146
+ *
147
+ * @returns The initial state as bytes32
148
+ */
149
+ async getInitialState() {
150
+ const state = await (0, transactions_js_1.readContractResult)(this.publicClient, {
151
+ address: this.address,
152
+ abi: engineAbi,
153
+ functionName: 'initialState',
154
+ args: [],
155
+ });
156
+ return state;
157
+ }
158
+ /**
159
+ * Get the document URI
160
+ *
161
+ * @returns The document URI string
162
+ */
163
+ async getDocUri() {
164
+ return await (0, transactions_js_1.readContractResult)(this.publicClient, {
165
+ address: this.address,
166
+ abi: engineAbi,
167
+ functionName: 'docUri',
168
+ args: [],
169
+ });
170
+ }
171
+ /**
172
+ * Get the document hash
173
+ *
174
+ * @returns The document hash as bytes32
175
+ */
176
+ async getDocHash() {
177
+ const hash = await (0, transactions_js_1.readContractResult)(this.publicClient, {
178
+ address: this.address,
179
+ abi: engineAbi,
180
+ functionName: 'docHash',
181
+ args: [],
182
+ });
183
+ return hash;
184
+ }
185
+ /**
186
+ * Get the owner of the agreement
187
+ *
188
+ * @returns The owner address
189
+ */
190
+ async getOwner() {
191
+ const owner = await (0, transactions_js_1.readContractResult)(this.publicClient, {
192
+ address: this.address,
193
+ abi: engineAbi,
194
+ functionName: 'owner',
195
+ args: [],
196
+ });
197
+ return owner;
198
+ }
199
+ /**
200
+ * Submit an input to progress the agreement's state machine
201
+ *
202
+ * @param agreement - The agreement JSON definition (for field type resolution)
203
+ * @param inputId - The input identifier (e.g., "grantorData")
204
+ * @param data - Plain object with field values
205
+ * @param waitForConfirmation - Whether to wait for transaction confirmation (default: false)
206
+ * @returns Transaction hash, or receipt if waitForConfirmation is true
207
+ *
208
+ * @example
209
+ * ```typescript
210
+ * const agreement = new Agreement("0x...", signer);
211
+ *
212
+ * // Fire and forget
213
+ * const txHash = await agreement.submitInput(
214
+ * agreementJson,
215
+ * "grantorData",
216
+ * { grantorName: "Alice", scope: "Development of Web3 tooling" }
217
+ * );
218
+ *
219
+ * // Wait for confirmation
220
+ * const receipt = await agreement.submitInput(
221
+ * agreementJson,
222
+ * "grantorData",
223
+ * { grantorName: "Alice", scope: "Development of Web3 tooling" },
224
+ * true
225
+ * );
226
+ * console.log(`Transaction confirmed in block ${receipt.blockNumber}`);
227
+ * ```
228
+ */
229
+ async submitInput(agreement, inputId, data, waitForConfirmation = false) {
230
+ return await (0, telemetry_js_1.withSdkSpan)("agreement_engine.submit_input", {
231
+ "blockchain.chain_id": this.publicClient.chain?.id,
232
+ "agreement.address": this.address,
233
+ "agreement.input_id": inputId,
234
+ }, async () => {
235
+ if (!this.walletClient) {
236
+ throw new Error("WalletClient required for submitting inputs. Pass a walletClient to the constructor.");
237
+ }
238
+ // Build payload using payload-builder
239
+ const payload = (0, payload_builder_js_1.buildInputPayload)(agreement, inputId, data);
240
+ const inputIdBytes32 = (0, payload_builder_js_1.inputToBytes32)(inputId);
241
+ // Build the write contract request
242
+ const request = {
243
+ chain: null,
244
+ account: this.walletClient.account,
245
+ address: this.address,
246
+ abi: engineAbi,
247
+ functionName: 'submitInput',
248
+ args: [inputIdBytes32, payload],
249
+ };
250
+ // Use executeTransaction utility for optional waiting
251
+ const result = await (0, transactions_js_1.executeTransaction)(request, this.publicClient, this.walletClient, waitForConfirmation);
252
+ // Return hash if not waiting, full receipt if waiting
253
+ if (waitForConfirmation) {
254
+ return result;
255
+ }
256
+ return result.transactionHash;
257
+ });
258
+ }
259
+ /**
260
+ * Get the verifier address for a given key
261
+ *
262
+ * @param key - Verifier key
263
+ * @returns The verifier contract address, or zero address if not registered
264
+ */
265
+ async getVerifier(key) {
266
+ const verifier = await (0, transactions_js_1.readContractResult)(this.publicClient, {
267
+ address: this.address,
268
+ abi: engineAbi,
269
+ functionName: 'verifierRegistry',
270
+ args: [key],
271
+ });
272
+ return verifier;
273
+ }
274
+ /**
275
+ * Get the current nonce for a signer address
276
+ *
277
+ * @param signer - The signer address to get the nonce for
278
+ * @returns The current nonce value
279
+ */
280
+ async getNonce(signer) {
281
+ const nonce = await (0, transactions_js_1.readContractResult)(this.publicClient, {
282
+ address: this.address,
283
+ abi: engineAbi,
284
+ functionName: 'nonces',
285
+ args: [signer],
286
+ });
287
+ return nonce;
288
+ }
289
+ /**
290
+ * Create an EIP-712 permit signature for submitting an input
291
+ *
292
+ * @param signer - The signer that will create the signature (must be a Signer, not Provider)
293
+ * @param agreement - The agreement JSON definition
294
+ * @param inputId - The input identifier (e.g., "grantorData")
295
+ * @param data - Plain object with field values
296
+ * @param deadline - Unix timestamp when the permit expires
297
+ * @returns The signature components (v, r, s) and the signer address
298
+ *
299
+ * @example
300
+ * ```typescript
301
+ * const agreement = new AgreementEngine("0x...", provider);
302
+ * const deadline = Math.floor(Date.now() / 1000) + 3600; // 1 hour from now
303
+ *
304
+ * const { signature, signerAddress } = await agreement.createPermitSignature(
305
+ * signer,
306
+ * agreementJson,
307
+ * "grantorData",
308
+ * { grantorName: "Alice" },
309
+ * deadline
310
+ * );
311
+ * ```
312
+ */
313
+ async createPermitSignature(walletClient, agreement, inputId, data, deadline) {
314
+ // Get current nonce for the signer
315
+ const account = walletClient.account;
316
+ if (!account) {
317
+ throw new Error("WalletClient must be connected to an account to sign typed data");
318
+ }
319
+ const signerAddress = account.address;
320
+ const nonce = await this.getNonce(signerAddress);
321
+ // Build the payload
322
+ const payload = (0, payload_builder_js_1.buildInputPayload)(agreement, inputId, data);
323
+ const inputIdBytes32 = (0, payload_builder_js_1.inputToBytes32)(inputId);
324
+ // Get chain ID
325
+ const chainId = await this.publicClient.getChainId();
326
+ // EIP-712 domain & types (kept structurally identical to previous ethers version)
327
+ const domain = {
328
+ name: "AgreementEngine",
329
+ version: "1",
330
+ chainId,
331
+ verifyingContract: this.address,
332
+ };
333
+ const types = {
334
+ PermitInput: [
335
+ { name: "inputId", type: "bytes32" },
336
+ { name: "payload", type: "bytes" },
337
+ { name: "nonce", type: "uint256" },
338
+ { name: "deadline", type: "uint256" },
339
+ ],
340
+ };
341
+ const message = {
342
+ inputId: inputIdBytes32,
343
+ payload: payload,
344
+ nonce: nonce,
345
+ deadline: BigInt(deadline),
346
+ };
347
+ // Sign using viem WalletClient
348
+ const signature = await walletClient.signTypedData({
349
+ account,
350
+ domain,
351
+ types,
352
+ primaryType: "PermitInput",
353
+ message,
354
+ });
355
+ // Split signature into v, r, s
356
+ const r = `0x${signature.slice(2, 66)}`;
357
+ const s = `0x${signature.slice(66, 130)}`;
358
+ const v = parseInt(signature.slice(130, 132), 16);
359
+ return {
360
+ signature: { v, r, s },
361
+ signerAddress,
362
+ };
363
+ }
364
+ /**
365
+ * Submit an input using a permit signature, allowing someone else to submit on behalf of the signer
366
+ *
367
+ * @param signer - The address that signed the permit
368
+ * @param agreement - The agreement JSON definition
369
+ * @param inputId - The input identifier
370
+ * @param data - Plain object with field values
371
+ * @param deadline - Unix timestamp when the permit expires
372
+ * @param signature - The permit signature (v, r, s components)
373
+ * @param waitForConfirmation - Whether to wait for transaction confirmation (default: false)
374
+ * @returns Transaction hash, or receipt if waitForConfirmation is true
375
+ *
376
+ * @example
377
+ * ```typescript
378
+ * // Signer creates permit off-chain
379
+ * const { signature, signerAddress } = await agreement.createPermitSignature(
380
+ * signer,
381
+ * agreementJson,
382
+ * "grantorData",
383
+ * { grantorName: "Alice" },
384
+ * deadline
385
+ * );
386
+ *
387
+ * // Anyone can submit using the permit
388
+ * const agreementWithSubmitter = new AgreementEngine(agreementAddress, submitterSigner);
389
+ *
390
+ * // Fire and forget
391
+ * const txHash = await agreementWithSubmitter.submitInputWithPermit(
392
+ * signerAddress,
393
+ * agreementJson,
394
+ * "grantorData",
395
+ * { grantorName: "Alice" },
396
+ * deadline,
397
+ * signature
398
+ * );
399
+ *
400
+ * // Wait for confirmation
401
+ * const receipt = await agreementWithSubmitter.submitInputWithPermit(
402
+ * signerAddress,
403
+ * agreementJson,
404
+ * "grantorData",
405
+ * { grantorName: "Alice" },
406
+ * deadline,
407
+ * signature,
408
+ * true
409
+ * );
410
+ * console.log(`Transaction confirmed in block ${receipt.blockNumber}`);
411
+ * ```
412
+ */
413
+ async submitInputWithPermit(signer, agreement, inputId, data, deadline, signature, waitForConfirmation = false) {
414
+ return await (0, telemetry_js_1.withSdkSpan)("agreement_engine.submit_input_with_permit", {
415
+ "blockchain.chain_id": this.publicClient.chain?.id,
416
+ "agreement.address": this.address,
417
+ "agreement.input_id": inputId,
418
+ "wallet.signer": signer,
419
+ }, async () => {
420
+ if (!this.walletClient) {
421
+ throw new Error("WalletClient required for submitting inputs. Pass a walletClient to the constructor.");
422
+ }
423
+ // Build payload (must match what was signed)
424
+ const payload = (0, payload_builder_js_1.buildInputPayload)(agreement, inputId, data);
425
+ const inputIdBytes32 = (0, payload_builder_js_1.inputToBytes32)(inputId);
426
+ // Build the write contract request
427
+ const request = {
428
+ chain: null,
429
+ account: this.walletClient.account,
430
+ address: this.address,
431
+ abi: engineAbi,
432
+ functionName: 'submitInputWithPermit',
433
+ args: [
434
+ signer,
435
+ inputIdBytes32,
436
+ payload,
437
+ BigInt(deadline),
438
+ signature.v,
439
+ signature.r,
440
+ signature.s,
441
+ ],
442
+ };
443
+ // Use executeTransaction utility for optional waiting
444
+ const result = await (0, transactions_js_1.executeTransaction)(request, this.publicClient, this.walletClient, waitForConfirmation);
445
+ // Return hash if not waiting, full receipt if waiting
446
+ if (waitForConfirmation) {
447
+ return result;
448
+ }
449
+ return result.transactionHash;
450
+ });
451
+ }
452
+ }
453
+ exports.AgreementEngine = AgreementEngine;
454
+ //# sourceMappingURL=AgreementEngine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgreementEngine.js","sourceRoot":"","sources":["../../src/AgreementEngine.ts"],"names":[],"mappings":";AAAA,sCAAsC;;;AAWtC,uDAA2E;AAE3E,6DAAyE;AACzE,qDAAkD;AAClD,iDAA6C;AAC7C,6EAAuE;AAEvE,2DAA2D;AAC3D,gEAAgE;AAChE,MAAM,SAAS,GAAQ,0CAAyB,CAAC;AAEjD;;;;;GAKG;AACH,MAAa,eAAe;IAK1B;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,OAAY,EAAE,YAA0B,EAAE,YAA2B;QAC/E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,OAAO;QACX,OAAO,MAAM,IAAA,0BAAW,EACtB,2BAA2B,EAC3B;YACE,qBAAqB,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE;YAClD,mBAAmB,EAAE,IAAI,CAAC,OAAO;SAClC,EACD,KAAK,IAAI,EAAE;YACT,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBAC7E,IAAA,oCAAkB,EAAqC,IAAI,CAAC,YAAY,EAAE;oBACxE,OAAO,EAAE,IAAI,CAAC,OAAO;oBACrB,GAAG,EAAE,SAAS;oBACd,YAAY,EAAE,QAAQ;oBACtB,IAAI,EAAE,EAAE;iBACT,CAAC;gBACF,IAAA,oCAAkB,EAAmC,IAAI,CAAC,YAAY,EAAE;oBACtE,OAAO,EAAE,IAAI,CAAC,OAAO;oBACrB,GAAG,EAAE,SAAS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N,cAAc;oBACd,OAAO;oBACP,MAAM,CAAC,QAAQ,CAAC;oBAChB,SAAS,CAAC,CAAC;oBACX,SAAS,CAAC,CAAC;oBACX,SAAS,CAAC,CAAC;iBACZ;aACF,CAAC;YAEF,sDAAsD;YACtD,MAAM,MAAM,GAAG,MAAM,IAAA,oCAAkB,EACrC,OAAO,EACP,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,YAAY,EACjB,mBAAmB,CACpB,CAAC;YAEF,sDAAsD;YACtD,IAAI,mBAAmB,EAAE,CAAC;gBACxB,OAAO,MAA4B,CAAC;YACtC,CAAC;YACD,OAAO,MAAM,CAAC,eAAgB,CAAC;QACjC,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AAvgBD,0CAugBC"}
@@ -0,0 +1,186 @@
1
+ import { type Hex, type PublicClient, type WalletClient, type WriteContractParameters } from 'viem';
2
+ import { AgreementJson, FactoryConfig, VerifierInit } from "./types.js";
3
+ import { InitValue } from "./transformer.js";
4
+ export type CreateAgreementOptions = {
5
+ docUri?: string;
6
+ initValues?: Record<string, InitValue>;
7
+ verifiers?: VerifierInit[];
8
+ };
9
+ export type CreateAgreementPermitSignature = {
10
+ v: number;
11
+ r: Hex;
12
+ s: Hex;
13
+ };
14
+ interface FactoryClients {
15
+ walletClient: WalletClient;
16
+ publicClient: PublicClient;
17
+ }
18
+ /**
19
+ * Factory for creating new Agreement instances
20
+ *
21
+ * The factory uses EIP-1167 minimal proxy clones where each agreement
22
+ * is deployed as a separate contract. The factory creates clones that
23
+ * point to a shared implementation.
24
+ */
25
+ export declare class AgreementFactory {
26
+ private readonly clients;
27
+ private config;
28
+ private chainId?;
29
+ /**
30
+ * Create a new AgreementFactory instance
31
+ *
32
+ * @param config - Factory configuration
33
+ * @param config.factoryAddress - The AgreementFactory contract address (required)
34
+ * @param config.chainId - Optional chain ID for reference (can be fetched via getChainId())
35
+ * @param clients.walletClient - Wallet client for creating agreements (must be connected to an account)
36
+ * @param clients.publicClient - Public client for reading receipts / logs
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * const factory = new AgreementFactory(
41
+ * { factoryAddress: "0x..." },
42
+ * { publicClient, walletClient }
43
+ * );
44
+ * ```
45
+ */
46
+ constructor(config: FactoryConfig, clients: FactoryClients);
47
+ /**
48
+ * Get the current chain ID from the signer's provider
49
+ *
50
+ * @returns The chain ID as a number
51
+ */
52
+ getChainId(): Promise<number>;
53
+ /**
54
+ * Internal helper: simulate a contract call, and if the RPC complains about
55
+ * gas price being below the configured minimum, bump gas values and re-simulate.
56
+ */
57
+ private simulate;
58
+ private parseAgreementDeployedAddress;
59
+ private hashInputDefs;
60
+ private hashTransitions;
61
+ private hashInitVars;
62
+ private hashVerifiers;
63
+ private hashActions;
64
+ /**
65
+ * Create a new agreement from an AgreementJson definition
66
+ *
67
+ * @param agreement - The agreement JSON definition
68
+ * @param options - Optional configuration
69
+ * @param options.docUri - Custom document URI (defaults to ipfs://agreement/{id})
70
+ * @param options.initValues - Initialization values for variables referenced in initialize.data
71
+ * @returns The deployed agreement contract address and transaction response
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const factory = new AgreementFactory(
76
+ * { factoryAddress: "0x..." },
77
+ * { publicClient, walletClient }
78
+ * );
79
+ *
80
+ * const { address, receipt } = await factory.createAgreement(agreementJson, {
81
+ * initValues: {
82
+ * grantorEthAddress: "0x123...",
83
+ * recipientEthAddress: "0x456..."
84
+ * }
85
+ * });
86
+ * ```
87
+ */
88
+ createAgreement(agreement: AgreementJson, options?: CreateAgreementOptions): Promise<{
89
+ address: Hex;
90
+ request: WriteContractParameters;
91
+ receipt: Awaited<ReturnType<PublicClient["waitForTransactionReceipt"]>>;
92
+ }>;
93
+ /**
94
+ * Read the current permit nonce for a signer address.
95
+ */
96
+ getNonce(signer: Hex): Promise<bigint>;
97
+ /**
98
+ * Create an EIP-712 permit signature for creating an agreement via the factory.
99
+ *
100
+ * The permit binds the full agreement creation parameters (docUri/docHash/initialState
101
+ * and hashes of inputDefs/transitions/initVars/verifiers/actions) plus the signer's current nonce + deadline.
102
+ *
103
+ * @param walletClient - viem WalletClient to sign typed data (must be connected to an account)
104
+ * @param agreement - The agreement JSON definition
105
+ * @param deadline - Unix timestamp when the permit expires
106
+ * @param options - Optional configuration (docUri + initValues)
107
+ */
108
+ createPermitSignature(walletClient: WalletClient, agreement: AgreementJson, deadline: number, options?: CreateAgreementOptions): Promise<{
109
+ signature: CreateAgreementPermitSignature;
110
+ signerAddress: Hex;
111
+ }>;
112
+ /**
113
+ * Create a new agreement using a permit signature, allowing a submitter to create
114
+ * on behalf of the signer (the signer becomes the agreement owner).
115
+ */
116
+ createAgreementWithPermit(signer: Hex, agreement: AgreementJson, deadline: number, signature: CreateAgreementPermitSignature, options?: CreateAgreementOptions): Promise<{
117
+ address: Hex;
118
+ request: WriteContractParameters;
119
+ receipt: Awaited<ReturnType<PublicClient["waitForTransactionReceipt"]>>;
120
+ }>;
121
+ /**
122
+ * Create a new agreement at a deterministic address
123
+ *
124
+ * @param agreement - The agreement JSON definition
125
+ * @param salt - Salt for deterministic address derivation
126
+ * @param options - Optional configuration
127
+ * @param options.docUri - Custom document URI (defaults to ipfs://agreement/{id})
128
+ * @param options.initValues - Initialization values for variables referenced in initialize.data
129
+ * @returns The deployed agreement contract address and transaction response
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * const factory = new AgreementFactory(
134
+ * { factoryAddress: "0x..." },
135
+ * { publicClient, walletClient }
136
+ * );
137
+ * const salt = "0x1234...";
138
+ *
139
+ * const { address, receipt } = await factory.createAgreementDeterministic(
140
+ * agreementJson,
141
+ * salt,
142
+ * { initValues: { ... } }
143
+ * );
144
+ * ```
145
+ */
146
+ createAgreementDeterministic(agreement: AgreementJson, salt: Hex, options?: CreateAgreementOptions): Promise<{
147
+ address: Hex;
148
+ request: WriteContractParameters;
149
+ receipt: Awaited<ReturnType<PublicClient["waitForTransactionReceipt"]>>;
150
+ }>;
151
+ /**
152
+ * Create a new deterministic agreement using a permit signature.
153
+ * Note: The on-chain permit does NOT bind the salt; the signature authorizes the agreement params.
154
+ */
155
+ createAgreementDeterministicWithPermit(signer: Hex, salt: Hex, agreement: AgreementJson, deadline: number, signature: CreateAgreementPermitSignature, options?: CreateAgreementOptions): Promise<{
156
+ address: Hex;
157
+ request: WriteContractParameters;
158
+ receipt: Awaited<ReturnType<PublicClient["waitForTransactionReceipt"]>>;
159
+ }>;
160
+ /**
161
+ * Predict the address of a deterministic agreement before deployment
162
+ *
163
+ * @param salt The salt that will be used for deployment
164
+ * @returns The predicted agreement address
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * const factory = new AgreementFactory(
169
+ * { factoryAddress: "0x..." },
170
+ * { publicClient, walletClient }
171
+ * );
172
+ * const predictedAddress = await factory.predictAddress("0x1234...");
173
+ * ```
174
+ */
175
+ predictAddress(salt: Hex): Promise<Hex>;
176
+ /**
177
+ * Get the factory contract address
178
+ */
179
+ getAddress(): Hex;
180
+ /**
181
+ * Get the implementation address that clones point to
182
+ */
183
+ getImplementationAddress(): Promise<Hex>;
184
+ }
185
+ export {};
186
+ //# sourceMappingURL=AgreementFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgreementFactory.d.ts","sourceRoot":"","sources":["../../src/AgreementFactory.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,GAAG,EACR,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAK7B,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,aAAa,EAAE,aAAa,EAAmC,YAAY,EAAc,MAAM,YAAY,CAAC;AACrH,OAAO,EAAqC,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAWhF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACvC,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;CAC5B,CAAC;AAEF,MAA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