@actalink/commonlib 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +354 -153
- package/dist/index.d.cts +430 -382
- package/dist/index.d.ts +430 -382
- package/dist/index.js +363 -161
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -231,14 +231,6 @@ var bscBNB = nativeToken({
|
|
|
231
231
|
symbol: "BNB",
|
|
232
232
|
logoURI: "https://api.acta.link/deposit/v1/logos/bnb.png" /* BNB */
|
|
233
233
|
});
|
|
234
|
-
var bscWBNB = token({
|
|
235
|
-
chainId: bsc2.id,
|
|
236
|
-
address: getAddress("0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"),
|
|
237
|
-
decimals: 18,
|
|
238
|
-
name: "Wrapped BNB",
|
|
239
|
-
symbol: "WBNB",
|
|
240
|
-
logoURI: "https://api.acta.link/deposit/v1/logos/bnb.png" /* BNB */
|
|
241
|
-
});
|
|
242
234
|
var bscUSDC = token({
|
|
243
235
|
chainId: bsc2.id,
|
|
244
236
|
address: getAddress("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),
|
|
@@ -565,7 +557,7 @@ function getTokenByChainIdAndAddress(chainId, address) {
|
|
|
565
557
|
}
|
|
566
558
|
|
|
567
559
|
// src/flexdeposit.ts
|
|
568
|
-
import { toHex as toHex3, zeroAddress as
|
|
560
|
+
import { toHex as toHex3, zeroAddress as zeroAddress3 } from "viem";
|
|
569
561
|
|
|
570
562
|
// src/account.ts
|
|
571
563
|
import {
|
|
@@ -699,6 +691,43 @@ var ViemClient = class {
|
|
|
699
691
|
return allowance;
|
|
700
692
|
});
|
|
701
693
|
}
|
|
694
|
+
approveToken(token2, spender, amount, allowMaxTokenApproval) {
|
|
695
|
+
return __async(this, null, function* () {
|
|
696
|
+
var _a;
|
|
697
|
+
if (this.walletClient === void 0) {
|
|
698
|
+
throw new Error("Wallet client is required");
|
|
699
|
+
}
|
|
700
|
+
const signerAddress = (_a = this.walletClient.account) == null ? void 0 : _a.address;
|
|
701
|
+
console.log("signerAddress", signerAddress);
|
|
702
|
+
if (signerAddress === void 0) {
|
|
703
|
+
throw new Error("Signer address is required");
|
|
704
|
+
}
|
|
705
|
+
const txn = yield this.walletClient.sendTransaction({
|
|
706
|
+
to: token2.address,
|
|
707
|
+
account: signerAddress,
|
|
708
|
+
chain: getChainById(token2.chainId),
|
|
709
|
+
value: BigInt(0),
|
|
710
|
+
data: encodeFunctionData({
|
|
711
|
+
abi: parseAbi(["function approve(address,uint)"]),
|
|
712
|
+
functionName: "approve",
|
|
713
|
+
args: [spender, allowMaxTokenApproval ? maxUint256 : amount]
|
|
714
|
+
})
|
|
715
|
+
});
|
|
716
|
+
return txn;
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
waitForTransactionReceipt(hash, blocks = 1) {
|
|
720
|
+
return __async(this, null, function* () {
|
|
721
|
+
if (this.walletClient === void 0) {
|
|
722
|
+
throw new Error("Wallet client is required");
|
|
723
|
+
}
|
|
724
|
+
const receipt = yield this.publicClient().waitForTransactionReceipt({
|
|
725
|
+
hash,
|
|
726
|
+
confirmations: blocks
|
|
727
|
+
});
|
|
728
|
+
return receipt;
|
|
729
|
+
});
|
|
730
|
+
}
|
|
702
731
|
};
|
|
703
732
|
|
|
704
733
|
// src/account.ts
|
|
@@ -1060,7 +1089,7 @@ var ActaAccount = class {
|
|
|
1060
1089
|
};
|
|
1061
1090
|
});
|
|
1062
1091
|
}
|
|
1063
|
-
|
|
1092
|
+
estimatePaymentAmount(singlePaymentParams) {
|
|
1064
1093
|
return __async(this, null, function* () {
|
|
1065
1094
|
try {
|
|
1066
1095
|
if (!this.signer) {
|
|
@@ -1073,7 +1102,6 @@ var ActaAccount = class {
|
|
|
1073
1102
|
amount,
|
|
1074
1103
|
receiver,
|
|
1075
1104
|
feeInclusive,
|
|
1076
|
-
allowMaxTokenApproval,
|
|
1077
1105
|
feebps
|
|
1078
1106
|
} = singlePaymentParams;
|
|
1079
1107
|
if (amount <= BigInt(0)) {
|
|
@@ -1086,14 +1114,10 @@ var ActaAccount = class {
|
|
|
1086
1114
|
if (!token2) {
|
|
1087
1115
|
throw new Error("Token not found.");
|
|
1088
1116
|
}
|
|
1089
|
-
const viemClient = new ViemClient(this.chainId, this.signer);
|
|
1090
1117
|
const {
|
|
1091
|
-
estimatedGasCostInToken,
|
|
1092
|
-
ActalinkFeesInToken,
|
|
1093
1118
|
feeInclusiveAmountInToken,
|
|
1094
1119
|
feeExclusiveAmountInToken,
|
|
1095
|
-
estimatedTotalFeesInToken
|
|
1096
|
-
paymaster
|
|
1120
|
+
estimatedTotalFeesInToken
|
|
1097
1121
|
} = yield this.estimateSinglePaymentGas({
|
|
1098
1122
|
signerAddress,
|
|
1099
1123
|
chainId,
|
|
@@ -1103,18 +1127,141 @@ var ActaAccount = class {
|
|
|
1103
1127
|
feeInclusive,
|
|
1104
1128
|
feebps
|
|
1105
1129
|
});
|
|
1106
|
-
const
|
|
1107
|
-
const
|
|
1108
|
-
const fromAddress = signerAddress;
|
|
1109
|
-
const smartAccountAddress = account.address;
|
|
1110
|
-
const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
|
|
1130
|
+
const totalAmount = feeInclusive ? amount : feeExclusiveAmountInToken;
|
|
1131
|
+
const actalinkFees = estimatedTotalFeesInToken;
|
|
1111
1132
|
const receiverAmount = feeInclusive ? feeInclusiveAmountInToken : amount;
|
|
1112
|
-
|
|
1133
|
+
return {
|
|
1134
|
+
totalAmount,
|
|
1135
|
+
actalinkFees,
|
|
1136
|
+
receiverAmount
|
|
1137
|
+
};
|
|
1138
|
+
} catch (error) {
|
|
1139
|
+
if (error instanceof Error) {
|
|
1140
|
+
throw new Error(error.message);
|
|
1141
|
+
}
|
|
1142
|
+
throw new Error("Failed to estimate payment amount.");
|
|
1143
|
+
}
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
checkAllowance(params) {
|
|
1147
|
+
return __async(this, null, function* () {
|
|
1148
|
+
var _a;
|
|
1149
|
+
try {
|
|
1150
|
+
if (!this.signer) {
|
|
1151
|
+
throw new Error("Signer is required for self custody payments.");
|
|
1152
|
+
}
|
|
1153
|
+
const { chainId, token: tokenSymbol } = params;
|
|
1154
|
+
const account = yield this.createAccount();
|
|
1155
|
+
const smartAccountAddress = yield account.getAddress();
|
|
1156
|
+
const owner = (_a = this.signer.account) == null ? void 0 : _a.address;
|
|
1157
|
+
console.log("signerAddress", owner);
|
|
1158
|
+
if (owner === void 0) {
|
|
1159
|
+
throw new Error("Signer address is required");
|
|
1160
|
+
}
|
|
1161
|
+
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
1162
|
+
if (!token2) {
|
|
1163
|
+
throw new Error("Token not found.");
|
|
1164
|
+
}
|
|
1165
|
+
const viemClient = new ViemClient(this.chainId, this.signer);
|
|
1166
|
+
const allowance = yield viemClient.checkTokenAllowance(
|
|
1167
|
+
token2,
|
|
1168
|
+
owner,
|
|
1169
|
+
smartAccountAddress
|
|
1170
|
+
);
|
|
1171
|
+
return allowance;
|
|
1172
|
+
} catch (error) {
|
|
1173
|
+
if (error instanceof Error) {
|
|
1174
|
+
throw new Error(error.message);
|
|
1175
|
+
}
|
|
1176
|
+
throw new Error("Failed to check token allownace.");
|
|
1177
|
+
}
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
approveToken(params) {
|
|
1181
|
+
return __async(this, null, function* () {
|
|
1182
|
+
try {
|
|
1183
|
+
if (!this.signer) {
|
|
1184
|
+
throw new Error("Signer is required for self custody payments.");
|
|
1185
|
+
}
|
|
1186
|
+
const {
|
|
1187
|
+
chainId,
|
|
1188
|
+
token: tokenSymbol,
|
|
1189
|
+
amount,
|
|
1190
|
+
allowMaxTokenApproval
|
|
1191
|
+
} = params;
|
|
1192
|
+
const account = yield this.createAccount();
|
|
1193
|
+
const smartAccountAddress = yield account.getAddress();
|
|
1194
|
+
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
1195
|
+
if (!token2) {
|
|
1196
|
+
throw new Error("Token not found.");
|
|
1197
|
+
}
|
|
1198
|
+
const viemClient = new ViemClient(this.chainId, this.signer);
|
|
1199
|
+
const allowance = yield viemClient.approveToken(
|
|
1113
1200
|
token2,
|
|
1114
1201
|
smartAccountAddress,
|
|
1115
|
-
|
|
1116
|
-
allowMaxTokenApproval
|
|
1202
|
+
amount,
|
|
1203
|
+
allowMaxTokenApproval
|
|
1117
1204
|
);
|
|
1205
|
+
return allowance;
|
|
1206
|
+
} catch (error) {
|
|
1207
|
+
if (error instanceof Error) {
|
|
1208
|
+
throw new Error(error.message);
|
|
1209
|
+
}
|
|
1210
|
+
throw new Error("Failed to approve token.");
|
|
1211
|
+
}
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
waitForTransactionReceipt(params) {
|
|
1215
|
+
return __async(this, null, function* () {
|
|
1216
|
+
try {
|
|
1217
|
+
if (!this.signer) {
|
|
1218
|
+
throw new Error("Signer is required for self custody payments.");
|
|
1219
|
+
}
|
|
1220
|
+
const { chainId, hash } = params;
|
|
1221
|
+
if (!hash) {
|
|
1222
|
+
throw new Error("Hash is not provided.");
|
|
1223
|
+
}
|
|
1224
|
+
const viemClient = new ViemClient(this.chainId, this.signer);
|
|
1225
|
+
const receipt = yield viemClient.waitForTransactionReceipt(hash);
|
|
1226
|
+
return receipt;
|
|
1227
|
+
} catch (error) {
|
|
1228
|
+
if (error instanceof Error) {
|
|
1229
|
+
throw new Error(error.message);
|
|
1230
|
+
}
|
|
1231
|
+
throw new Error("Failed to check token allownace.");
|
|
1232
|
+
}
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
signSinglePaymentOperation(singlePaymentParams) {
|
|
1236
|
+
return __async(this, null, function* () {
|
|
1237
|
+
try {
|
|
1238
|
+
if (!this.signer) {
|
|
1239
|
+
throw new Error("Signer is required for self custody payments.");
|
|
1240
|
+
}
|
|
1241
|
+
const {
|
|
1242
|
+
signerAddress,
|
|
1243
|
+
chainId,
|
|
1244
|
+
token: tokenSymbol,
|
|
1245
|
+
actalinkFees,
|
|
1246
|
+
receiverAmount,
|
|
1247
|
+
receiver
|
|
1248
|
+
} = singlePaymentParams;
|
|
1249
|
+
if (receiverAmount <= BigInt(0)) {
|
|
1250
|
+
throw new Error("Amount must be greater than 0.");
|
|
1251
|
+
}
|
|
1252
|
+
if (actalinkFees <= BigInt(0)) {
|
|
1253
|
+
throw new Error("Fees must be greater than 0.");
|
|
1254
|
+
}
|
|
1255
|
+
if (receiver === signerAddress) {
|
|
1256
|
+
throw new Error("Receiver cannot be the same as the signer.");
|
|
1257
|
+
}
|
|
1258
|
+
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
1259
|
+
if (!token2) {
|
|
1260
|
+
throw new Error("Token not found.");
|
|
1261
|
+
}
|
|
1262
|
+
const account = yield this.createAccount();
|
|
1263
|
+
const { accountClient } = yield this.createAccountHelpers();
|
|
1264
|
+
const fromAddress = signerAddress;
|
|
1118
1265
|
const userOperation = yield accountClient.prepareUserOperation({
|
|
1119
1266
|
calls: [
|
|
1120
1267
|
{
|
|
@@ -1124,7 +1271,7 @@ var ActaAccount = class {
|
|
|
1124
1271
|
args: [
|
|
1125
1272
|
fromAddress,
|
|
1126
1273
|
"0x26eeCa5956Bf8C01040BAC9e6D7982a0e87F31B4",
|
|
1127
|
-
|
|
1274
|
+
actalinkFees
|
|
1128
1275
|
]
|
|
1129
1276
|
},
|
|
1130
1277
|
{
|
|
@@ -1257,14 +1404,7 @@ var ActaAccount = class {
|
|
|
1257
1404
|
chainId,
|
|
1258
1405
|
token: tokenSymbol,
|
|
1259
1406
|
amount,
|
|
1260
|
-
receiver
|
|
1261
|
-
feeInclusive,
|
|
1262
|
-
count,
|
|
1263
|
-
intervalUnit,
|
|
1264
|
-
startDate,
|
|
1265
|
-
endDate,
|
|
1266
|
-
allowMaxTokenApproval,
|
|
1267
|
-
feebps
|
|
1407
|
+
receiver
|
|
1268
1408
|
} = recurringPaymentParams;
|
|
1269
1409
|
if (amount <= BigInt(0)) {
|
|
1270
1410
|
throw new Error("Amount must be greater than 0.");
|
|
@@ -1275,20 +1415,14 @@ var ActaAccount = class {
|
|
|
1275
1415
|
if (receiver === signerAddress) {
|
|
1276
1416
|
throw new Error("Receiver cannot be the same as the signer.");
|
|
1277
1417
|
}
|
|
1278
|
-
if (!intervalUnit) {
|
|
1279
|
-
throw new Error("Interval unit is required.");
|
|
1280
|
-
}
|
|
1281
1418
|
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
1282
1419
|
if (!token2) {
|
|
1283
1420
|
throw new Error("Token not found.");
|
|
1284
1421
|
}
|
|
1285
1422
|
const kernelVersion = KERNEL_V3_1;
|
|
1286
1423
|
const entryPoint = getEntryPoint("0.7");
|
|
1287
|
-
const paymentCount = count != null ? count : 24;
|
|
1288
1424
|
const account = yield this.createAccount();
|
|
1289
|
-
const smartAccountAddress = account.address;
|
|
1290
1425
|
const viemClient = new ViemClient(this.chainId, this.signer);
|
|
1291
|
-
const { paymasterClient, pimlicoClient } = yield this.createAccountHelpers();
|
|
1292
1426
|
const ecdsaValidator = yield signerToEcdsaValidator(
|
|
1293
1427
|
viemClient.publicClient(),
|
|
1294
1428
|
{
|
|
@@ -1300,32 +1434,7 @@ var ActaAccount = class {
|
|
|
1300
1434
|
const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
|
|
1301
1435
|
const emptyAccount = addressToEmptyAccount(sessionKeyAddress);
|
|
1302
1436
|
const emptySessionKeySigner = yield toECDSASigner({ signer: emptyAccount });
|
|
1303
|
-
const
|
|
1304
|
-
paymaster,
|
|
1305
|
-
ActalinkFeesInToken,
|
|
1306
|
-
feeInclusiveAmountInToken,
|
|
1307
|
-
feeExclusiveAmountInToken,
|
|
1308
|
-
estimatedTotalFeesInToken,
|
|
1309
|
-
userOperation,
|
|
1310
|
-
estimatedGasCostInToken
|
|
1311
|
-
} = yield this.estimateSinglePaymentGas({
|
|
1312
|
-
signerAddress,
|
|
1313
|
-
chainId,
|
|
1314
|
-
token: tokenSymbol,
|
|
1315
|
-
amount,
|
|
1316
|
-
receiver,
|
|
1317
|
-
feeInclusive,
|
|
1318
|
-
feebps
|
|
1319
|
-
});
|
|
1320
|
-
const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
|
|
1321
|
-
const receiverAmount = feeInclusive ? feeInclusiveAmountInToken : amount;
|
|
1322
|
-
yield viemClient.checkAndApproveToken(
|
|
1323
|
-
token2,
|
|
1324
|
-
smartAccountAddress,
|
|
1325
|
-
amountToTransfer * BigInt(paymentCount) + estimatedGasCostInToken * BigInt(2) * BigInt(paymentCount),
|
|
1326
|
-
allowMaxTokenApproval != null ? allowMaxTokenApproval : false
|
|
1327
|
-
);
|
|
1328
|
-
const amountExclusive = amountToTransfer + amountToTransfer / BigInt(2);
|
|
1437
|
+
const amountExclusive = amount + amount / BigInt(2);
|
|
1329
1438
|
const callPolicy = toCallPolicy({
|
|
1330
1439
|
policyVersion: CallPolicyVersion.V0_0_4,
|
|
1331
1440
|
permissions: [
|
|
@@ -1872,6 +1981,7 @@ var ActaFlexDeposit = class {
|
|
|
1872
1981
|
this.status = "not_started";
|
|
1873
1982
|
this.serviceType = "deposit";
|
|
1874
1983
|
this.allowMaxTokenApproval = false;
|
|
1984
|
+
this.feebps = 10;
|
|
1875
1985
|
var _a, _b, _c;
|
|
1876
1986
|
this.connectorType = parameters.connectorType;
|
|
1877
1987
|
this.walletClient = parameters.walletClient;
|
|
@@ -1898,13 +2008,13 @@ var ActaFlexDeposit = class {
|
|
|
1898
2008
|
createSession(serviceSessionparams) {
|
|
1899
2009
|
return __async(this, null, function* () {
|
|
1900
2010
|
try {
|
|
1901
|
-
if (!this.signerAddress || this.signerAddress ===
|
|
2011
|
+
if (!this.signerAddress || this.signerAddress === zeroAddress3) {
|
|
1902
2012
|
throw new Error("Signer address is required.");
|
|
1903
2013
|
}
|
|
1904
2014
|
if (this.paymentType !== "single" && this.paymentType !== "choose" && this.paymentType !== "recurring") {
|
|
1905
2015
|
throw new Error("Invalid payment type.");
|
|
1906
2016
|
}
|
|
1907
|
-
if (!this.receiver || this.receiver ===
|
|
2017
|
+
if (!this.receiver || this.receiver === zeroAddress3) {
|
|
1908
2018
|
throw new Error("Receiver is required.");
|
|
1909
2019
|
}
|
|
1910
2020
|
if (this.paymentType === "recurring" && (this.count === void 0 || this.count === 0)) {
|
|
@@ -1991,35 +2101,95 @@ var ActaFlexDeposit = class {
|
|
|
1991
2101
|
}
|
|
1992
2102
|
});
|
|
1993
2103
|
}
|
|
1994
|
-
|
|
2104
|
+
estimatePaymentAmount() {
|
|
2105
|
+
return __async(this, null, function* () {
|
|
2106
|
+
try {
|
|
2107
|
+
const signerAddress = this.signerAddress;
|
|
2108
|
+
const chainId = this.chainId;
|
|
2109
|
+
const tokenSymbol = this.token;
|
|
2110
|
+
const amount = this.amount;
|
|
2111
|
+
const receiver = this.receiver;
|
|
2112
|
+
const feeInclusive = this.feeInclusive;
|
|
2113
|
+
const feebps = this.feebps;
|
|
2114
|
+
const { totalAmount, actalinkFees, receiverAmount } = yield this.account.estimatePaymentAmount({
|
|
2115
|
+
signerAddress,
|
|
2116
|
+
chainId,
|
|
2117
|
+
token: tokenSymbol,
|
|
2118
|
+
amount,
|
|
2119
|
+
receiver,
|
|
2120
|
+
feeInclusive,
|
|
2121
|
+
feebps
|
|
2122
|
+
});
|
|
2123
|
+
return {
|
|
2124
|
+
totalAmount,
|
|
2125
|
+
actalinkFees,
|
|
2126
|
+
receiverAmount
|
|
2127
|
+
};
|
|
2128
|
+
} catch (error) {
|
|
2129
|
+
if (error instanceof Error) {
|
|
2130
|
+
throw new Error(error.message);
|
|
2131
|
+
}
|
|
2132
|
+
throw new Error("Failed to estimate payment amount.");
|
|
2133
|
+
}
|
|
2134
|
+
});
|
|
2135
|
+
}
|
|
2136
|
+
checkAllowance() {
|
|
1995
2137
|
return __async(this, null, function* () {
|
|
1996
2138
|
try {
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
const paymentParams = this.serviceType === "deposit" ? __spreadProps(__spreadValues({}, servicePaymentParams), {
|
|
2008
|
-
depositSessionId: this.depositSessionId
|
|
2009
|
-
}) : servicePaymentParams;
|
|
2010
|
-
const id = yield this.createRecurringPayments(paymentParams);
|
|
2011
|
-
return id;
|
|
2139
|
+
const chainId = this.chainId;
|
|
2140
|
+
const tokenSymbol = this.token;
|
|
2141
|
+
const allowance = yield this.account.checkAllowance({
|
|
2142
|
+
chainId,
|
|
2143
|
+
token: tokenSymbol
|
|
2144
|
+
});
|
|
2145
|
+
return allowance;
|
|
2146
|
+
} catch (error) {
|
|
2147
|
+
if (error instanceof Error) {
|
|
2148
|
+
throw new Error(error.message);
|
|
2012
2149
|
}
|
|
2150
|
+
throw new Error("Failed to check token allowance.");
|
|
2151
|
+
}
|
|
2152
|
+
});
|
|
2153
|
+
}
|
|
2154
|
+
approveToken(parameters) {
|
|
2155
|
+
return __async(this, null, function* () {
|
|
2156
|
+
try {
|
|
2157
|
+
const chainId = this.chainId;
|
|
2158
|
+
const tokenSymbol = this.token;
|
|
2159
|
+
const { totalAmount, allowMaxTokenApproval } = parameters;
|
|
2160
|
+
const hash = yield this.account.approveToken({
|
|
2161
|
+
chainId,
|
|
2162
|
+
token: tokenSymbol,
|
|
2163
|
+
amount: totalAmount,
|
|
2164
|
+
allowMaxTokenApproval
|
|
2165
|
+
});
|
|
2166
|
+
return hash;
|
|
2013
2167
|
} catch (error) {
|
|
2014
|
-
this.status = "payment_failed";
|
|
2015
2168
|
if (error instanceof Error) {
|
|
2016
2169
|
throw new Error(error.message);
|
|
2017
2170
|
}
|
|
2018
|
-
throw new Error("Failed to
|
|
2171
|
+
throw new Error("Failed to approve token.");
|
|
2019
2172
|
}
|
|
2020
2173
|
});
|
|
2021
2174
|
}
|
|
2022
|
-
|
|
2175
|
+
waitForTransactionReceipt(hash) {
|
|
2176
|
+
return __async(this, null, function* () {
|
|
2177
|
+
try {
|
|
2178
|
+
const chainId = this.chainId;
|
|
2179
|
+
const receipt = yield this.account.waitForTransactionReceipt({
|
|
2180
|
+
chainId,
|
|
2181
|
+
hash
|
|
2182
|
+
});
|
|
2183
|
+
return receipt;
|
|
2184
|
+
} catch (error) {
|
|
2185
|
+
if (error instanceof Error) {
|
|
2186
|
+
throw new Error(error.message);
|
|
2187
|
+
}
|
|
2188
|
+
throw new Error("Failed to fetch transaction receipt.");
|
|
2189
|
+
}
|
|
2190
|
+
});
|
|
2191
|
+
}
|
|
2192
|
+
createSinglePayment(parameters, servicePaymentParams) {
|
|
2023
2193
|
return __async(this, null, function* () {
|
|
2024
2194
|
try {
|
|
2025
2195
|
if (this.connectorType !== "Self-Custody" /* SELF_CUSTODY */) {
|
|
@@ -2031,18 +2201,12 @@ var ActaFlexDeposit = class {
|
|
|
2031
2201
|
const signerAddress = this.signerAddress;
|
|
2032
2202
|
const chainId = this.chainId;
|
|
2033
2203
|
const tokenSymbol = this.token;
|
|
2034
|
-
const amount = this.amount;
|
|
2035
2204
|
const receiver = this.receiver;
|
|
2205
|
+
const amount = this.amount;
|
|
2036
2206
|
const feeInclusive = this.feeInclusive;
|
|
2037
2207
|
const serviceType = this.serviceType;
|
|
2208
|
+
const { actalinkFees, receiverAmount } = parameters;
|
|
2038
2209
|
const { envTransactionServiceUrl, envDepositServiceUrl } = returnEnvUrl(chainId);
|
|
2039
|
-
if (this.depositSessionId !== "") {
|
|
2040
|
-
const session = yield verifySessionAPICall(
|
|
2041
|
-
`${envDepositServiceUrl}verify-session?sessionId=${this.depositSessionId}`,
|
|
2042
|
-
this.depositSessionId
|
|
2043
|
-
);
|
|
2044
|
-
this.depositSessionId = session.sessionId;
|
|
2045
|
-
}
|
|
2046
2210
|
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
2047
2211
|
if (!token2) {
|
|
2048
2212
|
throw new Error("Token not supported.");
|
|
@@ -2051,11 +2215,9 @@ var ActaFlexDeposit = class {
|
|
|
2051
2215
|
signerAddress,
|
|
2052
2216
|
chainId,
|
|
2053
2217
|
token: tokenSymbol,
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
allowMaxTokenApproval: this.allowMaxTokenApproval,
|
|
2058
|
-
feebps: 10
|
|
2218
|
+
actalinkFees,
|
|
2219
|
+
receiverAmount,
|
|
2220
|
+
receiver
|
|
2059
2221
|
});
|
|
2060
2222
|
const txn = yield executeSinglePaymentAPICall(
|
|
2061
2223
|
`${envTransactionServiceUrl}execute/single`,
|
|
@@ -2143,14 +2305,7 @@ var ActaFlexDeposit = class {
|
|
|
2143
2305
|
chainId,
|
|
2144
2306
|
token: tokenSymbol,
|
|
2145
2307
|
amount,
|
|
2146
|
-
|
|
2147
|
-
count,
|
|
2148
|
-
intervalUnit,
|
|
2149
|
-
startDate,
|
|
2150
|
-
endDate,
|
|
2151
|
-
receiver,
|
|
2152
|
-
allowMaxTokenApproval: this.allowMaxTokenApproval,
|
|
2153
|
-
feebps: 20
|
|
2308
|
+
receiver
|
|
2154
2309
|
});
|
|
2155
2310
|
const txn = yield scheduleRecurringPaymentsAPICall(
|
|
2156
2311
|
`${envTransactionServiceUrl}schedule/recurring`,
|
|
@@ -2174,39 +2329,6 @@ var ActaFlexDeposit = class {
|
|
|
2174
2329
|
return txn.recurringTransaction.id;
|
|
2175
2330
|
});
|
|
2176
2331
|
}
|
|
2177
|
-
getPaymentSteps() {
|
|
2178
|
-
return __async(this, null, function* () {
|
|
2179
|
-
const signerAddress = this.signerAddress;
|
|
2180
|
-
const chainId = this.chainId;
|
|
2181
|
-
const tokenSymbol = this.token;
|
|
2182
|
-
const amount = this.amount;
|
|
2183
|
-
const receiver = this.receiver;
|
|
2184
|
-
const feeInclusive = this.feeInclusive;
|
|
2185
|
-
const count = this.count;
|
|
2186
|
-
if (!signerAddress) return ["allowance", "confirm"];
|
|
2187
|
-
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
2188
|
-
if (!token2) return ["allowance", "confirm"];
|
|
2189
|
-
const smartAccount = yield this.account.createAccount();
|
|
2190
|
-
const { estimatedGasCostInToken, feeExclusiveAmountInToken } = yield this.account.estimateSinglePaymentGas({
|
|
2191
|
-
chainId,
|
|
2192
|
-
amount,
|
|
2193
|
-
feeInclusive,
|
|
2194
|
-
receiver,
|
|
2195
|
-
signerAddress,
|
|
2196
|
-
token: tokenSymbol,
|
|
2197
|
-
feebps: 10
|
|
2198
|
-
});
|
|
2199
|
-
const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
|
|
2200
|
-
let paymentAmount = (amountToTransfer + estimatedGasCostInToken * BigInt(2)) * BigInt(count != null ? count : 1);
|
|
2201
|
-
const allowance = yield this.viemClient.checkTokenAllowance(
|
|
2202
|
-
token2,
|
|
2203
|
-
signerAddress,
|
|
2204
|
-
smartAccount.address
|
|
2205
|
-
);
|
|
2206
|
-
if (paymentAmount <= allowance) return ["confirm"];
|
|
2207
|
-
return ["allowance", "confirm"];
|
|
2208
|
-
});
|
|
2209
|
-
}
|
|
2210
2332
|
};
|
|
2211
2333
|
|
|
2212
2334
|
// src/flexbatch.ts
|
|
@@ -2214,7 +2336,7 @@ import {
|
|
|
2214
2336
|
getAddress as getAddress3,
|
|
2215
2337
|
parseUnits,
|
|
2216
2338
|
toHex as toHex4,
|
|
2217
|
-
zeroAddress as
|
|
2339
|
+
zeroAddress as zeroAddress4
|
|
2218
2340
|
} from "viem";
|
|
2219
2341
|
var batchServiceUrl = "https://flex-api.acta.link/flex/batch/api/v1/";
|
|
2220
2342
|
var batchServiceTestUrl = "https://flex-api.acta.link/flex/batch/test/api/v1/";
|
|
@@ -2246,7 +2368,7 @@ var ActaFlexBatch = class {
|
|
|
2246
2368
|
if (!this.APIkey) {
|
|
2247
2369
|
throw new Error("No API key provided.");
|
|
2248
2370
|
}
|
|
2249
|
-
if (!signerAddress || signerAddress ===
|
|
2371
|
+
if (!signerAddress || signerAddress === zeroAddress4) {
|
|
2250
2372
|
throw new Error("Signer address is required.");
|
|
2251
2373
|
}
|
|
2252
2374
|
if (!name || name === "") {
|
|
@@ -2705,6 +2827,7 @@ var ActaBilling = class {
|
|
|
2705
2827
|
this.status = "not_started";
|
|
2706
2828
|
this.serviceType = "deposit";
|
|
2707
2829
|
this.allowMaxTokenApproval = false;
|
|
2830
|
+
this.feebps = 20;
|
|
2708
2831
|
var _a, _b;
|
|
2709
2832
|
this.connectorType = parameters.connectorType;
|
|
2710
2833
|
this.walletClient = parameters.walletClient;
|
|
@@ -2760,7 +2883,95 @@ var ActaBilling = class {
|
|
|
2760
2883
|
}
|
|
2761
2884
|
});
|
|
2762
2885
|
}
|
|
2763
|
-
|
|
2886
|
+
estimatePaymentAmount() {
|
|
2887
|
+
return __async(this, null, function* () {
|
|
2888
|
+
try {
|
|
2889
|
+
const signerAddress = this.signerAddress;
|
|
2890
|
+
const chainId = this.chainId;
|
|
2891
|
+
const tokenSymbol = this.token;
|
|
2892
|
+
const amount = this.amount;
|
|
2893
|
+
const receiver = this.receiver;
|
|
2894
|
+
const feeInclusive = this.feeInclusive;
|
|
2895
|
+
const feebps = this.feebps;
|
|
2896
|
+
const { totalAmount, actalinkFees, receiverAmount } = yield this.account.estimatePaymentAmount({
|
|
2897
|
+
signerAddress,
|
|
2898
|
+
chainId,
|
|
2899
|
+
token: tokenSymbol,
|
|
2900
|
+
amount,
|
|
2901
|
+
receiver,
|
|
2902
|
+
feeInclusive,
|
|
2903
|
+
feebps
|
|
2904
|
+
});
|
|
2905
|
+
return {
|
|
2906
|
+
totalAmount,
|
|
2907
|
+
actalinkFees,
|
|
2908
|
+
receiverAmount
|
|
2909
|
+
};
|
|
2910
|
+
} catch (error) {
|
|
2911
|
+
if (error instanceof Error) {
|
|
2912
|
+
throw new Error(error.message);
|
|
2913
|
+
}
|
|
2914
|
+
throw new Error("Failed to estimate payment amount.");
|
|
2915
|
+
}
|
|
2916
|
+
});
|
|
2917
|
+
}
|
|
2918
|
+
checkAllowance() {
|
|
2919
|
+
return __async(this, null, function* () {
|
|
2920
|
+
try {
|
|
2921
|
+
const chainId = this.chainId;
|
|
2922
|
+
const tokenSymbol = this.token;
|
|
2923
|
+
const allowance = yield this.account.checkAllowance({
|
|
2924
|
+
chainId,
|
|
2925
|
+
token: tokenSymbol
|
|
2926
|
+
});
|
|
2927
|
+
return allowance;
|
|
2928
|
+
} catch (error) {
|
|
2929
|
+
if (error instanceof Error) {
|
|
2930
|
+
throw new Error(error.message);
|
|
2931
|
+
}
|
|
2932
|
+
throw new Error("Failed to check token allowance.");
|
|
2933
|
+
}
|
|
2934
|
+
});
|
|
2935
|
+
}
|
|
2936
|
+
approveToken(parameters) {
|
|
2937
|
+
return __async(this, null, function* () {
|
|
2938
|
+
try {
|
|
2939
|
+
const chainId = this.chainId;
|
|
2940
|
+
const tokenSymbol = this.token;
|
|
2941
|
+
const { totalAmount, allowMaxTokenApproval } = parameters;
|
|
2942
|
+
const hash = yield this.account.approveToken({
|
|
2943
|
+
chainId,
|
|
2944
|
+
token: tokenSymbol,
|
|
2945
|
+
amount: totalAmount,
|
|
2946
|
+
allowMaxTokenApproval
|
|
2947
|
+
});
|
|
2948
|
+
return hash;
|
|
2949
|
+
} catch (error) {
|
|
2950
|
+
if (error instanceof Error) {
|
|
2951
|
+
throw new Error(error.message);
|
|
2952
|
+
}
|
|
2953
|
+
throw new Error("Failed to approve token.");
|
|
2954
|
+
}
|
|
2955
|
+
});
|
|
2956
|
+
}
|
|
2957
|
+
waitForTransactionReceipt(hash) {
|
|
2958
|
+
return __async(this, null, function* () {
|
|
2959
|
+
try {
|
|
2960
|
+
const chainId = this.chainId;
|
|
2961
|
+
const receipt = yield this.account.waitForTransactionReceipt({
|
|
2962
|
+
chainId,
|
|
2963
|
+
hash
|
|
2964
|
+
});
|
|
2965
|
+
return receipt;
|
|
2966
|
+
} catch (error) {
|
|
2967
|
+
if (error instanceof Error) {
|
|
2968
|
+
throw new Error(error.message);
|
|
2969
|
+
}
|
|
2970
|
+
throw new Error("Failed to fetch transaction receipt.");
|
|
2971
|
+
}
|
|
2972
|
+
});
|
|
2973
|
+
}
|
|
2974
|
+
createSinglePayment(parameters, servicePaymentParams) {
|
|
2764
2975
|
return __async(this, null, function* () {
|
|
2765
2976
|
try {
|
|
2766
2977
|
if (this.connectorType !== "Self-Custody" /* SELF_CUSTODY */) {
|
|
@@ -2769,6 +2980,7 @@ var ActaBilling = class {
|
|
|
2769
2980
|
if (!servicePaymentParams.checkoutSessionId || servicePaymentParams.checkoutSessionId === "") {
|
|
2770
2981
|
throw new Error("checkout session ID is required.");
|
|
2771
2982
|
}
|
|
2983
|
+
const { actalinkFees, receiverAmount } = parameters;
|
|
2772
2984
|
const signerAddress = this.signerAddress;
|
|
2773
2985
|
const chainId = this.chainId;
|
|
2774
2986
|
const tokenSymbol = this.token;
|
|
@@ -2785,11 +2997,9 @@ var ActaBilling = class {
|
|
|
2785
2997
|
signerAddress,
|
|
2786
2998
|
chainId,
|
|
2787
2999
|
token: tokenSymbol,
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
allowMaxTokenApproval: this.allowMaxTokenApproval,
|
|
2792
|
-
feebps: 20
|
|
3000
|
+
actalinkFees,
|
|
3001
|
+
receiverAmount,
|
|
3002
|
+
receiver
|
|
2793
3003
|
});
|
|
2794
3004
|
const txn = yield executeSinglePaymentAPICall(
|
|
2795
3005
|
`${envBillingServiceUrl}execute/single`,
|
|
@@ -2849,14 +3059,7 @@ var ActaBilling = class {
|
|
|
2849
3059
|
chainId,
|
|
2850
3060
|
token: tokenSymbol,
|
|
2851
3061
|
amount,
|
|
2852
|
-
|
|
2853
|
-
count,
|
|
2854
|
-
intervalUnit,
|
|
2855
|
-
startDate,
|
|
2856
|
-
endDate,
|
|
2857
|
-
receiver,
|
|
2858
|
-
allowMaxTokenApproval: this.allowMaxTokenApproval,
|
|
2859
|
-
feebps: 20
|
|
3062
|
+
receiver
|
|
2860
3063
|
});
|
|
2861
3064
|
const txn = yield scheduleSubscriptionPaymentsAPICall(
|
|
2862
3065
|
`${envBillingServiceUrl}schedule/subscription`,
|
|
@@ -2920,7 +3123,7 @@ import {
|
|
|
2920
3123
|
getAddress as getAddress4,
|
|
2921
3124
|
parseUnits as parseUnits2,
|
|
2922
3125
|
toHex as toHex6,
|
|
2923
|
-
zeroAddress as
|
|
3126
|
+
zeroAddress as zeroAddress5
|
|
2924
3127
|
} from "viem";
|
|
2925
3128
|
var batchServiceUrl2 = "https://api.acta.link/bexo/api/v1/";
|
|
2926
3129
|
var batchServiceTestUrl2 = "https://api.acta.link/bexo/test/api/v1/";
|
|
@@ -2952,7 +3155,7 @@ var ActaBatch = class {
|
|
|
2952
3155
|
if (!this.APIkey) {
|
|
2953
3156
|
throw new Error("No API key provided.");
|
|
2954
3157
|
}
|
|
2955
|
-
if (!signerAddress || signerAddress ===
|
|
3158
|
+
if (!signerAddress || signerAddress === zeroAddress5) {
|
|
2956
3159
|
throw new Error("Signer address is required.");
|
|
2957
3160
|
}
|
|
2958
3161
|
if (!name || name === "") {
|
|
@@ -3399,7 +3602,7 @@ import {
|
|
|
3399
3602
|
encodeAbiParameters,
|
|
3400
3603
|
keccak256,
|
|
3401
3604
|
slice,
|
|
3402
|
-
zeroAddress as
|
|
3605
|
+
zeroAddress as zeroAddress6,
|
|
3403
3606
|
decodeFunctionData,
|
|
3404
3607
|
hexToBigInt as hexToBigInt2
|
|
3405
3608
|
} from "viem";
|
|
@@ -3511,7 +3714,7 @@ function toPermissionValidator2(_0, _1) {
|
|
|
3511
3714
|
return __spreadProps(__spreadValues({}, signer.account), {
|
|
3512
3715
|
supportedKernelVersions: ">=0.3.0",
|
|
3513
3716
|
validatorType: "PERMISSION",
|
|
3514
|
-
address:
|
|
3717
|
+
address: zeroAddress6,
|
|
3515
3718
|
source: "PermissionValidator",
|
|
3516
3719
|
getEnableData,
|
|
3517
3720
|
getIdentifier: getPermissionId,
|
|
@@ -3882,7 +4085,6 @@ export {
|
|
|
3882
4085
|
bscBNB,
|
|
3883
4086
|
bscUSDC,
|
|
3884
4087
|
bscUSDT,
|
|
3885
|
-
bscWBNB,
|
|
3886
4088
|
bytesToBase64,
|
|
3887
4089
|
cancelRecurringPaymentAPICall,
|
|
3888
4090
|
cancelRecurringTransaction,
|