@deserialize/multi-vm-wallet 1.4.12 → 1.5.0
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/.claude/settings.local.json +7 -1
- package/BUILD_OPTIMIZATION_PLAN.md +640 -0
- package/BUILD_RESULTS.md +282 -0
- package/BUN_MIGRATION.md +415 -0
- package/CHANGELOG_SECURITY.md +573 -0
- package/IMPLEMENTATION_SUMMARY.md +494 -0
- package/SECURITY_AUDIT.md +1124 -0
- package/bun.lock +553 -0
- package/dist/IChainWallet.js +0 -5
- package/dist/bip32Old.js +0 -885
- package/dist/bip32Small.js +0 -79
- package/dist/bipTest.js +0 -362
- package/dist/constant.js +0 -17
- package/dist/english.js +0 -1
- package/dist/evm/aa-service/index.d.ts +0 -5
- package/dist/evm/aa-service/index.js +0 -14
- package/dist/evm/aa-service/lib/account-adapter.d.ts +0 -22
- package/dist/evm/aa-service/lib/account-adapter.js +0 -24
- package/dist/evm/aa-service/lib/kernel-account.d.ts +0 -30
- package/dist/evm/aa-service/lib/kernel-account.js +2 -67
- package/dist/evm/aa-service/lib/kernel-modules.d.ts +0 -177
- package/dist/evm/aa-service/lib/kernel-modules.js +4 -202
- package/dist/evm/aa-service/lib/session-keys.d.ts +0 -118
- package/dist/evm/aa-service/lib/session-keys.js +7 -151
- package/dist/evm/aa-service/lib/type.d.ts +0 -55
- package/dist/evm/aa-service/lib/type.js +0 -10
- package/dist/evm/aa-service/services/account-abstraction.d.ts +0 -426
- package/dist/evm/aa-service/services/account-abstraction.js +0 -461
- package/dist/evm/aa-service/services/bundler.d.ts +0 -6
- package/dist/evm/aa-service/services/bundler.js +0 -54
- package/dist/evm/evm.d.ts +10 -67
- package/dist/evm/evm.js +340 -102
- package/dist/evm/index.js +0 -3
- package/dist/evm/script.js +3 -17
- package/dist/evm/smartWallet.d.ts +0 -173
- package/dist/evm/smartWallet.js +0 -206
- package/dist/evm/smartWallet.types.d.ts +0 -6
- package/dist/evm/smartWallet.types.js +0 -8
- package/dist/evm/transaction.utils.d.ts +0 -242
- package/dist/evm/transaction.utils.js +4 -320
- package/dist/evm/transactionParsing.d.ts +0 -11
- package/dist/evm/transactionParsing.js +28 -147
- package/dist/evm/utils.d.ts +0 -46
- package/dist/evm/utils.js +1 -57
- package/dist/helpers/index.d.ts +0 -4
- package/dist/helpers/index.js +8 -44
- package/dist/helpers/routeScan.js +0 -1
- package/dist/index.js +0 -1
- package/dist/old.js +0 -884
- package/dist/price.js +0 -1
- package/dist/price.types.js +0 -2
- package/dist/rate-limiter.d.ts +28 -0
- package/dist/rate-limiter.js +95 -0
- package/dist/retry-logic.d.ts +14 -0
- package/dist/retry-logic.js +120 -0
- package/dist/savings/index.d.ts +1 -0
- package/dist/savings/index.js +16 -2
- package/dist/savings/saving-manager.d.ts +46 -0
- package/dist/savings/saving-manager.js +176 -0
- package/dist/savings/savings-operations.d.ts +39 -0
- package/dist/savings/savings-operations.js +141 -0
- package/dist/savings/smart-savings.d.ts +0 -63
- package/dist/savings/smart-savings.js +0 -78
- package/dist/savings/types.d.ts +0 -69
- package/dist/savings/types.js +0 -7
- package/dist/savings/validation.d.ts +9 -0
- package/dist/savings/validation.js +85 -0
- package/dist/svm/constant.js +0 -1
- package/dist/svm/index.js +0 -1
- package/dist/svm/svm.d.ts +7 -13
- package/dist/svm/svm.js +263 -46
- package/dist/svm/transactionParsing.d.ts +0 -7
- package/dist/svm/transactionParsing.js +3 -41
- package/dist/svm/transactionSender.js +0 -9
- package/dist/svm/utils.d.ts +0 -12
- package/dist/svm/utils.js +9 -60
- package/dist/test.d.ts +0 -4
- package/dist/test.js +15 -95
- package/dist/transaction-utils.d.ts +38 -0
- package/dist/transaction-utils.js +168 -0
- package/dist/types.d.ts +36 -0
- package/dist/types.js +0 -1
- package/dist/utils.js +0 -1
- package/dist/vm-validation.d.ts +11 -0
- package/dist/vm-validation.js +151 -0
- package/dist/vm.d.ts +14 -16
- package/dist/vm.js +64 -53
- package/dist/walletBip32.d.ts +2 -0
- package/dist/walletBip32.js +33 -66
- package/package.json +9 -4
- package/test-discovery.ts +235 -0
- package/test-pocket-discovery.ts +84 -0
- package/tsconfig.json +18 -11
- package/tsconfig.prod.json +10 -0
- package/utils/IChainWallet.ts +2 -0
- package/utils/evm/evm.ts +560 -39
- package/utils/rate-limiter.ts +179 -0
- package/utils/retry-logic.ts +271 -0
- package/utils/savings/EXAMPLES.md +883 -0
- package/utils/savings/SECURITY.md +731 -0
- package/utils/savings/index.ts +1 -1
- package/utils/savings/saving-manager.ts +656 -0
- package/utils/savings/savings-operations.ts +509 -0
- package/utils/savings/validation.ts +187 -0
- package/utils/svm/svm.ts +467 -20
- package/utils/test.ts +26 -3
- package/utils/transaction-utils.ts +394 -0
- package/utils/types.ts +100 -0
- package/utils/vm-validation.ts +280 -0
- package/utils/vm.ts +202 -24
- package/utils/walletBip32.ts +63 -3
- package/dist/IChainWallet.js.map +0 -1
- package/dist/bip32.d.ts +0 -9
- package/dist/bip32.js +0 -172
- package/dist/bip32.js.map +0 -1
- package/dist/bip32Old.js.map +0 -1
- package/dist/bip32Small.js.map +0 -1
- package/dist/bipTest.js.map +0 -1
- package/dist/constant.js.map +0 -1
- package/dist/english.js.map +0 -1
- package/dist/evm/SMART_WALLET_EXAMPLES.d.ts +0 -20
- package/dist/evm/SMART_WALLET_EXAMPLES.js +0 -451
- package/dist/evm/SMART_WALLET_EXAMPLES.js.map +0 -1
- package/dist/evm/aa-service/index.js.map +0 -1
- package/dist/evm/aa-service/lib/account-adapter.js.map +0 -1
- package/dist/evm/aa-service/lib/kernel-account.js.map +0 -1
- package/dist/evm/aa-service/lib/kernel-modules.js.map +0 -1
- package/dist/evm/aa-service/lib/session-keys.js.map +0 -1
- package/dist/evm/aa-service/lib/type.js.map +0 -1
- package/dist/evm/aa-service/services/account-abstraction.js.map +0 -1
- package/dist/evm/aa-service/services/bundler.js.map +0 -1
- package/dist/evm/evm.js.map +0 -1
- package/dist/evm/index.js.map +0 -1
- package/dist/evm/script.js.map +0 -1
- package/dist/evm/smartWallet.js.map +0 -1
- package/dist/evm/smartWallet.types.js.map +0 -1
- package/dist/evm/transaction.utils.js.map +0 -1
- package/dist/evm/transactionParsing.js.map +0 -1
- package/dist/evm/utils.js.map +0 -1
- package/dist/helpers/index.js.map +0 -1
- package/dist/helpers/routeScan.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/old.js.map +0 -1
- package/dist/price.js.map +0 -1
- package/dist/price.types.js.map +0 -1
- package/dist/privacy/artifact-manager.d.ts +0 -117
- package/dist/privacy/artifact-manager.js +0 -251
- package/dist/privacy/artifact-manager.js.map +0 -1
- package/dist/privacy/broadcaster-client.d.ts +0 -166
- package/dist/privacy/broadcaster-client.js +0 -261
- package/dist/privacy/broadcaster-client.js.map +0 -1
- package/dist/privacy/index.d.ts +0 -34
- package/dist/privacy/index.js +0 -56
- package/dist/privacy/index.js.map +0 -1
- package/dist/privacy/network-config.d.ts +0 -57
- package/dist/privacy/network-config.js +0 -118
- package/dist/privacy/network-config.js.map +0 -1
- package/dist/privacy/poi-helper.d.ts +0 -161
- package/dist/privacy/poi-helper.js +0 -249
- package/dist/privacy/poi-helper.js.map +0 -1
- package/dist/privacy/railgun-engine.d.ts +0 -135
- package/dist/privacy/railgun-engine.js +0 -205
- package/dist/privacy/railgun-engine.js.map +0 -1
- package/dist/privacy/railgun-privacy-wallet.d.ts +0 -288
- package/dist/privacy/railgun-privacy-wallet.js +0 -539
- package/dist/privacy/railgun-privacy-wallet.js.map +0 -1
- package/dist/privacy/types.d.ts +0 -229
- package/dist/privacy/types.js +0 -26
- package/dist/privacy/types.js.map +0 -1
- package/dist/savings/index.js.map +0 -1
- package/dist/savings/saving-actions.d.ts +0 -0
- package/dist/savings/saving-actions.js +0 -78
- package/dist/savings/saving-actions.js.map +0 -1
- package/dist/savings/savings-manager.d.ts +0 -126
- package/dist/savings/savings-manager.js +0 -234
- package/dist/savings/savings-manager.js.map +0 -1
- package/dist/savings/smart-savings.js.map +0 -1
- package/dist/savings/types.js.map +0 -1
- package/dist/svm/constant.js.map +0 -1
- package/dist/svm/index.js.map +0 -1
- package/dist/svm/svm.js.map +0 -1
- package/dist/svm/transactionParsing.js.map +0 -1
- package/dist/svm/transactionSender.js.map +0 -1
- package/dist/svm/utils.js.map +0 -1
- package/dist/test.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils.js.map +0 -1
- package/dist/vm.js.map +0 -1
- package/dist/walletBip32.js.map +0 -1
- package/utils/savings/saving-actions.ts +0 -92
- package/utils/savings/savings-manager.ts +0 -271
package/dist/evm/evm.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @param phrase this is the pass phrase for this vm
|
|
5
|
-
* this is a class that will be responsible for creating several evm wallets code
|
|
6
|
-
*/
|
|
7
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
3
|
exports.EVMChainWallet = exports.EVMVM = void 0;
|
|
9
4
|
const walletBip32_1 = require("../walletBip32");
|
|
10
5
|
const IChainWallet_1 = require("../IChainWallet");
|
|
11
6
|
const vm_1 = require("../vm");
|
|
7
|
+
const vm_validation_1 = require("../vm-validation");
|
|
12
8
|
const ethers_1 = require("ethers");
|
|
13
9
|
const utils_1 = require("./utils");
|
|
14
10
|
const transactionParsing_1 = require("./transactionParsing");
|
|
@@ -17,78 +13,384 @@ const smartWallet_1 = require("./smartWallet");
|
|
|
17
13
|
const price_1 = require("../price");
|
|
18
14
|
const accounts_1 = require("viem/accounts");
|
|
19
15
|
class EVMVM extends vm_1.VM {
|
|
20
|
-
derivationPath = "m/44'/60'/0'/0/";
|
|
16
|
+
derivationPath = "m/44'/60'/0'/0/";
|
|
21
17
|
constructor(seed) {
|
|
22
18
|
super(seed, "EVM");
|
|
23
19
|
}
|
|
24
20
|
getTokenInfo = utils_1.getTokenInfo;
|
|
25
21
|
static getTokenInfo = utils_1.getTokenInfo;
|
|
26
22
|
generatePrivateKey(index, seed, mnemonic, derivationPath = this.derivationPath) {
|
|
23
|
+
vm_validation_1.VMValidation.validateIndex(index, 'Wallet index');
|
|
24
|
+
vm_validation_1.VMValidation.validateDerivationPath(derivationPath + index + "'", 'EVM');
|
|
27
25
|
let _seed;
|
|
28
26
|
if (seed) {
|
|
27
|
+
vm_validation_1.VMValidation.validateSeed(seed);
|
|
29
28
|
_seed = seed;
|
|
30
29
|
}
|
|
31
30
|
else if (mnemonic) {
|
|
31
|
+
vm_validation_1.VMValidation.validateMnemonic(mnemonic);
|
|
32
32
|
_seed = vm_1.VM.mnemonicToSeed(mnemonic);
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
35
|
+
this.checkNotDisposed();
|
|
35
36
|
_seed = this.seed;
|
|
36
37
|
}
|
|
37
38
|
const privateKey = (0, walletBip32_1.EVMDeriveChildPrivateKey)(_seed, index, derivationPath).privateKey;
|
|
38
39
|
return { privateKey, index };
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*
|
|
43
|
-
* Uses the pattern: m/44'/60'/accountIndex'/0/0
|
|
44
|
-
* - Main wallet: m/44'/60'/0'/0/0 (account index 0)
|
|
45
|
-
* - Savings 1: m/44'/60'/1'/0/0 (account index 1)
|
|
46
|
-
* - Savings 2: m/44'/60'/2'/0/0 (account index 2)
|
|
47
|
-
*
|
|
48
|
-
* @param accountIndex - The BIP-44 account index (0 for main, 1+ for savings)
|
|
49
|
-
* @returns Object containing privateKey, address, and derivation path
|
|
50
|
-
*/
|
|
51
|
-
deriveSavingsAccount(accountIndex) {
|
|
52
|
-
// Use fixed address index 0 for savings accounts
|
|
53
|
-
// Vary only the account index (3rd position in BIP-44)
|
|
54
|
-
const derivationPath = `m/44'/60'/${accountIndex}'/0/0`;
|
|
55
|
-
// Derive the full path directly (no additional index appended)
|
|
56
|
-
const result = (0, walletBip32_1.EVMDeriveChildPrivateKey)(this.seed, 0, `m/44'/60'/${accountIndex}'/0/`);
|
|
57
|
-
const privateKey = result.privateKey;
|
|
58
|
-
// Derive address from private key
|
|
59
|
-
const wallet = new ethers_1.ethers.Wallet(privateKey);
|
|
60
|
-
const address = wallet.address;
|
|
61
|
-
return {
|
|
62
|
-
privateKey,
|
|
63
|
-
address,
|
|
64
|
-
derivationPath
|
|
65
|
-
};
|
|
41
|
+
static generateMnemonicFromPrivateKey(privateKey) {
|
|
42
|
+
return (0, walletBip32_1.EntropyToMnemonic)(privateKey);
|
|
66
43
|
}
|
|
67
44
|
static fromMnemonic(mnemonic) {
|
|
68
45
|
const seed = vm_1.VM.mnemonicToSeed(mnemonic);
|
|
69
46
|
return new EVMVM(seed);
|
|
70
47
|
}
|
|
71
|
-
static validateAddress(address) {
|
|
72
|
-
|
|
48
|
+
static validateAddress(address, requireChecksum = false) {
|
|
49
|
+
if (!ethers_1.ethers.isAddress(address)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
if (requireChecksum && address !== address.toLowerCase() && address !== address.toUpperCase()) {
|
|
53
|
+
try {
|
|
54
|
+
const checksummed = ethers_1.ethers.getAddress(address);
|
|
55
|
+
return checksummed === address;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
static normalizeAddress(address) {
|
|
64
|
+
if (!this.validateAddress(address)) {
|
|
65
|
+
throw new Error(`Invalid Ethereum address: ${address}`);
|
|
66
|
+
}
|
|
67
|
+
return ethers_1.ethers.getAddress(address);
|
|
73
68
|
}
|
|
74
69
|
static async getNativeBalance(address, connection) {
|
|
75
|
-
// Implement native balance retrieval logic here
|
|
76
70
|
return await (0, utils_1.getNativeBalance)(address, connection);
|
|
77
71
|
}
|
|
78
72
|
static async getTokenBalance(address, tokenAddress, connection) {
|
|
79
|
-
// Implement token balance retrieval logic here
|
|
80
73
|
return await (0, utils_1.getTokenBalance)(tokenAddress, address, connection);
|
|
81
74
|
}
|
|
82
75
|
static convertFromEntropyToPrivateKey = (entropy) => {
|
|
83
76
|
return (0, viem_1.toHex)(entropy);
|
|
84
77
|
};
|
|
78
|
+
async discoverWallets(connection, options) {
|
|
79
|
+
const startTime = Date.now();
|
|
80
|
+
const checkInParallel = options?.checkInParallel ?? true;
|
|
81
|
+
const opts = {
|
|
82
|
+
startIndex: options?.startIndex ?? 0,
|
|
83
|
+
maxIndex: options?.maxIndex ?? 100,
|
|
84
|
+
gapLimit: options?.gapLimit ?? 20,
|
|
85
|
+
minBalance: options?.minBalance ?? 0n,
|
|
86
|
+
includeZeroBalance: options?.includeZeroBalance ?? false,
|
|
87
|
+
includePrivateKeys: options?.includePrivateKeys ?? false,
|
|
88
|
+
checkInParallel,
|
|
89
|
+
batchSize: options?.batchSize ?? 10,
|
|
90
|
+
checkDelay: options?.checkDelay ?? (checkInParallel ? 200 : 50),
|
|
91
|
+
onProgress: options?.onProgress ?? (() => { }),
|
|
92
|
+
onDiscovered: options?.onDiscovered ?? (() => { }),
|
|
93
|
+
};
|
|
94
|
+
const discovered = [];
|
|
95
|
+
let gapCounter = 0;
|
|
96
|
+
let highestIndex = opts.startIndex;
|
|
97
|
+
let stoppedByGapLimit = false;
|
|
98
|
+
const isViem = 'readContract' in connection;
|
|
99
|
+
if (opts.checkInParallel) {
|
|
100
|
+
for (let i = opts.startIndex; i <= opts.maxIndex; i += opts.batchSize) {
|
|
101
|
+
if (gapCounter >= opts.gapLimit) {
|
|
102
|
+
stoppedByGapLimit = true;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
const batchIndices = Array.from({ length: Math.min(opts.batchSize, opts.maxIndex - i + 1) }, (_, idx) => i + idx);
|
|
106
|
+
const batchResults = await Promise.all(batchIndices.map(index => this.checkWalletBalance(index, connection, isViem)));
|
|
107
|
+
for (let j = 0; j < batchResults.length; j++) {
|
|
108
|
+
const result = batchResults[j];
|
|
109
|
+
const index = batchIndices[j];
|
|
110
|
+
highestIndex = index;
|
|
111
|
+
if (result) {
|
|
112
|
+
const meetsMinBalance = result.nativeBalance.amount >= opts.minBalance;
|
|
113
|
+
if (meetsMinBalance || opts.includeZeroBalance) {
|
|
114
|
+
if (!opts.includePrivateKeys) {
|
|
115
|
+
delete result.privateKey;
|
|
116
|
+
}
|
|
117
|
+
discovered.push(result);
|
|
118
|
+
opts.onDiscovered(result);
|
|
119
|
+
if (meetsMinBalance) {
|
|
120
|
+
gapCounter = 0;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
gapCounter++;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
gapCounter++;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
gapCounter++;
|
|
132
|
+
}
|
|
133
|
+
opts.onProgress(index + 1 - opts.startIndex, opts.maxIndex - opts.startIndex + 1, discovered.length);
|
|
134
|
+
if (gapCounter >= opts.gapLimit) {
|
|
135
|
+
stoppedByGapLimit = true;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (i + opts.batchSize <= opts.maxIndex && !stoppedByGapLimit) {
|
|
140
|
+
await this.sleep(opts.checkDelay);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
for (let index = opts.startIndex; index <= opts.maxIndex; index++) {
|
|
146
|
+
if (gapCounter >= opts.gapLimit) {
|
|
147
|
+
stoppedByGapLimit = true;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
const result = await this.checkWalletBalance(index, connection, isViem);
|
|
151
|
+
highestIndex = index;
|
|
152
|
+
if (result) {
|
|
153
|
+
const meetsMinBalance = result.nativeBalance.amount >= opts.minBalance;
|
|
154
|
+
if (meetsMinBalance || opts.includeZeroBalance) {
|
|
155
|
+
if (!opts.includePrivateKeys) {
|
|
156
|
+
delete result.privateKey;
|
|
157
|
+
}
|
|
158
|
+
discovered.push(result);
|
|
159
|
+
opts.onDiscovered(result);
|
|
160
|
+
if (meetsMinBalance) {
|
|
161
|
+
gapCounter = 0;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
gapCounter++;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
gapCounter++;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
gapCounter++;
|
|
173
|
+
}
|
|
174
|
+
opts.onProgress(index + 1 - opts.startIndex, opts.maxIndex - opts.startIndex + 1, discovered.length);
|
|
175
|
+
if (index < opts.maxIndex && !stoppedByGapLimit) {
|
|
176
|
+
await this.sleep(opts.checkDelay);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const totalBalance = discovered.reduce((sum, wallet) => sum + wallet.nativeBalance.amount, 0n);
|
|
181
|
+
const duration = Date.now() - startTime;
|
|
182
|
+
return {
|
|
183
|
+
discovered,
|
|
184
|
+
scannedIndices: highestIndex - opts.startIndex + 1,
|
|
185
|
+
highestIndex,
|
|
186
|
+
totalBalance,
|
|
187
|
+
stoppedByGapLimit,
|
|
188
|
+
duration,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
async checkWalletBalance(index, connection, isViem, maxRetries = 3) {
|
|
192
|
+
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
193
|
+
try {
|
|
194
|
+
const { privateKey } = this.generatePrivateKey(index);
|
|
195
|
+
const wallet = new ethers_1.ethers.Wallet(privateKey);
|
|
196
|
+
const address = wallet.address;
|
|
197
|
+
let balanceWei;
|
|
198
|
+
if (isViem) {
|
|
199
|
+
const viemConnection = connection;
|
|
200
|
+
balanceWei = await viemConnection.getBalance({ address: address });
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
const ethersConnection = connection;
|
|
204
|
+
balanceWei = await ethersConnection.getBalance(address);
|
|
205
|
+
}
|
|
206
|
+
const formatted = Number(ethers_1.ethers.formatEther(balanceWei));
|
|
207
|
+
return {
|
|
208
|
+
index,
|
|
209
|
+
address,
|
|
210
|
+
derivationPath: `${this.derivationPath}${index}'`,
|
|
211
|
+
nativeBalance: {
|
|
212
|
+
amount: balanceWei,
|
|
213
|
+
formatted,
|
|
214
|
+
symbol: 'ETH',
|
|
215
|
+
},
|
|
216
|
+
privateKey,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
if (attempt === maxRetries - 1) {
|
|
221
|
+
console.warn(`Failed to check wallet at index ${index} after ${maxRetries} attempts:`, error);
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
const delay = Math.pow(2, attempt) * 1000;
|
|
225
|
+
await this.sleep(delay);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
sleep(ms) {
|
|
231
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
232
|
+
}
|
|
233
|
+
async discoverPockets(connection, options) {
|
|
234
|
+
const startTime = Date.now();
|
|
235
|
+
const walletIndex = options?.walletIndex ?? 0;
|
|
236
|
+
const checkInParallel = options?.checkInParallel ?? true;
|
|
237
|
+
const opts = {
|
|
238
|
+
startIndex: options?.startIndex ?? 0,
|
|
239
|
+
maxIndex: options?.maxIndex ?? 100,
|
|
240
|
+
gapLimit: options?.gapLimit ?? 20,
|
|
241
|
+
minBalance: options?.minBalance ?? 0n,
|
|
242
|
+
includeZeroBalance: options?.includeZeroBalance ?? false,
|
|
243
|
+
includePrivateKeys: options?.includePrivateKeys ?? false,
|
|
244
|
+
checkInParallel,
|
|
245
|
+
batchSize: options?.batchSize ?? 10,
|
|
246
|
+
checkDelay: options?.checkDelay ?? (checkInParallel ? 200 : 50),
|
|
247
|
+
onProgress: options?.onProgress ?? (() => { }),
|
|
248
|
+
onDiscovered: options?.onDiscovered ?? (() => { }),
|
|
249
|
+
walletIndex,
|
|
250
|
+
};
|
|
251
|
+
const discovered = [];
|
|
252
|
+
let gapCounter = 0;
|
|
253
|
+
let highestIndex = opts.startIndex;
|
|
254
|
+
let stoppedByGapLimit = false;
|
|
255
|
+
const isViem = 'readContract' in connection;
|
|
256
|
+
if (opts.checkInParallel) {
|
|
257
|
+
for (let i = opts.startIndex; i <= opts.maxIndex; i += opts.batchSize) {
|
|
258
|
+
if (gapCounter >= opts.gapLimit) {
|
|
259
|
+
stoppedByGapLimit = true;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
const batchIndices = Array.from({ length: Math.min(opts.batchSize, opts.maxIndex - i + 1) }, (_, idx) => i + idx);
|
|
263
|
+
const batchResults = await Promise.all(batchIndices.map(index => this.checkPocketBalance(index, walletIndex, connection, isViem)));
|
|
264
|
+
for (let j = 0; j < batchResults.length; j++) {
|
|
265
|
+
const result = batchResults[j];
|
|
266
|
+
const index = batchIndices[j];
|
|
267
|
+
highestIndex = index;
|
|
268
|
+
if (result) {
|
|
269
|
+
const meetsMinBalance = result.nativeBalance.amount >= opts.minBalance;
|
|
270
|
+
if (meetsMinBalance || opts.includeZeroBalance) {
|
|
271
|
+
if (!opts.includePrivateKeys) {
|
|
272
|
+
delete result.privateKey;
|
|
273
|
+
}
|
|
274
|
+
discovered.push(result);
|
|
275
|
+
opts.onDiscovered(result);
|
|
276
|
+
if (meetsMinBalance) {
|
|
277
|
+
gapCounter = 0;
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
gapCounter++;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
gapCounter++;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
gapCounter++;
|
|
289
|
+
}
|
|
290
|
+
opts.onProgress(index + 1 - opts.startIndex, opts.maxIndex - opts.startIndex + 1, discovered.length);
|
|
291
|
+
if (gapCounter >= opts.gapLimit) {
|
|
292
|
+
stoppedByGapLimit = true;
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (i + opts.batchSize <= opts.maxIndex && !stoppedByGapLimit) {
|
|
297
|
+
await this.sleep(opts.checkDelay);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
for (let index = opts.startIndex; index <= opts.maxIndex; index++) {
|
|
303
|
+
if (gapCounter >= opts.gapLimit) {
|
|
304
|
+
stoppedByGapLimit = true;
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
const result = await this.checkPocketBalance(index, walletIndex, connection, isViem);
|
|
308
|
+
highestIndex = index;
|
|
309
|
+
if (result) {
|
|
310
|
+
const meetsMinBalance = result.nativeBalance.amount >= opts.minBalance;
|
|
311
|
+
if (meetsMinBalance || opts.includeZeroBalance) {
|
|
312
|
+
if (!opts.includePrivateKeys) {
|
|
313
|
+
delete result.privateKey;
|
|
314
|
+
}
|
|
315
|
+
discovered.push(result);
|
|
316
|
+
opts.onDiscovered(result);
|
|
317
|
+
if (meetsMinBalance) {
|
|
318
|
+
gapCounter = 0;
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
gapCounter++;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
gapCounter++;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
gapCounter++;
|
|
330
|
+
}
|
|
331
|
+
opts.onProgress(index + 1 - opts.startIndex, opts.maxIndex - opts.startIndex + 1, discovered.length);
|
|
332
|
+
if (index < opts.maxIndex && !stoppedByGapLimit) {
|
|
333
|
+
await this.sleep(opts.checkDelay);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
const totalBalance = discovered.reduce((sum, wallet) => sum + wallet.nativeBalance.amount, 0n);
|
|
338
|
+
const duration = Date.now() - startTime;
|
|
339
|
+
return {
|
|
340
|
+
discovered,
|
|
341
|
+
scannedIndices: highestIndex - opts.startIndex + 1,
|
|
342
|
+
highestIndex,
|
|
343
|
+
totalBalance,
|
|
344
|
+
stoppedByGapLimit,
|
|
345
|
+
duration,
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
async checkPocketBalance(accountIndex, walletIndex, connection, isViem, maxRetries = 3) {
|
|
349
|
+
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
350
|
+
try {
|
|
351
|
+
const pocketIndex = accountIndex + 1;
|
|
352
|
+
const derivationPath = `m/44'/60'/${pocketIndex}'/0/${walletIndex}'`;
|
|
353
|
+
const { privateKey } = (0, walletBip32_1.EVMDeriveChildPrivateKey)(this.seed, walletIndex, `m/44'/60'/${pocketIndex}'/0/`);
|
|
354
|
+
const wallet = new ethers_1.ethers.Wallet(privateKey);
|
|
355
|
+
const address = wallet.address;
|
|
356
|
+
let balanceWei;
|
|
357
|
+
if (isViem) {
|
|
358
|
+
const viemConnection = connection;
|
|
359
|
+
balanceWei = await viemConnection.getBalance({ address: address });
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
const ethersConnection = connection;
|
|
363
|
+
balanceWei = await ethersConnection.getBalance(address);
|
|
364
|
+
}
|
|
365
|
+
const formatted = Number(ethers_1.ethers.formatEther(balanceWei));
|
|
366
|
+
return {
|
|
367
|
+
index: accountIndex,
|
|
368
|
+
address,
|
|
369
|
+
derivationPath,
|
|
370
|
+
nativeBalance: {
|
|
371
|
+
amount: balanceWei,
|
|
372
|
+
formatted,
|
|
373
|
+
symbol: 'ETH',
|
|
374
|
+
},
|
|
375
|
+
privateKey,
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
catch (error) {
|
|
379
|
+
if (attempt === maxRetries - 1) {
|
|
380
|
+
console.warn(`Failed to check pocket at account ${accountIndex} after ${maxRetries} attempts:`, error);
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
const delay = Math.pow(2, attempt) * 1000;
|
|
384
|
+
await this.sleep(delay);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return null;
|
|
388
|
+
}
|
|
85
389
|
}
|
|
86
390
|
exports.EVMVM = EVMVM;
|
|
87
391
|
class EVMChainWallet extends IChainWallet_1.ChainWallet {
|
|
88
392
|
wallet;
|
|
89
393
|
smartWallet;
|
|
90
|
-
// private savingsManager?: SavingsManager
|
|
91
|
-
// private smartSavingsManager?: SmartSavingsManager
|
|
92
394
|
constructor(config, privateKey, index) {
|
|
93
395
|
privateKey = privateKey.startsWith('0x') ? privateKey : `0x${privateKey}`;
|
|
94
396
|
super(config, privateKey, index);
|
|
@@ -105,33 +407,15 @@ class EVMChainWallet extends IChainWallet_1.ChainWallet {
|
|
|
105
407
|
this.address = account.address;
|
|
106
408
|
this.privateKey = privateKey;
|
|
107
409
|
}
|
|
108
|
-
// ============================================
|
|
109
|
-
// Smart Wallet Extension Methods
|
|
110
|
-
// ============================================
|
|
111
|
-
/**
|
|
112
|
-
* Check if Account Abstraction is supported on this chain
|
|
113
|
-
* @returns true if aaSupport is enabled in config
|
|
114
|
-
*/
|
|
115
410
|
isAASupportedByChain() {
|
|
116
411
|
return this.config.aaSupport?.enabled === true;
|
|
117
412
|
}
|
|
118
413
|
convertFromEntropyToPrivateKey = (entropy) => {
|
|
119
414
|
return (0, viem_1.toHex)(entropy);
|
|
120
415
|
};
|
|
121
|
-
/**
|
|
122
|
-
* Check if smart wallet is initialized and ready for AA operations
|
|
123
|
-
* @returns true if extend() has been called and smart wallet exists
|
|
124
|
-
*/
|
|
125
416
|
isSmartWalletInitialized() {
|
|
126
417
|
return !!this.smartWallet;
|
|
127
418
|
}
|
|
128
|
-
// createSavingsManager(mnemonic: string, index: number = 0, chain: ChainWalletConfig) {
|
|
129
|
-
// return new SavingsManager(mnemonic, index, (chain))
|
|
130
|
-
// }
|
|
131
|
-
/**
|
|
132
|
-
* Validate that AA is available for sponsored transactions
|
|
133
|
-
* @throws Error with helpful message if AA is not available
|
|
134
|
-
*/
|
|
135
419
|
validateAAAvailability() {
|
|
136
420
|
if (!this.isSmartWalletInitialized()) {
|
|
137
421
|
if (this.isAASupportedByChain()) {
|
|
@@ -147,26 +431,8 @@ class EVMChainWallet extends IChainWallet_1.ChainWallet {
|
|
|
147
431
|
}
|
|
148
432
|
}
|
|
149
433
|
}
|
|
150
|
-
/**
|
|
151
|
-
* Extend wallet with smart wallet capabilities
|
|
152
|
-
* Enables Account Abstraction (EIP-4337) and EIP-7702 features
|
|
153
|
-
*
|
|
154
|
-
* @param options - Smart wallet configuration (optional if bundlerUrl is in config)
|
|
155
|
-
* @returns EVMSmartWallet instance
|
|
156
|
-
*
|
|
157
|
-
* @example
|
|
158
|
-
* // Using bundlerUrl from chainConfig
|
|
159
|
-
* const smartWallet = await evmWallet.extend();
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* // Or provide bundlerUrl directly
|
|
163
|
-
* const smartWallet = await evmWallet.extend({
|
|
164
|
-
* bundlerUrl: 'https://api.pimlico.io/v2/...'
|
|
165
|
-
* });
|
|
166
|
-
*/
|
|
167
434
|
async extend(options = {}) {
|
|
168
435
|
if (!this.smartWallet) {
|
|
169
|
-
// Merge options with aaSupport config (options take priority)
|
|
170
436
|
const mergedOptions = {
|
|
171
437
|
...options,
|
|
172
438
|
aaConfig: this.config.aaSupport,
|
|
@@ -174,14 +440,12 @@ class EVMChainWallet extends IChainWallet_1.ChainWallet {
|
|
|
174
440
|
paymasterUrl: options.paymasterUrl || this.config.aaSupport?.paymasterUrl,
|
|
175
441
|
entryPointVersion: options.entryPointVersion || this.config.aaSupport?.entryPoints?.[0]?.version
|
|
176
442
|
};
|
|
177
|
-
// Validate bundlerUrl is available
|
|
178
443
|
if (!mergedOptions.bundlerUrl) {
|
|
179
444
|
throw new Error('bundlerUrl is required to enable smart wallet features.\n' +
|
|
180
445
|
'Provide it via:\n' +
|
|
181
446
|
'1. extend({ bundlerUrl: "..." }), OR\n' +
|
|
182
447
|
'2. Configure aaSupport in your chain config');
|
|
183
448
|
}
|
|
184
|
-
// Create viem chain object from config
|
|
185
449
|
const chain = {
|
|
186
450
|
id: this.config.chainId,
|
|
187
451
|
name: this.config.name,
|
|
@@ -204,34 +468,18 @@ class EVMChainWallet extends IChainWallet_1.ChainWallet {
|
|
|
204
468
|
testnet: this.config.testnet || false
|
|
205
469
|
};
|
|
206
470
|
this.smartWallet = new smartWallet_1.EVMSmartWallet(this.privateKey, chain, mergedOptions);
|
|
207
|
-
// Auto-initialize if option is set (default: true)
|
|
208
471
|
if (options.autoInitialize !== false) {
|
|
209
472
|
await this.smartWallet.initialize();
|
|
210
473
|
}
|
|
211
474
|
}
|
|
212
475
|
return this.smartWallet;
|
|
213
476
|
}
|
|
214
|
-
/**
|
|
215
|
-
* Check if smart wallet is enabled
|
|
216
|
-
*
|
|
217
|
-
* @returns true if extend() has been called
|
|
218
|
-
*/
|
|
219
477
|
hasSmartWallet() {
|
|
220
478
|
return !!this.smartWallet;
|
|
221
479
|
}
|
|
222
|
-
/**
|
|
223
|
-
* Get smart wallet instance
|
|
224
|
-
*
|
|
225
|
-
* @returns EVMSmartWallet instance or undefined
|
|
226
|
-
*/
|
|
227
480
|
getSmartWallet() {
|
|
228
481
|
return this.smartWallet;
|
|
229
482
|
}
|
|
230
|
-
/**
|
|
231
|
-
* Get smart wallet address (if initialized)
|
|
232
|
-
*
|
|
233
|
-
* @returns Smart wallet address or undefined
|
|
234
|
-
*/
|
|
235
483
|
getSmartWalletAddress() {
|
|
236
484
|
if (!this.smartWallet) {
|
|
237
485
|
return undefined;
|
|
@@ -243,9 +491,6 @@ class EVMChainWallet extends IChainWallet_1.ChainWallet {
|
|
|
243
491
|
return undefined;
|
|
244
492
|
}
|
|
245
493
|
}
|
|
246
|
-
// ============================================
|
|
247
|
-
// Existing Wallet Methods
|
|
248
|
-
// ============================================
|
|
249
494
|
getWallet() {
|
|
250
495
|
return this.wallet;
|
|
251
496
|
}
|
|
@@ -253,22 +498,18 @@ class EVMChainWallet extends IChainWallet_1.ChainWallet {
|
|
|
253
498
|
return this.address;
|
|
254
499
|
}
|
|
255
500
|
async getNativeBalance() {
|
|
256
|
-
// Implement native balance retrieval logic here
|
|
257
501
|
return await EVMVM.getNativeBalance(this.address, this.connection);
|
|
258
502
|
}
|
|
259
503
|
async getTokenBalance(tokenAddress) {
|
|
260
|
-
// Implement token balance retrieval logic here
|
|
261
504
|
return await EVMVM.getTokenBalance(this.address, tokenAddress, this.connection);
|
|
262
505
|
}
|
|
263
506
|
async getTokenInfo(tokenAddress) {
|
|
264
507
|
return await EVMVM.getTokenInfo(tokenAddress, this.connection);
|
|
265
508
|
}
|
|
266
509
|
async discoverToken() {
|
|
267
|
-
// Implement token discovery logic here
|
|
268
510
|
return await (0, utils_1.discoverTokens)(this.address, this.config);
|
|
269
511
|
}
|
|
270
512
|
async discoverNFT() {
|
|
271
|
-
// Implement NFT discovery logic here
|
|
272
513
|
return await (0, utils_1.discoverNFTs)(this.address, this.config);
|
|
273
514
|
}
|
|
274
515
|
async transferNative(to, amount) {
|
|
@@ -300,11 +541,9 @@ class EVMChainWallet extends IChainWallet_1.ChainWallet {
|
|
|
300
541
|
}
|
|
301
542
|
return result.data;
|
|
302
543
|
}
|
|
303
|
-
// Updated swap method signature to match base class so created another method to use it inside swap
|
|
304
544
|
async swap(tokenAddress, to, amount, slippage = 50) {
|
|
305
545
|
throw new Error("Not Implemented");
|
|
306
546
|
}
|
|
307
|
-
// Helper method for EVMChainWallet class
|
|
308
547
|
fail(message) {
|
|
309
548
|
return {
|
|
310
549
|
success: false,
|
|
@@ -329,4 +568,3 @@ class EVMChainWallet extends IChainWallet_1.ChainWallet {
|
|
|
329
568
|
}
|
|
330
569
|
}
|
|
331
570
|
exports.EVMChainWallet = EVMChainWallet;
|
|
332
|
-
//# sourceMappingURL=evm.js.map
|
package/dist/evm/index.js
CHANGED
|
@@ -17,6 +17,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./evm"), exports);
|
|
18
18
|
__exportStar(require("./utils"), exports);
|
|
19
19
|
__exportStar(require("./smartWallet"), exports);
|
|
20
|
-
// Note: AA service types are re-exported through smartWallet.types.ts
|
|
21
|
-
// Direct AA service exports would cause duplicate export errors
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
package/dist/evm/script.js
CHANGED
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.quickSwapSetup = exports.quote = void 0;
|
|
4
4
|
const ethers_1 = require("ethers");
|
|
5
|
-
// Simplified ABI for Uniswap V3 Router
|
|
6
5
|
const ROUTER_ABI = [
|
|
7
6
|
'function exactInputSingle((address tokenIn, address tokenIn, uint24 fee, address recipient, uint256 deadline, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96)) external payable returns (uint256 amountOut)',
|
|
8
7
|
'function exactOutputSingle((address tokenIn, address tokenIn, uint24 fee, address recipient, uint256 deadline, uint256 amountOut, uint256 amountInMaximum, uint160 sqrtPriceLimitX96)) external payable returns (uint256 amountIn)'
|
|
9
8
|
];
|
|
10
|
-
// ERC20 ABI (simplified)
|
|
11
9
|
const ERC20_ABI = [
|
|
12
10
|
'function approve(address spender, uint256 amount) external returns (bool)',
|
|
13
11
|
'function allowance(address owner, address spender) external view returns (uint256)',
|
|
@@ -42,18 +40,13 @@ const quote = async (quoterAddress, rpc, tokenIn, tokenOut, amountIn, fee, sqrtP
|
|
|
42
40
|
};
|
|
43
41
|
exports.quote = quote;
|
|
44
42
|
const quickSwapSetup = async (params) => {
|
|
45
|
-
const { privateKey, tokenIn, tokenOut, amountIn, tokenInDecimal, adminAddress, routerAddress, rpcUrl, minAmountOut, feeTier = 100
|
|
46
|
-
} = params;
|
|
43
|
+
const { privateKey, tokenIn, tokenOut, amountIn, tokenInDecimal, adminAddress, routerAddress, rpcUrl, minAmountOut, feeTier = 100 } = params;
|
|
47
44
|
try {
|
|
48
|
-
// Setup provider and wallet
|
|
49
45
|
const provider = new ethers_1.ethers.JsonRpcProvider(rpcUrl);
|
|
50
46
|
const wallet = new ethers_1.ethers.Wallet(privateKey, provider);
|
|
51
|
-
// Create contract instances
|
|
52
47
|
const router = new ethers_1.ethers.Contract(routerAddress, ROUTER_ABI, wallet);
|
|
53
48
|
const tokenInContract = new ethers_1.ethers.Contract(tokenIn, ERC20_ABI, wallet);
|
|
54
|
-
|
|
55
|
-
const amountInWei = ethers_1.ethers.parseUnits(amountIn, tokenInDecimal); // Assuming 18 decimals
|
|
56
|
-
// Check and approve token allowance
|
|
49
|
+
const amountInWei = ethers_1.ethers.parseUnits(amountIn, tokenInDecimal);
|
|
57
50
|
const allowance = await tokenInContract.allowance(wallet.address, routerAddress);
|
|
58
51
|
if (allowance < amountInWei) {
|
|
59
52
|
console.log('Approving tokens...');
|
|
@@ -61,18 +54,14 @@ const quickSwapSetup = async (params) => {
|
|
|
61
54
|
await approveTx.wait();
|
|
62
55
|
console.log('Approval confirmed');
|
|
63
56
|
}
|
|
64
|
-
|
|
65
|
-
const feeAmount = amountInWei * BigInt(1) / BigInt(10000); // 0.01%
|
|
57
|
+
const feeAmount = amountInWei * BigInt(1) / BigInt(10000);
|
|
66
58
|
const amountAfterFee = amountInWei - feeAmount;
|
|
67
|
-
// Transfer fee to admin
|
|
68
59
|
if (feeAmount > 0) {
|
|
69
60
|
console.log(`Transferring ${ethers_1.ethers.formatUnits(feeAmount, tokenIn)} fee to admin`);
|
|
70
61
|
const feeTransferTx = await tokenInContract.transfer(adminAddress, feeAmount);
|
|
71
62
|
await feeTransferTx.wait();
|
|
72
63
|
}
|
|
73
|
-
// Set deadline (10 minutes from now)
|
|
74
64
|
const deadline = Math.floor(Date.now() / 1000) + 600;
|
|
75
|
-
// Prepare swap parameters
|
|
76
65
|
const swapParams = {
|
|
77
66
|
tokenIn: tokenIn,
|
|
78
67
|
tokenOut: tokenOut,
|
|
@@ -84,12 +73,10 @@ const quickSwapSetup = async (params) => {
|
|
|
84
73
|
sqrtPriceLimitX96: 0
|
|
85
74
|
};
|
|
86
75
|
console.log('Executing swap...');
|
|
87
|
-
// Execute swap
|
|
88
76
|
const swapTx = await router.exactInputSingle(swapParams);
|
|
89
77
|
const receipt = await swapTx.wait();
|
|
90
78
|
console.log('Swap successful!');
|
|
91
79
|
console.log('Transaction hash:', receipt.hash);
|
|
92
|
-
// Check final balances
|
|
93
80
|
const tokenOutContract = new ethers_1.ethers.Contract(tokenOut, ERC20_ABI, wallet);
|
|
94
81
|
const finalBalance = await tokenOutContract.balanceOf(wallet.address);
|
|
95
82
|
console.log(`Final ${tokenOut} balance:`, ethers_1.ethers.formatUnits(finalBalance, 18));
|
|
@@ -108,4 +95,3 @@ const quickSwapSetup = async (params) => {
|
|
|
108
95
|
}
|
|
109
96
|
};
|
|
110
97
|
exports.quickSwapSetup = quickSwapSetup;
|
|
111
|
-
//# sourceMappingURL=script.js.map
|