@actalink/commonlib 0.0.3 → 0.0.5
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 +49 -82
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +49 -82
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -612,14 +612,12 @@ var import_viem6 = require("viem");
|
|
|
612
612
|
|
|
613
613
|
// src/account.ts
|
|
614
614
|
var import_viem4 = require("viem");
|
|
615
|
-
var import_accounts3 = require("viem/accounts");
|
|
616
615
|
var import_account_abstraction2 = require("viem/account-abstraction");
|
|
617
616
|
var import_sdk2 = require("@zerodev/sdk");
|
|
618
617
|
var import_constants = require("@zerodev/sdk/constants");
|
|
619
618
|
var import_ecdsa_validator = require("@zerodev/ecdsa-validator");
|
|
620
619
|
var import_permissionless = require("permissionless");
|
|
621
620
|
var import_pimlico = require("permissionless/clients/pimlico");
|
|
622
|
-
var import_pimlico2 = require("permissionless/experimental/pimlico");
|
|
623
621
|
|
|
624
622
|
// src/rpc.ts
|
|
625
623
|
function getRpcByChainId(chainId) {
|
|
@@ -705,7 +703,7 @@ var ViemClient = class {
|
|
|
705
703
|
signerAddress,
|
|
706
704
|
spender
|
|
707
705
|
);
|
|
708
|
-
if (allowance < amount
|
|
706
|
+
if (allowance < amount) {
|
|
709
707
|
const txn = yield this.walletClient.sendTransaction({
|
|
710
708
|
to: token2.address,
|
|
711
709
|
account: signerAddress,
|
|
@@ -1147,8 +1145,7 @@ var ActaAccount = class {
|
|
|
1147
1145
|
userOperation: {
|
|
1148
1146
|
estimateFeesPerGas: () => __async(this, null, function* () {
|
|
1149
1147
|
return (yield pimlicoClient.getUserOperationGasPrice()).fast;
|
|
1150
|
-
})
|
|
1151
|
-
prepareUserOperation: (0, import_pimlico2.prepareUserOperationForErc20Paymaster)(pimlicoClient)
|
|
1148
|
+
})
|
|
1152
1149
|
}
|
|
1153
1150
|
});
|
|
1154
1151
|
return { paymasterClient, pimlicoClient, accountClient };
|
|
@@ -1188,28 +1185,17 @@ var ActaAccount = class {
|
|
|
1188
1185
|
to: (0, import_viem4.getAddress)(token2.address),
|
|
1189
1186
|
abi: (0, import_viem4.parseAbi)(["function transferFrom(address,address,uint)"]),
|
|
1190
1187
|
functionName: "transferFrom",
|
|
1191
|
-
args: [fromAddress, smartAccountAddress, BigInt(0)]
|
|
1192
|
-
},
|
|
1193
|
-
{
|
|
1194
|
-
to: (0, import_viem4.getAddress)(token2.address),
|
|
1195
|
-
abi: (0, import_viem4.parseAbi)(["function approve(address,uint)"]),
|
|
1196
|
-
functionName: "approve",
|
|
1197
|
-
args: [paymaster, BigInt(0)]
|
|
1198
|
-
},
|
|
1199
|
-
{
|
|
1200
|
-
to: (0, import_viem4.getAddress)(token2.address),
|
|
1201
|
-
abi: (0, import_viem4.parseAbi)(["function transfer(address,uint)"]),
|
|
1202
|
-
functionName: "transfer",
|
|
1203
1188
|
args: [
|
|
1189
|
+
fromAddress,
|
|
1204
1190
|
"0x061BA68bc8208F4AddBeE86F74F17D77129cCF70",
|
|
1205
1191
|
BigInt(0)
|
|
1206
1192
|
]
|
|
1207
1193
|
},
|
|
1208
1194
|
{
|
|
1209
1195
|
to: (0, import_viem4.getAddress)(token2.address),
|
|
1210
|
-
abi: (0, import_viem4.parseAbi)(["function
|
|
1211
|
-
functionName: "
|
|
1212
|
-
args: [receiver, BigInt(0)]
|
|
1196
|
+
abi: (0, import_viem4.parseAbi)(["function transferFrom(address,address,uint)"]),
|
|
1197
|
+
functionName: "transferFrom",
|
|
1198
|
+
args: [fromAddress, receiver, BigInt(0)]
|
|
1213
1199
|
}
|
|
1214
1200
|
]
|
|
1215
1201
|
});
|
|
@@ -1292,33 +1278,19 @@ var ActaAccount = class {
|
|
|
1292
1278
|
to: (0, import_viem4.getAddress)(token2.address),
|
|
1293
1279
|
abi: (0, import_viem4.parseAbi)(["function transferFrom(address,address,uint)"]),
|
|
1294
1280
|
functionName: "transferFrom",
|
|
1295
|
-
args: [fromAddress, smartAccountAddress, amountToTransfer]
|
|
1296
|
-
},
|
|
1297
|
-
{
|
|
1298
|
-
to: (0, import_viem4.getAddress)(token2.address),
|
|
1299
|
-
abi: (0, import_viem4.parseAbi)(["function approve(address,uint)"]),
|
|
1300
|
-
functionName: "approve",
|
|
1301
|
-
args: [paymaster, estimatedGasCostInToken]
|
|
1302
|
-
},
|
|
1303
|
-
{
|
|
1304
|
-
to: (0, import_viem4.getAddress)(token2.address),
|
|
1305
|
-
abi: (0, import_viem4.parseAbi)(["function transfer(address,uint)"]),
|
|
1306
|
-
functionName: "transfer",
|
|
1307
1281
|
args: [
|
|
1308
|
-
|
|
1309
|
-
|
|
1282
|
+
fromAddress,
|
|
1283
|
+
"0xC4910E5ec82Da0A41aF9C6360b7A1f531e1e37B0",
|
|
1284
|
+
estimatedGasCostInToken
|
|
1310
1285
|
]
|
|
1311
1286
|
},
|
|
1312
1287
|
{
|
|
1313
1288
|
to: (0, import_viem4.getAddress)(token2.address),
|
|
1314
|
-
abi: (0, import_viem4.parseAbi)(["function
|
|
1315
|
-
functionName: "
|
|
1316
|
-
args: [receiver, receiverAmount]
|
|
1289
|
+
abi: (0, import_viem4.parseAbi)(["function transferFrom(address,address,uint)"]),
|
|
1290
|
+
functionName: "transferFrom",
|
|
1291
|
+
args: [fromAddress, receiver, receiverAmount]
|
|
1317
1292
|
}
|
|
1318
|
-
]
|
|
1319
|
-
paymasterContext: {
|
|
1320
|
-
token: token2.address
|
|
1321
|
-
}
|
|
1293
|
+
]
|
|
1322
1294
|
});
|
|
1323
1295
|
const signature = yield account.signUserOperation(__spreadProps(__spreadValues({}, userOperation), {
|
|
1324
1296
|
chainId: this.chainId
|
|
@@ -1373,11 +1345,6 @@ var ActaAccount = class {
|
|
|
1373
1345
|
const smartAccountAddress = account.address;
|
|
1374
1346
|
const viemClient = new ViemClient(this.chainId, this.signer);
|
|
1375
1347
|
const { paymasterClient, pimlicoClient } = yield this.createAccountHelpers();
|
|
1376
|
-
const sessionKeySigner = yield toECDSASigner(
|
|
1377
|
-
(0, import_accounts3.privateKeyToAccount)(
|
|
1378
|
-
"0x8519baaeb81ebbcf3597d93c2f9790d1eda37097121e844e1b88c1ab77b67ae2"
|
|
1379
|
-
)
|
|
1380
|
-
);
|
|
1381
1348
|
const ecdsaValidator = yield (0, import_ecdsa_validator.signerToEcdsaValidator)(
|
|
1382
1349
|
viemClient.publicClient(),
|
|
1383
1350
|
{
|
|
@@ -1386,7 +1353,7 @@ var ActaAccount = class {
|
|
|
1386
1353
|
signer: this.signer
|
|
1387
1354
|
}
|
|
1388
1355
|
);
|
|
1389
|
-
const sessionKeyAddress = "
|
|
1356
|
+
const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
|
|
1390
1357
|
const emptyAccount = (0, import_sdk2.addressToEmptyAccount)(sessionKeyAddress);
|
|
1391
1358
|
const emptySessionKeySigner = yield toECDSASigner(emptyAccount);
|
|
1392
1359
|
const {
|
|
@@ -1426,45 +1393,13 @@ var ActaAccount = class {
|
|
|
1426
1393
|
condition: import_policies2.ParamCondition.EQUAL,
|
|
1427
1394
|
value: signerAddress
|
|
1428
1395
|
},
|
|
1429
|
-
{
|
|
1430
|
-
condition: import_policies2.ParamCondition.EQUAL,
|
|
1431
|
-
value: smartAccountAddress
|
|
1432
|
-
},
|
|
1433
|
-
{
|
|
1434
|
-
condition: import_policies2.ParamCondition.GREATER_THAN_OR_EQUAL,
|
|
1435
|
-
value: 0
|
|
1436
|
-
}
|
|
1437
|
-
]
|
|
1438
|
-
},
|
|
1439
|
-
{
|
|
1440
|
-
target: token2.address,
|
|
1441
|
-
valueLimit: BigInt(0),
|
|
1442
|
-
abi: (0, import_viem4.parseAbi)(["function approve(address,uint)"]),
|
|
1443
|
-
functionName: "approve",
|
|
1444
|
-
args: [
|
|
1445
|
-
{
|
|
1446
|
-
condition: import_policies2.ParamCondition.EQUAL,
|
|
1447
|
-
value: paymaster
|
|
1448
|
-
},
|
|
1449
|
-
{
|
|
1450
|
-
condition: import_policies2.ParamCondition.GREATER_THAN_OR_EQUAL,
|
|
1451
|
-
value: 0
|
|
1452
|
-
}
|
|
1453
|
-
]
|
|
1454
|
-
},
|
|
1455
|
-
{
|
|
1456
|
-
target: token2.address,
|
|
1457
|
-
valueLimit: BigInt(0),
|
|
1458
|
-
abi: (0, import_viem4.parseAbi)(["function transfer(address,uint)"]),
|
|
1459
|
-
functionName: "transfer",
|
|
1460
|
-
args: [
|
|
1461
1396
|
{
|
|
1462
1397
|
condition: import_policies2.ParamCondition.ONE_OF,
|
|
1463
|
-
value: ["
|
|
1398
|
+
value: ["0xC4910E5ec82Da0A41aF9C6360b7A1f531e1e37B0", receiver]
|
|
1464
1399
|
},
|
|
1465
1400
|
{
|
|
1466
|
-
condition: import_policies2.ParamCondition.
|
|
1467
|
-
value:
|
|
1401
|
+
condition: import_policies2.ParamCondition.LESS_THAN_OR_EQUAL,
|
|
1402
|
+
value: amountToTransfer + amountToTransfer / BigInt(2)
|
|
1468
1403
|
}
|
|
1469
1404
|
]
|
|
1470
1405
|
}
|
|
@@ -1921,6 +1856,38 @@ var ActaDeposit = class {
|
|
|
1921
1856
|
return txn.recurringTransaction.id;
|
|
1922
1857
|
});
|
|
1923
1858
|
}
|
|
1859
|
+
getPaymentSteps() {
|
|
1860
|
+
return __async(this, null, function* () {
|
|
1861
|
+
const signerAddress = this.signerAddress;
|
|
1862
|
+
const chainId = this.chainId;
|
|
1863
|
+
const tokenSymbol = this.token;
|
|
1864
|
+
const amount = this.amount;
|
|
1865
|
+
const receiver = this.receiver;
|
|
1866
|
+
const feeInclusive = this.feeInclusive;
|
|
1867
|
+
const count = this.count;
|
|
1868
|
+
if (!signerAddress) return ["allowance", "confirm"];
|
|
1869
|
+
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
1870
|
+
if (!token2) return ["allowance", "confirm"];
|
|
1871
|
+
const smartAccount = yield this.account.createAccount();
|
|
1872
|
+
const { estimatedGasCostInToken, feeExclusiveAmountInToken } = yield this.account.estimateSinglePaymentGas({
|
|
1873
|
+
chainId,
|
|
1874
|
+
amount,
|
|
1875
|
+
feeInclusive,
|
|
1876
|
+
receiver,
|
|
1877
|
+
signerAddress,
|
|
1878
|
+
token: tokenSymbol
|
|
1879
|
+
});
|
|
1880
|
+
const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
|
|
1881
|
+
let paymentAmount = (amountToTransfer + estimatedGasCostInToken * BigInt(2)) * BigInt(count != null ? count : 1);
|
|
1882
|
+
const allowance = yield this.viemClient.checkTokenAllowance(
|
|
1883
|
+
token2,
|
|
1884
|
+
signerAddress,
|
|
1885
|
+
smartAccount.address
|
|
1886
|
+
);
|
|
1887
|
+
if (paymentAmount <= allowance) return ["confirm"];
|
|
1888
|
+
return ["allowance", "confirm"];
|
|
1889
|
+
});
|
|
1890
|
+
}
|
|
1924
1891
|
};
|
|
1925
1892
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1926
1893
|
0 && (module.exports = {
|
package/dist/index.d.cts
CHANGED
|
@@ -241,6 +241,7 @@ declare class ActaDeposit {
|
|
|
241
241
|
createPayment(servicePaymentParams?: any): Promise<any>;
|
|
242
242
|
createSinglePayment(servicePaymentParams?: any): Promise<any>;
|
|
243
243
|
createRecurringPayments(servicePaymentParams?: any): Promise<any>;
|
|
244
|
+
getPaymentSteps(): Promise<string[]>;
|
|
244
245
|
}
|
|
245
246
|
|
|
246
247
|
declare class ActaAccount {
|
package/dist/index.d.ts
CHANGED
|
@@ -241,6 +241,7 @@ declare class ActaDeposit {
|
|
|
241
241
|
createPayment(servicePaymentParams?: any): Promise<any>;
|
|
242
242
|
createSinglePayment(servicePaymentParams?: any): Promise<any>;
|
|
243
243
|
createRecurringPayments(servicePaymentParams?: any): Promise<any>;
|
|
244
|
+
getPaymentSteps(): Promise<string[]>;
|
|
244
245
|
}
|
|
245
246
|
|
|
246
247
|
declare class ActaAccount {
|
package/dist/index.js
CHANGED
|
@@ -525,7 +525,6 @@ import {
|
|
|
525
525
|
getAddress as getAddress2,
|
|
526
526
|
parseAbi as parseAbi2
|
|
527
527
|
} from "viem";
|
|
528
|
-
import { privateKeyToAccount as privateKeyToAccount2 } from "viem/accounts";
|
|
529
528
|
import {
|
|
530
529
|
createPaymasterClient,
|
|
531
530
|
formatUserOperationRequest
|
|
@@ -535,7 +534,6 @@ import { getEntryPoint, KERNEL_V3_1 } from "@zerodev/sdk/constants";
|
|
|
535
534
|
import { signerToEcdsaValidator } from "@zerodev/ecdsa-validator";
|
|
536
535
|
import { createSmartAccountClient } from "permissionless";
|
|
537
536
|
import { createPimlicoClient } from "permissionless/clients/pimlico";
|
|
538
|
-
import { prepareUserOperationForErc20Paymaster } from "permissionless/experimental/pimlico";
|
|
539
537
|
|
|
540
538
|
// src/rpc.ts
|
|
541
539
|
function getRpcByChainId(chainId) {
|
|
@@ -627,7 +625,7 @@ var ViemClient = class {
|
|
|
627
625
|
signerAddress,
|
|
628
626
|
spender
|
|
629
627
|
);
|
|
630
|
-
if (allowance < amount
|
|
628
|
+
if (allowance < amount) {
|
|
631
629
|
const txn = yield this.walletClient.sendTransaction({
|
|
632
630
|
to: token2.address,
|
|
633
631
|
account: signerAddress,
|
|
@@ -1103,8 +1101,7 @@ var ActaAccount = class {
|
|
|
1103
1101
|
userOperation: {
|
|
1104
1102
|
estimateFeesPerGas: () => __async(this, null, function* () {
|
|
1105
1103
|
return (yield pimlicoClient.getUserOperationGasPrice()).fast;
|
|
1106
|
-
})
|
|
1107
|
-
prepareUserOperation: prepareUserOperationForErc20Paymaster(pimlicoClient)
|
|
1104
|
+
})
|
|
1108
1105
|
}
|
|
1109
1106
|
});
|
|
1110
1107
|
return { paymasterClient, pimlicoClient, accountClient };
|
|
@@ -1144,28 +1141,17 @@ var ActaAccount = class {
|
|
|
1144
1141
|
to: getAddress2(token2.address),
|
|
1145
1142
|
abi: parseAbi2(["function transferFrom(address,address,uint)"]),
|
|
1146
1143
|
functionName: "transferFrom",
|
|
1147
|
-
args: [fromAddress, smartAccountAddress, BigInt(0)]
|
|
1148
|
-
},
|
|
1149
|
-
{
|
|
1150
|
-
to: getAddress2(token2.address),
|
|
1151
|
-
abi: parseAbi2(["function approve(address,uint)"]),
|
|
1152
|
-
functionName: "approve",
|
|
1153
|
-
args: [paymaster, BigInt(0)]
|
|
1154
|
-
},
|
|
1155
|
-
{
|
|
1156
|
-
to: getAddress2(token2.address),
|
|
1157
|
-
abi: parseAbi2(["function transfer(address,uint)"]),
|
|
1158
|
-
functionName: "transfer",
|
|
1159
1144
|
args: [
|
|
1145
|
+
fromAddress,
|
|
1160
1146
|
"0x061BA68bc8208F4AddBeE86F74F17D77129cCF70",
|
|
1161
1147
|
BigInt(0)
|
|
1162
1148
|
]
|
|
1163
1149
|
},
|
|
1164
1150
|
{
|
|
1165
1151
|
to: getAddress2(token2.address),
|
|
1166
|
-
abi: parseAbi2(["function
|
|
1167
|
-
functionName: "
|
|
1168
|
-
args: [receiver, BigInt(0)]
|
|
1152
|
+
abi: parseAbi2(["function transferFrom(address,address,uint)"]),
|
|
1153
|
+
functionName: "transferFrom",
|
|
1154
|
+
args: [fromAddress, receiver, BigInt(0)]
|
|
1169
1155
|
}
|
|
1170
1156
|
]
|
|
1171
1157
|
});
|
|
@@ -1248,33 +1234,19 @@ var ActaAccount = class {
|
|
|
1248
1234
|
to: getAddress2(token2.address),
|
|
1249
1235
|
abi: parseAbi2(["function transferFrom(address,address,uint)"]),
|
|
1250
1236
|
functionName: "transferFrom",
|
|
1251
|
-
args: [fromAddress, smartAccountAddress, amountToTransfer]
|
|
1252
|
-
},
|
|
1253
|
-
{
|
|
1254
|
-
to: getAddress2(token2.address),
|
|
1255
|
-
abi: parseAbi2(["function approve(address,uint)"]),
|
|
1256
|
-
functionName: "approve",
|
|
1257
|
-
args: [paymaster, estimatedGasCostInToken]
|
|
1258
|
-
},
|
|
1259
|
-
{
|
|
1260
|
-
to: getAddress2(token2.address),
|
|
1261
|
-
abi: parseAbi2(["function transfer(address,uint)"]),
|
|
1262
|
-
functionName: "transfer",
|
|
1263
1237
|
args: [
|
|
1264
|
-
|
|
1265
|
-
|
|
1238
|
+
fromAddress,
|
|
1239
|
+
"0xC4910E5ec82Da0A41aF9C6360b7A1f531e1e37B0",
|
|
1240
|
+
estimatedGasCostInToken
|
|
1266
1241
|
]
|
|
1267
1242
|
},
|
|
1268
1243
|
{
|
|
1269
1244
|
to: getAddress2(token2.address),
|
|
1270
|
-
abi: parseAbi2(["function
|
|
1271
|
-
functionName: "
|
|
1272
|
-
args: [receiver, receiverAmount]
|
|
1245
|
+
abi: parseAbi2(["function transferFrom(address,address,uint)"]),
|
|
1246
|
+
functionName: "transferFrom",
|
|
1247
|
+
args: [fromAddress, receiver, receiverAmount]
|
|
1273
1248
|
}
|
|
1274
|
-
]
|
|
1275
|
-
paymasterContext: {
|
|
1276
|
-
token: token2.address
|
|
1277
|
-
}
|
|
1249
|
+
]
|
|
1278
1250
|
});
|
|
1279
1251
|
const signature = yield account.signUserOperation(__spreadProps(__spreadValues({}, userOperation), {
|
|
1280
1252
|
chainId: this.chainId
|
|
@@ -1329,11 +1301,6 @@ var ActaAccount = class {
|
|
|
1329
1301
|
const smartAccountAddress = account.address;
|
|
1330
1302
|
const viemClient = new ViemClient(this.chainId, this.signer);
|
|
1331
1303
|
const { paymasterClient, pimlicoClient } = yield this.createAccountHelpers();
|
|
1332
|
-
const sessionKeySigner = yield toECDSASigner(
|
|
1333
|
-
privateKeyToAccount2(
|
|
1334
|
-
"0x8519baaeb81ebbcf3597d93c2f9790d1eda37097121e844e1b88c1ab77b67ae2"
|
|
1335
|
-
)
|
|
1336
|
-
);
|
|
1337
1304
|
const ecdsaValidator = yield signerToEcdsaValidator(
|
|
1338
1305
|
viemClient.publicClient(),
|
|
1339
1306
|
{
|
|
@@ -1342,7 +1309,7 @@ var ActaAccount = class {
|
|
|
1342
1309
|
signer: this.signer
|
|
1343
1310
|
}
|
|
1344
1311
|
);
|
|
1345
|
-
const sessionKeyAddress = "
|
|
1312
|
+
const sessionKeyAddress = "0xFDEed8e268D74DF71f3Db7409F8A8290FF1263ED";
|
|
1346
1313
|
const emptyAccount = addressToEmptyAccount(sessionKeyAddress);
|
|
1347
1314
|
const emptySessionKeySigner = yield toECDSASigner(emptyAccount);
|
|
1348
1315
|
const {
|
|
@@ -1382,45 +1349,13 @@ var ActaAccount = class {
|
|
|
1382
1349
|
condition: ParamCondition.EQUAL,
|
|
1383
1350
|
value: signerAddress
|
|
1384
1351
|
},
|
|
1385
|
-
{
|
|
1386
|
-
condition: ParamCondition.EQUAL,
|
|
1387
|
-
value: smartAccountAddress
|
|
1388
|
-
},
|
|
1389
|
-
{
|
|
1390
|
-
condition: ParamCondition.GREATER_THAN_OR_EQUAL,
|
|
1391
|
-
value: 0
|
|
1392
|
-
}
|
|
1393
|
-
]
|
|
1394
|
-
},
|
|
1395
|
-
{
|
|
1396
|
-
target: token2.address,
|
|
1397
|
-
valueLimit: BigInt(0),
|
|
1398
|
-
abi: parseAbi2(["function approve(address,uint)"]),
|
|
1399
|
-
functionName: "approve",
|
|
1400
|
-
args: [
|
|
1401
|
-
{
|
|
1402
|
-
condition: ParamCondition.EQUAL,
|
|
1403
|
-
value: paymaster
|
|
1404
|
-
},
|
|
1405
|
-
{
|
|
1406
|
-
condition: ParamCondition.GREATER_THAN_OR_EQUAL,
|
|
1407
|
-
value: 0
|
|
1408
|
-
}
|
|
1409
|
-
]
|
|
1410
|
-
},
|
|
1411
|
-
{
|
|
1412
|
-
target: token2.address,
|
|
1413
|
-
valueLimit: BigInt(0),
|
|
1414
|
-
abi: parseAbi2(["function transfer(address,uint)"]),
|
|
1415
|
-
functionName: "transfer",
|
|
1416
|
-
args: [
|
|
1417
1352
|
{
|
|
1418
1353
|
condition: ParamCondition.ONE_OF,
|
|
1419
|
-
value: ["
|
|
1354
|
+
value: ["0xC4910E5ec82Da0A41aF9C6360b7A1f531e1e37B0", receiver]
|
|
1420
1355
|
},
|
|
1421
1356
|
{
|
|
1422
|
-
condition: ParamCondition.
|
|
1423
|
-
value:
|
|
1357
|
+
condition: ParamCondition.LESS_THAN_OR_EQUAL,
|
|
1358
|
+
value: amountToTransfer + amountToTransfer / BigInt(2)
|
|
1424
1359
|
}
|
|
1425
1360
|
]
|
|
1426
1361
|
}
|
|
@@ -1877,6 +1812,38 @@ var ActaDeposit = class {
|
|
|
1877
1812
|
return txn.recurringTransaction.id;
|
|
1878
1813
|
});
|
|
1879
1814
|
}
|
|
1815
|
+
getPaymentSteps() {
|
|
1816
|
+
return __async(this, null, function* () {
|
|
1817
|
+
const signerAddress = this.signerAddress;
|
|
1818
|
+
const chainId = this.chainId;
|
|
1819
|
+
const tokenSymbol = this.token;
|
|
1820
|
+
const amount = this.amount;
|
|
1821
|
+
const receiver = this.receiver;
|
|
1822
|
+
const feeInclusive = this.feeInclusive;
|
|
1823
|
+
const count = this.count;
|
|
1824
|
+
if (!signerAddress) return ["allowance", "confirm"];
|
|
1825
|
+
const token2 = getTokenByChainIdAndSymbol(chainId, tokenSymbol);
|
|
1826
|
+
if (!token2) return ["allowance", "confirm"];
|
|
1827
|
+
const smartAccount = yield this.account.createAccount();
|
|
1828
|
+
const { estimatedGasCostInToken, feeExclusiveAmountInToken } = yield this.account.estimateSinglePaymentGas({
|
|
1829
|
+
chainId,
|
|
1830
|
+
amount,
|
|
1831
|
+
feeInclusive,
|
|
1832
|
+
receiver,
|
|
1833
|
+
signerAddress,
|
|
1834
|
+
token: tokenSymbol
|
|
1835
|
+
});
|
|
1836
|
+
const amountToTransfer = feeInclusive ? amount : feeExclusiveAmountInToken;
|
|
1837
|
+
let paymentAmount = (amountToTransfer + estimatedGasCostInToken * BigInt(2)) * BigInt(count != null ? count : 1);
|
|
1838
|
+
const allowance = yield this.viemClient.checkTokenAllowance(
|
|
1839
|
+
token2,
|
|
1840
|
+
signerAddress,
|
|
1841
|
+
smartAccount.address
|
|
1842
|
+
);
|
|
1843
|
+
if (paymentAmount <= allowance) return ["confirm"];
|
|
1844
|
+
return ["allowance", "confirm"];
|
|
1845
|
+
});
|
|
1846
|
+
}
|
|
1880
1847
|
};
|
|
1881
1848
|
export {
|
|
1882
1849
|
ActaAccount,
|