@virtuals-protocol/acp-node 0.3.0-beta.23 → 0.3.0-beta.25

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.23",
11
+ version: "0.3.0-beta.25",
12
12
  main: "./dist/index.js",
13
13
  module: "./dist/index.mjs",
14
14
  types: "./dist/index.d.ts",
@@ -41,6 +41,8 @@ var require_package = __commonJS({
41
41
  "@account-kit/smart-contracts": "^4.73.0",
42
42
  "@virtuals-protocol/acp-node": "^0.3.0-beta.10",
43
43
  ajv: "^8.17.1",
44
+ axios: "^1.13.2",
45
+ "jwt-decode": "^4.0.0",
44
46
  "socket.io-client": "^4.8.1",
45
47
  tsup: "^8.5.0",
46
48
  viem: "^2.28.2"
@@ -1225,6 +1227,7 @@ var acpAbi_default = ACP_ABI;
1225
1227
  // src/acpClient.ts
1226
1228
  import { zeroAddress as zeroAddress3 } from "viem";
1227
1229
  import { io } from "socket.io-client";
1230
+ import { jwtDecode } from "jwt-decode";
1228
1231
 
1229
1232
  // src/contractClients/baseAcpContractClient.ts
1230
1233
  import {
@@ -1239,10 +1242,7 @@ import {
1239
1242
  } from "viem";
1240
1243
 
1241
1244
  // src/configs/acpConfigs.ts
1242
- import {
1243
- baseSepolia,
1244
- base
1245
- } from "@account-kit/infra";
1245
+ import { baseSepolia, base } from "@account-kit/infra";
1246
1246
 
1247
1247
  // src/acpFare.ts
1248
1248
  import {
@@ -1270,42 +1270,27 @@ var acpError_default = AcpError;
1270
1270
 
1271
1271
  // src/acpFare.ts
1272
1272
  var Fare = class _Fare {
1273
- constructor(contractAddress, decimals, chainId) {
1273
+ constructor(contractAddress, decimals) {
1274
1274
  this.contractAddress = contractAddress;
1275
1275
  this.decimals = decimals;
1276
- this.chainId = chainId;
1277
1276
  }
1278
1277
  formatAmount(amount) {
1279
1278
  return parseUnits(amount.toString(), this.decimals);
1280
1279
  }
1281
- static async fromContractAddress(contractAddress, config = baseAcpConfig, chainId = config.chain.id) {
1280
+ static async fromContractAddress(contractAddress, config = baseAcpConfig) {
1282
1281
  if (contractAddress === config.baseFare.contractAddress) {
1283
1282
  return config.baseFare;
1284
1283
  }
1285
- let chainConfig = config.chain;
1286
- let rpcUrl = config.rpcEndpoint;
1287
- if (chainId !== config.chain.id) {
1288
- const selectedConfig = config.chains?.find(
1289
- (chain) => chain.chain.id === chainId
1290
- );
1291
- if (!selectedConfig) {
1292
- throw new acpError_default(
1293
- `Chain configuration for chainId ${chainId} not found.`
1294
- );
1295
- }
1296
- chainConfig = selectedConfig.chain;
1297
- rpcUrl = selectedConfig.rpcUrl;
1298
- }
1299
1284
  const publicClient = createPublicClient({
1300
- chain: chainConfig,
1301
- transport: http(rpcUrl)
1285
+ chain: config.chain,
1286
+ transport: http(config.rpcEndpoint)
1302
1287
  });
1303
1288
  const decimals = await publicClient.readContract({
1304
1289
  address: contractAddress,
1305
1290
  abi: erc20Abi,
1306
1291
  functionName: "decimals"
1307
1292
  });
1308
- return new _Fare(contractAddress, decimals, chainId);
1293
+ return new _Fare(contractAddress, decimals);
1309
1294
  }
1310
1295
  };
1311
1296
  var FareAmountBase = class {
@@ -1724,34 +1709,6 @@ var ACP_V2_ABI = [
1724
1709
  stateMutability: "nonpayable",
1725
1710
  type: "function"
1726
1711
  },
1727
- {
1728
- inputs: [
1729
- { internalType: "uint256", name: "jobId", type: "uint256" },
1730
- { internalType: "string", name: "content", type: "string" },
1731
- { internalType: "address", name: "token", type: "address" },
1732
- { internalType: "uint256", name: "amount", type: "uint256" },
1733
- { internalType: "address", name: "recipient", type: "address" },
1734
- { internalType: "uint256", name: "feeAmount", type: "uint256" },
1735
- { internalType: "enum ACPTypes.FeeType", name: "feeType", type: "uint8" },
1736
- {
1737
- internalType: "enum ACPTypes.MemoType",
1738
- name: "memoType",
1739
- type: "uint8"
1740
- },
1741
- { internalType: "uint256", name: "expiredAt", type: "uint256" },
1742
- { internalType: "bool", name: "isSecured", type: "bool" },
1743
- {
1744
- internalType: "enum ACPTypes.JobPhase",
1745
- name: "nextPhase",
1746
- type: "uint8"
1747
- },
1748
- { internalType: "uint32", name: "lzDstEid", type: "uint32" }
1749
- ],
1750
- name: "createCrossChainPayableMemo",
1751
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1752
- stateMutability: "nonpayable",
1753
- type: "function"
1754
- },
1755
1712
  {
1756
1713
  inputs: [
1757
1714
  { internalType: "address", name: "provider", type: "address" },
@@ -1936,12 +1893,7 @@ var ACP_V2_ABI = [
1936
1893
  name: "nextPhase",
1937
1894
  type: "uint8"
1938
1895
  },
1939
- { internalType: "uint256", name: "expiredAt", type: "uint256" },
1940
- {
1941
- internalType: "enum ACPTypes.MemoState",
1942
- name: "state",
1943
- type: "uint8"
1944
- }
1896
+ { internalType: "uint256", name: "expiredAt", type: "uint256" }
1945
1897
  ],
1946
1898
  internalType: "struct ACPTypes.Memo[]",
1947
1899
  name: "memos",
@@ -1988,12 +1940,7 @@ var ACP_V2_ABI = [
1988
1940
  name: "nextPhase",
1989
1941
  type: "uint8"
1990
1942
  },
1991
- { internalType: "uint256", name: "expiredAt", type: "uint256" },
1992
- {
1993
- internalType: "enum ACPTypes.MemoState",
1994
- name: "state",
1995
- type: "uint8"
1996
- }
1943
+ { internalType: "uint256", name: "expiredAt", type: "uint256" }
1997
1944
  ],
1998
1945
  internalType: "struct ACPTypes.Memo[]",
1999
1946
  name: "memos",
@@ -2036,12 +1983,7 @@ var ACP_V2_ABI = [
2036
1983
  name: "nextPhase",
2037
1984
  type: "uint8"
2038
1985
  },
2039
- { internalType: "uint256", name: "expiredAt", type: "uint256" },
2040
- {
2041
- internalType: "enum ACPTypes.MemoState",
2042
- name: "state",
2043
- type: "uint8"
2044
- }
1986
+ { internalType: "uint256", name: "expiredAt", type: "uint256" }
2045
1987
  ],
2046
1988
  internalType: "struct ACPTypes.Memo[]",
2047
1989
  name: "memos",
@@ -2297,7 +2239,7 @@ var acpAbiV2_default = ACP_V2_ABI;
2297
2239
  var V1_MAX_RETRIES = 10;
2298
2240
  var V2_MAX_RETRIES = 3;
2299
2241
  var AcpContractConfig2 = class {
2300
- constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config, retryConfig, chains = []) {
2242
+ constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config, retryConfig) {
2301
2243
  this.chain = chain;
2302
2244
  this.contractAddress = contractAddress;
2303
2245
  this.baseFare = baseFare;
@@ -2308,7 +2250,6 @@ var AcpContractConfig2 = class {
2308
2250
  this.rpcEndpoint = rpcEndpoint;
2309
2251
  this.x402Config = x402Config;
2310
2252
  this.retryConfig = retryConfig;
2311
- this.chains = chains;
2312
2253
  }
2313
2254
  };
2314
2255
  var baseSepoliaAcpConfig = new AcpContractConfig2(
@@ -3536,10 +3477,7 @@ var SINGLE_SIGNER_VALIDATION_MODULE_ABI = [
3536
3477
  var singleSignerValidationModuleAbi_default = SINGLE_SIGNER_VALIDATION_MODULE_ABI;
3537
3478
 
3538
3479
  // src/constants.ts
3539
- import {
3540
- base as base2,
3541
- baseSepolia as baseSepolia2
3542
- } from "viem/chains";
3480
+ import { base as base2, baseSepolia as baseSepolia2 } from "viem/chains";
3543
3481
  var USDC_TOKEN_ADDRESS = {
3544
3482
  [baseSepolia2.id]: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
3545
3483
  [base2.id]: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
@@ -3587,7 +3525,6 @@ var BaseAcpContractClient = class {
3587
3525
  constructor(agentWalletAddress, config = baseAcpConfig) {
3588
3526
  this.agentWalletAddress = agentWalletAddress;
3589
3527
  this.config = config;
3590
- this.publicClients = {};
3591
3528
  this.chain = config.chain;
3592
3529
  this.abi = config.abi;
3593
3530
  this.contractAddress = config.contractAddress;
@@ -3687,12 +3624,12 @@ ${JSON.stringify(
3687
3624
  throw new acpError_default("Failed to create job", error);
3688
3625
  }
3689
3626
  }
3690
- approveAllowance(amountBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress, targetAddress) {
3627
+ approveAllowance(amountBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress) {
3691
3628
  try {
3692
3629
  const data = encodeFunctionData({
3693
3630
  abi: erc20Abi2,
3694
3631
  functionName: "approve",
3695
- args: [targetAddress ?? this.contractAddress, amountBaseUnit]
3632
+ args: [this.contractAddress, amountBaseUnit]
3696
3633
  });
3697
3634
  const payload = {
3698
3635
  data,
@@ -3731,35 +3668,6 @@ ${JSON.stringify(
3731
3668
  throw new acpError_default("Failed to create payable memo", error);
3732
3669
  }
3733
3670
  }
3734
- createCrossChainPayableMemo(jobId, content, token, amountBaseUnit, recipient, feeAmountBaseUnit, feeType, type, expiredAt, nextPhase, destinationEid, secured = true) {
3735
- try {
3736
- const data = encodeFunctionData({
3737
- abi: this.abi,
3738
- functionName: "createCrossChainPayableMemo",
3739
- args: [
3740
- jobId,
3741
- content,
3742
- token,
3743
- amountBaseUnit,
3744
- recipient,
3745
- feeAmountBaseUnit,
3746
- feeType,
3747
- type,
3748
- expiredAt,
3749
- secured,
3750
- nextPhase,
3751
- destinationEid
3752
- ]
3753
- });
3754
- const payload = {
3755
- data,
3756
- contractAddress: this.contractAddress
3757
- };
3758
- return payload;
3759
- } catch (error) {
3760
- throw new acpError_default("Failed to create cross chain payable memo", error);
3761
- }
3762
- }
3763
3671
  createMemo(jobId, content, type, isSecured, nextPhase) {
3764
3672
  try {
3765
3673
  const data = encodeFunctionData({
@@ -3776,22 +3684,6 @@ ${JSON.stringify(
3776
3684
  throw new acpError_default("Failed to create memo", error);
3777
3685
  }
3778
3686
  }
3779
- createMemoWithMetadata(jobId, content, type, isSecured, nextPhase, metadata) {
3780
- try {
3781
- const data = encodeFunctionData({
3782
- abi: this.abi,
3783
- functionName: "createMemoWithMetadata",
3784
- args: [jobId, content, type, isSecured, nextPhase, metadata]
3785
- });
3786
- const payload = {
3787
- data,
3788
- contractAddress: this.contractAddress
3789
- };
3790
- return payload;
3791
- } catch (error) {
3792
- throw new acpError_default("Failed to create memo with metadata", error);
3793
- }
3794
- }
3795
3687
  signMemo(memoId, isApproved, reason) {
3796
3688
  try {
3797
3689
  const data = encodeFunctionData({
@@ -3877,47 +3769,9 @@ ${JSON.stringify(
3877
3769
  throw new acpError_default("Failed to submit TransferWithAuthorization", error);
3878
3770
  }
3879
3771
  }
3880
- async getERC20Balance(chainId, tokenAddress, walletAddress) {
3881
- const publicClient = this.publicClients[chainId];
3882
- if (!publicClient) {
3883
- throw new acpError_default(`Public client for chainId ${chainId} not found`);
3884
- }
3885
- return await publicClient.readContract({
3886
- address: tokenAddress,
3887
- abi: erc20Abi2,
3888
- functionName: "balanceOf",
3889
- args: [walletAddress]
3890
- });
3891
- }
3892
- async getERC20Allowance(chainId, tokenAddress, walletAddress, spenderAddress) {
3893
- const publicClient = this.publicClients[chainId];
3894
- if (!publicClient) {
3895
- throw new acpError_default(`Public client for chainId ${chainId} not found`);
3896
- }
3897
- return await publicClient.readContract({
3898
- address: tokenAddress,
3899
- abi: erc20Abi2,
3900
- functionName: "allowance",
3901
- args: [walletAddress, spenderAddress]
3902
- });
3903
- }
3904
- async getERC20Symbol(chainId, tokenAddress) {
3905
- const publicClient = this.publicClients[chainId];
3906
- if (!publicClient) {
3907
- throw new acpError_default(`Public client for chainId ${chainId} not found`);
3908
- }
3909
- return await publicClient.readContract({
3910
- address: tokenAddress,
3911
- abi: erc20Abi2,
3912
- functionName: "symbol"
3913
- });
3914
- }
3915
3772
  };
3916
3773
  var baseAcpContractClient_default = BaseAcpContractClient;
3917
3774
 
3918
- // src/acpJob.ts
3919
- import { formatUnits } from "viem";
3920
-
3921
3775
  // src/interfaces.ts
3922
3776
  var AcpMemoStatus = /* @__PURE__ */ ((AcpMemoStatus2) => {
3923
3777
  AcpMemoStatus2["PENDING"] = "PENDING";
@@ -3925,15 +3779,6 @@ var AcpMemoStatus = /* @__PURE__ */ ((AcpMemoStatus2) => {
3925
3779
  AcpMemoStatus2["REJECTED"] = "REJECTED";
3926
3780
  return AcpMemoStatus2;
3927
3781
  })(AcpMemoStatus || {});
3928
- var AcpMemoState = /* @__PURE__ */ ((AcpMemoState2) => {
3929
- AcpMemoState2[AcpMemoState2["NONE"] = 0] = "NONE";
3930
- AcpMemoState2[AcpMemoState2["PENDING"] = 1] = "PENDING";
3931
- AcpMemoState2[AcpMemoState2["IN_PROGRESS"] = 2] = "IN_PROGRESS";
3932
- AcpMemoState2[AcpMemoState2["READY"] = 3] = "READY";
3933
- AcpMemoState2[AcpMemoState2["COMPLETED"] = 4] = "COMPLETED";
3934
- AcpMemoState2[AcpMemoState2["REJECTED"] = 5] = "REJECTED";
3935
- return AcpMemoState2;
3936
- })(AcpMemoState || {});
3937
3782
  var AcpAgentSort = /* @__PURE__ */ ((AcpAgentSort2) => {
3938
3783
  AcpAgentSort2["SUCCESSFUL_JOB_COUNT"] = "successfulJobCount";
3939
3784
  AcpAgentSort2["SUCCESS_RATE"] = "successRate";
@@ -3953,38 +3798,8 @@ var AcpOnlineStatus = /* @__PURE__ */ ((AcpOnlineStatus2) => {
3953
3798
  AcpOnlineStatus2["OFFLINE"] = "offline";
3954
3799
  return AcpOnlineStatus2;
3955
3800
  })(AcpOnlineStatus || {});
3956
- var PayloadType = /* @__PURE__ */ ((PayloadType2) => {
3957
- PayloadType2["FUND_RESPONSE"] = "fund_response";
3958
- PayloadType2["OPEN_POSITION"] = "open_position";
3959
- PayloadType2["SWAP_TOKEN"] = "swap_token";
3960
- PayloadType2["RESPONSE_SWAP_TOKEN"] = "response_swap_token";
3961
- PayloadType2["CLOSE_PARTIAL_POSITION"] = "close_partial_position";
3962
- PayloadType2["CLOSE_POSITION"] = "close_position";
3963
- PayloadType2["POSITION_FULFILLED"] = "position_fulfilled";
3964
- PayloadType2["CLOSE_JOB_AND_WITHDRAW"] = "close_job_and_withdraw";
3965
- PayloadType2["UNFULFILLED_POSITION"] = "unfulfilled_position";
3966
- return PayloadType2;
3967
- })(PayloadType || {});
3968
- var PositionDirection = /* @__PURE__ */ ((PositionDirection2) => {
3969
- PositionDirection2["LONG"] = "long";
3970
- PositionDirection2["SHORT"] = "short";
3971
- return PositionDirection2;
3972
- })(PositionDirection || {});
3973
3801
 
3974
3802
  // src/utils.ts
3975
- import { decodeAbiParameters, encodeAbiParameters } from "viem";
3976
- import {
3977
- arbitrum as arbitrum3,
3978
- arbitrumSepolia as arbitrumSepolia3,
3979
- base as base3,
3980
- baseSepolia as baseSepolia3,
3981
- bsc as bsc3,
3982
- bscTestnet as bscTestnet3,
3983
- mainnet as mainnet3,
3984
- polygon as polygon3,
3985
- polygonAmoy as polygonAmoy3,
3986
- sepolia as sepolia3
3987
- } from "viem/chains";
3988
3803
  function tryParseJson(content) {
3989
3804
  try {
3990
3805
  return JSON.parse(content);
@@ -4001,31 +3816,6 @@ function safeBase64Encode(data) {
4001
3816
  }
4002
3817
  return Buffer.from(data).toString("base64");
4003
3818
  }
4004
- function getDestinationEndpointId(chainId) {
4005
- switch (chainId) {
4006
- case baseSepolia3.id:
4007
- return 40245;
4008
- case sepolia3.id:
4009
- return 40161;
4010
- case polygonAmoy3.id:
4011
- return 40267;
4012
- case arbitrumSepolia3.id:
4013
- return 40231;
4014
- case bscTestnet3.id:
4015
- return 40102;
4016
- case base3.id:
4017
- return 30184;
4018
- case mainnet3.id:
4019
- return 30101;
4020
- case polygon3.id:
4021
- return 30109;
4022
- case arbitrum3.id:
4023
- return 30110;
4024
- case bsc3.id:
4025
- return 30102;
4026
- }
4027
- throw new Error(`Unsupported chain ID: ${chainId}`);
4028
- }
4029
3819
 
4030
3820
  // src/acpJobOffering.ts
4031
3821
  import { zeroAddress as zeroAddress2 } from "viem";
@@ -4042,6 +3832,11 @@ var AcpJobOffering = class {
4042
3832
  this.ajv = new Ajv({ allErrors: true });
4043
3833
  }
4044
3834
  async initiateJob(serviceRequirement, evaluatorAddress, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
3835
+ if (this.providerAddress === this.acpClient.walletAddress) {
3836
+ throw new acpError_default(
3837
+ "Provider address cannot be the same as the client address"
3838
+ );
3839
+ }
4045
3840
  if (this.requirement && typeof this.requirement === "object") {
4046
3841
  const validator = this.ajv.compile(this.requirement);
4047
3842
  const valid = validator(serviceRequirement);
@@ -4228,43 +4023,25 @@ var AcpJob = class {
4228
4023
  }
4229
4024
  const feeAmount = new FareAmount(0, this.acpContractClient.config.baseFare);
4230
4025
  const isPercentagePricing = this.priceType === "percentage" /* PERCENTAGE */;
4231
- if (amount.fare.chainId && amount.fare.chainId !== this.acpContractClient.config.chain.id) {
4232
- operations.push(
4233
- this.acpContractClient.createCrossChainPayableMemo(
4234
- this.id,
4235
- content,
4236
- amount.fare.contractAddress,
4237
- amount.amount,
4238
- recipient,
4239
- isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
4240
- isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
4241
- type,
4242
- expiredAt,
4243
- 2 /* TRANSACTION */,
4244
- getDestinationEndpointId(amount.fare.chainId)
4245
- )
4246
- );
4247
- } else {
4248
- operations.push(
4249
- this.acpContractClient.createPayableMemo(
4250
- this.id,
4251
- content,
4252
- amount.amount,
4253
- recipient,
4254
- isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
4255
- isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
4256
- 2 /* TRANSACTION */,
4257
- type,
4258
- expiredAt,
4259
- amount.fare.contractAddress
4260
- )
4261
- );
4262
- }
4026
+ operations.push(
4027
+ this.acpContractClient.createPayableMemo(
4028
+ this.id,
4029
+ content,
4030
+ amount.amount,
4031
+ recipient,
4032
+ isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
4033
+ isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
4034
+ 2 /* TRANSACTION */,
4035
+ type,
4036
+ expiredAt,
4037
+ amount.fare.contractAddress
4038
+ )
4039
+ );
4263
4040
  return await this.acpContractClient.handleOperation(operations);
4264
4041
  }
4265
4042
  async payAndAcceptRequirement(reason) {
4266
4043
  const memo = this.memos.find(
4267
- (m) => m.nextPhase === 2 /* TRANSACTION */ || m.nextPhase === 4 /* COMPLETED */
4044
+ (m) => m.nextPhase === 2 /* TRANSACTION */
4268
4045
  );
4269
4046
  if (!memo) {
4270
4047
  throw new acpError_default("No notification memo found");
@@ -4373,8 +4150,8 @@ var AcpJob = class {
4373
4150
  return await this.acpContractClient.handleOperation(operations);
4374
4151
  }
4375
4152
  async deliver(deliverable) {
4376
- if (this.latestMemo?.nextPhase !== 3 /* EVALUATION */) {
4377
- throw new acpError_default("No transaction memo found");
4153
+ if (this.phase !== 2 /* TRANSACTION */) {
4154
+ throw new acpError_default("Job is not in transaction phase");
4378
4155
  }
4379
4156
  const operations = [];
4380
4157
  operations.push(
@@ -4392,9 +4169,6 @@ var AcpJob = class {
4392
4169
  if (this.latestMemo?.nextPhase !== 3 /* EVALUATION */) {
4393
4170
  throw new acpError_default("No transaction memo found");
4394
4171
  }
4395
- if (amount.fare.chainId !== this.acpContractClient.config.chain.id) {
4396
- return await this.deliverCrossChainPayable(this.clientAddress, amount);
4397
- }
4398
4172
  const operations = [];
4399
4173
  operations.push(
4400
4174
  this.acpContractClient.approveAllowance(
@@ -4407,6 +4181,7 @@ var AcpJob = class {
4407
4181
  operations.push(
4408
4182
  this.acpContractClient.createPayableMemo(
4409
4183
  this.id,
4184
+ // memoContent.url,
4410
4185
  preparePayload(deliverable),
4411
4186
  amount.amount,
4412
4187
  this.clientAddress,
@@ -4525,57 +4300,6 @@ var AcpJob = class {
4525
4300
  waitMs = Math.min(waitMs * 2, maxWaitMs);
4526
4301
  }
4527
4302
  }
4528
- async deliverCrossChainPayable(recipient, amount, isRequest = false) {
4529
- if (!amount.fare.chainId) {
4530
- throw new acpError_default("Chain ID is required for cross chain payable");
4531
- }
4532
- const chainId = amount.fare.chainId;
4533
- const assetManagerAddress = await this.acpContractClient.getAssetManager();
4534
- const tokenBalance = await this.acpContractClient.getERC20Balance(
4535
- chainId,
4536
- amount.fare.contractAddress,
4537
- this.acpContractClient.agentWalletAddress
4538
- );
4539
- if (tokenBalance < amount.amount) {
4540
- throw new acpError_default("Insufficient token balance for cross chain payable");
4541
- }
4542
- const currentAllowance = await this.acpContractClient.getERC20Allowance(
4543
- chainId,
4544
- amount.fare.contractAddress,
4545
- this.acpContractClient.agentWalletAddress,
4546
- assetManagerAddress
4547
- );
4548
- const approveAllowanceOperation = this.acpContractClient.approveAllowance(
4549
- amount.amount + currentAllowance,
4550
- amount.fare.contractAddress,
4551
- assetManagerAddress
4552
- );
4553
- await this.acpContractClient.handleOperation(
4554
- [approveAllowanceOperation],
4555
- chainId
4556
- );
4557
- const tokenSymbol = await this.acpContractClient.getERC20Symbol(
4558
- chainId,
4559
- amount.fare.contractAddress
4560
- );
4561
- const createMemoOperation = this.acpContractClient.createCrossChainPayableMemo(
4562
- this.id,
4563
- `Performing cross chain payable transfer of ${formatUnits(
4564
- amount.amount,
4565
- amount.fare.decimals
4566
- )} ${tokenSymbol} to ${recipient}`,
4567
- amount.fare.contractAddress,
4568
- amount.amount,
4569
- recipient,
4570
- BigInt(0),
4571
- 0 /* NO_FEE */,
4572
- isRequest ? 6 /* PAYABLE_REQUEST */ : 7 /* PAYABLE_TRANSFER */,
4573
- new Date(Date.now() + 1e3 * 60 * 5),
4574
- isRequest ? 2 /* TRANSACTION */ : 4 /* COMPLETED */,
4575
- getDestinationEndpointId(chainId)
4576
- );
4577
- await this.acpContractClient.handleOperation([createMemoOperation]);
4578
- }
4579
4303
  [util.inspect.custom]() {
4580
4304
  return {
4581
4305
  id: this.id,
@@ -4599,7 +4323,7 @@ var acpJob_default = AcpJob;
4599
4323
  // src/acpMemo.ts
4600
4324
  import util2 from "util";
4601
4325
  var AcpMemo = class {
4602
- constructor(contractClient, id, type, content, nextPhase, status, senderAddress, signedReason, expiry, payableDetails, txHash, signedTxHash, state) {
4326
+ constructor(contractClient, id, type, content, nextPhase, status, senderAddress, signedReason, expiry, payableDetails, txHash, signedTxHash) {
4603
4327
  this.contractClient = contractClient;
4604
4328
  this.id = id;
4605
4329
  this.type = type;
@@ -4612,21 +4336,13 @@ var AcpMemo = class {
4612
4336
  this.payableDetails = payableDetails;
4613
4337
  this.txHash = txHash;
4614
4338
  this.signedTxHash = signedTxHash;
4615
- this.state = state;
4616
4339
  if (this.payableDetails) {
4617
4340
  this.payableDetails.amount = BigInt(this.payableDetails.amount);
4618
4341
  this.payableDetails.feeAmount = BigInt(this.payableDetails.feeAmount);
4619
4342
  }
4620
- this.structuredContent = tryParseJson(this.content) || void 0;
4621
- }
4622
- get payloadType() {
4623
- return this.structuredContent?.type;
4624
- }
4625
- getStructuredContent() {
4626
- return this.structuredContent;
4627
4343
  }
4628
4344
  async create(jobId, isSecured = true) {
4629
- return await this.contractClient.createMemo(
4345
+ return this.contractClient.createMemo(
4630
4346
  jobId,
4631
4347
  this.content,
4632
4348
  this.type,
@@ -4674,10 +4390,31 @@ var AcpAccount = class {
4674
4390
  }
4675
4391
  };
4676
4392
 
4393
+ // src/acpClient.ts
4394
+ import axios, { AxiosError } from "axios";
4395
+
4396
+ // src/acpAgent.ts
4397
+ var AcpAgent = class {
4398
+ constructor(args) {
4399
+ this.id = String(args.id);
4400
+ this.name = args.name;
4401
+ this.contractAddress = args.contractAddress;
4402
+ this.walletAddress = args.walletAddress;
4403
+ this.jobOfferings = Object.freeze([...args.jobOfferings]);
4404
+ this.description = args.description;
4405
+ this.twitterHandle = args.twitterHandle;
4406
+ this.metrics = args.metrics;
4407
+ this.resources = args.resources;
4408
+ }
4409
+ };
4410
+ var acpAgent_default = AcpAgent;
4411
+
4677
4412
  // src/acpClient.ts
4678
4413
  var { version } = require_package();
4679
4414
  var AcpClient = class {
4680
4415
  constructor(options) {
4416
+ this.accessToken = null;
4417
+ this.accessTokenInflight = null;
4681
4418
  this.contractClients = Array.isArray(options.acpContractClient) ? options.acpContractClient : [options.acpContractClient];
4682
4419
  if (this.contractClients.length === 0) {
4683
4420
  throw new acpError_default("ACP contract client is required");
@@ -4689,10 +4426,86 @@ var AcpClient = class {
4689
4426
  );
4690
4427
  }
4691
4428
  });
4429
+ this.acpClient = axios.create({
4430
+ baseURL: `${this.acpUrl}/api`,
4431
+ headers: {
4432
+ "wallet-address": this.walletAddress
4433
+ }
4434
+ });
4435
+ this.noAuthAcpClient = this.acpClient.create({
4436
+ baseURL: `${this.acpUrl}/api`
4437
+ });
4438
+ this.acpClient.interceptors.request.use(async (config) => {
4439
+ const accessToken = await this.getAccessToken();
4440
+ config.headers["authorization"] = `Bearer ${accessToken}`;
4441
+ return config;
4442
+ });
4692
4443
  this.onNewTask = options.onNewTask;
4693
4444
  this.onEvaluate = options.onEvaluate || this.defaultOnEvaluate;
4694
4445
  this.init(options.skipSocketConnection);
4695
4446
  }
4447
+ async getAccessToken() {
4448
+ if (this.accessTokenInflight) {
4449
+ return await this.accessTokenInflight;
4450
+ }
4451
+ let refreshToken = this.accessToken ? false : true;
4452
+ if (this.accessToken) {
4453
+ const decodedToken = jwtDecode(this.accessToken);
4454
+ if (decodedToken.exp && decodedToken.exp - 60 * 5 < Math.floor(Date.now() / 1e3)) {
4455
+ refreshToken = true;
4456
+ }
4457
+ }
4458
+ if (!refreshToken) {
4459
+ return this.accessToken;
4460
+ }
4461
+ this.accessTokenInflight = (async () => {
4462
+ this.accessToken = await this.refreshToken();
4463
+ return this.accessToken;
4464
+ })().finally(() => {
4465
+ this.accessTokenInflight = null;
4466
+ });
4467
+ return await this.accessTokenInflight;
4468
+ }
4469
+ async refreshToken() {
4470
+ const challenge = await this.getAuthChallenge();
4471
+ const signature = await this.acpContractClient.signTypedData(challenge);
4472
+ const verified = await this.verifyAuthChallenge(
4473
+ challenge.message["walletAddress"],
4474
+ challenge.message["nonce"],
4475
+ challenge.message["expiresAt"],
4476
+ signature
4477
+ );
4478
+ return verified.accessToken;
4479
+ }
4480
+ async getAuthChallenge() {
4481
+ try {
4482
+ const response = await this.noAuthAcpClient.get("/auth/challenge", {
4483
+ params: {
4484
+ walletAddress: this.walletAddress
4485
+ }
4486
+ });
4487
+ return response.data.data;
4488
+ } catch (err) {
4489
+ console.error(
4490
+ "Failed to get auth challenge",
4491
+ err.response?.data
4492
+ );
4493
+ throw new acpError_default("Failed to get auth challenge", err);
4494
+ }
4495
+ }
4496
+ async verifyAuthChallenge(walletAddress, nonce, expiresAt, signature) {
4497
+ try {
4498
+ const response = await this.noAuthAcpClient.post("/auth/verify-typed-signature", {
4499
+ walletAddress,
4500
+ nonce,
4501
+ expiresAt,
4502
+ signature
4503
+ });
4504
+ return response.data.data;
4505
+ } catch (err) {
4506
+ throw new acpError_default("Failed to verify auth challenge", err);
4507
+ }
4508
+ }
4696
4509
  contractClientByAddress(address) {
4697
4510
  if (!address) {
4698
4511
  return this.contractClients[0];
@@ -4721,9 +4534,13 @@ var AcpClient = class {
4721
4534
  if (skipSocketConnection) {
4722
4535
  return;
4723
4536
  }
4537
+ console.log("Initializing socket");
4724
4538
  const socket = io(this.acpUrl, {
4725
- auth: {
4726
- walletAddress: this.walletAddress
4539
+ auth: async (cb) => {
4540
+ cb({
4541
+ walletAddress: this.walletAddress,
4542
+ accessToken: await this.getAccessToken()
4543
+ });
4727
4544
  },
4728
4545
  extraHeaders: {
4729
4546
  "x-sdk-version": version,
@@ -4737,87 +4554,23 @@ var AcpClient = class {
4737
4554
  console.log("Joined ACP Room");
4738
4555
  callback(true);
4739
4556
  });
4740
- socket.on(
4741
- "onEvaluate" /* ON_EVALUATE */,
4742
- async (data, callback) => {
4743
- callback(true);
4744
- if (this.onEvaluate) {
4745
- const job = new acpJob_default(
4746
- this,
4747
- data.id,
4748
- data.clientAddress,
4749
- data.providerAddress,
4750
- data.evaluatorAddress,
4751
- data.price,
4752
- data.priceTokenAddress,
4753
- data.memos.map((memo) => {
4754
- return new acpMemo_default(
4755
- this.contractClientByAddress(data.contractAddress),
4756
- memo.id,
4757
- memo.memoType,
4758
- memo.content,
4759
- memo.nextPhase,
4760
- memo.status,
4761
- memo.senderAddress,
4762
- memo.signedReason,
4763
- memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
4764
- memo.payableDetails,
4765
- memo.txHash,
4766
- memo.signedTxHash,
4767
- memo.state
4768
- );
4769
- }),
4770
- data.phase,
4771
- data.context,
4772
- data.contractAddress,
4773
- data.netPayableAmount
4774
- );
4775
- this.onEvaluate(job);
4776
- }
4557
+ socket.on("onEvaluate" /* ON_EVALUATE */, async (data, callback) => {
4558
+ callback(true);
4559
+ if (this.onEvaluate) {
4560
+ const job = this._hydrateJob(data);
4561
+ this.onEvaluate(job);
4777
4562
  }
4778
- );
4779
- socket.on(
4780
- "onNewTask" /* ON_NEW_TASK */,
4781
- async (data, callback) => {
4782
- callback(true);
4783
- if (this.onNewTask) {
4784
- const job = new acpJob_default(
4785
- this,
4786
- data.id,
4787
- data.clientAddress,
4788
- data.providerAddress,
4789
- data.evaluatorAddress,
4790
- data.price,
4791
- data.priceTokenAddress,
4792
- data.memos.map((memo) => {
4793
- return new acpMemo_default(
4794
- this.contractClientByAddress(data.contractAddress),
4795
- memo.id,
4796
- memo.memoType,
4797
- memo.content,
4798
- memo.nextPhase,
4799
- memo.status,
4800
- memo.senderAddress,
4801
- memo.signedReason,
4802
- memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
4803
- memo.payableDetails,
4804
- memo.txHash,
4805
- memo.signedTxHash,
4806
- memo.state
4807
- );
4808
- }),
4809
- data.phase,
4810
- data.context,
4811
- data.contractAddress,
4812
- data.netPayableAmount
4813
- );
4814
- this.onNewTask(
4815
- job,
4816
- job.memos.find((m) => m.id == data.memoToSign)
4817
- );
4818
- }
4563
+ });
4564
+ socket.on("onNewTask" /* ON_NEW_TASK */, async (data, callback) => {
4565
+ callback(true);
4566
+ if (this.onNewTask) {
4567
+ const job = this._hydrateJob(data);
4568
+ this.onNewTask(
4569
+ job,
4570
+ job.memos.find((m) => m.id == data.memoToSign)
4571
+ );
4819
4572
  }
4820
- );
4573
+ });
4821
4574
  const cleanup = async () => {
4822
4575
  if (socket) {
4823
4576
  socket.disconnect();
@@ -4827,77 +4580,156 @@ var AcpClient = class {
4827
4580
  process.on("SIGINT", cleanup);
4828
4581
  process.on("SIGTERM", cleanup);
4829
4582
  }
4830
- async browseAgents(keyword, options) {
4831
- let {
4583
+ async _fetch(url, method = "GET", params, data, errCallback) {
4584
+ try {
4585
+ const response = await this.acpClient.request({
4586
+ url,
4587
+ method,
4588
+ params,
4589
+ data
4590
+ });
4591
+ return response.data.data;
4592
+ } catch (err) {
4593
+ if (err instanceof AxiosError) {
4594
+ if (errCallback) {
4595
+ errCallback(err);
4596
+ } else if (err.response?.data.error?.message) {
4597
+ throw new acpError_default(err.response?.data.error.message);
4598
+ }
4599
+ } else {
4600
+ throw new acpError_default(
4601
+ `Failed to fetch ACP Endpoint: ${url} (network error)`,
4602
+ err
4603
+ );
4604
+ }
4605
+ }
4606
+ }
4607
+ _hydrateMemo(memo, contractClient) {
4608
+ try {
4609
+ return new acpMemo_default(
4610
+ contractClient,
4611
+ memo.id,
4612
+ memo.memoType,
4613
+ memo.content,
4614
+ memo.nextPhase,
4615
+ memo.status,
4616
+ memo.senderAddress,
4617
+ memo.signedReason,
4618
+ memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
4619
+ memo.payableDetails,
4620
+ memo.txHash,
4621
+ memo.signedTxHash
4622
+ );
4623
+ } catch (err) {
4624
+ throw new acpError_default(`Failed to hydrate memo ${memo.id}`, err);
4625
+ }
4626
+ }
4627
+ _hydrateJob(job) {
4628
+ try {
4629
+ return new acpJob_default(
4630
+ this,
4631
+ job.id,
4632
+ job.clientAddress,
4633
+ job.providerAddress,
4634
+ job.evaluatorAddress,
4635
+ job.price,
4636
+ job.priceTokenAddress,
4637
+ job.memos.map(
4638
+ (memo) => this._hydrateMemo(
4639
+ memo,
4640
+ this.contractClientByAddress(job.contractAddress)
4641
+ )
4642
+ ),
4643
+ job.phase,
4644
+ job.context,
4645
+ job.contractAddress,
4646
+ job.netPayableAmount
4647
+ );
4648
+ } catch (err) {
4649
+ throw new acpError_default(`Failed to hydrate job ${job.id}`, err);
4650
+ }
4651
+ }
4652
+ _hydrateJobs(rawJobs, options) {
4653
+ const jobs = rawJobs.map((job) => {
4654
+ try {
4655
+ return this._hydrateJob(job);
4656
+ } catch (err) {
4657
+ console.warn(`${options?.logPrefix ?? "Skipped"}`, err);
4658
+ return null;
4659
+ }
4660
+ });
4661
+ return jobs.filter((job) => !!job);
4662
+ }
4663
+ _hydrateAgent(agent) {
4664
+ const acpContractClient = this.contractClients.find(
4665
+ (client) => client.contractAddress.toLowerCase() === agent.contractAddress.toLowerCase()
4666
+ );
4667
+ if (!acpContractClient) {
4668
+ throw new acpError_default("ACP contract client not found");
4669
+ }
4670
+ return new acpAgent_default({
4671
+ id: agent.id,
4672
+ name: agent.name,
4673
+ description: agent.description,
4674
+ jobOfferings: agent.jobs.map((jobs) => {
4675
+ return new acpJobOffering_default(
4676
+ this,
4677
+ acpContractClient,
4678
+ agent.walletAddress,
4679
+ jobs.name,
4680
+ jobs.priceV2.value,
4681
+ jobs.priceV2.type,
4682
+ jobs.requirement
4683
+ );
4684
+ }),
4685
+ contractAddress: agent.contractAddress,
4686
+ twitterHandle: agent.twitterHandle,
4687
+ walletAddress: agent.walletAddress,
4688
+ metrics: agent.metrics,
4689
+ resources: agent.resources
4690
+ });
4691
+ }
4692
+ async browseAgents(keyword, options = {}) {
4693
+ const {
4832
4694
  cluster,
4833
- sort_by,
4834
- top_k,
4695
+ sortBy,
4696
+ topK = 5,
4835
4697
  graduationStatus,
4836
4698
  onlineStatus,
4837
4699
  showHiddenOfferings
4838
4700
  } = options;
4839
- top_k = top_k ?? 5;
4840
- let url = `${this.acpUrl}/api/agents/v4/search?search=${keyword}`;
4841
- if (sort_by && sort_by.length > 0) {
4842
- url += `&sortBy=${sort_by.map((s) => s).join(",")}`;
4843
- }
4844
- if (top_k) {
4845
- url += `&top_k=${top_k}`;
4846
- }
4847
- if (this.walletAddress) {
4848
- url += `&walletAddressesToExclude=${this.walletAddress}`;
4701
+ const params = {
4702
+ search: keyword
4703
+ };
4704
+ params.top_k = topK;
4705
+ params.walletAddressesToExclude = this.walletAddress;
4706
+ if (sortBy && sortBy.length > 0) {
4707
+ params.sortBy = sortBy.join(",");
4849
4708
  }
4850
4709
  if (cluster) {
4851
- url += `&cluster=${cluster}`;
4710
+ params.cluster = cluster;
4852
4711
  }
4853
4712
  if (graduationStatus) {
4854
- url += `&graduationStatus=${graduationStatus}`;
4713
+ params.graduationStatus = graduationStatus;
4855
4714
  }
4856
4715
  if (onlineStatus) {
4857
- url += `&onlineStatus=${onlineStatus}`;
4716
+ params.onlineStatus = onlineStatus;
4858
4717
  }
4859
4718
  if (showHiddenOfferings) {
4860
- url += `&showHiddenOfferings=${showHiddenOfferings}`;
4719
+ params.showHiddenOfferings = true;
4861
4720
  }
4862
- const response = await fetch(url);
4863
- const data = await response.json();
4721
+ const agents = await this._fetch("/agents/v4/search", "GET", params) || [];
4864
4722
  const availableContractClientAddresses = this.contractClients.map(
4865
4723
  (client) => client.contractAddress.toLowerCase()
4866
4724
  );
4867
- return data.data.filter(
4725
+ return agents.filter(
4868
4726
  (agent) => agent.walletAddress.toLowerCase() !== this.walletAddress.toLowerCase()
4869
4727
  ).filter(
4870
4728
  (agent) => availableContractClientAddresses.includes(
4871
4729
  agent.contractAddress.toLowerCase()
4872
4730
  )
4873
4731
  ).map((agent) => {
4874
- const acpContractClient = this.contractClients.find(
4875
- (client) => client.contractAddress.toLowerCase() === agent.contractAddress.toLowerCase()
4876
- );
4877
- if (!acpContractClient) {
4878
- throw new acpError_default("ACP contract client not found");
4879
- }
4880
- return {
4881
- id: agent.id,
4882
- name: agent.name,
4883
- description: agent.description,
4884
- jobOfferings: agent.jobs.map((jobs) => {
4885
- return new acpJobOffering_default(
4886
- this,
4887
- acpContractClient,
4888
- agent.walletAddress,
4889
- jobs.name,
4890
- jobs.priceV2.value,
4891
- jobs.priceV2.type,
4892
- jobs.requirement
4893
- );
4894
- }),
4895
- contractAddress: agent.contractAddress,
4896
- twitterHandle: agent.twitterHandle,
4897
- walletAddress: agent.walletAddress,
4898
- metrics: agent.metrics,
4899
- resources: agent.resources
4900
- };
4732
+ return this._hydrateAgent(agent);
4901
4733
  });
4902
4734
  }
4903
4735
  async initiateJob(providerAddress, serviceRequirement, fareAmount, evaluatorAddress, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
@@ -4967,257 +4799,137 @@ var AcpClient = class {
4967
4799
  return jobId;
4968
4800
  }
4969
4801
  async getActiveJobs(page = 1, pageSize = 10) {
4970
- const url = `${this.acpUrl}/api/jobs/active?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
4971
- const rawJobs = await this._fetchJobList(url);
4972
- return this._hydrateJobs(rawJobs, { logPrefix: "Active jobs" });
4802
+ const rawJobs = await this._fetch("/jobs/active", "GET", {
4803
+ pagination: {
4804
+ page,
4805
+ pageSize
4806
+ }
4807
+ });
4808
+ return this._hydrateJobs(rawJobs ?? [], { logPrefix: "Active jobs" });
4973
4809
  }
4974
4810
  async getPendingMemoJobs(page = 1, pageSize = 10) {
4975
- const url = `${this.acpUrl}/api/jobs/pending-memos?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
4976
- const rawJobs = await this._fetchJobList(url);
4977
- return this._hydrateJobs(rawJobs, { logPrefix: "Pending memo jobs" });
4811
+ const rawJobs = await this._fetch("/jobs/pending-memos", "GET", {
4812
+ pagination: {
4813
+ page,
4814
+ pageSize
4815
+ }
4816
+ });
4817
+ return this._hydrateJobs(rawJobs ?? [], { logPrefix: "Pending memo jobs" });
4978
4818
  }
4979
4819
  async getCompletedJobs(page = 1, pageSize = 10) {
4980
- const url = `${this.acpUrl}/api/jobs/completed?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
4981
- const rawJobs = await this._fetchJobList(url);
4982
- return this._hydrateJobs(rawJobs, { logPrefix: "Completed jobs" });
4820
+ const rawJobs = await this._fetch("/jobs/completed", "GET", {
4821
+ pagination: {
4822
+ page,
4823
+ pageSize
4824
+ }
4825
+ });
4826
+ return this._hydrateJobs(rawJobs ?? [], { logPrefix: "Completed jobs" });
4983
4827
  }
4984
4828
  async getCancelledJobs(page = 1, pageSize = 10) {
4985
- const url = `${this.acpUrl}/api/jobs/cancelled?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
4986
- const rawJobs = await this._fetchJobList(url);
4987
- return this._hydrateJobs(rawJobs, { logPrefix: "Cancelled jobs" });
4988
- }
4989
- async _fetchJobList(url) {
4990
- let response;
4991
- try {
4992
- response = await fetch(url, {
4993
- headers: {
4994
- "wallet-address": this.walletAddress
4995
- }
4996
- });
4997
- } catch (err) {
4998
- throw new acpError_default("Failed to fetch ACP jobs (network error)", err);
4999
- }
5000
- let data;
5001
- try {
5002
- data = await response.json();
5003
- } catch (err) {
5004
- throw new acpError_default("Failed to parse ACP jobs response", err);
5005
- }
5006
- if (data.error) {
5007
- throw new acpError_default(data.error.message);
5008
- }
5009
- return data.data;
5010
- }
5011
- _hydrateJobs(rawJobs, options) {
5012
- const jobs = [];
5013
- const errors = [];
5014
- for (const job of rawJobs) {
5015
- try {
5016
- const memos = job.memos.map(
5017
- (memo) => new acpMemo_default(
5018
- this.contractClientByAddress(job.contractAddress),
5019
- memo.id,
5020
- memo.memoType,
5021
- memo.content,
5022
- memo.nextPhase,
5023
- memo.status,
5024
- memo.senderAddress,
5025
- memo.signedReason,
5026
- memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
5027
- memo.payableDetails,
5028
- memo.txHash,
5029
- memo.signedTxHash,
5030
- memo.state
5031
- )
5032
- );
5033
- jobs.push(
5034
- new acpJob_default(
5035
- this,
5036
- job.id,
5037
- job.clientAddress,
5038
- job.providerAddress,
5039
- job.evaluatorAddress,
5040
- job.price,
5041
- job.priceTokenAddress,
5042
- memos,
5043
- job.phase,
5044
- job.context,
5045
- job.contractAddress,
5046
- job.netPayableAmount
5047
- )
5048
- );
5049
- } catch (err) {
5050
- errors.push({ jobId: job.id, error: err });
5051
- }
5052
- }
5053
- if (errors.length > 0) {
5054
- console.warn(
5055
- `${options?.logPrefix ?? "Skipped"} ${errors.length} malformed job(s)
5056
- ` + JSON.stringify(
5057
- errors.map((e) => ({ jobId: e.jobId, message: e.error.message })),
5058
- null,
5059
- 2
5060
- )
5061
- );
5062
- }
5063
- return jobs;
4829
+ const rawJobs = await this._fetch("/jobs/cancelled", "GET", {
4830
+ pagination: {
4831
+ page,
4832
+ pageSize
4833
+ }
4834
+ });
4835
+ return this._hydrateJobs(rawJobs ?? [], { logPrefix: "Cancelled jobs" });
5064
4836
  }
5065
4837
  async getJobById(jobId) {
5066
- const url = `${this.acpUrl}/api/jobs/${jobId}`;
5067
- let response;
5068
- try {
5069
- response = await fetch(url, {
5070
- headers: {
5071
- "wallet-address": this.acpContractClient.walletAddress
5072
- }
5073
- });
5074
- } catch (err) {
5075
- throw new acpError_default("Failed to fetch job by id (network error)", err);
5076
- }
5077
- let data;
5078
- try {
5079
- data = await response.json();
5080
- } catch (err) {
5081
- throw new acpError_default("Failed to parse job by id response", err);
5082
- }
5083
- if (data.error) {
5084
- throw new acpError_default(data.error.message);
5085
- }
5086
- const job = data.data;
4838
+ const job = await this._fetch(`/jobs/${jobId}`);
5087
4839
  if (!job) {
5088
- return void 0;
5089
- }
5090
- try {
5091
- const memos = job.memos.map(
5092
- (memo) => new acpMemo_default(
5093
- this.contractClientByAddress(job.contractAddress),
5094
- memo.id,
5095
- memo.memoType,
5096
- memo.content,
5097
- memo.nextPhase,
5098
- memo.status,
5099
- memo.senderAddress,
5100
- memo.signedReason,
5101
- memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
5102
- memo.payableDetails,
5103
- memo.txHash,
5104
- memo.signedTxHash,
5105
- memo.state
5106
- )
5107
- );
5108
- return new acpJob_default(
5109
- this,
5110
- job.id,
5111
- job.clientAddress,
5112
- job.providerAddress,
5113
- job.evaluatorAddress,
5114
- job.price,
5115
- job.priceTokenAddress,
5116
- memos,
5117
- job.phase,
5118
- job.context,
5119
- job.contractAddress,
5120
- job.netPayableAmount
5121
- );
5122
- } catch (err) {
5123
- throw new acpError_default(`Failed to hydrate job ${jobId}`, err);
4840
+ return null;
5124
4841
  }
4842
+ return this._hydrateJob(job);
5125
4843
  }
5126
4844
  async getMemoById(jobId, memoId) {
5127
- const url = `${this.acpUrl}/api/jobs/${jobId}/memos/${memoId}`;
5128
- let response;
5129
- try {
5130
- response = await fetch(url, {
5131
- headers: {
5132
- "wallet-address": this.walletAddress
5133
- }
5134
- });
5135
- } catch (err) {
5136
- throw new acpError_default("Failed to fetch memo by id (network error)", err);
5137
- }
5138
- let data;
5139
- try {
5140
- data = await response.json();
5141
- } catch (err) {
5142
- throw new acpError_default("Failed to parse memo by id response", err);
5143
- }
5144
- if (data.error) {
5145
- throw new acpError_default(data.error.message);
5146
- }
5147
- const memo = data.data;
4845
+ const memo = await this._fetch(
4846
+ `/jobs/${jobId}/memos/${memoId}`
4847
+ );
5148
4848
  if (!memo) {
5149
- return void 0;
5150
- }
5151
- try {
5152
- return new acpMemo_default(
5153
- this.contractClientByAddress(memo.contractAddress),
5154
- memo.id,
5155
- memo.memoType,
5156
- memo.content,
5157
- memo.nextPhase,
5158
- memo.status,
5159
- memo.senderAddress,
5160
- memo.signedReason,
5161
- memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
5162
- memo.payableDetails,
5163
- memo.txHash,
5164
- memo.signedTxHash,
5165
- memo.state
5166
- );
5167
- } catch (err) {
5168
- throw new acpError_default(
5169
- `Failed to hydrate memo ${memoId} for job ${jobId}`,
5170
- err
5171
- );
4849
+ return null;
5172
4850
  }
4851
+ return this._hydrateMemo(
4852
+ memo,
4853
+ this.contractClientByAddress(memo.contractAddress)
4854
+ );
5173
4855
  }
5174
- async getAgent(walletAddress) {
5175
- const url = `${this.acpUrl}/api/agents?filters[walletAddress]=${walletAddress}`;
5176
- const response = await fetch(url);
5177
- const data = await response.json();
5178
- const agents = data.data || [];
5179
- if (agents.length === 0) {
5180
- return;
4856
+ async getAgent(walletAddress, options = {}) {
4857
+ const params = {
4858
+ "filters[walletAddress]": walletAddress
4859
+ };
4860
+ const { showHiddenOfferings } = options;
4861
+ if (showHiddenOfferings) {
4862
+ params.showHiddenOfferings = true;
4863
+ }
4864
+ const agentsResponse = await this.noAuthAcpClient.get("/agents", {
4865
+ params
4866
+ });
4867
+ if (!agentsResponse.data) {
4868
+ return null;
5181
4869
  }
5182
- return agents[0];
4870
+ return this._hydrateAgent(agentsResponse.data.data[0]);
5183
4871
  }
5184
4872
  async getAccountByJobId(jobId, acpContractClient) {
5185
- try {
5186
- const url = `${this.acpUrl}/api/accounts/job/${jobId}`;
5187
- const response = await fetch(url);
5188
- const data = await response.json();
5189
- if (!data.data) {
5190
- return null;
5191
- }
5192
- return new AcpAccount(
5193
- acpContractClient || this.contractClients[0],
5194
- data.data.id,
5195
- data.data.clientAddress,
5196
- data.data.providerAddress,
5197
- data.data.metadata
5198
- );
5199
- } catch (error) {
5200
- throw new acpError_default("Failed to get account by job id", error);
4873
+ const account = await this._fetch(`/accounts/job/${jobId}`);
4874
+ if (!account) {
4875
+ return null;
5201
4876
  }
4877
+ return new AcpAccount(
4878
+ acpContractClient || this.contractClients[0],
4879
+ account.id,
4880
+ account.clientAddress,
4881
+ account.providerAddress,
4882
+ account.metadata
4883
+ );
5202
4884
  }
5203
4885
  async getByClientAndProvider(clientAddress, providerAddress, acpContractClient) {
5204
- try {
5205
- const url = `${this.acpUrl}/api/accounts/client/${clientAddress}/provider/${providerAddress}`;
5206
- const response = await fetch(url);
5207
- const data = await response.json();
5208
- if (!data.data) {
5209
- return null;
4886
+ const response = await this._fetch(
4887
+ `/accounts/client/${clientAddress}/provider/${providerAddress}`,
4888
+ "GET",
4889
+ {},
4890
+ {},
4891
+ (err) => {
4892
+ if (err.response?.status === 404) {
4893
+ console.warn("Account not found by client and provider");
4894
+ return;
4895
+ }
4896
+ throw new acpError_default("Failed to get account by client and provider", err);
5210
4897
  }
5211
- return new AcpAccount(
5212
- acpContractClient || this.contractClients[0],
5213
- data.data.id,
5214
- data.data.clientAddress,
5215
- data.data.providerAddress,
5216
- data.data.metadata
5217
- );
5218
- } catch (error) {
5219
- throw new acpError_default("Failed to get account by client and provider", error);
4898
+ );
4899
+ if (!response) {
4900
+ return null;
4901
+ }
4902
+ return new AcpAccount(
4903
+ acpContractClient || this.contractClients[0],
4904
+ response.id,
4905
+ response.clientAddress,
4906
+ response.providerAddress,
4907
+ response.metadata
4908
+ );
4909
+ }
4910
+ async createMemoContent(jobId, content) {
4911
+ const response = await this._fetch(
4912
+ `/memo-contents`,
4913
+ "POST",
4914
+ {},
4915
+ {
4916
+ data: {
4917
+ onChainJobId: jobId,
4918
+ content
4919
+ }
4920
+ }
4921
+ );
4922
+ if (!response) {
4923
+ throw new acpError_default("Failed to create memo content");
5220
4924
  }
4925
+ return response;
4926
+ }
4927
+ async getTokenBalances() {
4928
+ const response = await this._fetch(
4929
+ `/chains/token-balances`,
4930
+ "GET"
4931
+ );
4932
+ return response;
5221
4933
  }
5222
4934
  };
5223
4935
  var acpClient_default = AcpClient;
@@ -5228,7 +4940,10 @@ import { alchemy } from "@account-kit/infra";
5228
4940
  import {
5229
4941
  createModularAccountV2Client
5230
4942
  } from "@account-kit/smart-contracts";
5231
- import { decodeEventLog, encodeFunctionData as encodeFunctionData3 } from "viem";
4943
+ import {
4944
+ decodeEventLog,
4945
+ encodeFunctionData as encodeFunctionData3
4946
+ } from "viem";
5232
4947
 
5233
4948
  // src/acpX402.ts
5234
4949
  import {
@@ -5600,12 +5315,12 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5600
5315
  async performX402Request(url, version2, budget, signature) {
5601
5316
  return await this.acpX402.performRequest(url, version2, budget, signature);
5602
5317
  }
5603
- async getAssetManager() {
5604
- throw new Error("Asset Manager not supported");
5605
- }
5606
5318
  getAcpVersion() {
5607
5319
  return "1";
5608
5320
  }
5321
+ signTypedData(typedData) {
5322
+ return this.sessionKeyClient.signTypedData({ typedData });
5323
+ }
5609
5324
  };
5610
5325
  var acpContractClient_default = AcpContractClient;
5611
5326
 
@@ -5615,7 +5330,11 @@ import { alchemy as alchemy2 } from "@account-kit/infra";
5615
5330
  import {
5616
5331
  createModularAccountV2Client as createModularAccountV2Client2
5617
5332
  } from "@account-kit/smart-contracts";
5618
- import { createPublicClient as createPublicClient4, decodeEventLog as decodeEventLog2, http as http3 } from "viem";
5333
+ import {
5334
+ createPublicClient as createPublicClient4,
5335
+ decodeEventLog as decodeEventLog2,
5336
+ http as http3
5337
+ } from "viem";
5619
5338
 
5620
5339
  // src/abis/jobManagerAbi.ts
5621
5340
  var JOB_MANAGER_ABI = [
@@ -6319,1234 +6038,76 @@ var JOB_MANAGER_ABI = [
6319
6038
  var jobManagerAbi_default = JOB_MANAGER_ABI;
6320
6039
 
6321
6040
  // src/contractClients/acpContractClientV2.ts
6322
- import { base as base4, baseSepolia as baseSepolia4 } from "viem/chains";
6323
-
6324
- // src/abis/memoManagerAbi.ts
6325
- var MEMO_MANAGER_ABI = [
6326
- { inputs: [], stateMutability: "nonpayable", type: "constructor" },
6327
- { inputs: [], name: "AccessControlBadConfirmation", type: "error" },
6328
- {
6329
- inputs: [
6330
- { internalType: "address", name: "account", type: "address" },
6331
- { internalType: "bytes32", name: "neededRole", type: "bytes32" }
6332
- ],
6333
- name: "AccessControlUnauthorizedAccount",
6334
- type: "error"
6335
- },
6336
- {
6337
- inputs: [{ internalType: "address", name: "target", type: "address" }],
6338
- name: "AddressEmptyCode",
6339
- type: "error"
6340
- },
6341
- { inputs: [], name: "AlreadyVoted", type: "error" },
6342
- { inputs: [], name: "CannotApproveMemo", type: "error" },
6343
- { inputs: [], name: "CannotUpdateApprovedMemo", type: "error" },
6344
- { inputs: [], name: "CannotUpdateMemo", type: "error" },
6345
- { inputs: [], name: "CannotWithdrawYet", type: "error" },
6346
- { inputs: [], name: "DestinationChainNotConfigured", type: "error" },
6347
- {
6348
- inputs: [
6349
- { internalType: "address", name: "implementation", type: "address" }
6350
- ],
6351
- name: "ERC1967InvalidImplementation",
6352
- type: "error"
6353
- },
6354
- { inputs: [], name: "ERC1967NonPayable", type: "error" },
6355
- { inputs: [], name: "EmptyContent", type: "error" },
6356
- { inputs: [], name: "FailedInnerCall", type: "error" },
6357
- { inputs: [], name: "InvalidInitialization", type: "error" },
6358
- { inputs: [], name: "InvalidMemoState", type: "error" },
6359
- { inputs: [], name: "InvalidMemoStateTransition", type: "error" },
6360
- { inputs: [], name: "InvalidMemoType", type: "error" },
6361
- { inputs: [], name: "JobAlreadyCompleted", type: "error" },
6362
- { inputs: [], name: "JobDoesNotExist", type: "error" },
6363
- { inputs: [], name: "MemoAlreadyApproved", type: "error" },
6364
- { inputs: [], name: "MemoAlreadyExecuted", type: "error" },
6365
- { inputs: [], name: "MemoAlreadySigned", type: "error" },
6366
- { inputs: [], name: "MemoCannotBeSigned", type: "error" },
6367
- { inputs: [], name: "MemoDoesNotExist", type: "error" },
6368
- { inputs: [], name: "MemoDoesNotRequireApproval", type: "error" },
6369
- { inputs: [], name: "MemoExpired", type: "error" },
6370
- { inputs: [], name: "MemoNotApproved", type: "error" },
6371
- { inputs: [], name: "MemoNotReadyToBeSigned", type: "error" },
6372
- { inputs: [], name: "MemoStateUnchanged", type: "error" },
6373
- { inputs: [], name: "NoAmountToTransfer", type: "error" },
6374
- { inputs: [], name: "NoPaymentAmount", type: "error" },
6375
- { inputs: [], name: "NotEscrowTransferMemoType", type: "error" },
6376
- { inputs: [], name: "NotInitializing", type: "error" },
6377
- { inputs: [], name: "NotPayableMemoType", type: "error" },
6378
- { inputs: [], name: "OnlyACPContract", type: "error" },
6379
- { inputs: [], name: "OnlyAssetManager", type: "error" },
6380
- { inputs: [], name: "OnlyClientOrProvider", type: "error" },
6381
- { inputs: [], name: "OnlyCounterParty", type: "error" },
6382
- { inputs: [], name: "OnlyEvaluator", type: "error" },
6383
- { inputs: [], name: "OnlyMemoSender", type: "error" },
6384
- { inputs: [], name: "ReentrancyGuardReentrantCall", type: "error" },
6385
- { inputs: [], name: "UUPSUnauthorizedCallContext", type: "error" },
6386
- {
6387
- inputs: [{ internalType: "bytes32", name: "slot", type: "bytes32" }],
6388
- name: "UUPSUnsupportedProxiableUUID",
6389
- type: "error"
6390
- },
6391
- { inputs: [], name: "ZeroAcpContractAddress", type: "error" },
6392
- { inputs: [], name: "ZeroAddressRecipient", type: "error" },
6393
- { inputs: [], name: "ZeroAddressToken", type: "error" },
6394
- { inputs: [], name: "ZeroAssetManagerAddress", type: "error" },
6395
- { inputs: [], name: "ZeroJobManagerAddress", type: "error" },
6396
- {
6397
- anonymous: false,
6398
- inputs: [
6399
- {
6400
- indexed: false,
6401
- internalType: "uint64",
6402
- name: "version",
6403
- type: "uint64"
6404
- }
6405
- ],
6406
- name: "Initialized",
6407
- type: "event"
6408
- },
6409
- {
6410
- anonymous: false,
6411
- inputs: [
6412
- {
6413
- indexed: true,
6414
- internalType: "uint256",
6415
- name: "memoId",
6416
- type: "uint256"
6417
- },
6418
- {
6419
- indexed: true,
6420
- internalType: "address",
6421
- name: "approver",
6422
- type: "address"
6423
- },
6424
- { indexed: false, internalType: "bool", name: "approved", type: "bool" },
6425
- {
6426
- indexed: false,
6427
- internalType: "string",
6428
- name: "reason",
6429
- type: "string"
6430
- }
6431
- ],
6432
- name: "MemoSigned",
6433
- type: "event"
6434
- },
6435
- {
6436
- anonymous: false,
6437
- inputs: [
6438
- {
6439
- indexed: true,
6440
- internalType: "uint256",
6441
- name: "memoId",
6442
- type: "uint256"
6443
- },
6444
- {
6445
- indexed: false,
6446
- internalType: "enum ACPTypes.MemoState",
6447
- name: "oldState",
6448
- type: "uint8"
6449
- },
6450
- {
6451
- indexed: false,
6452
- internalType: "enum ACPTypes.MemoState",
6453
- name: "newState",
6454
- type: "uint8"
6455
- }
6456
- ],
6457
- name: "MemoStateUpdated",
6458
- type: "event"
6459
- },
6460
- {
6461
- anonymous: false,
6462
- inputs: [
6463
- {
6464
- indexed: true,
6465
- internalType: "uint256",
6466
- name: "memoId",
6467
- type: "uint256"
6468
- },
6469
- {
6470
- indexed: true,
6471
- internalType: "uint256",
6472
- name: "jobId",
6473
- type: "uint256"
6474
- },
6475
- {
6476
- indexed: true,
6477
- internalType: "address",
6478
- name: "sender",
6479
- type: "address"
6480
- },
6481
- {
6482
- indexed: false,
6483
- internalType: "enum ACPTypes.MemoType",
6484
- name: "memoType",
6485
- type: "uint8"
6486
- },
6487
- {
6488
- indexed: false,
6489
- internalType: "enum ACPTypes.JobPhase",
6490
- name: "nextPhase",
6491
- type: "uint8"
6492
- },
6493
- {
6494
- indexed: false,
6495
- internalType: "string",
6496
- name: "content",
6497
- type: "string"
6498
- }
6499
- ],
6500
- name: "NewMemo",
6501
- type: "event"
6502
- },
6503
- {
6504
- anonymous: false,
6505
- inputs: [
6506
- {
6507
- indexed: true,
6508
- internalType: "uint256",
6509
- name: "jobId",
6510
- type: "uint256"
6511
- },
6512
- {
6513
- indexed: true,
6514
- internalType: "uint256",
6515
- name: "memoId",
6516
- type: "uint256"
6517
- },
6518
- {
6519
- indexed: true,
6520
- internalType: "address",
6521
- name: "sender",
6522
- type: "address"
6523
- },
6524
- {
6525
- indexed: false,
6526
- internalType: "address",
6527
- name: "token",
6528
- type: "address"
6529
- },
6530
- {
6531
- indexed: false,
6532
- internalType: "uint256",
6533
- name: "amount",
6534
- type: "uint256"
6535
- }
6536
- ],
6537
- name: "PayableFeeRefunded",
6538
- type: "event"
6539
- },
6540
- {
6541
- anonymous: false,
6542
- inputs: [
6543
- {
6544
- indexed: true,
6545
- internalType: "uint256",
6546
- name: "jobId",
6547
- type: "uint256"
6548
- },
6549
- {
6550
- indexed: true,
6551
- internalType: "uint256",
6552
- name: "memoId",
6553
- type: "uint256"
6554
- },
6555
- {
6556
- indexed: true,
6557
- internalType: "address",
6558
- name: "sender",
6559
- type: "address"
6560
- },
6561
- {
6562
- indexed: false,
6563
- internalType: "address",
6564
- name: "token",
6565
- type: "address"
6566
- },
6567
- {
6568
- indexed: false,
6569
- internalType: "uint256",
6570
- name: "amount",
6571
- type: "uint256"
6572
- }
6573
- ],
6574
- name: "PayableFundsRefunded",
6575
- type: "event"
6576
- },
6577
- {
6578
- anonymous: false,
6579
- inputs: [
6580
- {
6581
- indexed: true,
6582
- internalType: "uint256",
6583
- name: "memoId",
6584
- type: "uint256"
6585
- },
6586
- {
6587
- indexed: true,
6588
- internalType: "uint256",
6589
- name: "jobId",
6590
- type: "uint256"
6591
- },
6592
- {
6593
- indexed: true,
6594
- internalType: "address",
6595
- name: "executor",
6596
- type: "address"
6597
- },
6598
- {
6599
- indexed: false,
6600
- internalType: "uint256",
6601
- name: "amount",
6602
- type: "uint256"
6603
- }
6604
- ],
6605
- name: "PayableMemoExecuted",
6606
- type: "event"
6607
- },
6608
- {
6609
- anonymous: false,
6610
- inputs: [
6611
- { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
6612
- {
6613
- indexed: true,
6614
- internalType: "bytes32",
6615
- name: "previousAdminRole",
6616
- type: "bytes32"
6617
- },
6618
- {
6619
- indexed: true,
6620
- internalType: "bytes32",
6621
- name: "newAdminRole",
6622
- type: "bytes32"
6623
- }
6624
- ],
6625
- name: "RoleAdminChanged",
6626
- type: "event"
6627
- },
6628
- {
6629
- anonymous: false,
6630
- inputs: [
6631
- { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
6632
- {
6633
- indexed: true,
6634
- internalType: "address",
6635
- name: "account",
6636
- type: "address"
6637
- },
6638
- {
6639
- indexed: true,
6640
- internalType: "address",
6641
- name: "sender",
6642
- type: "address"
6643
- }
6644
- ],
6645
- name: "RoleGranted",
6646
- type: "event"
6647
- },
6648
- {
6649
- anonymous: false,
6650
- inputs: [
6651
- { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
6652
- {
6653
- indexed: true,
6654
- internalType: "address",
6655
- name: "account",
6656
- type: "address"
6657
- },
6658
- {
6659
- indexed: true,
6660
- internalType: "address",
6661
- name: "sender",
6662
- type: "address"
6663
- }
6664
- ],
6665
- name: "RoleRevoked",
6666
- type: "event"
6667
- },
6668
- {
6669
- anonymous: false,
6670
- inputs: [
6671
- {
6672
- indexed: true,
6673
- internalType: "address",
6674
- name: "implementation",
6675
- type: "address"
6676
- }
6677
- ],
6678
- name: "Upgraded",
6679
- type: "event"
6680
- },
6681
- {
6682
- inputs: [],
6683
- name: "ACP_CONTRACT_ROLE",
6684
- outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
6685
- stateMutability: "view",
6686
- type: "function"
6687
- },
6688
- {
6689
- inputs: [],
6690
- name: "ADMIN_ROLE",
6691
- outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
6692
- stateMutability: "view",
6693
- type: "function"
6694
- },
6695
- {
6696
- inputs: [],
6697
- name: "DEFAULT_ADMIN_ROLE",
6698
- outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
6699
- stateMutability: "view",
6700
- type: "function"
6701
- },
6702
- {
6703
- inputs: [],
6704
- name: "UPGRADE_INTERFACE_VERSION",
6705
- outputs: [{ internalType: "string", name: "", type: "string" }],
6706
- stateMutability: "view",
6707
- type: "function"
6708
- },
6709
- {
6710
- inputs: [],
6711
- name: "acpContract",
6712
- outputs: [{ internalType: "address", name: "", type: "address" }],
6713
- stateMutability: "view",
6714
- type: "function"
6715
- },
6716
- {
6717
- inputs: [
6718
- { internalType: "uint256", name: "memoId", type: "uint256" },
6719
- { internalType: "address", name: "sender", type: "address" },
6720
- { internalType: "bool", name: "approved", type: "bool" },
6721
- { internalType: "string", name: "reason", type: "string" }
6722
- ],
6723
- name: "approveMemo",
6724
- outputs: [],
6725
- stateMutability: "nonpayable",
6726
- type: "function"
6727
- },
6728
- {
6729
- inputs: [],
6730
- name: "assetManager",
6731
- outputs: [{ internalType: "address", name: "", type: "address" }],
6732
- stateMutability: "view",
6733
- type: "function"
6734
- },
6735
- {
6736
- inputs: [
6737
- { internalType: "uint256[]", name: "memoIds", type: "uint256[]" },
6738
- { internalType: "bool", name: "approved", type: "bool" },
6739
- { internalType: "string", name: "reason", type: "string" }
6740
- ],
6741
- name: "bulkApproveMemos",
6742
- outputs: [],
6743
- stateMutability: "nonpayable",
6744
- type: "function"
6745
- },
6746
- {
6747
- inputs: [
6748
- { internalType: "uint256", name: "memoId", type: "uint256" },
6749
- { internalType: "address", name: "user", type: "address" }
6750
- ],
6751
- name: "canApproveMemo",
6752
- outputs: [{ internalType: "bool", name: "", type: "bool" }],
6753
- stateMutability: "view",
6754
- type: "function"
6755
- },
6756
- {
6757
- inputs: [
6758
- { internalType: "uint256", name: "jobId", type: "uint256" },
6759
- { internalType: "address", name: "sender", type: "address" },
6760
- { internalType: "string", name: "content", type: "string" },
6761
- {
6762
- internalType: "enum ACPTypes.MemoType",
6763
- name: "memoType",
6764
- type: "uint8"
6765
- },
6766
- { internalType: "bool", name: "isSecured", type: "bool" },
6767
- {
6768
- internalType: "enum ACPTypes.JobPhase",
6769
- name: "nextPhase",
6770
- type: "uint8"
6771
- },
6772
- { internalType: "string", name: "metadata", type: "string" }
6773
- ],
6774
- name: "createMemo",
6775
- outputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6776
- stateMutability: "nonpayable",
6777
- type: "function"
6778
- },
6779
- {
6780
- inputs: [
6781
- { internalType: "uint256", name: "jobId", type: "uint256" },
6782
- { internalType: "address", name: "sender", type: "address" },
6783
- { internalType: "string", name: "content", type: "string" },
6784
- {
6785
- internalType: "enum ACPTypes.MemoType",
6786
- name: "memoType",
6787
- type: "uint8"
6788
- },
6789
- { internalType: "bool", name: "isSecured", type: "bool" },
6790
- {
6791
- internalType: "enum ACPTypes.JobPhase",
6792
- name: "nextPhase",
6793
- type: "uint8"
6794
- },
6795
- {
6796
- components: [
6797
- { internalType: "address", name: "token", type: "address" },
6798
- { internalType: "uint256", name: "amount", type: "uint256" },
6799
- { internalType: "address", name: "recipient", type: "address" },
6800
- { internalType: "uint256", name: "feeAmount", type: "uint256" },
6801
- {
6802
- internalType: "enum ACPTypes.FeeType",
6803
- name: "feeType",
6804
- type: "uint8"
6805
- },
6806
- { internalType: "bool", name: "isExecuted", type: "bool" },
6807
- { internalType: "uint256", name: "expiredAt", type: "uint256" },
6808
- { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
6809
- { internalType: "uint32", name: "lzDstEid", type: "uint32" }
6810
- ],
6811
- internalType: "struct ACPTypes.PayableDetails",
6812
- name: "payableDetails_",
6813
- type: "tuple"
6814
- },
6815
- { internalType: "uint256", name: "expiredAt", type: "uint256" }
6816
- ],
6817
- name: "createPayableMemo",
6818
- outputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6819
- stateMutability: "nonpayable",
6820
- type: "function"
6821
- },
6822
- {
6823
- inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6824
- name: "emergencyApproveMemo",
6825
- outputs: [],
6826
- stateMutability: "nonpayable",
6827
- type: "function"
6828
- },
6829
- {
6830
- inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6831
- name: "executePayableMemo",
6832
- outputs: [],
6833
- stateMutability: "nonpayable",
6834
- type: "function"
6835
- },
6836
- {
6837
- inputs: [],
6838
- name: "getAssetManager",
6839
- outputs: [{ internalType: "address", name: "", type: "address" }],
6840
- stateMutability: "view",
6841
- type: "function"
6842
- },
6843
- {
6844
- inputs: [
6845
- { internalType: "uint256", name: "jobId", type: "uint256" },
6846
- { internalType: "uint256", name: "offset", type: "uint256" },
6847
- { internalType: "uint256", name: "limit", type: "uint256" }
6848
- ],
6849
- name: "getJobMemos",
6850
- outputs: [
6851
- {
6852
- components: [
6853
- { internalType: "uint256", name: "id", type: "uint256" },
6854
- { internalType: "uint256", name: "jobId", type: "uint256" },
6855
- { internalType: "address", name: "sender", type: "address" },
6856
- { internalType: "string", name: "content", type: "string" },
6857
- {
6858
- internalType: "enum ACPTypes.MemoType",
6859
- name: "memoType",
6860
- type: "uint8"
6861
- },
6862
- { internalType: "uint256", name: "createdAt", type: "uint256" },
6863
- { internalType: "bool", name: "isApproved", type: "bool" },
6864
- { internalType: "address", name: "approvedBy", type: "address" },
6865
- { internalType: "uint256", name: "approvedAt", type: "uint256" },
6866
- { internalType: "bool", name: "requiresApproval", type: "bool" },
6867
- { internalType: "string", name: "metadata", type: "string" },
6868
- { internalType: "bool", name: "isSecured", type: "bool" },
6869
- {
6870
- internalType: "enum ACPTypes.JobPhase",
6871
- name: "nextPhase",
6872
- type: "uint8"
6873
- },
6874
- { internalType: "uint256", name: "expiredAt", type: "uint256" },
6875
- {
6876
- internalType: "enum ACPTypes.MemoState",
6877
- name: "state",
6878
- type: "uint8"
6879
- }
6880
- ],
6881
- internalType: "struct ACPTypes.Memo[]",
6882
- name: "memoArray",
6883
- type: "tuple[]"
6884
- },
6885
- { internalType: "uint256", name: "total", type: "uint256" }
6886
- ],
6887
- stateMutability: "view",
6888
- type: "function"
6889
- },
6890
- {
6891
- inputs: [
6892
- { internalType: "uint256", name: "jobId", type: "uint256" },
6893
- { internalType: "enum ACPTypes.JobPhase", name: "phase", type: "uint8" },
6894
- { internalType: "uint256", name: "offset", type: "uint256" },
6895
- { internalType: "uint256", name: "limit", type: "uint256" }
6896
- ],
6897
- name: "getJobMemosByPhase",
6898
- outputs: [
6899
- {
6900
- components: [
6901
- { internalType: "uint256", name: "id", type: "uint256" },
6902
- { internalType: "uint256", name: "jobId", type: "uint256" },
6903
- { internalType: "address", name: "sender", type: "address" },
6904
- { internalType: "string", name: "content", type: "string" },
6905
- {
6906
- internalType: "enum ACPTypes.MemoType",
6907
- name: "memoType",
6908
- type: "uint8"
6909
- },
6910
- { internalType: "uint256", name: "createdAt", type: "uint256" },
6911
- { internalType: "bool", name: "isApproved", type: "bool" },
6912
- { internalType: "address", name: "approvedBy", type: "address" },
6913
- { internalType: "uint256", name: "approvedAt", type: "uint256" },
6914
- { internalType: "bool", name: "requiresApproval", type: "bool" },
6915
- { internalType: "string", name: "metadata", type: "string" },
6916
- { internalType: "bool", name: "isSecured", type: "bool" },
6917
- {
6918
- internalType: "enum ACPTypes.JobPhase",
6919
- name: "nextPhase",
6920
- type: "uint8"
6921
- },
6922
- { internalType: "uint256", name: "expiredAt", type: "uint256" },
6923
- {
6924
- internalType: "enum ACPTypes.MemoState",
6925
- name: "state",
6926
- type: "uint8"
6927
- }
6928
- ],
6929
- internalType: "struct ACPTypes.Memo[]",
6930
- name: "memoArray",
6931
- type: "tuple[]"
6932
- },
6933
- { internalType: "uint256", name: "total", type: "uint256" }
6934
- ],
6935
- stateMutability: "view",
6936
- type: "function"
6937
- },
6938
- {
6939
- inputs: [
6940
- { internalType: "uint256", name: "jobId", type: "uint256" },
6941
- {
6942
- internalType: "enum ACPTypes.MemoType",
6943
- name: "memoType",
6944
- type: "uint8"
6945
- },
6946
- { internalType: "uint256", name: "offset", type: "uint256" },
6947
- { internalType: "uint256", name: "limit", type: "uint256" }
6948
- ],
6949
- name: "getJobMemosByType",
6950
- outputs: [
6951
- {
6952
- components: [
6953
- { internalType: "uint256", name: "id", type: "uint256" },
6954
- { internalType: "uint256", name: "jobId", type: "uint256" },
6955
- { internalType: "address", name: "sender", type: "address" },
6956
- { internalType: "string", name: "content", type: "string" },
6957
- {
6958
- internalType: "enum ACPTypes.MemoType",
6959
- name: "memoType",
6960
- type: "uint8"
6961
- },
6962
- { internalType: "uint256", name: "createdAt", type: "uint256" },
6963
- { internalType: "bool", name: "isApproved", type: "bool" },
6964
- { internalType: "address", name: "approvedBy", type: "address" },
6965
- { internalType: "uint256", name: "approvedAt", type: "uint256" },
6966
- { internalType: "bool", name: "requiresApproval", type: "bool" },
6967
- { internalType: "string", name: "metadata", type: "string" },
6968
- { internalType: "bool", name: "isSecured", type: "bool" },
6969
- {
6970
- internalType: "enum ACPTypes.JobPhase",
6971
- name: "nextPhase",
6972
- type: "uint8"
6973
- },
6974
- { internalType: "uint256", name: "expiredAt", type: "uint256" },
6975
- {
6976
- internalType: "enum ACPTypes.MemoState",
6977
- name: "state",
6978
- type: "uint8"
6979
- }
6980
- ],
6981
- internalType: "struct ACPTypes.Memo[]",
6982
- name: "memoArray",
6983
- type: "tuple[]"
6984
- },
6985
- { internalType: "uint256", name: "total", type: "uint256" }
6986
- ],
6987
- stateMutability: "view",
6988
- type: "function"
6989
- },
6990
- {
6991
- inputs: [],
6992
- name: "getLocalEid",
6993
- outputs: [{ internalType: "uint32", name: "", type: "uint32" }],
6994
- stateMutability: "view",
6995
- type: "function"
6996
- },
6997
- {
6998
- inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6999
- name: "getMemo",
7000
- outputs: [
7001
- {
7002
- components: [
7003
- { internalType: "uint256", name: "id", type: "uint256" },
7004
- { internalType: "uint256", name: "jobId", type: "uint256" },
7005
- { internalType: "address", name: "sender", type: "address" },
7006
- { internalType: "string", name: "content", type: "string" },
7007
- {
7008
- internalType: "enum ACPTypes.MemoType",
7009
- name: "memoType",
7010
- type: "uint8"
7011
- },
7012
- { internalType: "uint256", name: "createdAt", type: "uint256" },
7013
- { internalType: "bool", name: "isApproved", type: "bool" },
7014
- { internalType: "address", name: "approvedBy", type: "address" },
7015
- { internalType: "uint256", name: "approvedAt", type: "uint256" },
7016
- { internalType: "bool", name: "requiresApproval", type: "bool" },
7017
- { internalType: "string", name: "metadata", type: "string" },
7018
- { internalType: "bool", name: "isSecured", type: "bool" },
7019
- {
7020
- internalType: "enum ACPTypes.JobPhase",
7021
- name: "nextPhase",
7022
- type: "uint8"
7023
- },
7024
- { internalType: "uint256", name: "expiredAt", type: "uint256" },
7025
- {
7026
- internalType: "enum ACPTypes.MemoState",
7027
- name: "state",
7028
- type: "uint8"
7029
- }
7030
- ],
7031
- internalType: "struct ACPTypes.Memo",
7032
- name: "",
7033
- type: "tuple"
7034
- }
7035
- ],
7036
- stateMutability: "view",
7037
- type: "function"
7038
- },
7039
- {
7040
- inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7041
- name: "getMemoApprovalStatus",
7042
- outputs: [
7043
- { internalType: "bool", name: "isApproved", type: "bool" },
7044
- { internalType: "address", name: "approvedBy", type: "address" },
7045
- { internalType: "uint256", name: "approvedAt", type: "uint256" }
7046
- ],
7047
- stateMutability: "view",
7048
- type: "function"
7049
- },
7050
- {
7051
- inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7052
- name: "getMemoWithPayableDetails",
7053
- outputs: [
7054
- {
7055
- components: [
7056
- { internalType: "uint256", name: "id", type: "uint256" },
7057
- { internalType: "uint256", name: "jobId", type: "uint256" },
7058
- { internalType: "address", name: "sender", type: "address" },
7059
- { internalType: "string", name: "content", type: "string" },
7060
- {
7061
- internalType: "enum ACPTypes.MemoType",
7062
- name: "memoType",
7063
- type: "uint8"
7064
- },
7065
- { internalType: "uint256", name: "createdAt", type: "uint256" },
7066
- { internalType: "bool", name: "isApproved", type: "bool" },
7067
- { internalType: "address", name: "approvedBy", type: "address" },
7068
- { internalType: "uint256", name: "approvedAt", type: "uint256" },
7069
- { internalType: "bool", name: "requiresApproval", type: "bool" },
7070
- { internalType: "string", name: "metadata", type: "string" },
7071
- { internalType: "bool", name: "isSecured", type: "bool" },
7072
- {
7073
- internalType: "enum ACPTypes.JobPhase",
7074
- name: "nextPhase",
7075
- type: "uint8"
7076
- },
7077
- { internalType: "uint256", name: "expiredAt", type: "uint256" },
7078
- {
7079
- internalType: "enum ACPTypes.MemoState",
7080
- name: "state",
7081
- type: "uint8"
7082
- }
7083
- ],
7084
- internalType: "struct ACPTypes.Memo",
7085
- name: "memo",
7086
- type: "tuple"
7087
- },
7088
- {
7089
- components: [
7090
- { internalType: "address", name: "token", type: "address" },
7091
- { internalType: "uint256", name: "amount", type: "uint256" },
7092
- { internalType: "address", name: "recipient", type: "address" },
7093
- { internalType: "uint256", name: "feeAmount", type: "uint256" },
7094
- {
7095
- internalType: "enum ACPTypes.FeeType",
7096
- name: "feeType",
7097
- type: "uint8"
7098
- },
7099
- { internalType: "bool", name: "isExecuted", type: "bool" },
7100
- { internalType: "uint256", name: "expiredAt", type: "uint256" },
7101
- { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
7102
- { internalType: "uint32", name: "lzDstEid", type: "uint32" }
7103
- ],
7104
- internalType: "struct ACPTypes.PayableDetails",
7105
- name: "details",
7106
- type: "tuple"
7107
- }
7108
- ],
7109
- stateMutability: "view",
7110
- type: "function"
7111
- },
7112
- {
7113
- inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7114
- name: "getPayableDetails",
7115
- outputs: [
7116
- {
7117
- components: [
7118
- { internalType: "address", name: "token", type: "address" },
7119
- { internalType: "uint256", name: "amount", type: "uint256" },
7120
- { internalType: "address", name: "recipient", type: "address" },
7121
- { internalType: "uint256", name: "feeAmount", type: "uint256" },
7122
- {
7123
- internalType: "enum ACPTypes.FeeType",
7124
- name: "feeType",
7125
- type: "uint8"
7126
- },
7127
- { internalType: "bool", name: "isExecuted", type: "bool" },
7128
- { internalType: "uint256", name: "expiredAt", type: "uint256" },
7129
- { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
7130
- { internalType: "uint32", name: "lzDstEid", type: "uint32" }
7131
- ],
7132
- internalType: "struct ACPTypes.PayableDetails",
7133
- name: "",
7134
- type: "tuple"
7135
- }
7136
- ],
7137
- stateMutability: "view",
7138
- type: "function"
7139
- },
7140
- {
7141
- inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }],
7142
- name: "getRoleAdmin",
7143
- outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
7144
- stateMutability: "view",
7145
- type: "function"
7146
- },
7147
- {
7148
- inputs: [
7149
- { internalType: "bytes32", name: "role", type: "bytes32" },
7150
- { internalType: "address", name: "account", type: "address" }
7151
- ],
7152
- name: "grantRole",
7153
- outputs: [],
7154
- stateMutability: "nonpayable",
7155
- type: "function"
7156
- },
7157
- {
7158
- inputs: [
7159
- { internalType: "bytes32", name: "role", type: "bytes32" },
7160
- { internalType: "address", name: "account", type: "address" }
7161
- ],
7162
- name: "hasRole",
7163
- outputs: [{ internalType: "bool", name: "", type: "bool" }],
7164
- stateMutability: "view",
7165
- type: "function"
7166
- },
7167
- {
7168
- inputs: [
7169
- { internalType: "address", name: "acpContract_", type: "address" },
7170
- { internalType: "address", name: "jobManager_", type: "address" },
7171
- { internalType: "address", name: "paymentManager_", type: "address" }
7172
- ],
7173
- name: "initialize",
7174
- outputs: [],
7175
- stateMutability: "nonpayable",
7176
- type: "function"
7177
- },
7178
- {
7179
- inputs: [
7180
- { internalType: "uint256", name: "jobId", type: "uint256" },
7181
- { internalType: "address", name: "user", type: "address" }
7182
- ],
7183
- name: "isJobEvaluator",
7184
- outputs: [{ internalType: "bool", name: "", type: "bool" }],
7185
- stateMutability: "view",
7186
- type: "function"
7187
- },
7188
- {
7189
- inputs: [
7190
- { internalType: "uint256", name: "memoId", type: "uint256" },
7191
- { internalType: "address", name: "user", type: "address" }
7192
- ],
7193
- name: "isMemoSigner",
7194
- outputs: [{ internalType: "bool", name: "", type: "bool" }],
7195
- stateMutability: "view",
7196
- type: "function"
7197
- },
7198
- {
7199
- inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7200
- name: "isPayable",
7201
- outputs: [{ internalType: "bool", name: "", type: "bool" }],
7202
- stateMutability: "view",
7203
- type: "function"
7204
- },
7205
- {
7206
- inputs: [],
7207
- name: "jobManager",
7208
- outputs: [{ internalType: "address", name: "", type: "address" }],
7209
- stateMutability: "view",
7210
- type: "function"
7211
- },
7212
- {
7213
- inputs: [
7214
- { internalType: "uint256", name: "", type: "uint256" },
7215
- { internalType: "uint256", name: "", type: "uint256" }
7216
- ],
7217
- name: "jobMemos",
7218
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7219
- stateMutability: "view",
7220
- type: "function"
7221
- },
7222
- {
7223
- inputs: [
7224
- { internalType: "uint256", name: "", type: "uint256" },
7225
- { internalType: "enum ACPTypes.JobPhase", name: "", type: "uint8" },
7226
- { internalType: "uint256", name: "", type: "uint256" }
7227
- ],
7228
- name: "jobMemosByPhase",
7229
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7230
- stateMutability: "view",
7231
- type: "function"
7232
- },
7233
- {
7234
- inputs: [
7235
- { internalType: "uint256", name: "", type: "uint256" },
7236
- { internalType: "enum ACPTypes.MemoType", name: "", type: "uint8" },
7237
- { internalType: "uint256", name: "", type: "uint256" }
7238
- ],
7239
- name: "jobMemosByType",
7240
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7241
- stateMutability: "view",
7242
- type: "function"
7243
- },
7244
- {
7245
- inputs: [
7246
- { internalType: "uint256", name: "", type: "uint256" },
7247
- { internalType: "address", name: "", type: "address" }
7248
- ],
7249
- name: "memoApprovals",
7250
- outputs: [{ internalType: "bool", name: "", type: "bool" }],
7251
- stateMutability: "view",
7252
- type: "function"
7253
- },
7254
- {
7255
- inputs: [],
7256
- name: "memoCounter",
7257
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7258
- stateMutability: "view",
7259
- type: "function"
7260
- },
7261
- {
7262
- inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7263
- name: "memos",
7264
- outputs: [
7265
- { internalType: "uint256", name: "id", type: "uint256" },
7266
- { internalType: "uint256", name: "jobId", type: "uint256" },
7267
- { internalType: "address", name: "sender", type: "address" },
7268
- { internalType: "string", name: "content", type: "string" },
7269
- {
7270
- internalType: "enum ACPTypes.MemoType",
7271
- name: "memoType",
7272
- type: "uint8"
7273
- },
7274
- { internalType: "uint256", name: "createdAt", type: "uint256" },
7275
- { internalType: "bool", name: "isApproved", type: "bool" },
7276
- { internalType: "address", name: "approvedBy", type: "address" },
7277
- { internalType: "uint256", name: "approvedAt", type: "uint256" },
7278
- { internalType: "bool", name: "requiresApproval", type: "bool" },
7279
- { internalType: "string", name: "metadata", type: "string" },
7280
- { internalType: "bool", name: "isSecured", type: "bool" },
7281
- {
7282
- internalType: "enum ACPTypes.JobPhase",
7283
- name: "nextPhase",
7284
- type: "uint8"
7285
- },
7286
- { internalType: "uint256", name: "expiredAt", type: "uint256" },
7287
- { internalType: "enum ACPTypes.MemoState", name: "state", type: "uint8" }
7288
- ],
7289
- stateMutability: "view",
7290
- type: "function"
7291
- },
7292
- {
7293
- inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7294
- name: "payableDetails",
7295
- outputs: [
7296
- { internalType: "address", name: "token", type: "address" },
7297
- { internalType: "uint256", name: "amount", type: "uint256" },
7298
- { internalType: "address", name: "recipient", type: "address" },
7299
- { internalType: "uint256", name: "feeAmount", type: "uint256" },
7300
- { internalType: "enum ACPTypes.FeeType", name: "feeType", type: "uint8" },
7301
- { internalType: "bool", name: "isExecuted", type: "bool" },
7302
- { internalType: "uint256", name: "expiredAt", type: "uint256" },
7303
- { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
7304
- { internalType: "uint32", name: "lzDstEid", type: "uint32" }
7305
- ],
7306
- stateMutability: "view",
7307
- type: "function"
7308
- },
7309
- {
7310
- inputs: [],
7311
- name: "paymentManager",
7312
- outputs: [{ internalType: "address", name: "", type: "address" }],
7313
- stateMutability: "view",
7314
- type: "function"
7315
- },
7316
- {
7317
- inputs: [],
7318
- name: "proxiableUUID",
7319
- outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
7320
- stateMutability: "view",
7321
- type: "function"
7322
- },
7323
- {
7324
- inputs: [
7325
- { internalType: "bytes32", name: "role", type: "bytes32" },
7326
- { internalType: "address", name: "callerConfirmation", type: "address" }
7327
- ],
7328
- name: "renounceRole",
7329
- outputs: [],
7330
- stateMutability: "nonpayable",
7331
- type: "function"
7332
- },
7333
- {
7334
- inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7335
- name: "requiredApprovals",
7336
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7337
- stateMutability: "view",
7338
- type: "function"
7339
- },
7340
- {
7341
- inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7342
- name: "requiresApproval",
7343
- outputs: [{ internalType: "bool", name: "", type: "bool" }],
7344
- stateMutability: "view",
7345
- type: "function"
7346
- },
7347
- {
7348
- inputs: [
7349
- { internalType: "bytes32", name: "role", type: "bytes32" },
7350
- { internalType: "address", name: "account", type: "address" }
7351
- ],
7352
- name: "revokeRole",
7353
- outputs: [],
7354
- stateMutability: "nonpayable",
7355
- type: "function"
7356
- },
7357
- {
7358
- inputs: [
7359
- {
7360
- internalType: "enum ACPTypes.MemoType",
7361
- name: "memoType",
7362
- type: "uint8"
7363
- },
7364
- { internalType: "uint256", name: "requiredApprovals_", type: "uint256" }
7365
- ],
7366
- name: "setApprovalRequirements",
7367
- outputs: [],
7368
- stateMutability: "nonpayable",
7369
- type: "function"
7370
- },
7371
- {
7372
- inputs: [
7373
- { internalType: "address", name: "assetManager_", type: "address" }
7374
- ],
7375
- name: "setAssetManager",
7376
- outputs: [],
7377
- stateMutability: "nonpayable",
7378
- type: "function"
7379
- },
7380
- {
7381
- inputs: [
7382
- { internalType: "uint256", name: "memoId", type: "uint256" },
7383
- { internalType: "address", name: "sender", type: "address" },
7384
- { internalType: "bool", name: "isApproved", type: "bool" },
7385
- { internalType: "string", name: "reason", type: "string" }
7386
- ],
7387
- name: "signMemo",
7388
- outputs: [{ internalType: "uint256", name: "jobId", type: "uint256" }],
7389
- stateMutability: "nonpayable",
7390
- type: "function"
7391
- },
7392
- {
7393
- inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
7394
- name: "supportsInterface",
7395
- outputs: [{ internalType: "bool", name: "", type: "bool" }],
7396
- stateMutability: "view",
7397
- type: "function"
7398
- },
7399
- {
7400
- inputs: [
7401
- { internalType: "address", name: "acpContract_", type: "address" },
7402
- { internalType: "address", name: "jobManager_", type: "address" },
7403
- { internalType: "address", name: "paymentManager_", type: "address" },
7404
- { internalType: "address", name: "assetManager_", type: "address" }
7405
- ],
7406
- name: "updateContracts",
7407
- outputs: [],
7408
- stateMutability: "nonpayable",
7409
- type: "function"
7410
- },
7411
- {
7412
- inputs: [
7413
- { internalType: "uint256", name: "memoId", type: "uint256" },
7414
- { internalType: "string", name: "newContent", type: "string" }
7415
- ],
7416
- name: "updateMemoContent",
7417
- outputs: [],
7418
- stateMutability: "nonpayable",
7419
- type: "function"
7420
- },
7421
- {
7422
- inputs: [
7423
- { internalType: "uint256", name: "memoId", type: "uint256" },
7424
- {
7425
- internalType: "enum ACPTypes.MemoState",
7426
- name: "newMemoState",
7427
- type: "uint8"
7428
- }
7429
- ],
7430
- name: "updateMemoState",
7431
- outputs: [],
7432
- stateMutability: "nonpayable",
7433
- type: "function"
7434
- },
7435
- {
7436
- inputs: [
7437
- { internalType: "address", name: "newImplementation", type: "address" },
7438
- { internalType: "bytes", name: "data", type: "bytes" }
7439
- ],
7440
- name: "upgradeToAndCall",
7441
- outputs: [],
7442
- stateMutability: "payable",
7443
- type: "function"
7444
- },
7445
- {
7446
- inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7447
- name: "withdrawEscrowedFunds",
7448
- outputs: [],
7449
- stateMutability: "nonpayable",
7450
- type: "function"
7451
- }
7452
- ];
7453
- var memoManagerAbi_default = MEMO_MANAGER_ABI;
7454
-
7455
- // src/contractClients/acpContractClientV2.ts
7456
- var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClient_default {
7457
- constructor(jobManagerAddress, memoManagerAddress, accountManagerAddress, agentWalletAddress, config = baseAcpConfigV2) {
7458
- super(agentWalletAddress, config);
7459
- this.jobManagerAddress = jobManagerAddress;
7460
- this.memoManagerAddress = memoManagerAddress;
7461
- this.accountManagerAddress = accountManagerAddress;
7462
- this.PRIORITY_FEE_MULTIPLIER = 2;
7463
- this.MAX_FEE_PER_GAS = 2e7;
7464
- this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
7465
- this.GAS_FEE_MULTIPLIER = 0.5;
7466
- this.RETRY_CONFIG = {
7467
- intervalMs: 200,
7468
- multiplier: 1.1,
7469
- maxRetries: 10
7470
- };
7471
- this._sessionKeyClients = {};
7472
- }
7473
- static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfigV2) {
7474
- const publicClients = {};
7475
- for (const chain of config.chains) {
7476
- publicClients[chain.chain.id] = createPublicClient4({
7477
- chain: chain.chain,
7478
- transport: http3(chain.rpcUrl)
7479
- });
7480
- }
7481
- const publicClient = createPublicClient4({
7482
- chain: config.chain,
7483
- transport: http3(config.rpcEndpoint)
7484
- });
7485
- const [jobManagerAddress, memoManagerAddress, accountManagerAddress] = await publicClient.multicall({
7486
- contracts: [
7487
- {
7488
- address: config.contractAddress,
7489
- abi: config.abi,
7490
- functionName: "jobManager"
7491
- },
7492
- {
7493
- address: config.contractAddress,
7494
- abi: config.abi,
7495
- functionName: "memoManager"
7496
- },
7497
- {
7498
- address: config.contractAddress,
7499
- abi: config.abi,
7500
- functionName: "accountManager"
7501
- }
7502
- ]
7503
- });
7504
- if (!jobManagerAddress || !memoManagerAddress || !accountManagerAddress) {
7505
- throw new acpError_default(
7506
- "Failed to get job manager, memo manager, or account manager address"
7507
- );
7508
- }
7509
- const acpContractClient = new _AcpContractClientV2(
7510
- jobManagerAddress.result,
7511
- memoManagerAddress.result,
7512
- accountManagerAddress.result,
7513
- agentWalletAddress,
7514
- config
7515
- );
7516
- acpContractClient.publicClients = publicClients;
7517
- await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
7518
- return acpContractClient;
7519
- }
7520
- async init(privateKey, sessionEntityKeyId) {
7521
- const sessionKeySigner = LocalAccountSigner2.privateKeyToAccountSigner(privateKey);
7522
- this._sessionKeyClient = await createModularAccountV2Client2({
7523
- chain: this.chain,
7524
- transport: alchemy2({
7525
- rpcUrl: this.config.alchemyRpcUrl
7526
- }),
7527
- signer: sessionKeySigner,
7528
- policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
7529
- accountAddress: this.agentWalletAddress,
7530
- signerEntity: {
7531
- entityId: sessionEntityKeyId,
7532
- isGlobalValidation: true
6041
+ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClient_default {
6042
+ constructor(jobManagerAddress, memoManagerAddress, accountManagerAddress, agentWalletAddress, config = baseAcpConfigV2) {
6043
+ super(agentWalletAddress, config);
6044
+ this.jobManagerAddress = jobManagerAddress;
6045
+ this.memoManagerAddress = memoManagerAddress;
6046
+ this.accountManagerAddress = accountManagerAddress;
6047
+ this.PRIORITY_FEE_MULTIPLIER = 2;
6048
+ this.MAX_FEE_PER_GAS = 2e7;
6049
+ this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
6050
+ this.GAS_FEE_MULTIPLIER = 0.5;
6051
+ this.RETRY_CONFIG = {
6052
+ intervalMs: 200,
6053
+ multiplier: 1.1,
6054
+ maxRetries: 10
6055
+ };
6056
+ }
6057
+ static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfigV2) {
6058
+ const publicClient = createPublicClient4({
6059
+ chain: config.chain,
6060
+ transport: http3(config.rpcEndpoint)
6061
+ });
6062
+ const [jobManagerAddress, memoManagerAddress, accountManagerAddress] = await publicClient.multicall({
6063
+ contracts: [
6064
+ {
6065
+ address: config.contractAddress,
6066
+ abi: config.abi,
6067
+ functionName: "jobManager"
6068
+ },
6069
+ {
6070
+ address: config.contractAddress,
6071
+ abi: config.abi,
6072
+ functionName: "memoManager"
6073
+ },
6074
+ {
6075
+ address: config.contractAddress,
6076
+ abi: config.abi,
6077
+ functionName: "accountManager"
6078
+ }
6079
+ ]
6080
+ });
6081
+ if (!jobManagerAddress || !memoManagerAddress || !accountManagerAddress) {
6082
+ throw new acpError_default(
6083
+ "Failed to get job manager, memo manager, or account manager address"
6084
+ );
6085
+ }
6086
+ const acpContractClient = new _AcpContractClientV2(
6087
+ jobManagerAddress.result,
6088
+ memoManagerAddress.result,
6089
+ accountManagerAddress.result,
6090
+ agentWalletAddress,
6091
+ config
6092
+ );
6093
+ await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
6094
+ return acpContractClient;
6095
+ }
6096
+ async init(privateKey, sessionEntityKeyId) {
6097
+ const sessionKeySigner = LocalAccountSigner2.privateKeyToAccountSigner(privateKey);
6098
+ this._sessionKeyClient = await createModularAccountV2Client2({
6099
+ chain: this.chain,
6100
+ transport: alchemy2({
6101
+ rpcUrl: this.config.alchemyRpcUrl
6102
+ }),
6103
+ signer: sessionKeySigner,
6104
+ policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
6105
+ accountAddress: this.agentWalletAddress,
6106
+ signerEntity: {
6107
+ entityId: sessionEntityKeyId,
6108
+ isGlobalValidation: true
7533
6109
  }
7534
6110
  });
7535
- for (const chain of this.config.chains) {
7536
- this._sessionKeyClients[chain.chain.id] = await createModularAccountV2Client2({
7537
- chain: chain.chain,
7538
- transport: alchemy2({
7539
- rpcUrl: `${this.config.alchemyRpcUrl}?chainId=${chain.chain.id}`
7540
- }),
7541
- signer: sessionKeySigner,
7542
- policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
7543
- accountAddress: this.agentWalletAddress,
7544
- signerEntity: {
7545
- entityId: sessionEntityKeyId,
7546
- isGlobalValidation: true
7547
- }
7548
- });
7549
- }
7550
6111
  this._acpX402 = new AcpX402(
7551
6112
  this.config,
7552
6113
  this.sessionKeyClient,
@@ -7591,20 +6152,11 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
7591
6152
  }
7592
6153
  return this._acpX402;
7593
6154
  }
7594
- async calculateGasFees(chainId) {
7595
- if (chainId) {
7596
- const { maxFeePerGas } = await this.publicClients[chainId].estimateFeesPerGas();
7597
- const increasedMaxFeePerGas = BigInt(maxFeePerGas) + BigInt(maxFeePerGas) * BigInt(this.GAS_FEE_MULTIPLIER * 100) / BigInt(100);
7598
- return increasedMaxFeePerGas;
7599
- }
6155
+ async calculateGasFees() {
7600
6156
  const finalMaxFeePerGas = BigInt(this.MAX_FEE_PER_GAS) + BigInt(this.MAX_PRIORITY_FEE_PER_GAS) * BigInt(Math.max(0, this.PRIORITY_FEE_MULTIPLIER - 1));
7601
6157
  return finalMaxFeePerGas;
7602
6158
  }
7603
- async handleOperation(operations, chainId) {
7604
- const sessionKeyClient = chainId ? this._sessionKeyClients[chainId] : this.sessionKeyClient;
7605
- if (!sessionKeyClient) {
7606
- throw new acpError_default("Session key client not initialized");
7607
- }
6159
+ async handleOperation(operations) {
7608
6160
  const basePayload = {
7609
6161
  uo: operations.map((operation) => ({
7610
6162
  target: operation.contractAddress,
@@ -7629,17 +6181,12 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
7629
6181
  }
7630
6182
  }
7631
6183
  };
7632
- const { hash } = await sessionKeyClient.sendUserOperation(payload);
7633
- const checkTransactionConfig = {
6184
+ const { hash } = await this.sessionKeyClient.sendUserOperation(payload);
6185
+ const txnHash = await this.sessionKeyClient.waitForUserOperationTransaction({
7634
6186
  hash,
6187
+ tag: "pending",
7635
6188
  retries: this.RETRY_CONFIG
7636
- };
7637
- if (!chainId || chainId === baseSepolia4.id || chainId === base4.id) {
7638
- checkTransactionConfig["tag"] = "pending";
7639
- }
7640
- const txnHash = await sessionKeyClient.waitForUserOperationTransaction(
7641
- checkTransactionConfig
7642
- );
6189
+ });
7643
6190
  return { userOpHash: hash, txnHash };
7644
6191
  } catch (error) {
7645
6192
  iteration++;
@@ -7702,16 +6249,12 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
7702
6249
  throw new acpError_default("Failed to get X402 payment details", error);
7703
6250
  }
7704
6251
  }
7705
- async getAssetManager() {
7706
- return await this.publicClient.readContract({
7707
- address: this.memoManagerAddress,
7708
- abi: memoManagerAbi_default,
7709
- functionName: "assetManager"
7710
- });
7711
- }
7712
6252
  getAcpVersion() {
7713
6253
  return "2";
7714
6254
  }
6255
+ async signTypedData(typedData) {
6256
+ return await this.sessionKeyClient.signTypedData({ typedData });
6257
+ }
7715
6258
  };
7716
6259
  var acpContractClientV2_default = AcpContractClientV2;
7717
6260
 
@@ -7719,6 +6262,7 @@ var acpContractClientV2_default = AcpContractClientV2;
7719
6262
  var index_default = acpClient_default;
7720
6263
  export {
7721
6264
  acpAbi_default as ACP_ABI,
6265
+ acpAgent_default as AcpAgent,
7722
6266
  AcpAgentSort,
7723
6267
  acpContractClient_default as AcpContractClient,
7724
6268
  acpContractClientV2_default as AcpContractClientV2,
@@ -7728,7 +6272,6 @@ export {
7728
6272
  acpJob_default as AcpJob,
7729
6273
  AcpJobPhases,
7730
6274
  acpMemo_default as AcpMemo,
7731
- AcpMemoState,
7732
6275
  AcpMemoStatus,
7733
6276
  AcpOnlineStatus,
7734
6277
  baseAcpContractClient_default as BaseAcpContractClient,
@@ -7736,15 +6279,12 @@ export {
7736
6279
  FareAmount,
7737
6280
  FareBigInt,
7738
6281
  MemoType,
7739
- PayloadType,
7740
- PositionDirection,
7741
6282
  baseAcpConfig,
7742
6283
  baseAcpConfigV2,
7743
6284
  baseAcpX402Config,
7744
6285
  baseAcpX402ConfigV2,
7745
6286
  baseSepoliaAcpConfig,
7746
6287
  baseSepoliaAcpConfigV2,
7747
- baseSepoliaAcpX402ConfigV2,
7748
6288
  index_default as default,
7749
6289
  ethFare,
7750
6290
  preparePayload,