@virtuals-protocol/acp-node 0.2.0-beta.7 → 0.2.0-beta.9
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.d.mts +251 -204
- package/dist/index.d.ts +251 -204
- package/dist/index.js +426 -103
- package/dist/index.mjs +408 -100
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -72,7 +72,7 @@ var require_package = __commonJS({
|
|
|
72
72
|
"package.json"(exports2, module2) {
|
|
73
73
|
module2.exports = {
|
|
74
74
|
name: "@virtuals-protocol/acp-node",
|
|
75
|
-
version: "0.2.0-beta.
|
|
75
|
+
version: "0.2.0-beta.9",
|
|
76
76
|
main: "./dist/index.js",
|
|
77
77
|
module: "./dist/index.mjs",
|
|
78
78
|
types: "./dist/index.d.ts",
|
|
@@ -108,17 +108,24 @@ __export(index_exports, {
|
|
|
108
108
|
ACP_ABI: () => acpAbi_default,
|
|
109
109
|
AcpAgentSort: () => AcpAgentSort,
|
|
110
110
|
AcpContractClient: () => acpContractClient_default,
|
|
111
|
+
AcpContractConfig: () => AcpContractConfig,
|
|
111
112
|
AcpGraduationStatus: () => AcpGraduationStatus,
|
|
112
113
|
AcpJob: () => acpJob_default,
|
|
113
114
|
AcpJobPhases: () => AcpJobPhases,
|
|
114
115
|
AcpMemo: () => acpMemo_default,
|
|
115
116
|
AcpMemoStatus: () => AcpMemoStatus,
|
|
116
117
|
AcpOnlineStatus: () => AcpOnlineStatus,
|
|
118
|
+
Fare: () => Fare,
|
|
119
|
+
FareAmount: () => FareAmount,
|
|
120
|
+
FareBigInt: () => FareBigInt,
|
|
117
121
|
MemoType: () => MemoType,
|
|
118
122
|
PayloadType: () => PayloadType,
|
|
123
|
+
PositionDirection: () => PositionDirection,
|
|
119
124
|
baseAcpConfig: () => baseAcpConfig,
|
|
120
125
|
baseSepoliaAcpConfig: () => baseSepoliaAcpConfig,
|
|
121
|
-
default: () => index_default
|
|
126
|
+
default: () => index_default,
|
|
127
|
+
ethFare: () => ethFare,
|
|
128
|
+
wethFare: () => wethFare
|
|
122
129
|
});
|
|
123
130
|
module.exports = __toCommonJS(index_exports);
|
|
124
131
|
|
|
@@ -1902,35 +1909,242 @@ var import_socket = require("socket.io-client");
|
|
|
1902
1909
|
var import_core = require("@aa-sdk/core");
|
|
1903
1910
|
var import_infra2 = require("@account-kit/infra");
|
|
1904
1911
|
var import_smart_contracts = require("@account-kit/smart-contracts");
|
|
1912
|
+
var import_viem2 = require("viem");
|
|
1905
1913
|
|
|
1906
|
-
// src/
|
|
1914
|
+
// src/acpConfigs.ts
|
|
1907
1915
|
var import_infra = require("@account-kit/infra");
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1916
|
+
|
|
1917
|
+
// src/acpFare.ts
|
|
1918
|
+
var import_viem = require("viem");
|
|
1919
|
+
var Fare = class {
|
|
1920
|
+
constructor(contractAddress, decimals) {
|
|
1921
|
+
this.contractAddress = contractAddress;
|
|
1922
|
+
this.decimals = decimals;
|
|
1923
|
+
}
|
|
1924
|
+
formatAmount(amount) {
|
|
1925
|
+
return (0, import_viem.parseUnits)(amount.toString(), this.decimals);
|
|
1926
|
+
}
|
|
1927
|
+
};
|
|
1928
|
+
var FareAmount = class _FareAmount {
|
|
1929
|
+
constructor(fareAmount, fare) {
|
|
1930
|
+
this.amount = fare.formatAmount(
|
|
1931
|
+
this.truncateTo6Decimals(fareAmount.toString())
|
|
1932
|
+
);
|
|
1933
|
+
this.fare = fare;
|
|
1934
|
+
}
|
|
1935
|
+
truncateTo6Decimals(input) {
|
|
1936
|
+
const [intPart, decPart = ""] = input.split(".");
|
|
1937
|
+
if (decPart === "") {
|
|
1938
|
+
return parseFloat(intPart);
|
|
1939
|
+
}
|
|
1940
|
+
const truncated = decPart.slice(0, 6).padEnd(6, "0");
|
|
1941
|
+
return parseFloat(`${intPart}.${truncated}`);
|
|
1942
|
+
}
|
|
1943
|
+
add(other) {
|
|
1944
|
+
if (this.fare.contractAddress !== other.fare.contractAddress) {
|
|
1945
|
+
throw new Error("Token addresses do not match");
|
|
1946
|
+
}
|
|
1947
|
+
return new _FareAmount(Number(this.amount + other.amount), this.fare);
|
|
1948
|
+
}
|
|
1918
1949
|
};
|
|
1919
|
-
var
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1950
|
+
var FareBigInt = class _FareBigInt {
|
|
1951
|
+
constructor(amount, fare) {
|
|
1952
|
+
this.amount = amount;
|
|
1953
|
+
this.fare = fare;
|
|
1954
|
+
}
|
|
1955
|
+
add(other) {
|
|
1956
|
+
if (this.fare.contractAddress !== other.fare.contractAddress) {
|
|
1957
|
+
throw new Error("Token addresses do not match");
|
|
1958
|
+
}
|
|
1959
|
+
return new _FareBigInt(this.amount + other.amount, this.fare);
|
|
1960
|
+
}
|
|
1961
|
+
};
|
|
1962
|
+
var wethFare = new Fare("0x4200000000000000000000000000000000000006", 18);
|
|
1963
|
+
var ethFare = new Fare(import_viem.ethAddress, 18);
|
|
1964
|
+
|
|
1965
|
+
// src/acpConfigs.ts
|
|
1966
|
+
var AcpContractConfig = class {
|
|
1967
|
+
constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, rpcEndpoint) {
|
|
1968
|
+
this.chain = chain;
|
|
1969
|
+
this.contractAddress = contractAddress;
|
|
1970
|
+
this.baseFare = baseFare;
|
|
1971
|
+
this.alchemyRpcUrl = alchemyRpcUrl;
|
|
1972
|
+
this.acpUrl = acpUrl;
|
|
1973
|
+
this.rpcEndpoint = rpcEndpoint;
|
|
1974
|
+
}
|
|
1929
1975
|
};
|
|
1976
|
+
var baseSepoliaAcpConfig = new AcpContractConfig(
|
|
1977
|
+
import_infra.baseSepolia,
|
|
1978
|
+
"0x8Db6B1c839Fc8f6bd35777E194677B67b4D51928",
|
|
1979
|
+
new Fare("0x036CbD53842c5426634e7929541eC2318f3dCF7e", 6),
|
|
1980
|
+
"https://alchemy-proxy.virtuals.io/api/proxy/rpc",
|
|
1981
|
+
"https://acpx.virtuals.gg"
|
|
1982
|
+
);
|
|
1983
|
+
var baseAcpConfig = new AcpContractConfig(
|
|
1984
|
+
import_infra.base,
|
|
1985
|
+
"0x6a1FE26D54ab0d3E1e3168f2e0c0cDa5cC0A0A4A",
|
|
1986
|
+
new Fare("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", 6),
|
|
1987
|
+
"https://alchemy-proxy-prod.virtuals.io/api/proxy/rpc",
|
|
1988
|
+
"https://acpx.virtuals.io"
|
|
1989
|
+
);
|
|
1990
|
+
|
|
1991
|
+
// src/wethAbi.ts
|
|
1992
|
+
var WETH_ABI = [
|
|
1993
|
+
{
|
|
1994
|
+
anonymous: false,
|
|
1995
|
+
inputs: [
|
|
1996
|
+
{ indexed: true, internalType: "address", name: "src", type: "address" },
|
|
1997
|
+
{ indexed: true, internalType: "address", name: "guy", type: "address" },
|
|
1998
|
+
{ indexed: false, internalType: "uint256", name: "wad", type: "uint256" }
|
|
1999
|
+
],
|
|
2000
|
+
name: "Approval",
|
|
2001
|
+
type: "event"
|
|
2002
|
+
},
|
|
2003
|
+
{
|
|
2004
|
+
anonymous: false,
|
|
2005
|
+
inputs: [
|
|
2006
|
+
{ indexed: true, internalType: "address", name: "dst", type: "address" },
|
|
2007
|
+
{ indexed: false, internalType: "uint256", name: "wad", type: "uint256" }
|
|
2008
|
+
],
|
|
2009
|
+
name: "Deposit",
|
|
2010
|
+
type: "event"
|
|
2011
|
+
},
|
|
2012
|
+
{
|
|
2013
|
+
anonymous: false,
|
|
2014
|
+
inputs: [
|
|
2015
|
+
{ indexed: true, internalType: "address", name: "src", type: "address" },
|
|
2016
|
+
{ indexed: true, internalType: "address", name: "dst", type: "address" },
|
|
2017
|
+
{ indexed: false, internalType: "uint256", name: "wad", type: "uint256" }
|
|
2018
|
+
],
|
|
2019
|
+
name: "Transfer",
|
|
2020
|
+
type: "event"
|
|
2021
|
+
},
|
|
2022
|
+
{
|
|
2023
|
+
anonymous: false,
|
|
2024
|
+
inputs: [
|
|
2025
|
+
{ indexed: true, internalType: "address", name: "src", type: "address" },
|
|
2026
|
+
{ indexed: false, internalType: "uint256", name: "wad", type: "uint256" }
|
|
2027
|
+
],
|
|
2028
|
+
name: "Withdrawal",
|
|
2029
|
+
type: "event"
|
|
2030
|
+
},
|
|
2031
|
+
{ payable: true, stateMutability: "payable", type: "fallback" },
|
|
2032
|
+
{
|
|
2033
|
+
constant: true,
|
|
2034
|
+
inputs: [
|
|
2035
|
+
{ internalType: "address", name: "", type: "address" },
|
|
2036
|
+
{ internalType: "address", name: "", type: "address" }
|
|
2037
|
+
],
|
|
2038
|
+
name: "allowance",
|
|
2039
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
2040
|
+
payable: false,
|
|
2041
|
+
stateMutability: "view",
|
|
2042
|
+
type: "function"
|
|
2043
|
+
},
|
|
2044
|
+
{
|
|
2045
|
+
constant: false,
|
|
2046
|
+
inputs: [
|
|
2047
|
+
{ internalType: "address", name: "guy", type: "address" },
|
|
2048
|
+
{ internalType: "uint256", name: "wad", type: "uint256" }
|
|
2049
|
+
],
|
|
2050
|
+
name: "approve",
|
|
2051
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
2052
|
+
payable: false,
|
|
2053
|
+
stateMutability: "nonpayable",
|
|
2054
|
+
type: "function"
|
|
2055
|
+
},
|
|
2056
|
+
{
|
|
2057
|
+
constant: true,
|
|
2058
|
+
inputs: [{ internalType: "address", name: "", type: "address" }],
|
|
2059
|
+
name: "balanceOf",
|
|
2060
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
2061
|
+
payable: false,
|
|
2062
|
+
stateMutability: "view",
|
|
2063
|
+
type: "function"
|
|
2064
|
+
},
|
|
2065
|
+
{
|
|
2066
|
+
constant: true,
|
|
2067
|
+
inputs: [],
|
|
2068
|
+
name: "decimals",
|
|
2069
|
+
outputs: [{ internalType: "uint8", name: "", type: "uint8" }],
|
|
2070
|
+
payable: false,
|
|
2071
|
+
stateMutability: "view",
|
|
2072
|
+
type: "function"
|
|
2073
|
+
},
|
|
2074
|
+
{
|
|
2075
|
+
constant: false,
|
|
2076
|
+
inputs: [],
|
|
2077
|
+
name: "deposit",
|
|
2078
|
+
outputs: [],
|
|
2079
|
+
payable: true,
|
|
2080
|
+
stateMutability: "payable",
|
|
2081
|
+
type: "function"
|
|
2082
|
+
},
|
|
2083
|
+
{
|
|
2084
|
+
constant: true,
|
|
2085
|
+
inputs: [],
|
|
2086
|
+
name: "name",
|
|
2087
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
2088
|
+
payable: false,
|
|
2089
|
+
stateMutability: "view",
|
|
2090
|
+
type: "function"
|
|
2091
|
+
},
|
|
2092
|
+
{
|
|
2093
|
+
constant: true,
|
|
2094
|
+
inputs: [],
|
|
2095
|
+
name: "symbol",
|
|
2096
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
2097
|
+
payable: false,
|
|
2098
|
+
stateMutability: "view",
|
|
2099
|
+
type: "function"
|
|
2100
|
+
},
|
|
2101
|
+
{
|
|
2102
|
+
constant: true,
|
|
2103
|
+
inputs: [],
|
|
2104
|
+
name: "totalSupply",
|
|
2105
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
2106
|
+
payable: false,
|
|
2107
|
+
stateMutability: "view",
|
|
2108
|
+
type: "function"
|
|
2109
|
+
},
|
|
2110
|
+
{
|
|
2111
|
+
constant: false,
|
|
2112
|
+
inputs: [
|
|
2113
|
+
{ internalType: "address", name: "dst", type: "address" },
|
|
2114
|
+
{ internalType: "uint256", name: "wad", type: "uint256" }
|
|
2115
|
+
],
|
|
2116
|
+
name: "transfer",
|
|
2117
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
2118
|
+
payable: false,
|
|
2119
|
+
stateMutability: "nonpayable",
|
|
2120
|
+
type: "function"
|
|
2121
|
+
},
|
|
2122
|
+
{
|
|
2123
|
+
constant: false,
|
|
2124
|
+
inputs: [
|
|
2125
|
+
{ internalType: "address", name: "src", type: "address" },
|
|
2126
|
+
{ internalType: "address", name: "dst", type: "address" },
|
|
2127
|
+
{ internalType: "uint256", name: "wad", type: "uint256" }
|
|
2128
|
+
],
|
|
2129
|
+
name: "transferFrom",
|
|
2130
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
2131
|
+
payable: false,
|
|
2132
|
+
stateMutability: "nonpayable",
|
|
2133
|
+
type: "function"
|
|
2134
|
+
},
|
|
2135
|
+
{
|
|
2136
|
+
constant: false,
|
|
2137
|
+
inputs: [{ internalType: "uint256", name: "wad", type: "uint256" }],
|
|
2138
|
+
name: "withdraw",
|
|
2139
|
+
outputs: [],
|
|
2140
|
+
payable: false,
|
|
2141
|
+
stateMutability: "nonpayable",
|
|
2142
|
+
type: "function"
|
|
2143
|
+
}
|
|
2144
|
+
];
|
|
2145
|
+
var wethAbi_default = WETH_ABI;
|
|
1930
2146
|
|
|
1931
2147
|
// src/acpContractClient.ts
|
|
1932
|
-
var import_viem = require("viem");
|
|
1933
|
-
var import_op_stack = require("viem/op-stack");
|
|
1934
2148
|
var MemoType = /* @__PURE__ */ ((MemoType2) => {
|
|
1935
2149
|
MemoType2[MemoType2["MESSAGE"] = 0] = "MESSAGE";
|
|
1936
2150
|
MemoType2[MemoType2["CONTEXT_URL"] = 1] = "CONTEXT_URL";
|
|
@@ -1954,30 +2168,26 @@ var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases2) => {
|
|
|
1954
2168
|
return AcpJobPhases2;
|
|
1955
2169
|
})(AcpJobPhases || {});
|
|
1956
2170
|
var AcpContractClient = class _AcpContractClient {
|
|
1957
|
-
|
|
2171
|
+
// private paymentTokenAddress: Address;
|
|
2172
|
+
constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
|
|
1958
2173
|
this.walletPrivateKey = walletPrivateKey;
|
|
1959
2174
|
this.sessionEntityKeyId = sessionEntityKeyId;
|
|
1960
2175
|
this.agentWalletAddress = agentWalletAddress;
|
|
1961
2176
|
this.config = config;
|
|
1962
|
-
this.customRpcUrl = customRpcUrl;
|
|
1963
2177
|
this.MAX_RETRIES = 3;
|
|
2178
|
+
this.PRIORITY_FEE_MULTIPLIER = 2;
|
|
2179
|
+
this.MAX_FEE_PER_GAS = 2e7;
|
|
2180
|
+
this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
|
|
1964
2181
|
this.chain = config.chain;
|
|
1965
2182
|
this.contractAddress = config.contractAddress;
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
this
|
|
1969
|
-
chain: this.chain,
|
|
1970
|
-
transport: this.customRpcUrl ? (0, import_viem.http)(this.customRpcUrl) : (0, import_viem.http)()
|
|
1971
|
-
}).extend((0, import_op_stack.publicActionsL2)());
|
|
1972
|
-
}
|
|
1973
|
-
static build(_0, _1, _2, _3) {
|
|
1974
|
-
return __async(this, arguments, function* (walletPrivateKey, sessionEntityKeyId, agentWalletAddress, customRpcUrl, config = baseAcpConfig) {
|
|
2183
|
+
}
|
|
2184
|
+
static build(_0, _1, _2) {
|
|
2185
|
+
return __async(this, arguments, function* (walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
|
|
1975
2186
|
const acpContractClient = new _AcpContractClient(
|
|
1976
2187
|
walletPrivateKey,
|
|
1977
2188
|
sessionEntityKeyId,
|
|
1978
2189
|
agentWalletAddress,
|
|
1979
|
-
config
|
|
1980
|
-
customRpcUrl
|
|
2190
|
+
config
|
|
1981
2191
|
);
|
|
1982
2192
|
yield acpContractClient.init();
|
|
1983
2193
|
return acpContractClient;
|
|
@@ -2012,21 +2222,17 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
2012
2222
|
}
|
|
2013
2223
|
calculateGasFees() {
|
|
2014
2224
|
return __async(this, null, function* () {
|
|
2015
|
-
const
|
|
2016
|
-
let finalMaxFeePerGas = maxFeePerGas;
|
|
2017
|
-
let priorityFeeMultiplier = Number(this.config.priorityFeeMultiplier) || 2;
|
|
2018
|
-
const overrideMaxFeePerGas = this.config.maxFeePerGas || maxFeePerGas;
|
|
2019
|
-
const overrideMaxPriorityFeePerGas = this.config.maxPriorityFeePerGas || maxPriorityFeePerGas;
|
|
2020
|
-
finalMaxFeePerGas = BigInt(overrideMaxFeePerGas) + BigInt(overrideMaxPriorityFeePerGas) * BigInt(Math.max(0, priorityFeeMultiplier - 1));
|
|
2225
|
+
const finalMaxFeePerGas = BigInt(this.MAX_FEE_PER_GAS) + BigInt(this.MAX_PRIORITY_FEE_PER_GAS) * BigInt(Math.max(0, this.PRIORITY_FEE_MULTIPLIER - 1));
|
|
2021
2226
|
return finalMaxFeePerGas;
|
|
2022
2227
|
});
|
|
2023
2228
|
}
|
|
2024
2229
|
handleSendUserOperation(_0) {
|
|
2025
|
-
return __async(this, arguments, function* (data, contractAddress = this.contractAddress) {
|
|
2230
|
+
return __async(this, arguments, function* (data, contractAddress = this.contractAddress, value) {
|
|
2026
2231
|
const payload = {
|
|
2027
2232
|
uo: {
|
|
2028
2233
|
target: contractAddress,
|
|
2029
|
-
data
|
|
2234
|
+
data,
|
|
2235
|
+
value
|
|
2030
2236
|
},
|
|
2031
2237
|
overrides: {}
|
|
2032
2238
|
};
|
|
@@ -2070,16 +2276,13 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
2070
2276
|
if (!contractLogs) {
|
|
2071
2277
|
throw new Error("Failed to get contract logs");
|
|
2072
2278
|
}
|
|
2073
|
-
return (0,
|
|
2279
|
+
return (0, import_viem2.fromHex)(contractLogs.data, "number");
|
|
2074
2280
|
});
|
|
2075
2281
|
}
|
|
2076
|
-
formatAmount(amount) {
|
|
2077
|
-
return (0, import_viem.parseUnits)(amount.toString(), this.config.paymentTokenDecimals);
|
|
2078
|
-
}
|
|
2079
2282
|
createJob(providerAddress, evaluatorAddress, expireAt) {
|
|
2080
2283
|
return __async(this, null, function* () {
|
|
2081
2284
|
try {
|
|
2082
|
-
const data = (0,
|
|
2285
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
2083
2286
|
abi: acpAbi_default,
|
|
2084
2287
|
functionName: "createJob",
|
|
2085
2288
|
args: [
|
|
@@ -2098,12 +2301,12 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
2098
2301
|
});
|
|
2099
2302
|
}
|
|
2100
2303
|
approveAllowance(_0) {
|
|
2101
|
-
return __async(this, arguments, function* (
|
|
2304
|
+
return __async(this, arguments, function* (amountBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress) {
|
|
2102
2305
|
try {
|
|
2103
|
-
const data = (0,
|
|
2104
|
-
abi:
|
|
2306
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
2307
|
+
abi: import_viem2.erc20Abi,
|
|
2105
2308
|
functionName: "approve",
|
|
2106
|
-
args: [this.contractAddress,
|
|
2309
|
+
args: [this.contractAddress, amountBaseUnit]
|
|
2107
2310
|
});
|
|
2108
2311
|
return yield this.handleSendUserOperation(data, paymentTokenAddress);
|
|
2109
2312
|
} catch (error) {
|
|
@@ -2113,20 +2316,20 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
2113
2316
|
});
|
|
2114
2317
|
}
|
|
2115
2318
|
createPayableMemo(_0, _1, _2, _3, _4, _5, _6, _7, _8) {
|
|
2116
|
-
return __async(this, arguments, function* (jobId, content,
|
|
2319
|
+
return __async(this, arguments, function* (jobId, content, amountBaseUnit, recipient, feeAmountBaseUnit, feeType, nextPhase, type, expiredAt, token = this.config.baseFare.contractAddress) {
|
|
2117
2320
|
let retries = 3;
|
|
2118
2321
|
while (retries > 0) {
|
|
2119
2322
|
try {
|
|
2120
|
-
const data = (0,
|
|
2323
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
2121
2324
|
abi: acpAbi_default,
|
|
2122
2325
|
functionName: "createPayableMemo",
|
|
2123
2326
|
args: [
|
|
2124
2327
|
jobId,
|
|
2125
2328
|
content,
|
|
2126
2329
|
token,
|
|
2127
|
-
|
|
2330
|
+
amountBaseUnit,
|
|
2128
2331
|
recipient,
|
|
2129
|
-
|
|
2332
|
+
feeAmountBaseUnit,
|
|
2130
2333
|
feeType,
|
|
2131
2334
|
type,
|
|
2132
2335
|
nextPhase,
|
|
@@ -2157,7 +2360,7 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
2157
2360
|
createMemo(jobId, content, type, isSecured, nextPhase) {
|
|
2158
2361
|
return __async(this, null, function* () {
|
|
2159
2362
|
try {
|
|
2160
|
-
const data = (0,
|
|
2363
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
2161
2364
|
abi: acpAbi_default,
|
|
2162
2365
|
functionName: "createMemo",
|
|
2163
2366
|
args: [jobId, content, type, isSecured, nextPhase]
|
|
@@ -2181,7 +2384,7 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
2181
2384
|
if (!contractLogs) {
|
|
2182
2385
|
throw new Error("Failed to get contract logs");
|
|
2183
2386
|
}
|
|
2184
|
-
const decoded = (0,
|
|
2387
|
+
const decoded = (0, import_viem2.decodeEventLog)({
|
|
2185
2388
|
abi: acpAbi_default,
|
|
2186
2389
|
data: contractLogs.data,
|
|
2187
2390
|
topics: contractLogs.topics
|
|
@@ -2195,7 +2398,7 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
2195
2398
|
signMemo(memoId, isApproved, reason) {
|
|
2196
2399
|
return __async(this, null, function* () {
|
|
2197
2400
|
try {
|
|
2198
|
-
const data = (0,
|
|
2401
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
2199
2402
|
abi: acpAbi_default,
|
|
2200
2403
|
functionName: "signMemo",
|
|
2201
2404
|
args: [memoId, isApproved, reason]
|
|
@@ -2207,13 +2410,13 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
2207
2410
|
}
|
|
2208
2411
|
});
|
|
2209
2412
|
}
|
|
2210
|
-
setBudget(jobId,
|
|
2413
|
+
setBudget(jobId, budgetBaseUnit) {
|
|
2211
2414
|
return __async(this, null, function* () {
|
|
2212
2415
|
try {
|
|
2213
|
-
const data = (0,
|
|
2416
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
2214
2417
|
abi: acpAbi_default,
|
|
2215
2418
|
functionName: "setBudget",
|
|
2216
|
-
args: [jobId,
|
|
2419
|
+
args: [jobId, budgetBaseUnit]
|
|
2217
2420
|
});
|
|
2218
2421
|
return yield this.handleSendUserOperation(data);
|
|
2219
2422
|
} catch (error) {
|
|
@@ -2223,12 +2426,12 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
2223
2426
|
});
|
|
2224
2427
|
}
|
|
2225
2428
|
setBudgetWithPaymentToken(_0, _1) {
|
|
2226
|
-
return __async(this, arguments, function* (jobId,
|
|
2429
|
+
return __async(this, arguments, function* (jobId, budgetBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress) {
|
|
2227
2430
|
try {
|
|
2228
|
-
const data = (0,
|
|
2431
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
2229
2432
|
abi: acpAbi_default,
|
|
2230
2433
|
functionName: "setBudgetWithPaymentToken",
|
|
2231
|
-
args: [jobId,
|
|
2434
|
+
args: [jobId, budgetBaseUnit, paymentTokenAddress]
|
|
2232
2435
|
});
|
|
2233
2436
|
return yield this.handleSendUserOperation(data);
|
|
2234
2437
|
} catch (error) {
|
|
@@ -2237,6 +2440,24 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
2237
2440
|
}
|
|
2238
2441
|
});
|
|
2239
2442
|
}
|
|
2443
|
+
wrapEth(amountBaseUnit) {
|
|
2444
|
+
return __async(this, null, function* () {
|
|
2445
|
+
try {
|
|
2446
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
2447
|
+
abi: wethAbi_default,
|
|
2448
|
+
functionName: "deposit"
|
|
2449
|
+
});
|
|
2450
|
+
return yield this.handleSendUserOperation(
|
|
2451
|
+
data,
|
|
2452
|
+
wethFare.contractAddress,
|
|
2453
|
+
amountBaseUnit
|
|
2454
|
+
);
|
|
2455
|
+
} catch (error) {
|
|
2456
|
+
console.error(`Failed to wrap eth ${error}`);
|
|
2457
|
+
throw new Error("Failed to wrap eth");
|
|
2458
|
+
}
|
|
2459
|
+
});
|
|
2460
|
+
}
|
|
2240
2461
|
};
|
|
2241
2462
|
var acpContractClient_default = AcpContractClient;
|
|
2242
2463
|
|
|
@@ -2269,6 +2490,8 @@ var AcpOnlineStatus = /* @__PURE__ */ ((AcpOnlineStatus2) => {
|
|
|
2269
2490
|
var PayloadType = /* @__PURE__ */ ((PayloadType2) => {
|
|
2270
2491
|
PayloadType2["FUND_RESPONSE"] = "fund_response";
|
|
2271
2492
|
PayloadType2["OPEN_POSITION"] = "open_position";
|
|
2493
|
+
PayloadType2["SWAP_TOKEN"] = "swap_token";
|
|
2494
|
+
PayloadType2["RESPONSE_SWAP_TOKEN"] = "response_swap_token";
|
|
2272
2495
|
PayloadType2["CLOSE_PARTIAL_POSITION"] = "close_partial_position";
|
|
2273
2496
|
PayloadType2["CLOSE_POSITION"] = "close_position";
|
|
2274
2497
|
PayloadType2["POSITION_FULFILLED"] = "position_fulfilled";
|
|
@@ -2276,6 +2499,11 @@ var PayloadType = /* @__PURE__ */ ((PayloadType2) => {
|
|
|
2276
2499
|
PayloadType2["UNFULFILLED_POSITION"] = "unfulfilled_position";
|
|
2277
2500
|
return PayloadType2;
|
|
2278
2501
|
})(PayloadType || {});
|
|
2502
|
+
var PositionDirection = /* @__PURE__ */ ((PositionDirection2) => {
|
|
2503
|
+
PositionDirection2["LONG"] = "long";
|
|
2504
|
+
PositionDirection2["SHORT"] = "short";
|
|
2505
|
+
return PositionDirection2;
|
|
2506
|
+
})(PositionDirection || {});
|
|
2279
2507
|
|
|
2280
2508
|
// src/utils.ts
|
|
2281
2509
|
function tryParseJson(content) {
|
|
@@ -2299,6 +2527,7 @@ var AcpJob = class {
|
|
|
2299
2527
|
this.memos = memos;
|
|
2300
2528
|
this.phase = phase;
|
|
2301
2529
|
this.context = context;
|
|
2530
|
+
this.baseFare = acpClient.acpContractClient.config.baseFare;
|
|
2302
2531
|
}
|
|
2303
2532
|
get serviceRequirement() {
|
|
2304
2533
|
var _a;
|
|
@@ -2352,7 +2581,12 @@ var AcpJob = class {
|
|
|
2352
2581
|
if (!memo) {
|
|
2353
2582
|
throw new Error("No transaction memo found");
|
|
2354
2583
|
}
|
|
2355
|
-
return yield this.acpClient.payJob(
|
|
2584
|
+
return yield this.acpClient.payJob(
|
|
2585
|
+
this.id,
|
|
2586
|
+
this.baseFare.formatAmount(amount),
|
|
2587
|
+
memo.id,
|
|
2588
|
+
reason
|
|
2589
|
+
);
|
|
2356
2590
|
});
|
|
2357
2591
|
}
|
|
2358
2592
|
respond(accept, payload, reason) {
|
|
@@ -2397,11 +2631,12 @@ var AcpJob = class {
|
|
|
2397
2631
|
if (payload.length === 0) {
|
|
2398
2632
|
throw new Error("No positions to open");
|
|
2399
2633
|
}
|
|
2634
|
+
const sumAmount = payload.reduce((acc, curr) => acc + curr.amount, 0);
|
|
2400
2635
|
return yield this.acpClient.transferFunds(
|
|
2401
2636
|
this.id,
|
|
2402
|
-
|
|
2637
|
+
new FareAmount(sumAmount, this.baseFare),
|
|
2403
2638
|
walletAddress || this.providerAddress,
|
|
2404
|
-
feeAmount,
|
|
2639
|
+
new FareAmount(feeAmount, this.baseFare),
|
|
2405
2640
|
1 /* IMMEDIATE_FEE */,
|
|
2406
2641
|
{
|
|
2407
2642
|
type: "open_position" /* OPEN_POSITION */,
|
|
@@ -2412,6 +2647,55 @@ var AcpJob = class {
|
|
|
2412
2647
|
);
|
|
2413
2648
|
});
|
|
2414
2649
|
}
|
|
2650
|
+
swapToken(payload, decimals, feeAmount, walletAddress) {
|
|
2651
|
+
return __async(this, null, function* () {
|
|
2652
|
+
return yield this.acpClient.transferFunds(
|
|
2653
|
+
this.id,
|
|
2654
|
+
new FareAmount(
|
|
2655
|
+
payload.amount,
|
|
2656
|
+
new Fare(payload.fromContractAddress, decimals)
|
|
2657
|
+
),
|
|
2658
|
+
walletAddress || this.providerAddress,
|
|
2659
|
+
new FareAmount(feeAmount, this.baseFare),
|
|
2660
|
+
1 /* IMMEDIATE_FEE */,
|
|
2661
|
+
{
|
|
2662
|
+
type: "swap_token" /* SWAP_TOKEN */,
|
|
2663
|
+
data: payload
|
|
2664
|
+
},
|
|
2665
|
+
2 /* TRANSACTION */,
|
|
2666
|
+
new Date(Date.now() + 1e3 * 60 * 30)
|
|
2667
|
+
);
|
|
2668
|
+
});
|
|
2669
|
+
}
|
|
2670
|
+
responseSwapToken(memoId, accept, reason) {
|
|
2671
|
+
return __async(this, null, function* () {
|
|
2672
|
+
const memo = this.memos.find((m) => m.id === memoId);
|
|
2673
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
|
|
2674
|
+
throw new Error("No swap token memo found");
|
|
2675
|
+
}
|
|
2676
|
+
const payload = tryParseJson(
|
|
2677
|
+
memo.content
|
|
2678
|
+
);
|
|
2679
|
+
if ((payload == null ? void 0 : payload.type) !== "swap_token" /* SWAP_TOKEN */) {
|
|
2680
|
+
throw new Error("Invalid swap token memo");
|
|
2681
|
+
}
|
|
2682
|
+
return yield memo.sign(accept, reason);
|
|
2683
|
+
});
|
|
2684
|
+
}
|
|
2685
|
+
transferFunds(_0, _1, _2) {
|
|
2686
|
+
return __async(this, arguments, function* (payload, fareAmount, walletAddress, expiredAt = new Date(Date.now() + 1e3 * 60 * 30)) {
|
|
2687
|
+
return yield this.acpClient.transferFunds(
|
|
2688
|
+
this.id,
|
|
2689
|
+
fareAmount,
|
|
2690
|
+
walletAddress || this.clientAddress,
|
|
2691
|
+
new FareAmount(0, this.baseFare),
|
|
2692
|
+
0 /* NO_FEE */,
|
|
2693
|
+
payload,
|
|
2694
|
+
2 /* TRANSACTION */,
|
|
2695
|
+
expiredAt
|
|
2696
|
+
);
|
|
2697
|
+
});
|
|
2698
|
+
}
|
|
2415
2699
|
responseOpenPosition(memoId, accept, reason) {
|
|
2416
2700
|
return __async(this, null, function* () {
|
|
2417
2701
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
@@ -2431,9 +2715,9 @@ var AcpJob = class {
|
|
|
2431
2715
|
return __async(this, arguments, function* (payload, expireAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
2432
2716
|
return yield this.acpClient.requestFunds(
|
|
2433
2717
|
this.id,
|
|
2434
|
-
payload.amount,
|
|
2718
|
+
new FareAmount(payload.amount, this.baseFare),
|
|
2435
2719
|
this.clientAddress,
|
|
2436
|
-
0,
|
|
2720
|
+
new FareAmount(0, this.baseFare),
|
|
2437
2721
|
0 /* NO_FEE */,
|
|
2438
2722
|
{
|
|
2439
2723
|
type: "close_partial_position" /* CLOSE_PARTIAL_POSITION */,
|
|
@@ -2459,7 +2743,7 @@ var AcpJob = class {
|
|
|
2459
2743
|
return yield this.acpClient.responseFundsRequest(
|
|
2460
2744
|
memo.id,
|
|
2461
2745
|
accept,
|
|
2462
|
-
payload.data.amount,
|
|
2746
|
+
this.baseFare.formatAmount(payload.data.amount),
|
|
2463
2747
|
reason
|
|
2464
2748
|
);
|
|
2465
2749
|
});
|
|
@@ -2490,9 +2774,9 @@ var AcpJob = class {
|
|
|
2490
2774
|
if (accept) {
|
|
2491
2775
|
return yield this.acpClient.transferFunds(
|
|
2492
2776
|
this.id,
|
|
2493
|
-
payload.amount,
|
|
2777
|
+
new FareAmount(payload.amount, this.baseFare),
|
|
2494
2778
|
this.clientAddress,
|
|
2495
|
-
0,
|
|
2779
|
+
new FareAmount(0, this.baseFare),
|
|
2496
2780
|
0 /* NO_FEE */,
|
|
2497
2781
|
{
|
|
2498
2782
|
type: "close_position" /* CLOSE_POSITION */,
|
|
@@ -2523,9 +2807,9 @@ var AcpJob = class {
|
|
|
2523
2807
|
return __async(this, arguments, function* (payload, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
2524
2808
|
return yield this.acpClient.transferFunds(
|
|
2525
2809
|
this.id,
|
|
2526
|
-
payload.amount,
|
|
2810
|
+
new FareAmount(payload.amount, this.baseFare),
|
|
2527
2811
|
this.clientAddress,
|
|
2528
|
-
0,
|
|
2812
|
+
new FareAmount(0, this.baseFare),
|
|
2529
2813
|
0 /* NO_FEE */,
|
|
2530
2814
|
{
|
|
2531
2815
|
type: "position_fulfilled" /* POSITION_FULFILLED */,
|
|
@@ -2540,9 +2824,9 @@ var AcpJob = class {
|
|
|
2540
2824
|
return __async(this, arguments, function* (payload, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
2541
2825
|
return yield this.acpClient.transferFunds(
|
|
2542
2826
|
this.id,
|
|
2543
|
-
payload.amount,
|
|
2827
|
+
new FareAmount(payload.amount, this.baseFare),
|
|
2544
2828
|
this.clientAddress,
|
|
2545
|
-
0,
|
|
2829
|
+
new FareAmount(0, this.baseFare),
|
|
2546
2830
|
0 /* NO_FEE */,
|
|
2547
2831
|
{
|
|
2548
2832
|
type: "unfulfilled_position" /* UNFULFILLED_POSITION */,
|
|
@@ -2629,9 +2913,9 @@ var AcpJob = class {
|
|
|
2629
2913
|
}
|
|
2630
2914
|
return yield this.acpClient.transferFunds(
|
|
2631
2915
|
this.id,
|
|
2632
|
-
|
|
2916
|
+
new FareAmount(totalAmount, this.baseFare),
|
|
2633
2917
|
this.clientAddress,
|
|
2634
|
-
0,
|
|
2918
|
+
new FareAmount(0, this.baseFare),
|
|
2635
2919
|
0 /* NO_FEE */,
|
|
2636
2920
|
{
|
|
2637
2921
|
type: "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */,
|
|
@@ -2672,6 +2956,10 @@ var AcpMemo = class {
|
|
|
2672
2956
|
this.signedReason = signedReason;
|
|
2673
2957
|
this.expiry = expiry;
|
|
2674
2958
|
this.payableDetails = payableDetails;
|
|
2959
|
+
if (this.payableDetails) {
|
|
2960
|
+
this.payableDetails.amount = BigInt(this.payableDetails.amount);
|
|
2961
|
+
this.payableDetails.feeAmount = BigInt(this.payableDetails.feeAmount);
|
|
2962
|
+
}
|
|
2675
2963
|
this.structuredContent = tryParseJson(this.content) || void 0;
|
|
2676
2964
|
}
|
|
2677
2965
|
get payloadType() {
|
|
@@ -2739,7 +3027,10 @@ var AcpJobOffering = class {
|
|
|
2739
3027
|
return yield this.acpClient.initiateJob(
|
|
2740
3028
|
this.providerAddress,
|
|
2741
3029
|
finalServiceRequirement,
|
|
2742
|
-
|
|
3030
|
+
new FareAmount(
|
|
3031
|
+
this.price,
|
|
3032
|
+
this.acpClient.acpContractClient.config.baseFare
|
|
3033
|
+
),
|
|
2743
3034
|
evaluatorAddress,
|
|
2744
3035
|
expiredAt
|
|
2745
3036
|
);
|
|
@@ -2907,13 +3198,22 @@ var AcpClient = class {
|
|
|
2907
3198
|
});
|
|
2908
3199
|
}
|
|
2909
3200
|
initiateJob(_0, _1, _2, _3) {
|
|
2910
|
-
return __async(this, arguments, function* (providerAddress, serviceRequirement,
|
|
3201
|
+
return __async(this, arguments, function* (providerAddress, serviceRequirement, fareAmount, evaluatorAddress, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
3202
|
+
if (providerAddress === this.acpContractClient.walletAddress) {
|
|
3203
|
+
throw new Error(
|
|
3204
|
+
"Provider address cannot be the same as the client address"
|
|
3205
|
+
);
|
|
3206
|
+
}
|
|
2911
3207
|
const { jobId } = yield this.acpContractClient.createJob(
|
|
2912
3208
|
providerAddress,
|
|
2913
3209
|
evaluatorAddress || this.acpContractClient.walletAddress,
|
|
2914
3210
|
expiredAt
|
|
2915
3211
|
);
|
|
2916
|
-
yield this.acpContractClient.setBudgetWithPaymentToken(
|
|
3212
|
+
yield this.acpContractClient.setBudgetWithPaymentToken(
|
|
3213
|
+
jobId,
|
|
3214
|
+
fareAmount.amount,
|
|
3215
|
+
fareAmount.fare.contractAddress
|
|
3216
|
+
);
|
|
2917
3217
|
yield this.acpContractClient.createMemo(
|
|
2918
3218
|
jobId,
|
|
2919
3219
|
typeof serviceRequirement === "string" ? serviceRequirement : JSON.stringify(serviceRequirement),
|
|
@@ -2939,29 +3239,29 @@ var AcpClient = class {
|
|
|
2939
3239
|
);
|
|
2940
3240
|
});
|
|
2941
3241
|
}
|
|
2942
|
-
payJob(jobId,
|
|
3242
|
+
payJob(jobId, amountBaseUnit, memoId, reason) {
|
|
2943
3243
|
return __async(this, null, function* () {
|
|
2944
|
-
if (
|
|
2945
|
-
yield this.acpContractClient.approveAllowance(
|
|
3244
|
+
if (amountBaseUnit > BigInt(0)) {
|
|
3245
|
+
yield this.acpContractClient.approveAllowance(amountBaseUnit);
|
|
2946
3246
|
}
|
|
2947
3247
|
yield this.acpContractClient.signMemo(memoId, true, reason);
|
|
2948
3248
|
return yield this.acpContractClient.createMemo(
|
|
2949
3249
|
jobId,
|
|
2950
|
-
`Payment
|
|
3250
|
+
`Payment made. ${reason != null ? reason : ""}`,
|
|
2951
3251
|
0 /* MESSAGE */,
|
|
2952
3252
|
false,
|
|
2953
3253
|
3 /* EVALUATION */
|
|
2954
3254
|
);
|
|
2955
3255
|
});
|
|
2956
3256
|
}
|
|
2957
|
-
requestFunds(jobId,
|
|
3257
|
+
requestFunds(jobId, transferFareAmount, recipient, feeFareAmount, feeType, reason, nextPhase, expiredAt) {
|
|
2958
3258
|
return __async(this, null, function* () {
|
|
2959
3259
|
return yield this.acpContractClient.createPayableMemo(
|
|
2960
3260
|
jobId,
|
|
2961
3261
|
JSON.stringify(reason),
|
|
2962
|
-
amount,
|
|
3262
|
+
transferFareAmount.amount,
|
|
2963
3263
|
recipient,
|
|
2964
|
-
|
|
3264
|
+
feeFareAmount.amount,
|
|
2965
3265
|
feeType,
|
|
2966
3266
|
nextPhase,
|
|
2967
3267
|
6 /* PAYABLE_REQUEST */,
|
|
@@ -2969,33 +3269,49 @@ var AcpClient = class {
|
|
|
2969
3269
|
);
|
|
2970
3270
|
});
|
|
2971
3271
|
}
|
|
2972
|
-
responseFundsRequest(memoId, accept,
|
|
3272
|
+
responseFundsRequest(memoId, accept, amountBaseUnit, reason) {
|
|
2973
3273
|
return __async(this, null, function* () {
|
|
2974
3274
|
if (!accept) {
|
|
2975
3275
|
return yield this.acpContractClient.signMemo(memoId, accept, reason);
|
|
2976
3276
|
}
|
|
2977
|
-
if (
|
|
2978
|
-
yield this.acpContractClient.approveAllowance(
|
|
3277
|
+
if (amountBaseUnit > BigInt(0)) {
|
|
3278
|
+
yield this.acpContractClient.approveAllowance(amountBaseUnit);
|
|
2979
3279
|
}
|
|
2980
3280
|
return yield this.acpContractClient.signMemo(memoId, true, reason);
|
|
2981
3281
|
});
|
|
2982
3282
|
}
|
|
2983
|
-
transferFunds(jobId,
|
|
3283
|
+
transferFunds(jobId, transferFareAmount, recipient, feeFareAmount, feeType, reason, nextPhase, expiredAt) {
|
|
2984
3284
|
return __async(this, null, function* () {
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
3285
|
+
if (transferFareAmount.fare.contractAddress === ethFare.contractAddress) {
|
|
3286
|
+
yield this.acpContractClient.wrapEth(transferFareAmount.amount);
|
|
3287
|
+
transferFareAmount = new FareBigInt(transferFareAmount.amount, wethFare);
|
|
3288
|
+
}
|
|
3289
|
+
if (feeFareAmount.amount > 0 && feeFareAmount.fare.contractAddress !== this.acpContractClient.config.baseFare.contractAddress) {
|
|
3290
|
+
throw new Error("Fee token address is not the same as the base fare");
|
|
3291
|
+
}
|
|
3292
|
+
const isFeeTokenDifferent = feeFareAmount.fare.contractAddress !== transferFareAmount.fare.contractAddress;
|
|
3293
|
+
if (isFeeTokenDifferent) {
|
|
3294
|
+
yield this.acpContractClient.approveAllowance(
|
|
3295
|
+
feeFareAmount.amount,
|
|
3296
|
+
feeFareAmount.fare.contractAddress
|
|
3297
|
+
);
|
|
2988
3298
|
}
|
|
3299
|
+
const finalAmount = isFeeTokenDifferent ? transferFareAmount : transferFareAmount.add(feeFareAmount);
|
|
3300
|
+
yield this.acpContractClient.approveAllowance(
|
|
3301
|
+
finalAmount.amount,
|
|
3302
|
+
transferFareAmount.fare.contractAddress
|
|
3303
|
+
);
|
|
2989
3304
|
return yield this.acpContractClient.createPayableMemo(
|
|
2990
3305
|
jobId,
|
|
2991
3306
|
JSON.stringify(reason),
|
|
2992
|
-
amount,
|
|
3307
|
+
transferFareAmount.amount,
|
|
2993
3308
|
recipient,
|
|
2994
|
-
|
|
3309
|
+
feeFareAmount.amount,
|
|
2995
3310
|
feeType,
|
|
2996
3311
|
nextPhase,
|
|
2997
3312
|
8 /* PAYABLE_TRANSFER_ESCROW */,
|
|
2998
|
-
expiredAt
|
|
3313
|
+
expiredAt,
|
|
3314
|
+
transferFareAmount.fare.contractAddress
|
|
2999
3315
|
);
|
|
3000
3316
|
});
|
|
3001
3317
|
}
|
|
@@ -3259,14 +3575,21 @@ var index_default = acpClient_default;
|
|
|
3259
3575
|
ACP_ABI,
|
|
3260
3576
|
AcpAgentSort,
|
|
3261
3577
|
AcpContractClient,
|
|
3578
|
+
AcpContractConfig,
|
|
3262
3579
|
AcpGraduationStatus,
|
|
3263
3580
|
AcpJob,
|
|
3264
3581
|
AcpJobPhases,
|
|
3265
3582
|
AcpMemo,
|
|
3266
3583
|
AcpMemoStatus,
|
|
3267
3584
|
AcpOnlineStatus,
|
|
3585
|
+
Fare,
|
|
3586
|
+
FareAmount,
|
|
3587
|
+
FareBigInt,
|
|
3268
3588
|
MemoType,
|
|
3269
3589
|
PayloadType,
|
|
3590
|
+
PositionDirection,
|
|
3270
3591
|
baseAcpConfig,
|
|
3271
|
-
baseSepoliaAcpConfig
|
|
3592
|
+
baseSepoliaAcpConfig,
|
|
3593
|
+
ethFare,
|
|
3594
|
+
wethFare
|
|
3272
3595
|
});
|