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