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