@agirails/sdk 2.3.0 → 2.3.1

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 (153) hide show
  1. package/README.md +45 -8
  2. package/dist/ACTPClient.d.ts +35 -1
  3. package/dist/ACTPClient.d.ts.map +1 -1
  4. package/dist/ACTPClient.js +156 -26
  5. package/dist/ACTPClient.js.map +1 -1
  6. package/dist/adapters/AdapterRouter.d.ts.map +1 -1
  7. package/dist/adapters/AdapterRouter.js.map +1 -1
  8. package/dist/adapters/BasicAdapter.d.ts +10 -1
  9. package/dist/adapters/BasicAdapter.d.ts.map +1 -1
  10. package/dist/adapters/BasicAdapter.js +36 -1
  11. package/dist/adapters/BasicAdapter.js.map +1 -1
  12. package/dist/cli/commands/init.d.ts +1 -0
  13. package/dist/cli/commands/init.d.ts.map +1 -1
  14. package/dist/cli/commands/init.js +210 -18
  15. package/dist/cli/commands/init.js.map +1 -1
  16. package/dist/cli/commands/publish.d.ts.map +1 -1
  17. package/dist/cli/commands/publish.js.map +1 -1
  18. package/dist/cli/commands/register.d.ts +16 -0
  19. package/dist/cli/commands/register.d.ts.map +1 -0
  20. package/dist/cli/commands/register.js +211 -0
  21. package/dist/cli/commands/register.js.map +1 -0
  22. package/dist/cli/index.js +3 -0
  23. package/dist/cli/index.js.map +1 -1
  24. package/dist/cli/utils/config.d.ts +6 -0
  25. package/dist/cli/utils/config.d.ts.map +1 -1
  26. package/dist/cli/utils/config.js.map +1 -1
  27. package/dist/config/networks.d.ts +20 -4
  28. package/dist/config/networks.d.ts.map +1 -1
  29. package/dist/config/networks.js +59 -27
  30. package/dist/config/networks.js.map +1 -1
  31. package/dist/config/publishPipeline.d.ts +14 -0
  32. package/dist/config/publishPipeline.d.ts.map +1 -1
  33. package/dist/config/publishPipeline.js +2 -1
  34. package/dist/config/publishPipeline.js.map +1 -1
  35. package/dist/erc8004/ERC8004Bridge.d.ts.map +1 -1
  36. package/dist/erc8004/ERC8004Bridge.js +6 -5
  37. package/dist/erc8004/ERC8004Bridge.js.map +1 -1
  38. package/dist/erc8004/ReputationReporter.d.ts.map +1 -1
  39. package/dist/erc8004/ReputationReporter.js +9 -12
  40. package/dist/erc8004/ReputationReporter.js.map +1 -1
  41. package/dist/index.d.ts +4 -0
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +7 -3
  44. package/dist/index.js.map +1 -1
  45. package/dist/level1/Agent.js +4 -4
  46. package/dist/level1/Agent.js.map +1 -1
  47. package/dist/protocol/ACTPKernel.d.ts +7 -1
  48. package/dist/protocol/ACTPKernel.d.ts.map +1 -1
  49. package/dist/protocol/ACTPKernel.js +13 -10
  50. package/dist/protocol/ACTPKernel.js.map +1 -1
  51. package/dist/protocol/EventMonitor.d.ts +14 -0
  52. package/dist/protocol/EventMonitor.d.ts.map +1 -1
  53. package/dist/protocol/EventMonitor.js +14 -0
  54. package/dist/protocol/EventMonitor.js.map +1 -1
  55. package/dist/runtime/BlockchainRuntime.d.ts +5 -0
  56. package/dist/runtime/BlockchainRuntime.d.ts.map +1 -1
  57. package/dist/runtime/BlockchainRuntime.js +1 -1
  58. package/dist/runtime/BlockchainRuntime.js.map +1 -1
  59. package/dist/storage/ArchiveBundleBuilder.d.ts.map +1 -1
  60. package/dist/storage/ArchiveBundleBuilder.js.map +1 -1
  61. package/dist/storage/ArweaveClient.d.ts.map +1 -1
  62. package/dist/storage/ArweaveClient.js +2 -0
  63. package/dist/storage/ArweaveClient.js.map +1 -1
  64. package/dist/storage/FilebaseClient.d.ts.map +1 -1
  65. package/dist/storage/FilebaseClient.js +2 -0
  66. package/dist/storage/FilebaseClient.js.map +1 -1
  67. package/dist/utils/ErrorRecoveryGuide.d.ts.map +1 -1
  68. package/dist/utils/ErrorRecoveryGuide.js +3 -2
  69. package/dist/utils/ErrorRecoveryGuide.js.map +1 -1
  70. package/dist/utils/IPFSClient.d.ts +3 -2
  71. package/dist/utils/IPFSClient.d.ts.map +1 -1
  72. package/dist/utils/IPFSClient.js +7 -5
  73. package/dist/utils/IPFSClient.js.map +1 -1
  74. package/dist/utils/computeTypeHash.js +1 -3
  75. package/dist/utils/computeTypeHash.js.map +1 -1
  76. package/dist/utils/retry.d.ts.map +1 -1
  77. package/dist/utils/retry.js +0 -1
  78. package/dist/utils/retry.js.map +1 -1
  79. package/dist/utils/validation.d.ts +2 -2
  80. package/dist/utils/validation.d.ts.map +1 -1
  81. package/dist/utils/validation.js +2 -2
  82. package/dist/utils/validation.js.map +1 -1
  83. package/dist/wallet/AutoWalletProvider.d.ts +77 -0
  84. package/dist/wallet/AutoWalletProvider.d.ts.map +1 -0
  85. package/dist/wallet/AutoWalletProvider.js +197 -0
  86. package/dist/wallet/AutoWalletProvider.js.map +1 -0
  87. package/dist/wallet/EOAWalletProvider.d.ts +21 -0
  88. package/dist/wallet/EOAWalletProvider.d.ts.map +1 -0
  89. package/dist/wallet/EOAWalletProvider.js +57 -0
  90. package/dist/wallet/EOAWalletProvider.js.map +1 -0
  91. package/dist/wallet/IWalletProvider.d.ts +115 -0
  92. package/dist/wallet/IWalletProvider.d.ts.map +1 -0
  93. package/dist/wallet/IWalletProvider.js +12 -0
  94. package/dist/wallet/IWalletProvider.js.map +1 -0
  95. package/dist/wallet/aa/BundlerClient.d.ts +70 -0
  96. package/dist/wallet/aa/BundlerClient.d.ts.map +1 -0
  97. package/dist/wallet/aa/BundlerClient.js +183 -0
  98. package/dist/wallet/aa/BundlerClient.js.map +1 -0
  99. package/dist/wallet/aa/DualNonceManager.d.ts +55 -0
  100. package/dist/wallet/aa/DualNonceManager.d.ts.map +1 -0
  101. package/dist/wallet/aa/DualNonceManager.js +131 -0
  102. package/dist/wallet/aa/DualNonceManager.js.map +1 -0
  103. package/dist/wallet/aa/PaymasterClient.d.ts +52 -0
  104. package/dist/wallet/aa/PaymasterClient.d.ts.map +1 -0
  105. package/dist/wallet/aa/PaymasterClient.js +115 -0
  106. package/dist/wallet/aa/PaymasterClient.js.map +1 -0
  107. package/dist/wallet/aa/TransactionBatcher.d.ts +87 -0
  108. package/dist/wallet/aa/TransactionBatcher.d.ts.map +1 -0
  109. package/dist/wallet/aa/TransactionBatcher.js +148 -0
  110. package/dist/wallet/aa/TransactionBatcher.js.map +1 -0
  111. package/dist/wallet/aa/UserOpBuilder.d.ts +71 -0
  112. package/dist/wallet/aa/UserOpBuilder.d.ts.map +1 -0
  113. package/dist/wallet/aa/UserOpBuilder.js +196 -0
  114. package/dist/wallet/aa/UserOpBuilder.js.map +1 -0
  115. package/dist/wallet/aa/constants.d.ts +54 -0
  116. package/dist/wallet/aa/constants.d.ts.map +1 -0
  117. package/dist/wallet/aa/constants.js +18 -0
  118. package/dist/wallet/aa/constants.js.map +1 -0
  119. package/package.json +4 -2
  120. package/src/ACTPClient.ts +217 -31
  121. package/src/adapters/AdapterRouter.ts +0 -1
  122. package/src/adapters/BasicAdapter.ts +41 -1
  123. package/src/cli/commands/init.ts +247 -19
  124. package/src/cli/commands/publish.ts +1 -2
  125. package/src/cli/commands/register.ts +233 -0
  126. package/src/cli/index.ts +4 -0
  127. package/src/cli/utils/config.ts +9 -0
  128. package/src/config/networks.ts +82 -27
  129. package/src/config/publishPipeline.ts +2 -2
  130. package/src/erc8004/ERC8004Bridge.ts +6 -5
  131. package/src/erc8004/ReputationReporter.ts +14 -18
  132. package/src/index.ts +12 -0
  133. package/src/level1/Agent.ts +5 -5
  134. package/src/protocol/ACTPKernel.ts +20 -10
  135. package/src/protocol/EventMonitor.ts +14 -0
  136. package/src/runtime/BlockchainRuntime.ts +7 -1
  137. package/src/storage/ArchiveBundleBuilder.ts +0 -2
  138. package/src/storage/ArweaveClient.ts +2 -1
  139. package/src/storage/FilebaseClient.ts +3 -3
  140. package/src/utils/ErrorRecoveryGuide.ts +4 -2
  141. package/src/utils/IPFSClient.ts +9 -7
  142. package/src/utils/computeTypeHash.ts +1 -3
  143. package/src/utils/retry.ts +0 -1
  144. package/src/utils/validation.ts +2 -2
  145. package/src/wallet/AutoWalletProvider.ts +294 -0
  146. package/src/wallet/EOAWalletProvider.ts +69 -0
  147. package/src/wallet/IWalletProvider.ts +133 -0
  148. package/src/wallet/aa/BundlerClient.ts +273 -0
  149. package/src/wallet/aa/DualNonceManager.ts +163 -0
  150. package/src/wallet/aa/PaymasterClient.ts +173 -0
  151. package/src/wallet/aa/TransactionBatcher.ts +240 -0
  152. package/src/wallet/aa/UserOpBuilder.ts +246 -0
  153. package/src/wallet/aa/constants.ts +60 -0
