@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
package/dist/services/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { HDNodeWallet } from 'ethers';
|
|
|
2
2
|
import { mnemonicToSeedSync, validateMnemonic, generateMnemonic } from '@scure/bip39';
|
|
3
3
|
import { wordlist } from '@scure/bip39/wordlists/english';
|
|
4
4
|
import { HDKey } from '@scure/bip32';
|
|
5
|
-
import { bech32 } from '@scure/base';
|
|
5
|
+
import { bech32, base58check } from '@scure/base';
|
|
6
6
|
import { sha256 } from '@noble/hashes/sha256';
|
|
7
7
|
import { ripemd160 } from '@noble/hashes/ripemd160';
|
|
8
8
|
|
|
@@ -2408,59 +2408,6 @@ var require_bs58 = __commonJS({
|
|
|
2408
2408
|
}
|
|
2409
2409
|
});
|
|
2410
2410
|
|
|
2411
|
-
// ../../node_modules/bs58check/base.js
|
|
2412
|
-
var require_base = __commonJS({
|
|
2413
|
-
"../../node_modules/bs58check/base.js"(exports$1, module) {
|
|
2414
|
-
var base58 = require_bs58();
|
|
2415
|
-
module.exports = function(checksumFn) {
|
|
2416
|
-
function encode(payload) {
|
|
2417
|
-
var payloadU8 = Uint8Array.from(payload);
|
|
2418
|
-
var checksum = checksumFn(payloadU8);
|
|
2419
|
-
var length = payloadU8.length + 4;
|
|
2420
|
-
var both = new Uint8Array(length);
|
|
2421
|
-
both.set(payloadU8, 0);
|
|
2422
|
-
both.set(checksum.subarray(0, 4), payloadU8.length);
|
|
2423
|
-
return base58.encode(both, length);
|
|
2424
|
-
}
|
|
2425
|
-
function decodeRaw(buffer) {
|
|
2426
|
-
var payload = buffer.slice(0, -4);
|
|
2427
|
-
var checksum = buffer.slice(-4);
|
|
2428
|
-
var newChecksum = checksumFn(payload);
|
|
2429
|
-
if (checksum[0] ^ newChecksum[0] | checksum[1] ^ newChecksum[1] | checksum[2] ^ newChecksum[2] | checksum[3] ^ newChecksum[3]) return;
|
|
2430
|
-
return payload;
|
|
2431
|
-
}
|
|
2432
|
-
function decodeUnsafe(string) {
|
|
2433
|
-
var buffer = base58.decodeUnsafe(string);
|
|
2434
|
-
if (!buffer) return;
|
|
2435
|
-
return decodeRaw(buffer);
|
|
2436
|
-
}
|
|
2437
|
-
function decode(string) {
|
|
2438
|
-
var buffer = base58.decode(string);
|
|
2439
|
-
var payload = decodeRaw(buffer);
|
|
2440
|
-
if (!payload) throw new Error("Invalid checksum");
|
|
2441
|
-
return payload;
|
|
2442
|
-
}
|
|
2443
|
-
return {
|
|
2444
|
-
encode,
|
|
2445
|
-
decode,
|
|
2446
|
-
decodeUnsafe
|
|
2447
|
-
};
|
|
2448
|
-
};
|
|
2449
|
-
}
|
|
2450
|
-
});
|
|
2451
|
-
|
|
2452
|
-
// ../../node_modules/bs58check/index.js
|
|
2453
|
-
var require_bs58check = __commonJS({
|
|
2454
|
-
"../../node_modules/bs58check/index.js"(exports$1, module) {
|
|
2455
|
-
var { sha256: sha2562 } = __require("@noble/hashes/sha256");
|
|
2456
|
-
var bs58checkBase = require_base();
|
|
2457
|
-
function sha256x2(buffer) {
|
|
2458
|
-
return sha2562(sha2562(buffer));
|
|
2459
|
-
}
|
|
2460
|
-
module.exports = bs58checkBase(sha256x2);
|
|
2461
|
-
}
|
|
2462
|
-
});
|
|
2463
|
-
|
|
2464
2411
|
// src/config/contracts.ts
|
|
2465
2412
|
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
2466
2413
|
var ZUBARI_CONTRACTS = {
|
|
@@ -2784,9 +2731,8 @@ function crc16(data) {
|
|
|
2784
2731
|
}
|
|
2785
2732
|
return crc;
|
|
2786
2733
|
}
|
|
2787
|
-
|
|
2734
|
+
function deriveTronAddress(seed) {
|
|
2788
2735
|
try {
|
|
2789
|
-
const bs58check = await Promise.resolve().then(() => __toESM(require_bs58check()));
|
|
2790
2736
|
const hdNode = HDNodeWallet.fromPhrase(seed, void 0, DERIVATION_PATHS.tron);
|
|
2791
2737
|
const ethAddressHex = hdNode.address.slice(2).toLowerCase();
|
|
2792
2738
|
const addressBytes = new Uint8Array(21);
|
|
@@ -2794,7 +2740,8 @@ async function deriveTronAddress(seed) {
|
|
|
2794
2740
|
for (let i = 0; i < 20; i++) {
|
|
2795
2741
|
addressBytes[i + 1] = parseInt(ethAddressHex.slice(i * 2, i * 2 + 2), 16);
|
|
2796
2742
|
}
|
|
2797
|
-
|
|
2743
|
+
const tronBase58check = base58check(sha256);
|
|
2744
|
+
return tronBase58check.encode(addressBytes);
|
|
2798
2745
|
} catch (error) {
|
|
2799
2746
|
console.error("TRON address derivation failed:", error);
|
|
2800
2747
|
throw error;
|
|
@@ -2844,10 +2791,14 @@ async function deriveAllAddresses(seed, network = "testnet") {
|
|
|
2844
2791
|
} catch (e) {
|
|
2845
2792
|
console.error("Spark derivation failed:", e);
|
|
2846
2793
|
}
|
|
2847
|
-
|
|
2794
|
+
try {
|
|
2795
|
+
addresses.tron = deriveTronAddress(seed);
|
|
2796
|
+
} catch (e) {
|
|
2797
|
+
console.error("TRON derivation failed:", e);
|
|
2798
|
+
}
|
|
2799
|
+
const [solResult, tonResult] = await Promise.allSettled([
|
|
2848
2800
|
deriveSolanaAddress(seed),
|
|
2849
|
-
deriveTonAddress(seed)
|
|
2850
|
-
deriveTronAddress(seed)
|
|
2801
|
+
deriveTonAddress(seed)
|
|
2851
2802
|
]);
|
|
2852
2803
|
if (solResult.status === "fulfilled") {
|
|
2853
2804
|
addresses.solana = solResult.value;
|
|
@@ -2859,11 +2810,6 @@ async function deriveAllAddresses(seed, network = "testnet") {
|
|
|
2859
2810
|
} else {
|
|
2860
2811
|
console.error("TON derivation failed:", tonResult.reason);
|
|
2861
2812
|
}
|
|
2862
|
-
if (tronResult.status === "fulfilled") {
|
|
2863
|
-
addresses.tron = tronResult.value;
|
|
2864
|
-
} else {
|
|
2865
|
-
console.error("TRON derivation failed:", tronResult.reason);
|
|
2866
|
-
}
|
|
2867
2813
|
return addresses;
|
|
2868
2814
|
}
|
|
2869
2815
|
function isValidSeed(seed) {
|