@deserialize/multi-vm-wallet 1.2.0 → 1.2.2
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/constant.d.ts +16 -0
- package/dist/constant.js +19 -3
- package/dist/constant.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.d.ts +6 -1
- package/dist/evm/evm.js +36 -45
- package/dist/evm/evm.js.map +1 -1
- package/dist/evm/transactionParsing.d.ts +3687 -0
- package/dist/evm/transactionParsing.js +441 -0
- package/dist/evm/transactionParsing.js.map +1 -0
- package/dist/evm/utils.d.ts +2 -9
- package/dist/evm/utils.js +19 -22
- package/dist/evm/utils.js.map +1 -1
- package/dist/helpers/index.d.ts +4 -0
- package/dist/helpers/index.js +13 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/svm/constant.d.ts +15 -0
- package/dist/svm/constant.js +25 -0
- package/dist/svm/constant.js.map +1 -0
- package/dist/svm/svm.d.ts +5 -2
- package/dist/svm/svm.js +10 -0
- package/dist/svm/svm.js.map +1 -1
- package/dist/svm/transactionParsing.d.ts +28 -0
- package/dist/svm/transactionParsing.js +207 -0
- package/dist/svm/transactionParsing.js.map +1 -0
- package/dist/svm/utils.d.ts +4 -3
- package/dist/svm/utils.js +83 -10
- package/dist/svm/utils.js.map +1 -1
- package/dist/test.d.ts +1 -1
- package/dist/test.js +47 -9
- package/dist/test.js.map +1 -1
- package/dist/types.d.ts +5 -1
- package/dist/types.js.map +1 -1
- package/dist/walletBip32.js +1 -1
- package/dist/walletBip32.js.map +1 -1
- package/package.json +4 -2
- package/utils/IChainWallet.ts +1 -1
- package/utils/bip32Old.ts +988 -988
- package/utils/bip32Small.ts +78 -78
- package/utils/constant.ts +22 -4
- package/utils/english.ts +2048 -0
- package/utils/evm/evm.ts +54 -48
- package/utils/evm/transactionParsing.ts +639 -0
- package/utils/evm/utils.ts +29 -33
- package/utils/helpers/index.ts +11 -0
- package/utils/svm/constant.ts +29 -0
- package/utils/svm/svm.ts +14 -2
- package/utils/svm/transactionParsing.ts +294 -0
- package/utils/svm/utils.ts +105 -14
- package/utils/test.ts +56 -6
- package/utils/types.ts +6 -1
- package/utils/walletBip32.ts +1 -1
package/utils/bip32Small.ts
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
import { Keypair } from "@solana/web3.js";
|
|
4
|
-
import * as bip39 from "@scure/bip39";
|
|
5
|
-
import { HDKey } from "@scure/bip32"
|
|
6
|
-
import { Buffer } from "buffer"; // Import the polyfill
|
|
7
|
-
window.Buffer = Buffer; // Inject Buffer into the global scope
|
|
8
|
-
import { wordlist } from "@scure/bip39/wordlists/english";
|
|
9
|
-
import { hmac } from "@noble/hashes/hmac";
|
|
10
|
-
import { sha512 } from "@noble/hashes/sha2";
|
|
3
|
+
// import { Keypair } from "@solana/web3.js";
|
|
4
|
+
// import * as bip39 from "@scure/bip39";
|
|
5
|
+
// import { HDKey } from "@scure/bip32"
|
|
6
|
+
// import { Buffer } from "buffer"; // Import the polyfill
|
|
7
|
+
// window.Buffer = Buffer; // Inject Buffer into the global scope
|
|
8
|
+
// import { wordlist } from "@scure/bip39/wordlists/english";
|
|
9
|
+
// import { hmac } from "@noble/hashes/hmac";
|
|
10
|
+
// import { sha512 } from "@noble/hashes/sha2";
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
export function GenerateNewMnemonic() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
export function ValidateMnemonic(mnemonic: string) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
export function GenerateSeed(_mnemonic?: string) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
//EVM
|
|
30
|
-
export function EVMDeriveChildPrivateKey(seed: string, index: number, derivationPath: string) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
13
|
+
// export function GenerateNewMnemonic() {
|
|
14
|
+
// const mnemonic = bip39.generateMnemonic(wordlist);
|
|
15
|
+
// return mnemonic;
|
|
16
|
+
// }
|
|
17
|
+
// export function ValidateMnemonic(mnemonic: string) {
|
|
18
|
+
// const isValid = bip39.validateMnemonic(mnemonic, wordlist);
|
|
19
|
+
// if (!isValid) {
|
|
20
|
+
// throw new Error("Invalid mnemonic");
|
|
21
|
+
// }
|
|
22
|
+
// return isValid;
|
|
23
|
+
// }
|
|
24
|
+
// export function GenerateSeed(_mnemonic?: string) {
|
|
25
|
+
// const mnemonic = _mnemonic || bip39.generateMnemonic(wordlist);
|
|
26
|
+
// const seedString = bip39.mnemonicToSeedSync(mnemonic);
|
|
27
|
+
// return seedString;
|
|
28
|
+
// }
|
|
29
|
+
// //EVM
|
|
30
|
+
// export function EVMDeriveChildPrivateKey(seed: string, index: number, derivationPath: string) {
|
|
31
|
+
// const path = `${derivationPath}${index}'`
|
|
32
|
+
// const scureNode = HDKey.fromMasterSeed(Buffer.from(seed, "hex"))
|
|
33
|
+
// const child = scureNode.derive(path);
|
|
34
|
+
// const privateKey = Buffer.from(child.privateKey!).toString("hex");
|
|
35
|
+
// const publicKey = Buffer.from(child.publicKey!).toString("hex");
|
|
36
|
+
// return { privateKey, publicKey };
|
|
37
|
+
// }
|
|
38
38
|
|
|
39
|
-
//SVM
|
|
40
|
-
export function SVMDeriveChildPrivateKey(seed: string, index: number, derivationPath: string) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
39
|
+
// //SVM
|
|
40
|
+
// export function SVMDeriveChildPrivateKey(seed: string, index: number, derivationPath: string) {
|
|
41
|
+
// const path = `${derivationPath}${index}'`;
|
|
42
|
+
// // Derive a seed from the given path
|
|
43
|
+
// const derivedSeed = derivePathEclipticCurve(path, Buffer.from(seed, "hex")).key;
|
|
44
|
+
// const derivedKeyPair = Keypair.fromSeed(derivedSeed);
|
|
45
|
+
// return derivedKeyPair;
|
|
46
|
+
// }
|
|
47
47
|
|
|
48
|
-
function derivePathEclipticCurve(path: string, seed: Uint8Array): { key: Uint8Array, chainCode: Uint8Array } {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
// function derivePathEclipticCurve(path: string, seed: Uint8Array): { key: Uint8Array, chainCode: Uint8Array } {
|
|
49
|
+
// const segments = path
|
|
50
|
+
// .split("/")
|
|
51
|
+
// .slice(1)
|
|
52
|
+
// .map((seg) => {
|
|
53
|
+
// if (!seg.endsWith("'")) {
|
|
54
|
+
// throw new Error("Only hardened derivation is supported");
|
|
55
|
+
// }
|
|
56
|
+
// return parseInt(seg.slice(0, -1), 10) + 0x80000000;
|
|
57
|
+
// });
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
// // Initialize with master key derivation
|
|
60
|
+
// let hmacResult = hmac(sha512, Buffer.from("ed25519 seed"), seed);
|
|
61
|
+
// let key = hmacResult.slice(0, 32);
|
|
62
|
+
// let chainCode = hmacResult.slice(32, 64);
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
// // Derive each path segment
|
|
65
|
+
// for (const segment of segments) {
|
|
66
|
+
// const result = hardenedDerivation(key, chainCode, segment);
|
|
67
|
+
// key = Buffer.from(result.key);
|
|
68
|
+
// chainCode = Buffer.from(result.chainCode);
|
|
69
|
+
// }
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
}
|
|
71
|
+
// return { key, chainCode };
|
|
72
|
+
// }
|
|
73
73
|
|
|
74
|
-
function hardenedDerivation(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
): { key: Uint8Array, chainCode: Uint8Array } {
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
// function hardenedDerivation(
|
|
75
|
+
// parentKey: Uint8Array,
|
|
76
|
+
// parentChainCode: Uint8Array,
|
|
77
|
+
// index: number
|
|
78
|
+
// ): { key: Uint8Array, chainCode: Uint8Array } {
|
|
79
|
+
// const indexBuffer = new Uint8Array(4);
|
|
80
|
+
// new DataView(indexBuffer.buffer).setUint32(0, index, false);
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
// // Proper SLIP-0010 format: 0x00 + parent_key + index
|
|
83
|
+
// const data = new Uint8Array([0x00, ...parentKey, ...indexBuffer]);
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
// const hmacResult = hmac(sha512, parentChainCode, data);
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
87
|
+
// return {
|
|
88
|
+
// key: hmacResult.slice(0, 32), // Left 32 bytes
|
|
89
|
+
// chainCode: hmacResult.slice(32, 64) // Right 32 bytes
|
|
90
|
+
// };
|
|
91
|
+
// }
|
package/utils/constant.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChainWalletConfig } from "./types";
|
|
2
2
|
|
|
3
3
|
export const DefaultChains: ChainWalletConfig[] = [{
|
|
4
|
-
chainId:
|
|
4
|
+
chainId: 123456789,
|
|
5
5
|
name: "Solana Mainnet",
|
|
6
6
|
rpcUrl: "https://solana-mainnet.g.alchemy.com/v2/vB5mKztdJeFdz9RkW99Qf",
|
|
7
7
|
explorerUrl: "https://explorer.solana.com", // e.g. Solana Explorer
|
|
@@ -13,7 +13,6 @@ export const DefaultChains: ChainWalletConfig[] = [{
|
|
|
13
13
|
testnet: false,
|
|
14
14
|
logoUrl: "https://cryptologos.cc/logos/solana-sol-logo.png?v=040",
|
|
15
15
|
vmType: "SVM"
|
|
16
|
-
|
|
17
16
|
}
|
|
18
17
|
, {
|
|
19
18
|
chainId: 1,
|
|
@@ -42,7 +41,7 @@ export const DefaultChains: ChainWalletConfig[] = [{
|
|
|
42
41
|
logoUrl: "https://cryptologos.cc/logos/bnb-bnb-logo.png?v=040",
|
|
43
42
|
vmType: "EVM"
|
|
44
43
|
}, {
|
|
45
|
-
chainId:
|
|
44
|
+
chainId: 123456791,
|
|
46
45
|
name: "Eclipse Mainnet",
|
|
47
46
|
rpcUrl: "https://mainnetbeta-rpc.eclipse.xyz",
|
|
48
47
|
explorerUrl: "https://explorer.eclipse.xyz/", // e.g. Solana Explorer
|
|
@@ -71,4 +70,23 @@ export const DefaultChains: ChainWalletConfig[] = [{
|
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
|
|
74
|
-
]
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
export const TRANSACTION_TYPE = {
|
|
76
|
+
// CAPITALIZE THE VALUES
|
|
77
|
+
NATIVE_TRANSFER: 'NATIVE_TRANSFER',
|
|
78
|
+
TOKEN_TRANSFER: 'TOKEN_TRANSFER',
|
|
79
|
+
NFT_TRANSFER: 'NFT_TRANSFER',
|
|
80
|
+
DEPOSIT: 'DEPOSIT',
|
|
81
|
+
WITHDRAWAL: 'WITHDRAWAL',
|
|
82
|
+
CONTRACT_INTERACTION: 'CONTRACT_INTERACTION',
|
|
83
|
+
SWAP: 'SWAP',
|
|
84
|
+
STAKING: 'STAKING',
|
|
85
|
+
TOKEN_INTERACTIONS: 'TOKEN_INTERACTIONS',
|
|
86
|
+
CONTRACT_CREATION: 'CONTRACT_CREATION',
|
|
87
|
+
PROGRAM_INTERACTION: 'PROGRAM_INTERACTION',
|
|
88
|
+
SYSTEM: 'SYSTEM',
|
|
89
|
+
UNKNOWN: 'UNKNOWN'
|
|
90
|
+
|
|
91
|
+
} as const
|
|
92
|
+
export type TransactionType = keyof typeof TRANSACTION_TYPE;
|