@@ -0,0 +1,52 @@
1
+ /**
2
+ * PaymasterClient — Gas sponsorship via ERC-7677 paymasters.
3
+ *
4
+ * Fallback chain: Coinbase CDP (primary) → Pimlico (backup).
5
+ * Both implement ERC-7677 pm_getPaymasterStubData / pm_getPaymasterData.
6
+ *
7
+ * The paymaster fills the `paymasterAndData` field of the UserOp,
8
+ * which the EntryPoint uses to debit gas from the paymaster instead
9
+ * of the sender's ETH balance.
10
+ *
11
+ * @module wallet/aa/PaymasterClient
12
+ */
13
+ import { UserOperationV06 } from './constants';
14
+ export interface PaymasterConfig {
15
+ /** Primary paymaster URL (Coinbase CDP) */
16
+ primaryUrl: string;
17
+ /** Backup paymaster URL (Pimlico) */
18
+ backupUrl?: string;
19
+ /** Chain ID (8453 for Base Mainnet, 84532 for Sepolia) */
20
+ chainId: number;
21
+ /** Request timeout (ms) */
22
+ timeoutMs?: number;
23
+ }
24
+ export declare class PaymasterClient {
25
+ private readonly primaryUrl;
26
+ private readonly backupUrl;
27
+ private readonly chainId;
28
+ private readonly timeoutMs;
29
+ private requestId;
30
+ constructor(config: PaymasterConfig);
31
+ /**
32
+ * Get stub paymaster data for gas estimation.
33
+ *
34
+ * Returns approximate paymasterAndData that the bundler can use
35
+ * for gas estimation (exact values come from getPaymasterData).
36
+ */
37
+ getPaymasterStubData(userOp: UserOperationV06): Promise<{
38
+ paymasterAndData: string;
39
+ }>;
40
+ /**
41
+ * Get final paymaster data for the signed UserOp.
42
+ *
43
+ * This is called after gas estimation with final gas values.
44
+ * Returns the paymaster signature that goes into paymasterAndData.
45
+ */
46
+ getPaymasterData(userOp: UserOperationV06): Promise<{
47
+ paymasterAndData: string;
48
+ }>;
49
+ private callWithFallback;
50
+ private jsonRpc;
51
+ }
52
+ //# sourceMappingURL=PaymasterClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PaymasterClient.d.ts","sourceRoot":"","sources":["../../../src/wallet/aa/PaymasterClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAS/C,MAAM,WAAW,eAAe;IAC9B,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAaD,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAC/C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,SAAS,CAAK;gBAEV,MAAM,EAAE,eAAe;IAOnC;;;;;OAKG;IACG,oBAAoB,CACxB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC;QAAE,gBAAgB,EAAE,MAAM,CAAA;KAAE,CAAC;IAYxC;;;;;OAKG;IACG,gBAAgB,CACpB,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC;QAAE,gBAAgB,EAAE,MAAM,CAAA;KAAE,CAAC;YAgB1B,gBAAgB;YA8BhB,OAAO;CAwCtB"}
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ /**
3
+ * PaymasterClient — Gas sponsorship via ERC-7677 paymasters.
4
+ *
5
+ * Fallback chain: Coinbase CDP (primary) → Pimlico (backup).
6
+ * Both implement ERC-7677 pm_getPaymasterStubData / pm_getPaymasterData.
7
+ *
8
+ * The paymaster fills the `paymasterAndData` field of the UserOp,
9
+ * which the EntryPoint uses to debit gas from the paymaster instead
10
+ * of the sender's ETH balance.
11
+ *
12
+ * @module wallet/aa/PaymasterClient
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.PaymasterClient = void 0;
16
+ const UserOpBuilder_1 = require("./UserOpBuilder");
17
+ const constants_1 = require("./constants");
18
+ const Logger_1 = require("../../utils/Logger");
19
+ // ============================================================================
20
+ // PaymasterClient
21
+ // ============================================================================
22
+ class PaymasterClient {
23
+ constructor(config) {
24
+ this.requestId = 1;
25
+ this.primaryUrl = config.primaryUrl;
26
+ this.backupUrl = config.backupUrl;
27
+ this.chainId = config.chainId;
28
+ this.timeoutMs = config.timeoutMs ?? 15000;
29
+ }
30
+ /**
31
+ * Get stub paymaster data for gas estimation.
32
+ *
33
+ * Returns approximate paymasterAndData that the bundler can use
34
+ * for gas estimation (exact values come from getPaymasterData).
35
+ */
36
+ async getPaymasterStubData(userOp) {
37
+ return this.callWithFallback('pm_getPaymasterStubData', [
38
+ (0, UserOpBuilder_1.serializeUserOp)(userOp),
39
+ constants_1.ENTRYPOINT_V06,
40
+ '0x' + this.chainId.toString(16),
41
+ {}, // context
42
+ ]);
43
+ }
44
+ /**
45
+ * Get final paymaster data for the signed UserOp.
46
+ *
47
+ * This is called after gas estimation with final gas values.
48
+ * Returns the paymaster signature that goes into paymasterAndData.
49
+ */
50
+ async getPaymasterData(userOp) {
51
+ return this.callWithFallback('pm_getPaymasterData', [
52
+ (0, UserOpBuilder_1.serializeUserOp)(userOp),
53
+ constants_1.ENTRYPOINT_V06,
54
+ '0x' + this.chainId.toString(16),
55
+ {}, // context
56
+ ]);
57
+ }
58
+ // ==========================================================================
59
+ // Internal
60
+ // ==========================================================================
61
+ async callWithFallback(method, params) {
62
+ try {
63
+ return await this.jsonRpc(this.primaryUrl, method, params);
64
+ }
65
+ catch (primaryError) {
66
+ if (!this.backupUrl) {
67
+ throw new Error(`Gas sponsorship unavailable: ${primaryError instanceof Error ? primaryError.message : String(primaryError)}. ` +
68
+ 'No backup paymaster configured.');
69
+ }
70
+ Logger_1.sdkLogger.warn('Primary paymaster failed, trying backup', {
71
+ method,
72
+ error: primaryError instanceof Error ? primaryError.message : String(primaryError),
73
+ });
74
+ }
75
+ try {
76
+ return await this.jsonRpc(this.backupUrl, method, params);
77
+ }
78
+ catch (backupError) {
79
+ throw new Error('Gas sponsorship temporarily unavailable — both Coinbase and Pimlico paymasters failed. ' +
80
+ 'Please retry later. ' +
81
+ `Primary: ${backupError instanceof Error ? backupError.message : String(backupError)}`);
82
+ }
83
+ }
84
+ async jsonRpc(url, method, params) {
85
+ const body = JSON.stringify({
86
+ jsonrpc: '2.0',
87
+ id: this.requestId++,
88
+ method,
89
+ params,
90
+ });
91
+ const controller = new AbortController();
92
+ const timeout = setTimeout(() => controller.abort(), this.timeoutMs);
93
+ try {
94
+ const response = await fetch(url, {
95
+ method: 'POST',
96
+ headers: { 'Content-Type': 'application/json' },
97
+ body,
98
+ signal: controller.signal,
99
+ });
100
+ if (!response.ok) {
101
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
102
+ }
103
+ const json = (await response.json());
104
+ if (json.error) {
105
+ throw new Error(`Paymaster RPC error ${json.error.code}: ${json.error.message}`);
106
+ }
107
+ return json.result;
108
+ }
109
+ finally {
110
+ clearTimeout(timeout);
111
+ }
112
+ }
113
+ }
114
+ exports.PaymasterClient = PaymasterClient;
115
+ //# sourceMappingURL=PaymasterClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PaymasterClient.js","sourceRoot":"","sources":["../../../src/wallet/aa/PaymasterClient.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAGH,mDAAkD;AAClD,2CAA6C;AAC7C,+CAA+C;AAwB/C,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E,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,MAAM;aAC1B,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,QAAQ,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;YACrE,CAAC;YAED,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAuB,CAAC;YAE3D,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CACb,uBAAuB,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAChE,CAAC;YACJ,CAAC;YAED,OAAO,IAAI,CAAC,MAAW,CAAC;QAC1B,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;CACF;AAhID,0CAgIC"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * TransactionBatcher — Encodes ACTP multi-call batches.
3
+ *
4
+ * An ACTP payment requires 3 contract calls:
5
+ * 1. USDC.approve(escrowVault, amount)
6
+ * 2. ACTPKernel.createTransaction(provider, requester, amount, deadline, disputeWindow, serviceHash, agentId)
7
+ * 3. ACTPKernel.linkEscrow(txId, escrowVault, escrowId)
8
+ *
9
+ * TransactionBatcher encodes all 3 as SmartWalletCall[] for executeBatch.
10
+ * It pre-computes the txId using the same keccak256 formula as the contract.
11
+ *
12
+ * @module wallet/aa/TransactionBatcher
13
+ */
14
+ import { SmartWalletCall } from './constants';
15
+ import { ServiceDescriptor } from '../../types/agent';
16
+ export interface ACTPBatchParams {
17
+ /** Provider address */
18
+ provider: string;
19
+ /** Requester address (= Smart Wallet address) */
20
+ requester: string;
21
+ /** Amount in USDC wei (e.g., "1000000" for 1 USDC) */
22
+ amount: string;
23
+ /** Unix timestamp deadline */
24
+ deadline: number;
25
+ /** Dispute window in seconds */
26
+ disputeWindow: number;
27
+ /** Service hash (bytes32) */
28
+ serviceHash: string;
29
+ /** ERC-8004 agent ID (0 if none) */
30
+ agentId: string;
31
+ /** Current ACTP nonce for the requester (from ACTPKernel.requesterNonces) */
32
+ actpNonce: bigint;
33
+ /** Contract addresses */
34
+ contracts: {
35
+ usdc: string;
36
+ actpKernel: string;
37
+ escrowVault: string;
38
+ };
39
+ }
40
+ export interface ACTPBatchResult {
41
+ /** Encoded SmartWalletCall[] ready for executeBatch */
42
+ calls: SmartWalletCall[];
43
+ /** Pre-computed transaction ID */
44
+ txId: string;
45
+ }
46
+ /**
47
+ * Pre-compute ACTP transaction ID.
48
+ *
49
+ * Matches ACTPKernel.sol:
50
+ * transactionId = keccak256(abi.encodePacked(requester, provider, amount, serviceHash, nonce))
51
+ */
52
+ export declare function computeTransactionId(requester: string, provider: string, amount: string, serviceHash: string, nonce: bigint): string;
53
+ /**
54
+ * Build the 3-call ACTP payment batch.
55
+ *
56
+ * Returns SmartWalletCall[] for executeBatch and the pre-computed txId.
57
+ */
58
+ export declare function buildACTPPayBatch(params: ACTPBatchParams): ACTPBatchResult;
59
+ /**
60
+ * Build a register-agent batch for AgentRegistry.
61
+ *
62
+ * Used for bootstrap registration (gasless even before registration — chicken-and-egg).
63
+ *
64
+ * @param agentRegistryAddress - AgentRegistry contract address
65
+ * @param endpoint - Agent webhook / IPFS gateway URL
66
+ * @param serviceDescriptors - At least 1 service descriptor (contract requirement)
67
+ */
68
+ export declare function buildRegisterAgentBatch(agentRegistryAddress: string, endpoint: string, serviceDescriptors: ServiceDescriptor[]): SmartWalletCall[];
69
+ /**
70
+ * Build a MockUSDC mint call (testnet only).
71
+ */
72
+ export declare function buildTestnetMintBatch(mockUsdcAddress: string, recipient: string, amount: string): SmartWalletCall[];
73
+ /**
74
+ * Build a combined register + mint batch for testnet init.
75
+ *
76
+ * Single UserOp: register on AgentRegistry + mint test USDC.
77
+ * Both are bootstrap-allowed (gasless without prior registration).
78
+ */
79
+ export declare function buildTestnetInitBatch(params: {
80
+ agentRegistryAddress: string;
81
+ endpoint: string;
82
+ serviceDescriptors: ServiceDescriptor[];
83
+ mockUsdcAddress: string;
84
+ recipient: string;
85
+ mintAmount: string;
86
+ }): SmartWalletCall[];
87
+ //# sourceMappingURL=TransactionBatcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransactionBatcher.d.ts","sourceRoot":"","sources":["../../../src/wallet/aa/TransactionBatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAmBtD,MAAM,WAAW,eAAe;IAC9B,uBAAuB;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,6BAA6B;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,SAAS,EAAE,MAAM,CAAC;IAClB,yBAAyB;IACzB,SAAS,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,eAAe;IAC9B,uDAAuD;IACvD,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;AAMD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,GACZ,MAAM,CAOR;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CA+C1E;AAcD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,oBAAoB,EAAE,MAAM,EAC5B,QAAQ,EAAE,MAAM,EAChB,kBAAkB,EAAE,iBAAiB,EAAE,GACtC,eAAe,EAAE,CAuBnB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,eAAe,EAAE,CASnB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,iBAAiB,EAAE,CAAC;IACxC,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,eAAe,EAAE,CAYpB"}
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ /**
3
+ * TransactionBatcher — Encodes ACTP multi-call batches.
4
+ *
5
+ * An ACTP payment requires 3 contract calls:
6
+ * 1. USDC.approve(escrowVault, amount)
7
+ * 2. ACTPKernel.createTransaction(provider, requester, amount, deadline, disputeWindow, serviceHash, agentId)
8
+ * 3. ACTPKernel.linkEscrow(txId, escrowVault, escrowId)
9
+ *
10
+ * TransactionBatcher encodes all 3 as SmartWalletCall[] for executeBatch.
11
+ * It pre-computes the txId using the same keccak256 formula as the contract.
12
+ *
13
+ * @module wallet/aa/TransactionBatcher
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.buildTestnetInitBatch = exports.buildTestnetMintBatch = exports.buildRegisterAgentBatch = exports.buildACTPPayBatch = exports.computeTransactionId = void 0;
17
+ const ethers_1 = require("ethers");
18
+ // ============================================================================
19
+ // ABI fragments — minimal for encoding only
20
+ // ============================================================================
21
+ const ERC20_APPROVE_ABI = [
22
+ 'function approve(address spender, uint256 amount)',
23
+ ];
24
+ const ACTP_KERNEL_ABI = [
25
+ 'function createTransaction(address provider, address requester, uint256 amount, uint256 deadline, uint256 disputeWindow, bytes32 serviceHash, uint256 agentId)',
26
+ 'function linkEscrow(bytes32 txId, address escrowVault, bytes32 escrowId)',
27
+ ];
28
+ // ============================================================================
29
+ // Public API
30
+ // ============================================================================
31
+ /**
32
+ * Pre-compute ACTP transaction ID.
33
+ *
34
+ * Matches ACTPKernel.sol:
35
+ * transactionId = keccak256(abi.encodePacked(requester, provider, amount, serviceHash, nonce))
36
+ */
37
+ function computeTransactionId(requester, provider, amount, serviceHash, nonce) {
38
+ return ethers_1.ethers.keccak256(ethers_1.ethers.solidityPacked(['address', 'address', 'uint256', 'bytes32', 'uint256'], [requester, provider, BigInt(amount), serviceHash, nonce]));
39
+ }
40
+ exports.computeTransactionId = computeTransactionId;
41
+ /**
42
+ * Build the 3-call ACTP payment batch.
43
+ *
44
+ * Returns SmartWalletCall[] for executeBatch and the pre-computed txId.
45
+ */
46
+ function buildACTPPayBatch(params) {
47
+ const amount = BigInt(params.amount);
48
+ // Pre-compute txId
49
+ const txId = computeTransactionId(params.requester, params.provider, params.amount, params.serviceHash, params.actpNonce);
50
+ const erc20Iface = new ethers_1.ethers.Interface(ERC20_APPROVE_ABI);
51
+ const kernelIface = new ethers_1.ethers.Interface(ACTP_KERNEL_ABI);
52
+ // Call 1: USDC.approve(escrowVault, amount)
53
+ const approveData = erc20Iface.encodeFunctionData('approve', [
54
+ params.contracts.escrowVault,
55
+ amount,
56
+ ]);
57
+ // Call 2: ACTPKernel.createTransaction(...)
58
+ const createTxData = kernelIface.encodeFunctionData('createTransaction', [
59
+ params.provider,
60
+ params.requester,
61
+ amount,
62
+ params.deadline,
63
+ params.disputeWindow,
64
+ params.serviceHash,
65
+ BigInt(params.agentId || '0'),
66
+ ]);
67
+ // Call 3: ACTPKernel.linkEscrow(txId, escrowVault, escrowId)
68
+ // escrowId = txId (ACTP standard)
69
+ const linkEscrowData = kernelIface.encodeFunctionData('linkEscrow', [
70
+ txId,
71
+ params.contracts.escrowVault,
72
+ txId,
73
+ ]);
74
+ const calls = [
75
+ { target: params.contracts.usdc, value: 0n, data: approveData },
76
+ { target: params.contracts.actpKernel, value: 0n, data: createTxData },
77
+ { target: params.contracts.actpKernel, value: 0n, data: linkEscrowData },
78
+ ];
79
+ return { calls, txId };
80
+ }
81
+ exports.buildACTPPayBatch = buildACTPPayBatch;
82
+ /**
83
+ * ABI fragment for AgentRegistry.registerAgent.
84
+ *
85
+ * Matches IAgentRegistry.sol:
86
+ * registerAgent(string endpoint, ServiceDescriptor[] serviceDescriptors)
87
+ *
88
+ * ServiceDescriptor = (bytes32, string, string, uint256, uint256, uint256, string)
89
+ */
90
+ const AGENT_REGISTRY_ABI = [
91
+ 'function registerAgent(string endpoint, (bytes32 serviceTypeHash, string serviceType, string schemaURI, uint256 minPrice, uint256 maxPrice, uint256 avgCompletionTime, string metadataCID)[] serviceDescriptors)',
92
+ ];
93
+ /**
94
+ * Build a register-agent batch for AgentRegistry.
95
+ *
96
+ * Used for bootstrap registration (gasless even before registration — chicken-and-egg).
97
+ *
98
+ * @param agentRegistryAddress - AgentRegistry contract address
99
+ * @param endpoint - Agent webhook / IPFS gateway URL
100
+ * @param serviceDescriptors - At least 1 service descriptor (contract requirement)
101
+ */
102
+ function buildRegisterAgentBatch(agentRegistryAddress, endpoint, serviceDescriptors) {
103
+ if (serviceDescriptors.length === 0) {
104
+ throw new Error('At least one service descriptor is required for registration');
105
+ }
106
+ const iface = new ethers_1.ethers.Interface(AGENT_REGISTRY_ABI);
107
+ // Convert to contract format (bigint fields already correct)
108
+ const descriptors = serviceDescriptors.map(sd => ({
109
+ serviceTypeHash: sd.serviceTypeHash,
110
+ serviceType: sd.serviceType,
111
+ schemaURI: sd.schemaURI,
112
+ minPrice: sd.minPrice,
113
+ maxPrice: sd.maxPrice,
114
+ avgCompletionTime: sd.avgCompletionTime,
115
+ metadataCID: sd.metadataCID,
116
+ }));
117
+ const data = iface.encodeFunctionData('registerAgent', [endpoint, descriptors]);
118
+ return [
119
+ { target: agentRegistryAddress, value: 0n, data },
120
+ ];
121
+ }
122
+ exports.buildRegisterAgentBatch = buildRegisterAgentBatch;
123
+ /**
124
+ * Build a MockUSDC mint call (testnet only).
125
+ */
126
+ function buildTestnetMintBatch(mockUsdcAddress, recipient, amount) {
127
+ const iface = new ethers_1.ethers.Interface([
128
+ 'function mint(address to, uint256 amount)',
129
+ ]);
130
+ const data = iface.encodeFunctionData('mint', [recipient, BigInt(amount)]);
131
+ return [
132
+ { target: mockUsdcAddress, value: 0n, data },
133
+ ];
134
+ }
135
+ exports.buildTestnetMintBatch = buildTestnetMintBatch;
136
+ /**
137
+ * Build a combined register + mint batch for testnet init.
138
+ *
139
+ * Single UserOp: register on AgentRegistry + mint test USDC.
140
+ * Both are bootstrap-allowed (gasless without prior registration).
141
+ */
142
+ function buildTestnetInitBatch(params) {
143
+ const registerCalls = buildRegisterAgentBatch(params.agentRegistryAddress, params.endpoint, params.serviceDescriptors);
144
+ const mintCalls = buildTestnetMintBatch(params.mockUsdcAddress, params.recipient, params.mintAmount);
145
+ return [...registerCalls, ...mintCalls];
146
+ }
147
+ exports.buildTestnetInitBatch = buildTestnetInitBatch;
148
+ //# sourceMappingURL=TransactionBatcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransactionBatcher.js","sourceRoot":"","sources":["../../../src/wallet/aa/TransactionBatcher.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAEH,mCAAgC;AAIhC,+EAA+E;AAC/E,4CAA4C;AAC5C,+EAA+E;AAE/E,MAAM,iBAAiB,GAAG;IACxB,mDAAmD;CACpD,CAAC;AAEF,MAAM,eAAe,GAAG;IACtB,gKAAgK;IAChK,0EAA0E;CAC3E,CAAC;AAsCF,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E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Wallet:
5
+ * - Encodes executeBatch(Call[]) as callData
6
+ * - Adds initCode for first-time wallet deployment
7
+ * - Signs with owner's private key (EIP-191 over UserOp hash)
8
+ *
9
+ * Uses ethers v6 for ABI encoding (no viem dependency yet — see Phase 2 note).
10
+ * viem+permissionless will be added if needed for paymaster integration.
11
+ *
12
+ * @module wallet/aa/UserOpBuilder
13
+ */
14
+ import { ethers } from 'ethers';
15
+ import { UserOperationV06, SmartWalletCall } from './constants';
16
+ /**
17
+ * Compute the counterfactual Smart Wallet address for a given signer.
18
+ *
19
+ * This address is deterministic (CREATE2) and can be computed off-chain
20
+ * without deploying the wallet.
21
+ */
22
+ export declare function computeSmartWalletAddress(signerAddress: string, provider: ethers.JsonRpcProvider, nonce?: bigint): Promise<string>;
23
+ /**
24
+ * Build initCode for first-time wallet deployment.
25
+ *
26
+ * initCode = factory address + createAccount calldata
27
+ * When the wallet already exists, pass '0x' as initCode.
28
+ */
29
+ export declare function buildInitCode(signerAddress: string, nonce?: bigint): string;
30
+ /**
31
+ * Encode executeBatch calldata from an array of calls.
32
+ */
33
+ export declare function encodeExecuteBatch(calls: SmartWalletCall[]): string;
34
+ /**
35
+ * Build a full UserOperation (unsigned).
36
+ *
37
+ * Gas limits and paymasterAndData must be filled by the caller
38
+ * (via BundlerClient.estimateGas and PaymasterClient.sponsor).
39
+ */
40
+ export declare function buildUserOp(params: {
41
+ sender: string;
42
+ nonce: bigint;
43
+ calls: SmartWalletCall[];
44
+ isFirstDeploy: boolean;
45
+ signerAddress: string;
46
+ }): UserOperationV06;
47
+ /**
48
+ * Compute the UserOperation hash for signing (v0.6).
49
+ *
50
+ * hash = keccak256(abi.encode(
51
+ * keccak256(pack(userOp)),
52
+ * entryPoint,
53
+ * chainId
54
+ * ))
55
+ */
56
+ export declare function getUserOpHash(userOp: UserOperationV06, chainId: number): string;
57
+ /**
58
+ * Sign a UserOperation with the owner's private key.
59
+ *
60
+ * CoinbaseSmartWallet expects the signature to be:
61
+ * abi.encode(SignatureWrapper(0, abi.encodePacked(r,s,v)))
62
+ *
63
+ * where ownerIndex=0 for single-owner wallets.
64
+ */
65
+ export declare function signUserOp(userOp: UserOperationV06, signer: ethers.Wallet, chainId: number): Promise<string>;
66
+ /**
67
+ * Serialize UserOp for JSON-RPC (bundler API).
68
+ * Converts bigints to hex strings.
69
+ */
70
+ export declare function serializeUserOp(userOp: UserOperationV06): Record<string, string>;
71
+ //# sourceMappingURL=UserOpBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserOpBuilder.d.ts","sourceRoot":"","sources":["../../../src/wallet/aa/UserOpBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EACL,gBAAgB,EAChB,eAAe,EAIhB,MAAM,aAAa,CAAC;AAiCrB;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,CAAC,eAAe,EAChC,KAAK,GAAE,MAA6B,GACnC,OAAO,CAAC,MAAM,CAAC,CAWjB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,aAAa,EAAE,MAAM,EACrB,KAAK,GAAE,MAA6B,GACnC,MAAM,CASR;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,MAAM,CASnE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;CACvB,GAAG,gBAAgB,CAoBnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,MAAM,GACd,MAAM,CAqCR;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EACrB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CAajB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAchF"}