@zubari/sdk 0.1.3 → 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 +65 -64
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -65
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.js +65 -64
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +66 -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 +65 -64
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +66 -65
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -122,8 +122,9 @@ declare function deriveTonAddress(seed: string): Promise<string>;
|
|
|
122
122
|
/**
|
|
123
123
|
* Derive TRON address from seed phrase
|
|
124
124
|
* TRON uses secp256k1 like Ethereum but with base58check encoding
|
|
125
|
+
* Uses @scure/base for browser compatibility
|
|
125
126
|
*/
|
|
126
|
-
declare function deriveTronAddress(seed: string):
|
|
127
|
+
declare function deriveTronAddress(seed: string): string;
|
|
127
128
|
/**
|
|
128
129
|
* Derive Spark address from seed phrase
|
|
129
130
|
* Spark uses its own derivation path and bech32 format
|
package/dist/services/index.d.ts
CHANGED
|
@@ -122,8 +122,9 @@ declare function deriveTonAddress(seed: string): Promise<string>;
|
|
|
122
122
|
/**
|
|
123
123
|
* Derive TRON address from seed phrase
|
|
124
124
|
* TRON uses secp256k1 like Ethereum but with base58check encoding
|
|
125
|
+
* Uses @scure/base for browser compatibility
|
|
125
126
|
*/
|
|
126
|
-
declare function deriveTronAddress(seed: string):
|
|
127
|
+
declare function deriveTronAddress(seed: string): string;
|
|
127
128
|
/**
|
|
128
129
|
* Derive Spark address from seed phrase
|
|
129
130
|
* Spark uses its own derivation path and bech32 format
|
package/dist/services/index.js
CHANGED
|
@@ -2410,59 +2410,6 @@ var require_bs58 = __commonJS({
|
|
|
2410
2410
|
}
|
|
2411
2411
|
});
|
|
2412
2412
|
|
|
2413
|
-
// ../../node_modules/bs58check/base.js
|
|
2414
|
-
var require_base = __commonJS({
|
|
2415
|
-
"../../node_modules/bs58check/base.js"(exports$1, module) {
|
|
2416
|
-
var base58 = require_bs58();
|
|
2417
|
-
module.exports = function(checksumFn) {
|
|
2418
|
-
function encode(payload) {
|
|
2419
|
-
var payloadU8 = Uint8Array.from(payload);
|
|
2420
|
-
var checksum = checksumFn(payloadU8);
|
|
2421
|
-
var length = payloadU8.length + 4;
|
|
2422
|
-
var both = new Uint8Array(length);
|
|
2423
|
-
both.set(payloadU8, 0);
|
|
2424
|
-
both.set(checksum.subarray(0, 4), payloadU8.length);
|
|
2425
|
-
return base58.encode(both, length);
|
|
2426
|
-
}
|
|
2427
|
-
function decodeRaw(buffer) {
|
|
2428
|
-
var payload = buffer.slice(0, -4);
|
|
2429
|
-
var checksum = buffer.slice(-4);
|
|
2430
|
-
var newChecksum = checksumFn(payload);
|
|
2431
|
-
if (checksum[0] ^ newChecksum[0] | checksum[1] ^ newChecksum[1] | checksum[2] ^ newChecksum[2] | checksum[3] ^ newChecksum[3]) return;
|
|
2432
|
-
return payload;
|
|
2433
|
-
}
|
|
2434
|
-
function decodeUnsafe(string) {
|
|
2435
|
-
var buffer = base58.decodeUnsafe(string);
|
|
2436
|
-
if (!buffer) return;
|
|
2437
|
-
return decodeRaw(buffer);
|
|
2438
|
-
}
|
|
2439
|
-
function decode(string) {
|
|
2440
|
-
var buffer = base58.decode(string);
|
|
2441
|
-
var payload = decodeRaw(buffer);
|
|
2442
|
-
if (!payload) throw new Error("Invalid checksum");
|
|
2443
|
-
return payload;
|
|
2444
|
-
}
|
|
2445
|
-
return {
|
|
2446
|
-
encode,
|
|
2447
|
-
decode,
|
|
2448
|
-
decodeUnsafe
|
|
2449
|
-
};
|
|
2450
|
-
};
|
|
2451
|
-
}
|
|
2452
|
-
});
|
|
2453
|
-
|
|
2454
|
-
// ../../node_modules/bs58check/index.js
|
|
2455
|
-
var require_bs58check = __commonJS({
|
|
2456
|
-
"../../node_modules/bs58check/index.js"(exports$1, module) {
|
|
2457
|
-
var { sha256: sha2562 } = __require("@noble/hashes/sha256");
|
|
2458
|
-
var bs58checkBase = require_base();
|
|
2459
|
-
function sha256x2(buffer) {
|
|
2460
|
-
return sha2562(sha2562(buffer));
|
|
2461
|
-
}
|
|
2462
|
-
module.exports = bs58checkBase(sha256x2);
|
|
2463
|
-
}
|
|
2464
|
-
});
|
|
2465
|
-
|
|
2466
2413
|
// src/config/contracts.ts
|
|
2467
2414
|
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
2468
2415
|
var ZUBARI_CONTRACTS = {
|
|
@@ -2786,9 +2733,8 @@ function crc16(data) {
|
|
|
2786
2733
|
}
|
|
2787
2734
|
return crc;
|
|
2788
2735
|
}
|
|
2789
|
-
|
|
2736
|
+
function deriveTronAddress(seed) {
|
|
2790
2737
|
try {
|
|
2791
|
-
const bs58check = await Promise.resolve().then(() => __toESM(require_bs58check()));
|
|
2792
2738
|
const hdNode = ethers.HDNodeWallet.fromPhrase(seed, void 0, DERIVATION_PATHS.tron);
|
|
2793
2739
|
const ethAddressHex = hdNode.address.slice(2).toLowerCase();
|
|
2794
2740
|
const addressBytes = new Uint8Array(21);
|
|
@@ -2796,7 +2742,8 @@ async function deriveTronAddress(seed) {
|
|
|
2796
2742
|
for (let i = 0; i < 20; i++) {
|
|
2797
2743
|
addressBytes[i + 1] = parseInt(ethAddressHex.slice(i * 2, i * 2 + 2), 16);
|
|
2798
2744
|
}
|
|
2799
|
-
|
|
2745
|
+
const tronBase58check = base.base58check(sha256.sha256);
|
|
2746
|
+
return tronBase58check.encode(addressBytes);
|
|
2800
2747
|
} catch (error) {
|
|
2801
2748
|
console.error("TRON address derivation failed:", error);
|
|
2802
2749
|
throw error;
|
|
@@ -2846,10 +2793,14 @@ async function deriveAllAddresses(seed, network = "testnet") {
|
|
|
2846
2793
|
} catch (e) {
|
|
2847
2794
|
console.error("Spark derivation failed:", e);
|
|
2848
2795
|
}
|
|
2849
|
-
|
|
2796
|
+
try {
|
|
2797
|
+
addresses.tron = deriveTronAddress(seed);
|
|
2798
|
+
} catch (e) {
|
|
2799
|
+
console.error("TRON derivation failed:", e);
|
|
2800
|
+
}
|
|
2801
|
+
const [solResult, tonResult] = await Promise.allSettled([
|
|
2850
2802
|
deriveSolanaAddress(seed),
|
|
2851
|
-
deriveTonAddress(seed)
|
|
2852
|
-
deriveTronAddress(seed)
|
|
2803
|
+
deriveTonAddress(seed)
|
|
2853
2804
|
]);
|
|
2854
2805
|
if (solResult.status === "fulfilled") {
|
|
2855
2806
|
addresses.solana = solResult.value;
|
|
@@ -2861,11 +2812,6 @@ async function deriveAllAddresses(seed, network = "testnet") {
|
|
|
2861
2812
|
} else {
|
|
2862
2813
|
console.error("TON derivation failed:", tonResult.reason);
|
|
2863
2814
|
}
|
|
2864
|
-
if (tronResult.status === "fulfilled") {
|
|
2865
|
-
addresses.tron = tronResult.value;
|
|
2866
|
-
} else {
|
|
2867
|
-
console.error("TRON derivation failed:", tronResult.reason);
|
|
2868
|
-
}
|
|
2869
2815
|
return addresses;
|
|
2870
2816
|
}
|
|
2871
2817
|
function isValidSeed(seed) {
|