@deserialize/multi-vm-wallet 1.1.47 → 1.2.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/bip32Old.d.ts +0 -51
- package/dist/bip32Old.js +876 -845
- package/dist/bip32Old.js.map +1 -1
- package/dist/bip32Small.d.ts +0 -9
- package/dist/bip32Small.js +78 -113
- package/dist/bip32Small.js.map +1 -1
- package/dist/english.d.ts +1 -0
- package/dist/english.js +2052 -0
- package/dist/english.js.map +1 -0
- package/dist/evm/evm.js +2 -2
- package/dist/evm/evm.js.map +1 -1
- package/dist/evm/utils.js +3 -6
- package/dist/evm/utils.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/svm/svm.js +2 -2
- package/dist/svm/svm.js.map +1 -1
- package/dist/test.js +4 -22
- package/dist/test.js.map +1 -1
- package/dist/walletBip32.d.ts +9 -0
- package/dist/walletBip32.js +172 -0
- package/dist/walletBip32.js.map +1 -0
- package/package.json +4 -4
- package/utils/bip32Old.ts +988 -988
- package/utils/bip32Small.ts +78 -78
- package/utils/english.ts +2048 -0
- package/utils/evm/evm.ts +2 -2
- package/utils/evm/utils.ts +12 -17
- package/utils/index.ts +1 -2
- package/utils/svm/svm.ts +1 -1
- package/utils/test.ts +3 -27
- package/utils/{bip32.ts → walletBip32.ts} +1 -1
package/utils/evm/evm.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* this is a class that will be responsible for creating several evm wallets code
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { EVMDeriveChildPrivateKey } from "../
|
|
7
|
+
import { EVMDeriveChildPrivateKey } from "../walletBip32";
|
|
8
8
|
import { ChainWallet } from "../IChainWallet";
|
|
9
9
|
import { Balance, ChainWalletConfig, NFTInfo, TokenInfo, TransactionResult } from "../types";
|
|
10
10
|
import { VM } from "../vm";
|
|
@@ -514,7 +514,7 @@ export class EVMChainWallet extends ChainWallet<string, string, JsonRpcProvider>
|
|
|
514
514
|
gasEstimate: string;
|
|
515
515
|
route: string[];
|
|
516
516
|
}> {
|
|
517
|
-
|
|
517
|
+
|
|
518
518
|
try {
|
|
519
519
|
const chainId = (await this.connection!.getNetwork()).chainId.toString();
|
|
520
520
|
|
package/utils/evm/utils.ts
CHANGED
|
@@ -23,7 +23,7 @@ interface TransactionResult {
|
|
|
23
23
|
effectiveGasPrice?: bigint
|
|
24
24
|
blockNumber?: number
|
|
25
25
|
confirmations: number
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export interface SwapParams {
|
|
@@ -147,18 +147,13 @@ const ERC20_ABI = [
|
|
|
147
147
|
]
|
|
148
148
|
|
|
149
149
|
export const getNativeBalance = async (address: string, provider: JsonRpcProvider): Promise<Balance> => {
|
|
150
|
-
const balance = await provider.getBalance(address)
|
|
151
|
-
|
|
152
|
-
const dem = 10n ** 18n;
|
|
153
|
-
|
|
154
|
-
// ⚠️ BigInt division truncates, so avoid dividing BigInt directly
|
|
155
|
-
const formatted = Number(balance) / Number(dem);
|
|
150
|
+
const balance = await provider.getBalance(address)
|
|
156
151
|
|
|
157
152
|
return {
|
|
158
|
-
balance: new BN(balance
|
|
159
|
-
formatted
|
|
153
|
+
balance: new BN(balance),
|
|
154
|
+
formatted: Number(balance / 10n ** 18n),
|
|
160
155
|
decimal: 18
|
|
161
|
-
}
|
|
156
|
+
}
|
|
162
157
|
}
|
|
163
158
|
|
|
164
159
|
export const getTokenInfo = async (
|
|
@@ -774,9 +769,9 @@ export async function performSwap(params: {
|
|
|
774
769
|
amountIn: params.amountIn,
|
|
775
770
|
chainId: params.chainId
|
|
776
771
|
});
|
|
777
|
-
|
|
772
|
+
|
|
778
773
|
console.log('Fetching best swap route across all DEXs...');
|
|
779
|
-
|
|
774
|
+
|
|
780
775
|
const routeResponse = await getKyberSwapRoute({
|
|
781
776
|
chainId: params.chainId,
|
|
782
777
|
tokenIn: params.tokenIn,
|
|
@@ -797,7 +792,7 @@ export async function performSwap(params: {
|
|
|
797
792
|
}
|
|
798
793
|
|
|
799
794
|
const { routeSummary, routerAddress } = routeResponse.data;
|
|
800
|
-
|
|
795
|
+
|
|
801
796
|
// Debug: Log what we actually received
|
|
802
797
|
console.log('routeSummary keys:', Object.keys(routeSummary));
|
|
803
798
|
console.log('routeSummary.swaps exists:', !!routeSummary.swaps);
|
|
@@ -813,13 +808,13 @@ export async function performSwap(params: {
|
|
|
813
808
|
// Only try to access swaps if it exists
|
|
814
809
|
swapsCount: routeSummary.swaps ? routeSummary.swaps.length : 0,
|
|
815
810
|
// Only extract exchange names if swaps exists and has the expected structure
|
|
816
|
-
dexSources: routeSummary.swaps && Array.isArray(routeSummary.swaps)
|
|
811
|
+
dexSources: routeSummary.swaps && Array.isArray(routeSummary.swaps)
|
|
817
812
|
? routeSummary.swaps.map(swap => swap?.exchange || 'unknown').filter(Boolean)
|
|
818
813
|
: ['unknown']
|
|
819
814
|
});
|
|
820
815
|
|
|
821
816
|
console.log('Building executable transaction...');
|
|
822
|
-
|
|
817
|
+
|
|
823
818
|
const buildResponse = await buildKyberSwapTransaction(
|
|
824
819
|
params.chainId,
|
|
825
820
|
routeSummary,
|
|
@@ -857,7 +852,7 @@ export async function performSwap(params: {
|
|
|
857
852
|
|
|
858
853
|
} catch (error) {
|
|
859
854
|
console.error('❌ KyberSwap aggregation failed:', error);
|
|
860
|
-
|
|
855
|
+
|
|
861
856
|
// More detailed error logging
|
|
862
857
|
if (error instanceof Error) {
|
|
863
858
|
console.error('Error details:', {
|
|
@@ -866,7 +861,7 @@ export async function performSwap(params: {
|
|
|
866
861
|
name: error.name
|
|
867
862
|
});
|
|
868
863
|
}
|
|
869
|
-
|
|
864
|
+
|
|
870
865
|
throw new Error(`Swap preparation failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
871
866
|
}
|
|
872
867
|
}
|
package/utils/index.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./walletBip32"
|
|
2
2
|
export * from "./evm/evm"
|
|
3
3
|
export * from "./types"
|
|
4
4
|
export * from "./vm"
|
|
5
5
|
export * from "./evm"
|
|
6
6
|
export * from "./svm"
|
|
7
|
-
export * from "./bip32"
|
|
8
7
|
export * from "./types"
|
|
9
8
|
export * from "./constant"
|
|
10
9
|
export * from "bs58"
|
package/utils/svm/svm.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
|
|
2
|
-
import { SVMDeriveChildPrivateKey } from "../
|
|
2
|
+
import { SVMDeriveChildPrivateKey } from "../walletBip32";
|
|
3
3
|
import { VM } from "../vm";
|
|
4
4
|
import { ChainWallet } from "../IChainWallet";
|
|
5
5
|
import { Balance, ChainWalletConfig, TokenInfo, TransactionResult } from "../types";
|
package/utils/test.ts
CHANGED
|
@@ -7,9 +7,7 @@ import { NATIVE_MINT } from "@solana/spl-token";
|
|
|
7
7
|
import { SVMChainWallet, SVMVM } from "./svm";
|
|
8
8
|
import { VM } from "./vm";
|
|
9
9
|
import { ChainWalletConfig } from "./types";
|
|
10
|
-
import {
|
|
11
|
-
import { JsonRpcProvider } from "ethers";
|
|
12
|
-
import BN from "bn.js";
|
|
10
|
+
import { Keypair } from ".";
|
|
13
11
|
// const mnemonic = GenerateNewMnemonic()
|
|
14
12
|
|
|
15
13
|
|
|
@@ -46,34 +44,12 @@ const evmChainConfig: ChainWalletConfig = {
|
|
|
46
44
|
nativeToken: { name: "Ethereum", symbol: "ETH", decimals: 18 },
|
|
47
45
|
confirmationNo: 1,
|
|
48
46
|
}
|
|
49
|
-
const gChainConfig: ChainWalletConfig = {
|
|
50
|
-
chainId: "16661",
|
|
51
|
-
name: "Ethereum",
|
|
52
|
-
rpcUrl: "https://evmrpc.0g.ai",
|
|
53
|
-
explorerUrl: "https://chainscan.0g.ai",
|
|
54
|
-
nativeToken: {
|
|
55
|
-
name: "OG Mainnet",
|
|
56
|
-
symbol: "0G",
|
|
57
|
-
decimals: 18,
|
|
58
|
-
},
|
|
59
|
-
confirmationNo: 1,
|
|
60
|
-
}
|
|
61
47
|
|
|
62
|
-
// const wallet = new SVMChainWallet(chainConfig, testUserKeyPair, 0)
|
|
63
|
-
// const wallet = new EVMChainWallet(chainConfig, testUserKeyPair, 0)
|
|
64
|
-
const address = "0x34906823118C27B83243a4d3B19dd2984DdfB645"
|
|
65
|
-
EVMVM.getNativeBalance(address, new JsonRpcProvider(gChainConfig.rpcUrl)).then(e => {
|
|
66
|
-
const bal = (e.balance as BN).toString()
|
|
67
|
-
console.log('bal: ', bal);
|
|
68
|
-
console.log('native balance: ', e)
|
|
69
48
|
|
|
70
|
-
|
|
49
|
+
const wallet = new SVMChainWallet(chainConfig, testUserKeyPair, 0)
|
|
71
50
|
// console.log('wallet: ', wallet);
|
|
72
51
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
52
|
+
wallet.getNativeBalance().then(e => console.log('native balance: ', e))
|
|
77
53
|
// const toBuy = new PublicKey("9BB6NFEcjBCtnNLFko2FqVQBq8HHM13kCyYcdQbgpump")
|
|
78
54
|
// wallet.swap({
|
|
79
55
|
// name: NATIVE_MINT.toBase58(),
|
|
@@ -73,7 +73,7 @@ if (typeof window !== 'undefined') {
|
|
|
73
73
|
window.Buffer = Buffer; // Inject Buffer into the global scope
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
import { wordlist } from "
|
|
76
|
+
import { wordlist } from "./english";
|
|
77
77
|
import { hmac } from "@noble/hashes/hmac";
|
|
78
78
|
import { sha512 } from "@noble/hashes/sha2";
|
|
79
79
|
|