@virtuals-protocol/acp-node 0.3.0-beta.18 → 0.3.0-beta.19

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/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ var require_package = __commonJS({
8
8
  "package.json"(exports, module) {
9
9
  module.exports = {
10
10
  name: "@virtuals-protocol/acp-node",
11
- version: "0.3.0-beta.18",
11
+ version: "0.3.0-beta.19",
12
12
  main: "./dist/index.js",
13
13
  module: "./dist/index.mjs",
14
14
  types: "./dist/index.d.ts",
@@ -3535,16 +3535,8 @@ var singleSignerValidationModuleAbi_default = SINGLE_SIGNER_VALIDATION_MODULE_AB
3535
3535
 
3536
3536
  // src/constants.ts
3537
3537
  import {
3538
- arbitrum as arbitrum2,
3539
- arbitrumSepolia as arbitrumSepolia2,
3540
3538
  base as base2,
3541
- baseSepolia as baseSepolia2,
3542
- bsc as bsc2,
3543
- bscTestnet as bscTestnet2,
3544
- mainnet as mainnet2,
3545
- polygon as polygon2,
3546
- polygonAmoy as polygonAmoy2,
3547
- sepolia as sepolia2
3539
+ baseSepolia as baseSepolia2
3548
3540
  } from "viem/chains";
3549
3541
  var USDC_TOKEN_ADDRESS = {
3550
3542
  [baseSepolia2.id]: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
@@ -3563,16 +3555,6 @@ var HTTP_STATUS_CODES = {
3563
3555
  PAYMENT_REQUIRED: 402
3564
3556
  };
3565
3557
  var SINGLE_SIGNER_VALIDATION_MODULE_ADDRESS = "0x00000000000099DE0BF6fA90dEB851E2A2df7d83";
3566
- var ASSET_MANAGER_ADDRESSES = {
3567
- [bscTestnet2.id]: "0xfCf52B02936623852dd5132007E9414f9060168b",
3568
- [bsc2.id]: "",
3569
- [polygonAmoy2.id]: "0xfCf52B02936623852dd5132007E9414f9060168b",
3570
- [polygon2.id]: "",
3571
- [arbitrum2.id]: "",
3572
- [arbitrumSepolia2.id]: "0xfCf52B02936623852dd5132007E9414f9060168b",
3573
- [sepolia2.id]: "0xfCf52B02936623852dd5132007E9414f9060168b",
3574
- [mainnet2.id]: ""
3575
- };
3576
3558
 
3577
3559
  // src/contractClients/baseAcpContractClient.ts
3578
3560
  var MemoType = /* @__PURE__ */ ((MemoType3) => {
@@ -3587,7 +3569,6 @@ var MemoType = /* @__PURE__ */ ((MemoType3) => {
3587
3569
  MemoType3[MemoType3["PAYABLE_TRANSFER_ESCROW"] = 8] = "PAYABLE_TRANSFER_ESCROW";
3588
3570
  MemoType3[MemoType3["NOTIFICATION"] = 9] = "NOTIFICATION";
3589
3571
  MemoType3[MemoType3["PAYABLE_NOTIFICATION"] = 10] = "PAYABLE_NOTIFICATION";
3590
- MemoType3[MemoType3["TRANSFER_EVENT"] = 11] = "TRANSFER_EVENT";
3591
3572
  return MemoType3;
3592
3573
  })(MemoType || {});
3593
3574
  var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases3) => {
@@ -3943,12 +3924,12 @@ var AcpMemoStatus = /* @__PURE__ */ ((AcpMemoStatus2) => {
3943
3924
  return AcpMemoStatus2;
3944
3925
  })(AcpMemoStatus || {});
3945
3926
  var AcpMemoState = /* @__PURE__ */ ((AcpMemoState2) => {
3946
- AcpMemoState2["NONE"] = "NONE";
3947
- AcpMemoState2["PENDING"] = "PENDING";
3948
- AcpMemoState2["IN_PROGRESS"] = "IN_PROGRESS";
3949
- AcpMemoState2["READY"] = "READY";
3950
- AcpMemoState2["COMPLETED"] = "COMPLETED";
3951
- AcpMemoState2["REJECTED"] = "REJECTED";
3927
+ AcpMemoState2[AcpMemoState2["NONE"] = 0] = "NONE";
3928
+ AcpMemoState2[AcpMemoState2["PENDING"] = 1] = "PENDING";
3929
+ AcpMemoState2[AcpMemoState2["IN_PROGRESS"] = 2] = "IN_PROGRESS";
3930
+ AcpMemoState2[AcpMemoState2["READY"] = 3] = "READY";
3931
+ AcpMemoState2[AcpMemoState2["COMPLETED"] = 4] = "COMPLETED";
3932
+ AcpMemoState2[AcpMemoState2["REJECTED"] = 5] = "REJECTED";
3952
3933
  return AcpMemoState2;
3953
3934
  })(AcpMemoState || {});
3954
3935
  var AcpAgentSort = /* @__PURE__ */ ((AcpAgentSort2) => {
@@ -4281,7 +4262,7 @@ var AcpJob = class {
4281
4262
  }
4282
4263
  async payAndAcceptRequirement(reason) {
4283
4264
  const memo = this.memos.find(
4284
- (m) => m.nextPhase === 2 /* TRANSACTION */
4265
+ (m) => m.nextPhase === 2 /* TRANSACTION */ || m.nextPhase === 4 /* COMPLETED */
4285
4266
  );
4286
4267
  if (!memo) {
4287
4268
  throw new acpError_default("No notification memo found");
@@ -4542,11 +4523,12 @@ var AcpJob = class {
4542
4523
  waitMs = Math.min(waitMs * 2, maxWaitMs);
4543
4524
  }
4544
4525
  }
4545
- async deliverCrossChainPayable(recipient, amount) {
4526
+ async deliverCrossChainPayable(recipient, amount, isRequest = false) {
4546
4527
  if (!amount.fare.chainId) {
4547
4528
  throw new acpError_default("Chain ID is required for cross chain payable");
4548
4529
  }
4549
4530
  const chainId = amount.fare.chainId;
4531
+ const assetManagerAddress = await this.acpContractClient.getAssetManager();
4550
4532
  const tokenBalance = await this.acpContractClient.getERC20Balance(
4551
4533
  chainId,
4552
4534
  amount.fare.contractAddress,
@@ -4559,12 +4541,12 @@ var AcpJob = class {
4559
4541
  chainId,
4560
4542
  amount.fare.contractAddress,
4561
4543
  this.acpContractClient.agentWalletAddress,
4562
- ASSET_MANAGER_ADDRESSES[chainId]
4544
+ assetManagerAddress
4563
4545
  );
4564
4546
  const approveAllowanceOperation = this.acpContractClient.approveAllowance(
4565
4547
  amount.amount + currentAllowance,
4566
4548
  amount.fare.contractAddress,
4567
- ASSET_MANAGER_ADDRESSES[chainId]
4549
+ assetManagerAddress
4568
4550
  );
4569
4551
  await this.acpContractClient.handleOperation(
4570
4552
  [approveAllowanceOperation],
@@ -4585,9 +4567,9 @@ var AcpJob = class {
4585
4567
  recipient,
4586
4568
  BigInt(0),
4587
4569
  0 /* NO_FEE */,
4588
- 7 /* PAYABLE_TRANSFER */,
4570
+ isRequest ? 6 /* PAYABLE_REQUEST */ : 7 /* PAYABLE_TRANSFER */,
4589
4571
  new Date(Date.now() + 1e3 * 60 * 5),
4590
- 4 /* COMPLETED */,
4572
+ isRequest ? 2 /* TRANSACTION */ : 4 /* COMPLETED */,
4591
4573
  getDestinationEndpointId(chainId)
4592
4574
  );
4593
4575
  await this.acpContractClient.handleOperation([createMemoOperation]);
@@ -5399,10 +5381,7 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5399
5381
  this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
5400
5382
  }
5401
5383
  static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
5402
- const acpContractClient = new _AcpContractClient(
5403
- agentWalletAddress,
5404
- config
5405
- );
5384
+ const acpContractClient = new _AcpContractClient(agentWalletAddress, config);
5406
5385
  await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
5407
5386
  return acpContractClient;
5408
5387
  }
@@ -5433,7 +5412,10 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5433
5412
  `ACP Contract Client validation failed: agent account ${this.agentWalletAddress} is not deployed on-chain`
5434
5413
  );
5435
5414
  }
5436
- await this.validateSessionKeyOnChain(sessionSignerAddress, sessionEntityKeyId);
5415
+ await this.validateSessionKeyOnChain(
5416
+ sessionSignerAddress,
5417
+ sessionEntityKeyId
5418
+ );
5437
5419
  console.log("Connected to ACP with v1 Contract Client (Legacy):", {
5438
5420
  agentWalletAddress: this.agentWalletAddress,
5439
5421
  whitelistedWalletAddress: sessionSignerAddress,
@@ -5503,7 +5485,9 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5503
5485
  throw new acpError_default(`Failed to send user operation`, finalError);
5504
5486
  }
5505
5487
  async getJobId(createJobUserOpHash, clientAddress, providerAddress) {
5506
- const result = await this.sessionKeyClient.getUserOperationReceipt(createJobUserOpHash);
5488
+ const result = await this.sessionKeyClient.getUserOperationReceipt(
5489
+ createJobUserOpHash
5490
+ );
5507
5491
  if (!result) {
5508
5492
  throw new acpError_default("Failed to get user operation receipt");
5509
5493
  }
@@ -5602,6 +5586,9 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5602
5586
  async performX402Request(url, version2, budget, signature) {
5603
5587
  return await this.acpX402.performRequest(url, version2, budget, signature);
5604
5588
  }
5589
+ async getAssetManager() {
5590
+ throw new Error("Asset Manager not supported");
5591
+ }
5605
5592
  getAcpVersion() {
5606
5593
  return "1";
5607
5594
  }
@@ -6319,188 +6306,1321 @@ var jobManagerAbi_default = JOB_MANAGER_ABI;
6319
6306
 
6320
6307
  // src/contractClients/acpContractClientV2.ts
6321
6308
  import { base as base4, baseSepolia as baseSepolia4 } from "viem/chains";
6322
- var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClient_default {
6323
- constructor(jobManagerAddress, memoManagerAddress, accountManagerAddress, agentWalletAddress, config = baseAcpConfigV2) {
6324
- super(agentWalletAddress, config);
6325
- this.jobManagerAddress = jobManagerAddress;
6326
- this.memoManagerAddress = memoManagerAddress;
6327
- this.accountManagerAddress = accountManagerAddress;
6328
- this.PRIORITY_FEE_MULTIPLIER = 2;
6329
- this.MAX_FEE_PER_GAS = 2e7;
6330
- this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
6331
- this.GAS_FEE_MULTIPLIER = 0.5;
6332
- this._sessionKeyClients = {};
6333
- }
6334
- static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfigV2) {
6335
- const publicClients = {};
6336
- for (const chain of config.chains) {
6337
- publicClients[chain.chain.id] = createPublicClient4({
6338
- chain: chain.chain,
6339
- transport: http3(chain.rpcUrl)
6340
- });
6341
- }
6342
- const publicClient = createPublicClient4({
6343
- chain: config.chain,
6344
- transport: http3(config.rpcEndpoint)
6345
- });
6346
- const [jobManagerAddress, memoManagerAddress, accountManagerAddress] = await publicClient.multicall({
6347
- contracts: [
6348
- {
6349
- address: config.contractAddress,
6350
- abi: config.abi,
6351
- functionName: "jobManager"
6352
- },
6353
- {
6354
- address: config.contractAddress,
6355
- abi: config.abi,
6356
- functionName: "memoManager"
6357
- },
6358
- {
6359
- address: config.contractAddress,
6360
- abi: config.abi,
6361
- functionName: "accountManager"
6362
- }
6363
- ]
6364
- });
6365
- if (!jobManagerAddress || !memoManagerAddress || !accountManagerAddress) {
6366
- throw new acpError_default(
6367
- "Failed to get job manager, memo manager, or account manager address"
6368
- );
6369
- }
6370
- const acpContractClient = new _AcpContractClientV2(
6371
- jobManagerAddress.result,
6372
- memoManagerAddress.result,
6373
- accountManagerAddress.result,
6374
- agentWalletAddress,
6375
- config
6376
- );
6377
- acpContractClient.publicClients = publicClients;
6378
- await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
6379
- return acpContractClient;
6380
- }
6381
- async init(privateKey, sessionEntityKeyId) {
6382
- const sessionKeySigner = LocalAccountSigner2.privateKeyToAccountSigner(privateKey);
6383
- this._sessionKeyClient = await createModularAccountV2Client2({
6384
- chain: this.chain,
6385
- transport: alchemy2({
6386
- rpcUrl: this.config.alchemyRpcUrl
6387
- }),
6388
- signer: sessionKeySigner,
6389
- policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
6390
- accountAddress: this.agentWalletAddress,
6391
- signerEntity: {
6392
- entityId: sessionEntityKeyId,
6393
- isGlobalValidation: true
6309
+
6310
+ // src/abis/memoManagerAbi.ts
6311
+ var MEMO_MANAGER_ABI = [
6312
+ { inputs: [], stateMutability: "nonpayable", type: "constructor" },
6313
+ { inputs: [], name: "AccessControlBadConfirmation", type: "error" },
6314
+ {
6315
+ inputs: [
6316
+ { internalType: "address", name: "account", type: "address" },
6317
+ { internalType: "bytes32", name: "neededRole", type: "bytes32" }
6318
+ ],
6319
+ name: "AccessControlUnauthorizedAccount",
6320
+ type: "error"
6321
+ },
6322
+ {
6323
+ inputs: [{ internalType: "address", name: "target", type: "address" }],
6324
+ name: "AddressEmptyCode",
6325
+ type: "error"
6326
+ },
6327
+ { inputs: [], name: "AlreadyVoted", type: "error" },
6328
+ { inputs: [], name: "CannotApproveMemo", type: "error" },
6329
+ { inputs: [], name: "CannotUpdateApprovedMemo", type: "error" },
6330
+ { inputs: [], name: "CannotUpdateMemo", type: "error" },
6331
+ { inputs: [], name: "CannotWithdrawYet", type: "error" },
6332
+ { inputs: [], name: "DestinationChainNotConfigured", type: "error" },
6333
+ {
6334
+ inputs: [
6335
+ { internalType: "address", name: "implementation", type: "address" }
6336
+ ],
6337
+ name: "ERC1967InvalidImplementation",
6338
+ type: "error"
6339
+ },
6340
+ { inputs: [], name: "ERC1967NonPayable", type: "error" },
6341
+ { inputs: [], name: "EmptyContent", type: "error" },
6342
+ { inputs: [], name: "FailedInnerCall", type: "error" },
6343
+ { inputs: [], name: "InvalidInitialization", type: "error" },
6344
+ { inputs: [], name: "InvalidMemoState", type: "error" },
6345
+ { inputs: [], name: "InvalidMemoStateTransition", type: "error" },
6346
+ { inputs: [], name: "InvalidMemoType", type: "error" },
6347
+ { inputs: [], name: "JobAlreadyCompleted", type: "error" },
6348
+ { inputs: [], name: "JobDoesNotExist", type: "error" },
6349
+ { inputs: [], name: "MemoAlreadyApproved", type: "error" },
6350
+ { inputs: [], name: "MemoAlreadyExecuted", type: "error" },
6351
+ { inputs: [], name: "MemoAlreadySigned", type: "error" },
6352
+ { inputs: [], name: "MemoCannotBeSigned", type: "error" },
6353
+ { inputs: [], name: "MemoDoesNotExist", type: "error" },
6354
+ { inputs: [], name: "MemoDoesNotRequireApproval", type: "error" },
6355
+ { inputs: [], name: "MemoExpired", type: "error" },
6356
+ { inputs: [], name: "MemoNotApproved", type: "error" },
6357
+ { inputs: [], name: "MemoNotReadyToBeSigned", type: "error" },
6358
+ { inputs: [], name: "MemoStateUnchanged", type: "error" },
6359
+ { inputs: [], name: "NoAmountToTransfer", type: "error" },
6360
+ { inputs: [], name: "NoPaymentAmount", type: "error" },
6361
+ { inputs: [], name: "NotEscrowTransferMemoType", type: "error" },
6362
+ { inputs: [], name: "NotInitializing", type: "error" },
6363
+ { inputs: [], name: "NotPayableMemoType", type: "error" },
6364
+ { inputs: [], name: "OnlyACPContract", type: "error" },
6365
+ { inputs: [], name: "OnlyAssetManager", type: "error" },
6366
+ { inputs: [], name: "OnlyClientOrProvider", type: "error" },
6367
+ { inputs: [], name: "OnlyCounterParty", type: "error" },
6368
+ { inputs: [], name: "OnlyEvaluator", type: "error" },
6369
+ { inputs: [], name: "OnlyMemoSender", type: "error" },
6370
+ { inputs: [], name: "ReentrancyGuardReentrantCall", type: "error" },
6371
+ { inputs: [], name: "UUPSUnauthorizedCallContext", type: "error" },
6372
+ {
6373
+ inputs: [{ internalType: "bytes32", name: "slot", type: "bytes32" }],
6374
+ name: "UUPSUnsupportedProxiableUUID",
6375
+ type: "error"
6376
+ },
6377
+ { inputs: [], name: "ZeroAcpContractAddress", type: "error" },
6378
+ { inputs: [], name: "ZeroAddressRecipient", type: "error" },
6379
+ { inputs: [], name: "ZeroAddressToken", type: "error" },
6380
+ { inputs: [], name: "ZeroAssetManagerAddress", type: "error" },
6381
+ { inputs: [], name: "ZeroJobManagerAddress", type: "error" },
6382
+ {
6383
+ anonymous: false,
6384
+ inputs: [
6385
+ {
6386
+ indexed: false,
6387
+ internalType: "uint64",
6388
+ name: "version",
6389
+ type: "uint64"
6394
6390
  }
6395
- });
6396
- for (const chain of this.config.chains) {
6397
- this._sessionKeyClients[chain.chain.id] = await createModularAccountV2Client2({
6398
- chain: chain.chain,
6399
- transport: alchemy2({
6400
- rpcUrl: `${this.config.alchemyRpcUrl}?chainId=${chain.chain.id}`
6401
- }),
6402
- signer: sessionKeySigner,
6403
- policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
6404
- accountAddress: this.agentWalletAddress,
6405
- signerEntity: {
6406
- entityId: sessionEntityKeyId,
6407
- isGlobalValidation: true
6408
- }
6409
- });
6410
- }
6411
- this._acpX402 = new AcpX402(
6412
- this.config,
6413
- this.sessionKeyClient,
6414
- this.publicClient
6415
- );
6416
- const account = this.sessionKeyClient.account;
6417
- const sessionSignerAddress = await account.getSigner().getAddress();
6418
- if (!await account.isAccountDeployed()) {
6419
- throw new acpError_default(
6420
- `ACP Contract Client validation failed: agent account ${this.agentWalletAddress} is not deployed on-chain`
6421
- );
6422
- }
6423
- await this.validateSessionKeyOnChain(
6424
- sessionSignerAddress,
6425
- sessionEntityKeyId
6426
- );
6427
- console.log("Connected to ACP:", {
6428
- agentWalletAddress: this.agentWalletAddress,
6429
- whitelistedWalletAddress: sessionSignerAddress,
6430
- entityId: sessionEntityKeyId
6431
- });
6432
- }
6433
- getRandomNonce(bits = 152) {
6434
- const bytes = bits / 8;
6435
- const array = new Uint8Array(bytes);
6436
- crypto.getRandomValues(array);
6437
- let hex = Array.from(array, (b) => b.toString(16).padStart(2, "0")).join(
6438
- ""
6439
- );
6440
- return BigInt("0x" + hex);
6441
- }
6442
- get sessionKeyClient() {
6443
- if (!this._sessionKeyClient) {
6444
- throw new acpError_default("Session key client not initialized");
6445
- }
6446
- return this._sessionKeyClient;
6447
- }
6448
- get acpX402() {
6449
- if (!this._acpX402) {
6450
- throw new acpError_default("ACP X402 not initialized");
6451
- }
6452
- return this._acpX402;
6453
- }
6454
- async calculateGasFees(chainId) {
6455
- if (chainId) {
6456
- const { maxFeePerGas } = await this.publicClients[chainId].estimateFeesPerGas();
6457
- const increasedMaxFeePerGas = BigInt(maxFeePerGas) + BigInt(maxFeePerGas) * BigInt(this.GAS_FEE_MULTIPLIER * 100) / BigInt(100);
6458
- return increasedMaxFeePerGas;
6459
- }
6460
- const finalMaxFeePerGas = BigInt(this.MAX_FEE_PER_GAS) + BigInt(this.MAX_PRIORITY_FEE_PER_GAS) * BigInt(Math.max(0, this.PRIORITY_FEE_MULTIPLIER - 1));
6461
- return finalMaxFeePerGas;
6462
- }
6463
- async handleOperation(operations, chainId) {
6464
- const sessionKeyClient = chainId ? this._sessionKeyClients[chainId] : this.sessionKeyClient;
6465
- if (!sessionKeyClient) {
6466
- throw new acpError_default("Session key client not initialized");
6467
- }
6468
- const payload = {
6469
- uo: operations.map((operation) => ({
6470
- target: operation.contractAddress,
6471
- data: operation.data,
6472
- value: operation.value
6473
- })),
6474
- overrides: {
6475
- nonceKey: this.getRandomNonce()
6391
+ ],
6392
+ name: "Initialized",
6393
+ type: "event"
6394
+ },
6395
+ {
6396
+ anonymous: false,
6397
+ inputs: [
6398
+ {
6399
+ indexed: true,
6400
+ internalType: "uint256",
6401
+ name: "memoId",
6402
+ type: "uint256"
6403
+ },
6404
+ {
6405
+ indexed: true,
6406
+ internalType: "address",
6407
+ name: "approver",
6408
+ type: "address"
6409
+ },
6410
+ { indexed: false, internalType: "bool", name: "approved", type: "bool" },
6411
+ {
6412
+ indexed: false,
6413
+ internalType: "string",
6414
+ name: "reason",
6415
+ type: "string"
6476
6416
  }
6477
- };
6478
- let retries = this.config.maxRetries;
6479
- let finalError;
6480
- while (retries > 0) {
6481
- try {
6482
- if (this.config.maxRetries > retries) {
6483
- const gasFees = await this.calculateGasFees();
6484
- payload["overrides"] = {
6485
- maxFeePerGas: `0x${gasFees.toString(16)}`
6486
- };
6487
- }
6488
- const { hash } = await sessionKeyClient.sendUserOperation(payload);
6489
- const checkTransactionConfig = {
6490
- hash,
6491
- retries: {
6492
- intervalMs: 200,
6493
- multiplier: 1.1,
6494
- maxRetries: 10
6495
- }
6496
- };
6497
- if (!chainId || chainId === baseSepolia4.id || chainId === base4.id) {
6498
- checkTransactionConfig["tag"] = "pending";
6499
- }
6500
- const txnHash = await sessionKeyClient.waitForUserOperationTransaction(
6501
- checkTransactionConfig
6502
- );
6503
- return { userOpHash: hash, txnHash };
6417
+ ],
6418
+ name: "MemoSigned",
6419
+ type: "event"
6420
+ },
6421
+ {
6422
+ anonymous: false,
6423
+ inputs: [
6424
+ {
6425
+ indexed: true,
6426
+ internalType: "uint256",
6427
+ name: "memoId",
6428
+ type: "uint256"
6429
+ },
6430
+ {
6431
+ indexed: false,
6432
+ internalType: "enum ACPTypes.MemoState",
6433
+ name: "oldState",
6434
+ type: "uint8"
6435
+ },
6436
+ {
6437
+ indexed: false,
6438
+ internalType: "enum ACPTypes.MemoState",
6439
+ name: "newState",
6440
+ type: "uint8"
6441
+ }
6442
+ ],
6443
+ name: "MemoStateUpdated",
6444
+ type: "event"
6445
+ },
6446
+ {
6447
+ anonymous: false,
6448
+ inputs: [
6449
+ {
6450
+ indexed: true,
6451
+ internalType: "uint256",
6452
+ name: "memoId",
6453
+ type: "uint256"
6454
+ },
6455
+ {
6456
+ indexed: true,
6457
+ internalType: "uint256",
6458
+ name: "jobId",
6459
+ type: "uint256"
6460
+ },
6461
+ {
6462
+ indexed: true,
6463
+ internalType: "address",
6464
+ name: "sender",
6465
+ type: "address"
6466
+ },
6467
+ {
6468
+ indexed: false,
6469
+ internalType: "enum ACPTypes.MemoType",
6470
+ name: "memoType",
6471
+ type: "uint8"
6472
+ },
6473
+ {
6474
+ indexed: false,
6475
+ internalType: "enum ACPTypes.JobPhase",
6476
+ name: "nextPhase",
6477
+ type: "uint8"
6478
+ },
6479
+ {
6480
+ indexed: false,
6481
+ internalType: "string",
6482
+ name: "content",
6483
+ type: "string"
6484
+ }
6485
+ ],
6486
+ name: "NewMemo",
6487
+ type: "event"
6488
+ },
6489
+ {
6490
+ anonymous: false,
6491
+ inputs: [
6492
+ {
6493
+ indexed: true,
6494
+ internalType: "uint256",
6495
+ name: "jobId",
6496
+ type: "uint256"
6497
+ },
6498
+ {
6499
+ indexed: true,
6500
+ internalType: "uint256",
6501
+ name: "memoId",
6502
+ type: "uint256"
6503
+ },
6504
+ {
6505
+ indexed: true,
6506
+ internalType: "address",
6507
+ name: "sender",
6508
+ type: "address"
6509
+ },
6510
+ {
6511
+ indexed: false,
6512
+ internalType: "address",
6513
+ name: "token",
6514
+ type: "address"
6515
+ },
6516
+ {
6517
+ indexed: false,
6518
+ internalType: "uint256",
6519
+ name: "amount",
6520
+ type: "uint256"
6521
+ }
6522
+ ],
6523
+ name: "PayableFeeRefunded",
6524
+ type: "event"
6525
+ },
6526
+ {
6527
+ anonymous: false,
6528
+ inputs: [
6529
+ {
6530
+ indexed: true,
6531
+ internalType: "uint256",
6532
+ name: "jobId",
6533
+ type: "uint256"
6534
+ },
6535
+ {
6536
+ indexed: true,
6537
+ internalType: "uint256",
6538
+ name: "memoId",
6539
+ type: "uint256"
6540
+ },
6541
+ {
6542
+ indexed: true,
6543
+ internalType: "address",
6544
+ name: "sender",
6545
+ type: "address"
6546
+ },
6547
+ {
6548
+ indexed: false,
6549
+ internalType: "address",
6550
+ name: "token",
6551
+ type: "address"
6552
+ },
6553
+ {
6554
+ indexed: false,
6555
+ internalType: "uint256",
6556
+ name: "amount",
6557
+ type: "uint256"
6558
+ }
6559
+ ],
6560
+ name: "PayableFundsRefunded",
6561
+ type: "event"
6562
+ },
6563
+ {
6564
+ anonymous: false,
6565
+ inputs: [
6566
+ {
6567
+ indexed: true,
6568
+ internalType: "uint256",
6569
+ name: "memoId",
6570
+ type: "uint256"
6571
+ },
6572
+ {
6573
+ indexed: true,
6574
+ internalType: "uint256",
6575
+ name: "jobId",
6576
+ type: "uint256"
6577
+ },
6578
+ {
6579
+ indexed: true,
6580
+ internalType: "address",
6581
+ name: "executor",
6582
+ type: "address"
6583
+ },
6584
+ {
6585
+ indexed: false,
6586
+ internalType: "uint256",
6587
+ name: "amount",
6588
+ type: "uint256"
6589
+ }
6590
+ ],
6591
+ name: "PayableMemoExecuted",
6592
+ type: "event"
6593
+ },
6594
+ {
6595
+ anonymous: false,
6596
+ inputs: [
6597
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
6598
+ {
6599
+ indexed: true,
6600
+ internalType: "bytes32",
6601
+ name: "previousAdminRole",
6602
+ type: "bytes32"
6603
+ },
6604
+ {
6605
+ indexed: true,
6606
+ internalType: "bytes32",
6607
+ name: "newAdminRole",
6608
+ type: "bytes32"
6609
+ }
6610
+ ],
6611
+ name: "RoleAdminChanged",
6612
+ type: "event"
6613
+ },
6614
+ {
6615
+ anonymous: false,
6616
+ inputs: [
6617
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
6618
+ {
6619
+ indexed: true,
6620
+ internalType: "address",
6621
+ name: "account",
6622
+ type: "address"
6623
+ },
6624
+ {
6625
+ indexed: true,
6626
+ internalType: "address",
6627
+ name: "sender",
6628
+ type: "address"
6629
+ }
6630
+ ],
6631
+ name: "RoleGranted",
6632
+ type: "event"
6633
+ },
6634
+ {
6635
+ anonymous: false,
6636
+ inputs: [
6637
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
6638
+ {
6639
+ indexed: true,
6640
+ internalType: "address",
6641
+ name: "account",
6642
+ type: "address"
6643
+ },
6644
+ {
6645
+ indexed: true,
6646
+ internalType: "address",
6647
+ name: "sender",
6648
+ type: "address"
6649
+ }
6650
+ ],
6651
+ name: "RoleRevoked",
6652
+ type: "event"
6653
+ },
6654
+ {
6655
+ anonymous: false,
6656
+ inputs: [
6657
+ {
6658
+ indexed: true,
6659
+ internalType: "address",
6660
+ name: "implementation",
6661
+ type: "address"
6662
+ }
6663
+ ],
6664
+ name: "Upgraded",
6665
+ type: "event"
6666
+ },
6667
+ {
6668
+ inputs: [],
6669
+ name: "ACP_CONTRACT_ROLE",
6670
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
6671
+ stateMutability: "view",
6672
+ type: "function"
6673
+ },
6674
+ {
6675
+ inputs: [],
6676
+ name: "ADMIN_ROLE",
6677
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
6678
+ stateMutability: "view",
6679
+ type: "function"
6680
+ },
6681
+ {
6682
+ inputs: [],
6683
+ name: "DEFAULT_ADMIN_ROLE",
6684
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
6685
+ stateMutability: "view",
6686
+ type: "function"
6687
+ },
6688
+ {
6689
+ inputs: [],
6690
+ name: "UPGRADE_INTERFACE_VERSION",
6691
+ outputs: [{ internalType: "string", name: "", type: "string" }],
6692
+ stateMutability: "view",
6693
+ type: "function"
6694
+ },
6695
+ {
6696
+ inputs: [],
6697
+ name: "acpContract",
6698
+ outputs: [{ internalType: "address", name: "", type: "address" }],
6699
+ stateMutability: "view",
6700
+ type: "function"
6701
+ },
6702
+ {
6703
+ inputs: [
6704
+ { internalType: "uint256", name: "memoId", type: "uint256" },
6705
+ { internalType: "address", name: "sender", type: "address" },
6706
+ { internalType: "bool", name: "approved", type: "bool" },
6707
+ { internalType: "string", name: "reason", type: "string" }
6708
+ ],
6709
+ name: "approveMemo",
6710
+ outputs: [],
6711
+ stateMutability: "nonpayable",
6712
+ type: "function"
6713
+ },
6714
+ {
6715
+ inputs: [],
6716
+ name: "assetManager",
6717
+ outputs: [{ internalType: "address", name: "", type: "address" }],
6718
+ stateMutability: "view",
6719
+ type: "function"
6720
+ },
6721
+ {
6722
+ inputs: [
6723
+ { internalType: "uint256[]", name: "memoIds", type: "uint256[]" },
6724
+ { internalType: "bool", name: "approved", type: "bool" },
6725
+ { internalType: "string", name: "reason", type: "string" }
6726
+ ],
6727
+ name: "bulkApproveMemos",
6728
+ outputs: [],
6729
+ stateMutability: "nonpayable",
6730
+ type: "function"
6731
+ },
6732
+ {
6733
+ inputs: [
6734
+ { internalType: "uint256", name: "memoId", type: "uint256" },
6735
+ { internalType: "address", name: "user", type: "address" }
6736
+ ],
6737
+ name: "canApproveMemo",
6738
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
6739
+ stateMutability: "view",
6740
+ type: "function"
6741
+ },
6742
+ {
6743
+ inputs: [
6744
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6745
+ { internalType: "address", name: "sender", type: "address" },
6746
+ { internalType: "string", name: "content", type: "string" },
6747
+ {
6748
+ internalType: "enum ACPTypes.MemoType",
6749
+ name: "memoType",
6750
+ type: "uint8"
6751
+ },
6752
+ { internalType: "bool", name: "isSecured", type: "bool" },
6753
+ {
6754
+ internalType: "enum ACPTypes.JobPhase",
6755
+ name: "nextPhase",
6756
+ type: "uint8"
6757
+ },
6758
+ { internalType: "string", name: "metadata", type: "string" }
6759
+ ],
6760
+ name: "createMemo",
6761
+ outputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6762
+ stateMutability: "nonpayable",
6763
+ type: "function"
6764
+ },
6765
+ {
6766
+ inputs: [
6767
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6768
+ { internalType: "address", name: "sender", type: "address" },
6769
+ { internalType: "string", name: "content", type: "string" },
6770
+ {
6771
+ internalType: "enum ACPTypes.MemoType",
6772
+ name: "memoType",
6773
+ type: "uint8"
6774
+ },
6775
+ { internalType: "bool", name: "isSecured", type: "bool" },
6776
+ {
6777
+ internalType: "enum ACPTypes.JobPhase",
6778
+ name: "nextPhase",
6779
+ type: "uint8"
6780
+ },
6781
+ {
6782
+ components: [
6783
+ { internalType: "address", name: "token", type: "address" },
6784
+ { internalType: "uint256", name: "amount", type: "uint256" },
6785
+ { internalType: "address", name: "recipient", type: "address" },
6786
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
6787
+ {
6788
+ internalType: "enum ACPTypes.FeeType",
6789
+ name: "feeType",
6790
+ type: "uint8"
6791
+ },
6792
+ { internalType: "bool", name: "isExecuted", type: "bool" },
6793
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
6794
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
6795
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
6796
+ ],
6797
+ internalType: "struct ACPTypes.PayableDetails",
6798
+ name: "payableDetails_",
6799
+ type: "tuple"
6800
+ },
6801
+ { internalType: "uint256", name: "expiredAt", type: "uint256" }
6802
+ ],
6803
+ name: "createPayableMemo",
6804
+ outputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6805
+ stateMutability: "nonpayable",
6806
+ type: "function"
6807
+ },
6808
+ {
6809
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6810
+ name: "emergencyApproveMemo",
6811
+ outputs: [],
6812
+ stateMutability: "nonpayable",
6813
+ type: "function"
6814
+ },
6815
+ {
6816
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6817
+ name: "executePayableMemo",
6818
+ outputs: [],
6819
+ stateMutability: "nonpayable",
6820
+ type: "function"
6821
+ },
6822
+ {
6823
+ inputs: [],
6824
+ name: "getAssetManager",
6825
+ outputs: [{ internalType: "address", name: "", type: "address" }],
6826
+ stateMutability: "view",
6827
+ type: "function"
6828
+ },
6829
+ {
6830
+ inputs: [
6831
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6832
+ { internalType: "uint256", name: "offset", type: "uint256" },
6833
+ { internalType: "uint256", name: "limit", type: "uint256" }
6834
+ ],
6835
+ name: "getJobMemos",
6836
+ outputs: [
6837
+ {
6838
+ components: [
6839
+ { internalType: "uint256", name: "id", type: "uint256" },
6840
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6841
+ { internalType: "address", name: "sender", type: "address" },
6842
+ { internalType: "string", name: "content", type: "string" },
6843
+ {
6844
+ internalType: "enum ACPTypes.MemoType",
6845
+ name: "memoType",
6846
+ type: "uint8"
6847
+ },
6848
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
6849
+ { internalType: "bool", name: "isApproved", type: "bool" },
6850
+ { internalType: "address", name: "approvedBy", type: "address" },
6851
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
6852
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
6853
+ { internalType: "string", name: "metadata", type: "string" },
6854
+ { internalType: "bool", name: "isSecured", type: "bool" },
6855
+ {
6856
+ internalType: "enum ACPTypes.JobPhase",
6857
+ name: "nextPhase",
6858
+ type: "uint8"
6859
+ },
6860
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
6861
+ {
6862
+ internalType: "enum ACPTypes.MemoState",
6863
+ name: "state",
6864
+ type: "uint8"
6865
+ }
6866
+ ],
6867
+ internalType: "struct ACPTypes.Memo[]",
6868
+ name: "memoArray",
6869
+ type: "tuple[]"
6870
+ },
6871
+ { internalType: "uint256", name: "total", type: "uint256" }
6872
+ ],
6873
+ stateMutability: "view",
6874
+ type: "function"
6875
+ },
6876
+ {
6877
+ inputs: [
6878
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6879
+ { internalType: "enum ACPTypes.JobPhase", name: "phase", type: "uint8" },
6880
+ { internalType: "uint256", name: "offset", type: "uint256" },
6881
+ { internalType: "uint256", name: "limit", type: "uint256" }
6882
+ ],
6883
+ name: "getJobMemosByPhase",
6884
+ outputs: [
6885
+ {
6886
+ components: [
6887
+ { internalType: "uint256", name: "id", type: "uint256" },
6888
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6889
+ { internalType: "address", name: "sender", type: "address" },
6890
+ { internalType: "string", name: "content", type: "string" },
6891
+ {
6892
+ internalType: "enum ACPTypes.MemoType",
6893
+ name: "memoType",
6894
+ type: "uint8"
6895
+ },
6896
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
6897
+ { internalType: "bool", name: "isApproved", type: "bool" },
6898
+ { internalType: "address", name: "approvedBy", type: "address" },
6899
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
6900
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
6901
+ { internalType: "string", name: "metadata", type: "string" },
6902
+ { internalType: "bool", name: "isSecured", type: "bool" },
6903
+ {
6904
+ internalType: "enum ACPTypes.JobPhase",
6905
+ name: "nextPhase",
6906
+ type: "uint8"
6907
+ },
6908
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
6909
+ {
6910
+ internalType: "enum ACPTypes.MemoState",
6911
+ name: "state",
6912
+ type: "uint8"
6913
+ }
6914
+ ],
6915
+ internalType: "struct ACPTypes.Memo[]",
6916
+ name: "memoArray",
6917
+ type: "tuple[]"
6918
+ },
6919
+ { internalType: "uint256", name: "total", type: "uint256" }
6920
+ ],
6921
+ stateMutability: "view",
6922
+ type: "function"
6923
+ },
6924
+ {
6925
+ inputs: [
6926
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6927
+ {
6928
+ internalType: "enum ACPTypes.MemoType",
6929
+ name: "memoType",
6930
+ type: "uint8"
6931
+ },
6932
+ { internalType: "uint256", name: "offset", type: "uint256" },
6933
+ { internalType: "uint256", name: "limit", type: "uint256" }
6934
+ ],
6935
+ name: "getJobMemosByType",
6936
+ outputs: [
6937
+ {
6938
+ components: [
6939
+ { internalType: "uint256", name: "id", type: "uint256" },
6940
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6941
+ { internalType: "address", name: "sender", type: "address" },
6942
+ { internalType: "string", name: "content", type: "string" },
6943
+ {
6944
+ internalType: "enum ACPTypes.MemoType",
6945
+ name: "memoType",
6946
+ type: "uint8"
6947
+ },
6948
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
6949
+ { internalType: "bool", name: "isApproved", type: "bool" },
6950
+ { internalType: "address", name: "approvedBy", type: "address" },
6951
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
6952
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
6953
+ { internalType: "string", name: "metadata", type: "string" },
6954
+ { internalType: "bool", name: "isSecured", type: "bool" },
6955
+ {
6956
+ internalType: "enum ACPTypes.JobPhase",
6957
+ name: "nextPhase",
6958
+ type: "uint8"
6959
+ },
6960
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
6961
+ {
6962
+ internalType: "enum ACPTypes.MemoState",
6963
+ name: "state",
6964
+ type: "uint8"
6965
+ }
6966
+ ],
6967
+ internalType: "struct ACPTypes.Memo[]",
6968
+ name: "memoArray",
6969
+ type: "tuple[]"
6970
+ },
6971
+ { internalType: "uint256", name: "total", type: "uint256" }
6972
+ ],
6973
+ stateMutability: "view",
6974
+ type: "function"
6975
+ },
6976
+ {
6977
+ inputs: [],
6978
+ name: "getLocalEid",
6979
+ outputs: [{ internalType: "uint32", name: "", type: "uint32" }],
6980
+ stateMutability: "view",
6981
+ type: "function"
6982
+ },
6983
+ {
6984
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6985
+ name: "getMemo",
6986
+ outputs: [
6987
+ {
6988
+ components: [
6989
+ { internalType: "uint256", name: "id", type: "uint256" },
6990
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6991
+ { internalType: "address", name: "sender", type: "address" },
6992
+ { internalType: "string", name: "content", type: "string" },
6993
+ {
6994
+ internalType: "enum ACPTypes.MemoType",
6995
+ name: "memoType",
6996
+ type: "uint8"
6997
+ },
6998
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
6999
+ { internalType: "bool", name: "isApproved", type: "bool" },
7000
+ { internalType: "address", name: "approvedBy", type: "address" },
7001
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
7002
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
7003
+ { internalType: "string", name: "metadata", type: "string" },
7004
+ { internalType: "bool", name: "isSecured", type: "bool" },
7005
+ {
7006
+ internalType: "enum ACPTypes.JobPhase",
7007
+ name: "nextPhase",
7008
+ type: "uint8"
7009
+ },
7010
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7011
+ {
7012
+ internalType: "enum ACPTypes.MemoState",
7013
+ name: "state",
7014
+ type: "uint8"
7015
+ }
7016
+ ],
7017
+ internalType: "struct ACPTypes.Memo",
7018
+ name: "",
7019
+ type: "tuple"
7020
+ }
7021
+ ],
7022
+ stateMutability: "view",
7023
+ type: "function"
7024
+ },
7025
+ {
7026
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7027
+ name: "getMemoApprovalStatus",
7028
+ outputs: [
7029
+ { internalType: "bool", name: "isApproved", type: "bool" },
7030
+ { internalType: "address", name: "approvedBy", type: "address" },
7031
+ { internalType: "uint256", name: "approvedAt", type: "uint256" }
7032
+ ],
7033
+ stateMutability: "view",
7034
+ type: "function"
7035
+ },
7036
+ {
7037
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7038
+ name: "getMemoWithPayableDetails",
7039
+ outputs: [
7040
+ {
7041
+ components: [
7042
+ { internalType: "uint256", name: "id", type: "uint256" },
7043
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7044
+ { internalType: "address", name: "sender", type: "address" },
7045
+ { internalType: "string", name: "content", type: "string" },
7046
+ {
7047
+ internalType: "enum ACPTypes.MemoType",
7048
+ name: "memoType",
7049
+ type: "uint8"
7050
+ },
7051
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
7052
+ { internalType: "bool", name: "isApproved", type: "bool" },
7053
+ { internalType: "address", name: "approvedBy", type: "address" },
7054
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
7055
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
7056
+ { internalType: "string", name: "metadata", type: "string" },
7057
+ { internalType: "bool", name: "isSecured", type: "bool" },
7058
+ {
7059
+ internalType: "enum ACPTypes.JobPhase",
7060
+ name: "nextPhase",
7061
+ type: "uint8"
7062
+ },
7063
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7064
+ {
7065
+ internalType: "enum ACPTypes.MemoState",
7066
+ name: "state",
7067
+ type: "uint8"
7068
+ }
7069
+ ],
7070
+ internalType: "struct ACPTypes.Memo",
7071
+ name: "memo",
7072
+ type: "tuple"
7073
+ },
7074
+ {
7075
+ components: [
7076
+ { internalType: "address", name: "token", type: "address" },
7077
+ { internalType: "uint256", name: "amount", type: "uint256" },
7078
+ { internalType: "address", name: "recipient", type: "address" },
7079
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
7080
+ {
7081
+ internalType: "enum ACPTypes.FeeType",
7082
+ name: "feeType",
7083
+ type: "uint8"
7084
+ },
7085
+ { internalType: "bool", name: "isExecuted", type: "bool" },
7086
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7087
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
7088
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
7089
+ ],
7090
+ internalType: "struct ACPTypes.PayableDetails",
7091
+ name: "details",
7092
+ type: "tuple"
7093
+ }
7094
+ ],
7095
+ stateMutability: "view",
7096
+ type: "function"
7097
+ },
7098
+ {
7099
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7100
+ name: "getPayableDetails",
7101
+ outputs: [
7102
+ {
7103
+ components: [
7104
+ { internalType: "address", name: "token", type: "address" },
7105
+ { internalType: "uint256", name: "amount", type: "uint256" },
7106
+ { internalType: "address", name: "recipient", type: "address" },
7107
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
7108
+ {
7109
+ internalType: "enum ACPTypes.FeeType",
7110
+ name: "feeType",
7111
+ type: "uint8"
7112
+ },
7113
+ { internalType: "bool", name: "isExecuted", type: "bool" },
7114
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7115
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
7116
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
7117
+ ],
7118
+ internalType: "struct ACPTypes.PayableDetails",
7119
+ name: "",
7120
+ type: "tuple"
7121
+ }
7122
+ ],
7123
+ stateMutability: "view",
7124
+ type: "function"
7125
+ },
7126
+ {
7127
+ inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }],
7128
+ name: "getRoleAdmin",
7129
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
7130
+ stateMutability: "view",
7131
+ type: "function"
7132
+ },
7133
+ {
7134
+ inputs: [
7135
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7136
+ { internalType: "address", name: "account", type: "address" }
7137
+ ],
7138
+ name: "grantRole",
7139
+ outputs: [],
7140
+ stateMutability: "nonpayable",
7141
+ type: "function"
7142
+ },
7143
+ {
7144
+ inputs: [
7145
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7146
+ { internalType: "address", name: "account", type: "address" }
7147
+ ],
7148
+ name: "hasRole",
7149
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7150
+ stateMutability: "view",
7151
+ type: "function"
7152
+ },
7153
+ {
7154
+ inputs: [
7155
+ { internalType: "address", name: "acpContract_", type: "address" },
7156
+ { internalType: "address", name: "jobManager_", type: "address" },
7157
+ { internalType: "address", name: "paymentManager_", type: "address" }
7158
+ ],
7159
+ name: "initialize",
7160
+ outputs: [],
7161
+ stateMutability: "nonpayable",
7162
+ type: "function"
7163
+ },
7164
+ {
7165
+ inputs: [
7166
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7167
+ { internalType: "address", name: "user", type: "address" }
7168
+ ],
7169
+ name: "isJobEvaluator",
7170
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7171
+ stateMutability: "view",
7172
+ type: "function"
7173
+ },
7174
+ {
7175
+ inputs: [
7176
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7177
+ { internalType: "address", name: "user", type: "address" }
7178
+ ],
7179
+ name: "isMemoSigner",
7180
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7181
+ stateMutability: "view",
7182
+ type: "function"
7183
+ },
7184
+ {
7185
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7186
+ name: "isPayable",
7187
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7188
+ stateMutability: "view",
7189
+ type: "function"
7190
+ },
7191
+ {
7192
+ inputs: [],
7193
+ name: "jobManager",
7194
+ outputs: [{ internalType: "address", name: "", type: "address" }],
7195
+ stateMutability: "view",
7196
+ type: "function"
7197
+ },
7198
+ {
7199
+ inputs: [
7200
+ { internalType: "uint256", name: "", type: "uint256" },
7201
+ { internalType: "uint256", name: "", type: "uint256" }
7202
+ ],
7203
+ name: "jobMemos",
7204
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7205
+ stateMutability: "view",
7206
+ type: "function"
7207
+ },
7208
+ {
7209
+ inputs: [
7210
+ { internalType: "uint256", name: "", type: "uint256" },
7211
+ { internalType: "enum ACPTypes.JobPhase", name: "", type: "uint8" },
7212
+ { internalType: "uint256", name: "", type: "uint256" }
7213
+ ],
7214
+ name: "jobMemosByPhase",
7215
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7216
+ stateMutability: "view",
7217
+ type: "function"
7218
+ },
7219
+ {
7220
+ inputs: [
7221
+ { internalType: "uint256", name: "", type: "uint256" },
7222
+ { internalType: "enum ACPTypes.MemoType", name: "", type: "uint8" },
7223
+ { internalType: "uint256", name: "", type: "uint256" }
7224
+ ],
7225
+ name: "jobMemosByType",
7226
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7227
+ stateMutability: "view",
7228
+ type: "function"
7229
+ },
7230
+ {
7231
+ inputs: [
7232
+ { internalType: "uint256", name: "", type: "uint256" },
7233
+ { internalType: "address", name: "", type: "address" }
7234
+ ],
7235
+ name: "memoApprovals",
7236
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7237
+ stateMutability: "view",
7238
+ type: "function"
7239
+ },
7240
+ {
7241
+ inputs: [],
7242
+ name: "memoCounter",
7243
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7244
+ stateMutability: "view",
7245
+ type: "function"
7246
+ },
7247
+ {
7248
+ inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7249
+ name: "memos",
7250
+ outputs: [
7251
+ { internalType: "uint256", name: "id", type: "uint256" },
7252
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7253
+ { internalType: "address", name: "sender", type: "address" },
7254
+ { internalType: "string", name: "content", type: "string" },
7255
+ {
7256
+ internalType: "enum ACPTypes.MemoType",
7257
+ name: "memoType",
7258
+ type: "uint8"
7259
+ },
7260
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
7261
+ { internalType: "bool", name: "isApproved", type: "bool" },
7262
+ { internalType: "address", name: "approvedBy", type: "address" },
7263
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
7264
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
7265
+ { internalType: "string", name: "metadata", type: "string" },
7266
+ { internalType: "bool", name: "isSecured", type: "bool" },
7267
+ {
7268
+ internalType: "enum ACPTypes.JobPhase",
7269
+ name: "nextPhase",
7270
+ type: "uint8"
7271
+ },
7272
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7273
+ { internalType: "enum ACPTypes.MemoState", name: "state", type: "uint8" }
7274
+ ],
7275
+ stateMutability: "view",
7276
+ type: "function"
7277
+ },
7278
+ {
7279
+ inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7280
+ name: "payableDetails",
7281
+ outputs: [
7282
+ { internalType: "address", name: "token", type: "address" },
7283
+ { internalType: "uint256", name: "amount", type: "uint256" },
7284
+ { internalType: "address", name: "recipient", type: "address" },
7285
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
7286
+ { internalType: "enum ACPTypes.FeeType", name: "feeType", type: "uint8" },
7287
+ { internalType: "bool", name: "isExecuted", type: "bool" },
7288
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7289
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
7290
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
7291
+ ],
7292
+ stateMutability: "view",
7293
+ type: "function"
7294
+ },
7295
+ {
7296
+ inputs: [],
7297
+ name: "paymentManager",
7298
+ outputs: [{ internalType: "address", name: "", type: "address" }],
7299
+ stateMutability: "view",
7300
+ type: "function"
7301
+ },
7302
+ {
7303
+ inputs: [],
7304
+ name: "proxiableUUID",
7305
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
7306
+ stateMutability: "view",
7307
+ type: "function"
7308
+ },
7309
+ {
7310
+ inputs: [
7311
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7312
+ { internalType: "address", name: "callerConfirmation", type: "address" }
7313
+ ],
7314
+ name: "renounceRole",
7315
+ outputs: [],
7316
+ stateMutability: "nonpayable",
7317
+ type: "function"
7318
+ },
7319
+ {
7320
+ inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7321
+ name: "requiredApprovals",
7322
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7323
+ stateMutability: "view",
7324
+ type: "function"
7325
+ },
7326
+ {
7327
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7328
+ name: "requiresApproval",
7329
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7330
+ stateMutability: "view",
7331
+ type: "function"
7332
+ },
7333
+ {
7334
+ inputs: [
7335
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7336
+ { internalType: "address", name: "account", type: "address" }
7337
+ ],
7338
+ name: "revokeRole",
7339
+ outputs: [],
7340
+ stateMutability: "nonpayable",
7341
+ type: "function"
7342
+ },
7343
+ {
7344
+ inputs: [
7345
+ {
7346
+ internalType: "enum ACPTypes.MemoType",
7347
+ name: "memoType",
7348
+ type: "uint8"
7349
+ },
7350
+ { internalType: "uint256", name: "requiredApprovals_", type: "uint256" }
7351
+ ],
7352
+ name: "setApprovalRequirements",
7353
+ outputs: [],
7354
+ stateMutability: "nonpayable",
7355
+ type: "function"
7356
+ },
7357
+ {
7358
+ inputs: [
7359
+ { internalType: "address", name: "assetManager_", type: "address" }
7360
+ ],
7361
+ name: "setAssetManager",
7362
+ outputs: [],
7363
+ stateMutability: "nonpayable",
7364
+ type: "function"
7365
+ },
7366
+ {
7367
+ inputs: [
7368
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7369
+ { internalType: "address", name: "sender", type: "address" },
7370
+ { internalType: "bool", name: "isApproved", type: "bool" },
7371
+ { internalType: "string", name: "reason", type: "string" }
7372
+ ],
7373
+ name: "signMemo",
7374
+ outputs: [{ internalType: "uint256", name: "jobId", type: "uint256" }],
7375
+ stateMutability: "nonpayable",
7376
+ type: "function"
7377
+ },
7378
+ {
7379
+ inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
7380
+ name: "supportsInterface",
7381
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7382
+ stateMutability: "view",
7383
+ type: "function"
7384
+ },
7385
+ {
7386
+ inputs: [
7387
+ { internalType: "address", name: "acpContract_", type: "address" },
7388
+ { internalType: "address", name: "jobManager_", type: "address" },
7389
+ { internalType: "address", name: "paymentManager_", type: "address" },
7390
+ { internalType: "address", name: "assetManager_", type: "address" }
7391
+ ],
7392
+ name: "updateContracts",
7393
+ outputs: [],
7394
+ stateMutability: "nonpayable",
7395
+ type: "function"
7396
+ },
7397
+ {
7398
+ inputs: [
7399
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7400
+ { internalType: "string", name: "newContent", type: "string" }
7401
+ ],
7402
+ name: "updateMemoContent",
7403
+ outputs: [],
7404
+ stateMutability: "nonpayable",
7405
+ type: "function"
7406
+ },
7407
+ {
7408
+ inputs: [
7409
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7410
+ {
7411
+ internalType: "enum ACPTypes.MemoState",
7412
+ name: "newMemoState",
7413
+ type: "uint8"
7414
+ }
7415
+ ],
7416
+ name: "updateMemoState",
7417
+ outputs: [],
7418
+ stateMutability: "nonpayable",
7419
+ type: "function"
7420
+ },
7421
+ {
7422
+ inputs: [
7423
+ { internalType: "address", name: "newImplementation", type: "address" },
7424
+ { internalType: "bytes", name: "data", type: "bytes" }
7425
+ ],
7426
+ name: "upgradeToAndCall",
7427
+ outputs: [],
7428
+ stateMutability: "payable",
7429
+ type: "function"
7430
+ },
7431
+ {
7432
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7433
+ name: "withdrawEscrowedFunds",
7434
+ outputs: [],
7435
+ stateMutability: "nonpayable",
7436
+ type: "function"
7437
+ }
7438
+ ];
7439
+ var memoManagerAbi_default = MEMO_MANAGER_ABI;
7440
+
7441
+ // src/contractClients/acpContractClientV2.ts
7442
+ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClient_default {
7443
+ constructor(jobManagerAddress, memoManagerAddress, accountManagerAddress, agentWalletAddress, config = baseAcpConfigV2) {
7444
+ super(agentWalletAddress, config);
7445
+ this.jobManagerAddress = jobManagerAddress;
7446
+ this.memoManagerAddress = memoManagerAddress;
7447
+ this.accountManagerAddress = accountManagerAddress;
7448
+ this.PRIORITY_FEE_MULTIPLIER = 2;
7449
+ this.MAX_FEE_PER_GAS = 2e7;
7450
+ this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
7451
+ this.GAS_FEE_MULTIPLIER = 0.5;
7452
+ this._sessionKeyClients = {};
7453
+ }
7454
+ static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfigV2) {
7455
+ const publicClients = {};
7456
+ for (const chain of config.chains) {
7457
+ publicClients[chain.chain.id] = createPublicClient4({
7458
+ chain: chain.chain,
7459
+ transport: http3(chain.rpcUrl)
7460
+ });
7461
+ }
7462
+ const publicClient = createPublicClient4({
7463
+ chain: config.chain,
7464
+ transport: http3(config.rpcEndpoint)
7465
+ });
7466
+ const [jobManagerAddress, memoManagerAddress, accountManagerAddress] = await publicClient.multicall({
7467
+ contracts: [
7468
+ {
7469
+ address: config.contractAddress,
7470
+ abi: config.abi,
7471
+ functionName: "jobManager"
7472
+ },
7473
+ {
7474
+ address: config.contractAddress,
7475
+ abi: config.abi,
7476
+ functionName: "memoManager"
7477
+ },
7478
+ {
7479
+ address: config.contractAddress,
7480
+ abi: config.abi,
7481
+ functionName: "accountManager"
7482
+ }
7483
+ ]
7484
+ });
7485
+ if (!jobManagerAddress || !memoManagerAddress || !accountManagerAddress) {
7486
+ throw new acpError_default(
7487
+ "Failed to get job manager, memo manager, or account manager address"
7488
+ );
7489
+ }
7490
+ const acpContractClient = new _AcpContractClientV2(
7491
+ jobManagerAddress.result,
7492
+ memoManagerAddress.result,
7493
+ accountManagerAddress.result,
7494
+ agentWalletAddress,
7495
+ config
7496
+ );
7497
+ acpContractClient.publicClients = publicClients;
7498
+ await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
7499
+ return acpContractClient;
7500
+ }
7501
+ async init(privateKey, sessionEntityKeyId) {
7502
+ const sessionKeySigner = LocalAccountSigner2.privateKeyToAccountSigner(privateKey);
7503
+ this._sessionKeyClient = await createModularAccountV2Client2({
7504
+ chain: this.chain,
7505
+ transport: alchemy2({
7506
+ rpcUrl: this.config.alchemyRpcUrl
7507
+ }),
7508
+ signer: sessionKeySigner,
7509
+ policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
7510
+ accountAddress: this.agentWalletAddress,
7511
+ signerEntity: {
7512
+ entityId: sessionEntityKeyId,
7513
+ isGlobalValidation: true
7514
+ }
7515
+ });
7516
+ for (const chain of this.config.chains) {
7517
+ this._sessionKeyClients[chain.chain.id] = await createModularAccountV2Client2({
7518
+ chain: chain.chain,
7519
+ transport: alchemy2({
7520
+ rpcUrl: `${this.config.alchemyRpcUrl}?chainId=${chain.chain.id}`
7521
+ }),
7522
+ signer: sessionKeySigner,
7523
+ policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
7524
+ accountAddress: this.agentWalletAddress,
7525
+ signerEntity: {
7526
+ entityId: sessionEntityKeyId,
7527
+ isGlobalValidation: true
7528
+ }
7529
+ });
7530
+ }
7531
+ this._acpX402 = new AcpX402(
7532
+ this.config,
7533
+ this.sessionKeyClient,
7534
+ this.publicClient
7535
+ );
7536
+ const account = this.sessionKeyClient.account;
7537
+ const sessionSignerAddress = await account.getSigner().getAddress();
7538
+ if (!await account.isAccountDeployed()) {
7539
+ throw new acpError_default(
7540
+ `ACP Contract Client validation failed: agent account ${this.agentWalletAddress} is not deployed on-chain`
7541
+ );
7542
+ }
7543
+ await this.validateSessionKeyOnChain(
7544
+ sessionSignerAddress,
7545
+ sessionEntityKeyId
7546
+ );
7547
+ console.log("Connected to ACP:", {
7548
+ agentWalletAddress: this.agentWalletAddress,
7549
+ whitelistedWalletAddress: sessionSignerAddress,
7550
+ entityId: sessionEntityKeyId
7551
+ });
7552
+ }
7553
+ getRandomNonce(bits = 152) {
7554
+ const bytes = bits / 8;
7555
+ const array = new Uint8Array(bytes);
7556
+ crypto.getRandomValues(array);
7557
+ let hex = Array.from(array, (b) => b.toString(16).padStart(2, "0")).join(
7558
+ ""
7559
+ );
7560
+ return BigInt("0x" + hex);
7561
+ }
7562
+ get sessionKeyClient() {
7563
+ if (!this._sessionKeyClient) {
7564
+ throw new acpError_default("Session key client not initialized");
7565
+ }
7566
+ return this._sessionKeyClient;
7567
+ }
7568
+ get acpX402() {
7569
+ if (!this._acpX402) {
7570
+ throw new acpError_default("ACP X402 not initialized");
7571
+ }
7572
+ return this._acpX402;
7573
+ }
7574
+ async calculateGasFees(chainId) {
7575
+ if (chainId) {
7576
+ const { maxFeePerGas } = await this.publicClients[chainId].estimateFeesPerGas();
7577
+ const increasedMaxFeePerGas = BigInt(maxFeePerGas) + BigInt(maxFeePerGas) * BigInt(this.GAS_FEE_MULTIPLIER * 100) / BigInt(100);
7578
+ return increasedMaxFeePerGas;
7579
+ }
7580
+ const finalMaxFeePerGas = BigInt(this.MAX_FEE_PER_GAS) + BigInt(this.MAX_PRIORITY_FEE_PER_GAS) * BigInt(Math.max(0, this.PRIORITY_FEE_MULTIPLIER - 1));
7581
+ return finalMaxFeePerGas;
7582
+ }
7583
+ async handleOperation(operations, chainId) {
7584
+ const sessionKeyClient = chainId ? this._sessionKeyClients[chainId] : this.sessionKeyClient;
7585
+ if (!sessionKeyClient) {
7586
+ throw new acpError_default("Session key client not initialized");
7587
+ }
7588
+ const payload = {
7589
+ uo: operations.map((operation) => ({
7590
+ target: operation.contractAddress,
7591
+ data: operation.data,
7592
+ value: operation.value
7593
+ })),
7594
+ overrides: {
7595
+ nonceKey: this.getRandomNonce()
7596
+ }
7597
+ };
7598
+ let retries = this.config.maxRetries;
7599
+ let finalError;
7600
+ while (retries > 0) {
7601
+ try {
7602
+ if (this.config.maxRetries > retries) {
7603
+ const gasFees = await this.calculateGasFees();
7604
+ payload["overrides"] = {
7605
+ maxFeePerGas: `0x${gasFees.toString(16)}`
7606
+ };
7607
+ }
7608
+ const { hash } = await sessionKeyClient.sendUserOperation(payload);
7609
+ const checkTransactionConfig = {
7610
+ hash,
7611
+ retries: {
7612
+ intervalMs: 200,
7613
+ multiplier: 1.1,
7614
+ maxRetries: 10
7615
+ }
7616
+ };
7617
+ if (!chainId || chainId === baseSepolia4.id || chainId === base4.id) {
7618
+ checkTransactionConfig["tag"] = "pending";
7619
+ }
7620
+ const txnHash = await sessionKeyClient.waitForUserOperationTransaction(
7621
+ checkTransactionConfig
7622
+ );
7623
+ return { userOpHash: hash, txnHash };
6504
7624
  } catch (error) {
6505
7625
  retries -= 1;
6506
7626
  if (retries === 0) {
@@ -6562,6 +7682,13 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6562
7682
  throw new acpError_default("Failed to get X402 payment details", error);
6563
7683
  }
6564
7684
  }
7685
+ async getAssetManager() {
7686
+ return await this.publicClient.readContract({
7687
+ address: this.memoManagerAddress,
7688
+ abi: memoManagerAbi_default,
7689
+ functionName: "assetManager"
7690
+ });
7691
+ }
6565
7692
  getAcpVersion() {
6566
7693
  return "2";
6567
7694
  }
@@ -6597,6 +7724,7 @@ export {
6597
7724
  baseAcpX402ConfigV2,
6598
7725
  baseSepoliaAcpConfig,
6599
7726
  baseSepoliaAcpConfigV2,
7727
+ baseSepoliaAcpX402ConfigV2,
6600
7728
  index_default as default,
6601
7729
  ethFare,
6602
7730
  preparePayload,