@zubari/sdk 0.1.4 → 0.1.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.js +10 -64
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -65
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.js +10 -64
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +11 -65
- package/dist/react/index.mjs.map +1 -1
- package/dist/services/index.d.mts +2 -1
- package/dist/services/index.d.ts +2 -1
- package/dist/services/index.js +10 -64
- package/dist/services/index.js.map +1 -1
- package/dist/services/index.mjs +11 -65
- package/dist/services/index.mjs.map +1 -1
- package/dist/wallet/index.js +10 -64
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +11 -65
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { mainnet, sepolia } from 'viem/chains';
|
|
|
4
4
|
import { mnemonicToSeedSync } from '@scure/bip39';
|
|
5
5
|
import '@scure/bip39/wordlists/english';
|
|
6
6
|
import { HDKey } from '@scure/bip32';
|
|
7
|
-
import { bech32 } from '@scure/base';
|
|
7
|
+
import { bech32, base58check } from '@scure/base';
|
|
8
8
|
import { sha256 } from '@noble/hashes/sha256';
|
|
9
9
|
import { ripemd160 } from '@noble/hashes/ripemd160';
|
|
10
10
|
import { useMemo, useState, useCallback, useEffect } from 'react';
|
|
@@ -2407,59 +2407,6 @@ var require_bs58 = __commonJS({
|
|
|
2407
2407
|
}
|
|
2408
2408
|
});
|
|
2409
2409
|
|
|
2410
|
-
// ../../node_modules/bs58check/base.js
|
|
2411
|
-
var require_base = __commonJS({
|
|
2412
|
-
"../../node_modules/bs58check/base.js"(exports$1, module) {
|
|
2413
|
-
var base58 = require_bs58();
|
|
2414
|
-
module.exports = function(checksumFn) {
|
|
2415
|
-
function encode(payload) {
|
|
2416
|
-
var payloadU8 = Uint8Array.from(payload);
|
|
2417
|
-
var checksum = checksumFn(payloadU8);
|
|
2418
|
-
var length = payloadU8.length + 4;
|
|
2419
|
-
var both = new Uint8Array(length);
|
|
2420
|
-
both.set(payloadU8, 0);
|
|
2421
|
-
both.set(checksum.subarray(0, 4), payloadU8.length);
|
|
2422
|
-
return base58.encode(both, length);
|
|
2423
|
-
}
|
|
2424
|
-
function decodeRaw(buffer) {
|
|
2425
|
-
var payload = buffer.slice(0, -4);
|
|
2426
|
-
var checksum = buffer.slice(-4);
|
|
2427
|
-
var newChecksum = checksumFn(payload);
|
|
2428
|
-
if (checksum[0] ^ newChecksum[0] | checksum[1] ^ newChecksum[1] | checksum[2] ^ newChecksum[2] | checksum[3] ^ newChecksum[3]) return;
|
|
2429
|
-
return payload;
|
|
2430
|
-
}
|
|
2431
|
-
function decodeUnsafe(string) {
|
|
2432
|
-
var buffer = base58.decodeUnsafe(string);
|
|
2433
|
-
if (!buffer) return;
|
|
2434
|
-
return decodeRaw(buffer);
|
|
2435
|
-
}
|
|
2436
|
-
function decode(string) {
|
|
2437
|
-
var buffer = base58.decode(string);
|
|
2438
|
-
var payload = decodeRaw(buffer);
|
|
2439
|
-
if (!payload) throw new Error("Invalid checksum");
|
|
2440
|
-
return payload;
|
|
2441
|
-
}
|
|
2442
|
-
return {
|
|
2443
|
-
encode,
|
|
2444
|
-
decode,
|
|
2445
|
-
decodeUnsafe
|
|
2446
|
-
};
|
|
2447
|
-
};
|
|
2448
|
-
}
|
|
2449
|
-
});
|
|
2450
|
-
|
|
2451
|
-
// ../../node_modules/bs58check/index.js
|
|
2452
|
-
var require_bs58check = __commonJS({
|
|
2453
|
-
"../../node_modules/bs58check/index.js"(exports$1, module) {
|
|
2454
|
-
var { sha256: sha2562 } = __require("@noble/hashes/sha256");
|
|
2455
|
-
var bs58checkBase = require_base();
|
|
2456
|
-
function sha256x2(buffer) {
|
|
2457
|
-
return sha2562(sha2562(buffer));
|
|
2458
|
-
}
|
|
2459
|
-
module.exports = bs58checkBase(sha256x2);
|
|
2460
|
-
}
|
|
2461
|
-
});
|
|
2462
|
-
|
|
2463
2410
|
// src/config/networks.ts
|
|
2464
2411
|
var NETWORKS = {
|
|
2465
2412
|
bitcoin: {
|
|
@@ -3702,9 +3649,8 @@ function crc16(data) {
|
|
|
3702
3649
|
}
|
|
3703
3650
|
return crc;
|
|
3704
3651
|
}
|
|
3705
|
-
|
|
3652
|
+
function deriveTronAddress(seed) {
|
|
3706
3653
|
try {
|
|
3707
|
-
const bs58check = await Promise.resolve().then(() => __toESM(require_bs58check()));
|
|
3708
3654
|
const hdNode = HDNodeWallet.fromPhrase(seed, void 0, DERIVATION_PATHS3.tron);
|
|
3709
3655
|
const ethAddressHex = hdNode.address.slice(2).toLowerCase();
|
|
3710
3656
|
const addressBytes = new Uint8Array(21);
|
|
@@ -3712,7 +3658,8 @@ async function deriveTronAddress(seed) {
|
|
|
3712
3658
|
for (let i = 0; i < 20; i++) {
|
|
3713
3659
|
addressBytes[i + 1] = parseInt(ethAddressHex.slice(i * 2, i * 2 + 2), 16);
|
|
3714
3660
|
}
|
|
3715
|
-
|
|
3661
|
+
const tronBase58check = base58check(sha256);
|
|
3662
|
+
return tronBase58check.encode(addressBytes);
|
|
3716
3663
|
} catch (error) {
|
|
3717
3664
|
console.error("TRON address derivation failed:", error);
|
|
3718
3665
|
throw error;
|
|
@@ -3762,10 +3709,14 @@ async function deriveAllAddresses(seed, network = "testnet") {
|
|
|
3762
3709
|
} catch (e) {
|
|
3763
3710
|
console.error("Spark derivation failed:", e);
|
|
3764
3711
|
}
|
|
3765
|
-
|
|
3712
|
+
try {
|
|
3713
|
+
addresses.tron = deriveTronAddress(seed);
|
|
3714
|
+
} catch (e) {
|
|
3715
|
+
console.error("TRON derivation failed:", e);
|
|
3716
|
+
}
|
|
3717
|
+
const [solResult, tonResult] = await Promise.allSettled([
|
|
3766
3718
|
deriveSolanaAddress(seed),
|
|
3767
|
-
deriveTonAddress(seed)
|
|
3768
|
-
deriveTronAddress(seed)
|
|
3719
|
+
deriveTonAddress(seed)
|
|
3769
3720
|
]);
|
|
3770
3721
|
if (solResult.status === "fulfilled") {
|
|
3771
3722
|
addresses.solana = solResult.value;
|
|
@@ -3777,11 +3728,6 @@ async function deriveAllAddresses(seed, network = "testnet") {
|
|
|
3777
3728
|
} else {
|
|
3778
3729
|
console.error("TON derivation failed:", tonResult.reason);
|
|
3779
3730
|
}
|
|
3780
|
-
if (tronResult.status === "fulfilled") {
|
|
3781
|
-
addresses.tron = tronResult.value;
|
|
3782
|
-
} else {
|
|
3783
|
-
console.error("TRON derivation failed:", tronResult.reason);
|
|
3784
|
-
}
|
|
3785
3731
|
return addresses;
|
|
3786
3732
|
}
|
|
3787
3733
|
|