@zubari/sdk 0.5.6 → 0.5.7
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/{TransactionService-DbNDRzXh.d.ts → TransactionService-BEkgF1T6.d.ts} +5 -9
- package/dist/{TransactionService-Cmw33HXX.d.mts → TransactionService-CF_C3Kqm.d.mts} +5 -9
- package/dist/{WalletManager-DIx8nENh.d.mts → WalletManager-BTewpMGA.d.mts} +131 -48
- package/dist/{WalletManager-CeLlZo2y.d.ts → WalletManager-BV1QA08D.d.ts} +131 -48
- package/dist/{contracts-JfZDzaV7.d.ts → contracts-CyIOTDtT.d.ts} +1 -1
- package/dist/{contracts-pugJnFzl.d.mts → contracts-i0GG-cBt.d.mts} +1 -1
- package/dist/index.d.mts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +59 -73
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -60
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +4 -3
- package/dist/react/index.d.ts +4 -3
- package/dist/react/index.js +59 -73
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +46 -60
- package/dist/react/index.mjs.map +1 -1
- package/dist/services/index.d.mts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +59 -73
- package/dist/services/index.js.map +1 -1
- package/dist/services/index.mjs +46 -60
- package/dist/services/index.mjs.map +1 -1
- package/dist/wallet/index.d.mts +4 -3
- package/dist/wallet/index.d.ts +4 -3
- package/dist/wallet/index.js +59 -73
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +46 -60
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +5 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BrowserAddressDerivation, C as BrowserChainAddress, a as BrowserMultiChainAddresses, l as ChainAddress, m as ChainBalance, D as DeriveAddressResponse, c as DeriveAllAddressesResponse, w as FeeEstimate, F as FeeRates, G as GenerateSeedResponse, M as MultiChainAddresses, e as SendTransactionResponse, k as SupportedChain, S as SwapService, o as TransactionErrorCode, v as TransactionHistoryItem, d as TransactionHistoryResponse, t as TransactionParams, u as TransactionResult, q as TransactionService, x as TransactionServiceConfig, f as TransactionStatusResponse, V as ValidateSeedResponse, W as WdkApiClient, b as WdkApiConfig, T as WdkTransactionHistoryItem, n as WdkTransactionResult, Z as ZubariWdkService, p as ZubariWdkServiceConfig, s as createTransactionService, i as createZubariWdkService, r as getTransactionService, g as getWdkApiClient, h as getZubariWdkService, j as isBrowser } from '../TransactionService-
|
|
1
|
+
export { B as BrowserAddressDerivation, C as BrowserChainAddress, a as BrowserMultiChainAddresses, l as ChainAddress, m as ChainBalance, D as DeriveAddressResponse, c as DeriveAllAddressesResponse, w as FeeEstimate, F as FeeRates, G as GenerateSeedResponse, M as MultiChainAddresses, e as SendTransactionResponse, k as SupportedChain, S as SwapService, o as TransactionErrorCode, v as TransactionHistoryItem, d as TransactionHistoryResponse, t as TransactionParams, u as TransactionResult, q as TransactionService, x as TransactionServiceConfig, f as TransactionStatusResponse, V as ValidateSeedResponse, W as WdkApiClient, b as WdkApiConfig, T as WdkTransactionHistoryItem, n as WdkTransactionResult, Z as ZubariWdkService, p as ZubariWdkServiceConfig, s as createTransactionService, i as createZubariWdkService, r as getTransactionService, g as getWdkApiClient, h as getZubariWdkService, j as isBrowser } from '../TransactionService-CF_C3Kqm.mjs';
|
|
2
2
|
import { N as NFTCurrency } from '../index-c90msmwW.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BrowserAddressDerivation, C as BrowserChainAddress, a as BrowserMultiChainAddresses, l as ChainAddress, m as ChainBalance, D as DeriveAddressResponse, c as DeriveAllAddressesResponse, w as FeeEstimate, F as FeeRates, G as GenerateSeedResponse, M as MultiChainAddresses, e as SendTransactionResponse, k as SupportedChain, S as SwapService, o as TransactionErrorCode, v as TransactionHistoryItem, d as TransactionHistoryResponse, t as TransactionParams, u as TransactionResult, q as TransactionService, x as TransactionServiceConfig, f as TransactionStatusResponse, V as ValidateSeedResponse, W as WdkApiClient, b as WdkApiConfig, T as WdkTransactionHistoryItem, n as WdkTransactionResult, Z as ZubariWdkService, p as ZubariWdkServiceConfig, s as createTransactionService, i as createZubariWdkService, r as getTransactionService, g as getWdkApiClient, h as getZubariWdkService, j as isBrowser } from '../TransactionService-
|
|
1
|
+
export { B as BrowserAddressDerivation, C as BrowserChainAddress, a as BrowserMultiChainAddresses, l as ChainAddress, m as ChainBalance, D as DeriveAddressResponse, c as DeriveAllAddressesResponse, w as FeeEstimate, F as FeeRates, G as GenerateSeedResponse, M as MultiChainAddresses, e as SendTransactionResponse, k as SupportedChain, S as SwapService, o as TransactionErrorCode, v as TransactionHistoryItem, d as TransactionHistoryResponse, t as TransactionParams, u as TransactionResult, q as TransactionService, x as TransactionServiceConfig, f as TransactionStatusResponse, V as ValidateSeedResponse, W as WdkApiClient, b as WdkApiConfig, T as WdkTransactionHistoryItem, n as WdkTransactionResult, Z as ZubariWdkService, p as ZubariWdkServiceConfig, s as createTransactionService, i as createZubariWdkService, r as getTransactionService, g as getWdkApiClient, h as getZubariWdkService, j as isBrowser } from '../TransactionService-BEkgF1T6.js';
|
|
2
2
|
import { N as NFTCurrency } from '../index-c90msmwW.js';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/services/index.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var ethers = require('ethers');
|
|
4
|
+
var bip39 = require('@scure/bip39');
|
|
5
|
+
var english = require('@scure/bip39/wordlists/english');
|
|
6
|
+
var bip32 = require('@scure/bip32');
|
|
7
|
+
var base = require('@scure/base');
|
|
8
|
+
var sha256 = require('@noble/hashes/sha256');
|
|
9
|
+
var ripemd160 = require('@noble/hashes/ripemd160');
|
|
4
10
|
|
|
5
11
|
var __defProp = Object.defineProperty;
|
|
6
12
|
var __export = (target, all) => {
|
|
@@ -1097,50 +1103,25 @@ var DERIVATION_PATHS2 = {
|
|
|
1097
1103
|
solana: `${DERIVATION_PATHS.solana}/0'`,
|
|
1098
1104
|
spark: `${DERIVATION_PATHS.spark}/0`
|
|
1099
1105
|
};
|
|
1100
|
-
var _crypto = null;
|
|
1101
|
-
async function loadCrypto() {
|
|
1102
|
-
if (_crypto) return _crypto;
|
|
1103
|
-
const [bip39, bip39Words, bip32, scureBase, sha256Mod, ripemd160Mod] = await Promise.all([
|
|
1104
|
-
import('@scure/bip39'),
|
|
1105
|
-
import('@scure/bip39/wordlists/english'),
|
|
1106
|
-
import('@scure/bip32'),
|
|
1107
|
-
import('@scure/base'),
|
|
1108
|
-
import('@noble/hashes/sha256'),
|
|
1109
|
-
import('@noble/hashes/ripemd160')
|
|
1110
|
-
]);
|
|
1111
|
-
_crypto = {
|
|
1112
|
-
mnemonicToSeedSync: bip39.mnemonicToSeedSync,
|
|
1113
|
-
validateMnemonic: bip39.validateMnemonic,
|
|
1114
|
-
generateMnemonic: bip39.generateMnemonic,
|
|
1115
|
-
wordlist: bip39Words.wordlist,
|
|
1116
|
-
HDKey: bip32.HDKey,
|
|
1117
|
-
bech32: scureBase.bech32,
|
|
1118
|
-
base58check: scureBase.base58check,
|
|
1119
|
-
sha256: sha256Mod.sha256,
|
|
1120
|
-
ripemd160: ripemd160Mod.ripemd160
|
|
1121
|
-
};
|
|
1122
|
-
return _crypto;
|
|
1123
|
-
}
|
|
1124
1106
|
function deriveEthereumAddress(seed) {
|
|
1125
1107
|
const hdNode = ethers.HDNodeWallet.fromPhrase(seed, void 0, DERIVATION_PATHS2.ethereum);
|
|
1126
1108
|
return hdNode.address;
|
|
1127
1109
|
}
|
|
1128
|
-
|
|
1110
|
+
function deriveBitcoinAddress(seed, network = "mainnet") {
|
|
1129
1111
|
try {
|
|
1130
|
-
const
|
|
1131
|
-
const
|
|
1132
|
-
const hdKey = HDKey.fromMasterSeed(seedBytes);
|
|
1112
|
+
const seedBytes = bip39.mnemonicToSeedSync(seed);
|
|
1113
|
+
const hdKey = bip32.HDKey.fromMasterSeed(seedBytes);
|
|
1133
1114
|
const path = network === "testnet" ? DERIVATION_PATHS2.bitcoin_testnet : DERIVATION_PATHS2.bitcoin_mainnet;
|
|
1134
1115
|
const child = hdKey.derive(path);
|
|
1135
1116
|
if (!child.publicKey) {
|
|
1136
1117
|
throw new Error("Failed to derive public key");
|
|
1137
1118
|
}
|
|
1138
|
-
const pubKeyHash = ripemd160(sha256(child.publicKey));
|
|
1119
|
+
const pubKeyHash = ripemd160.ripemd160(sha256.sha256(child.publicKey));
|
|
1139
1120
|
const witnessVersion = 0;
|
|
1140
|
-
const words = bech32.toWords(pubKeyHash);
|
|
1121
|
+
const words = base.bech32.toWords(pubKeyHash);
|
|
1141
1122
|
words.unshift(witnessVersion);
|
|
1142
1123
|
const hrp = network === "testnet" ? "tb" : "bc";
|
|
1143
|
-
const address = bech32.encode(hrp, words);
|
|
1124
|
+
const address = base.bech32.encode(hrp, words);
|
|
1144
1125
|
return address;
|
|
1145
1126
|
} catch (error) {
|
|
1146
1127
|
console.error("Bitcoin address derivation failed:", error);
|
|
@@ -1149,14 +1130,13 @@ async function deriveBitcoinAddress(seed, network = "mainnet") {
|
|
|
1149
1130
|
}
|
|
1150
1131
|
async function deriveSolanaAddress(seed) {
|
|
1151
1132
|
try {
|
|
1152
|
-
const [
|
|
1153
|
-
loadCrypto(),
|
|
1133
|
+
const [ed25519, nacl, bs58Module] = await Promise.all([
|
|
1154
1134
|
import('ed25519-hd-key'),
|
|
1155
1135
|
import('tweetnacl'),
|
|
1156
1136
|
import('bs58')
|
|
1157
1137
|
]);
|
|
1158
1138
|
const bs58 = bs58Module.default || bs58Module;
|
|
1159
|
-
const seedBytes =
|
|
1139
|
+
const seedBytes = bip39.mnemonicToSeedSync(seed);
|
|
1160
1140
|
const derived = ed25519.derivePath(DERIVATION_PATHS2.solana, Buffer.from(seedBytes).toString("hex"));
|
|
1161
1141
|
const keypair = nacl.sign.keyPair.fromSeed(new Uint8Array(derived.key));
|
|
1162
1142
|
return bs58.encode(keypair.publicKey);
|
|
@@ -1167,18 +1147,17 @@ async function deriveSolanaAddress(seed) {
|
|
|
1167
1147
|
}
|
|
1168
1148
|
async function deriveTonAddress(seed) {
|
|
1169
1149
|
try {
|
|
1170
|
-
const [
|
|
1171
|
-
loadCrypto(),
|
|
1150
|
+
const [ed25519, nacl] = await Promise.all([
|
|
1172
1151
|
import('ed25519-hd-key'),
|
|
1173
1152
|
import('tweetnacl')
|
|
1174
1153
|
]);
|
|
1175
|
-
const seedBytes =
|
|
1154
|
+
const seedBytes = bip39.mnemonicToSeedSync(seed);
|
|
1176
1155
|
const derived = ed25519.derivePath(DERIVATION_PATHS2.ton, Buffer.from(seedBytes).toString("hex"));
|
|
1177
1156
|
const keypair = nacl.sign.keyPair.fromSeed(new Uint8Array(derived.key));
|
|
1178
1157
|
const publicKey = keypair.publicKey;
|
|
1179
1158
|
const workchain = 0;
|
|
1180
1159
|
const flags = 17;
|
|
1181
|
-
const hash =
|
|
1160
|
+
const hash = sha256.sha256(publicKey);
|
|
1182
1161
|
const addressData = new Uint8Array(34);
|
|
1183
1162
|
addressData[0] = flags;
|
|
1184
1163
|
addressData[1] = workchain;
|
|
@@ -1206,9 +1185,8 @@ function crc16(data) {
|
|
|
1206
1185
|
}
|
|
1207
1186
|
return crc;
|
|
1208
1187
|
}
|
|
1209
|
-
|
|
1188
|
+
function deriveTronAddress(seed) {
|
|
1210
1189
|
try {
|
|
1211
|
-
const { sha256, base58check } = await loadCrypto();
|
|
1212
1190
|
const hdNode = ethers.HDNodeWallet.fromPhrase(seed, void 0, DERIVATION_PATHS2.tron);
|
|
1213
1191
|
const ethAddressHex = hdNode.address.slice(2).toLowerCase();
|
|
1214
1192
|
const addressBytes = new Uint8Array(21);
|
|
@@ -1216,28 +1194,27 @@ async function deriveTronAddress(seed) {
|
|
|
1216
1194
|
for (let i = 0; i < 20; i++) {
|
|
1217
1195
|
addressBytes[i + 1] = parseInt(ethAddressHex.slice(i * 2, i * 2 + 2), 16);
|
|
1218
1196
|
}
|
|
1219
|
-
const tronBase58check = base58check(sha256);
|
|
1197
|
+
const tronBase58check = base.base58check(sha256.sha256);
|
|
1220
1198
|
return tronBase58check.encode(addressBytes);
|
|
1221
1199
|
} catch (error) {
|
|
1222
1200
|
console.error("TRON address derivation failed:", error);
|
|
1223
1201
|
throw error;
|
|
1224
1202
|
}
|
|
1225
1203
|
}
|
|
1226
|
-
|
|
1204
|
+
function deriveSparkAddress(seed, network = "mainnet") {
|
|
1227
1205
|
try {
|
|
1228
|
-
const
|
|
1229
|
-
const
|
|
1230
|
-
const hdKey = HDKey.fromMasterSeed(seedBytes);
|
|
1206
|
+
const seedBytes = bip39.mnemonicToSeedSync(seed);
|
|
1207
|
+
const hdKey = bip32.HDKey.fromMasterSeed(seedBytes);
|
|
1231
1208
|
const child = hdKey.derive(DERIVATION_PATHS2.spark);
|
|
1232
1209
|
if (!child.publicKey) {
|
|
1233
1210
|
throw new Error("Failed to derive public key");
|
|
1234
1211
|
}
|
|
1235
|
-
const pubKeyHash = ripemd160(sha256(child.publicKey));
|
|
1212
|
+
const pubKeyHash = ripemd160.ripemd160(sha256.sha256(child.publicKey));
|
|
1236
1213
|
const witnessVersion = 0;
|
|
1237
|
-
const words = bech32.toWords(pubKeyHash);
|
|
1214
|
+
const words = base.bech32.toWords(pubKeyHash);
|
|
1238
1215
|
words.unshift(witnessVersion);
|
|
1239
1216
|
const hrp = network === "testnet" ? "tsp" : "sp";
|
|
1240
|
-
const address = bech32.encode(hrp, words);
|
|
1217
|
+
const address = base.bech32.encode(hrp, words);
|
|
1241
1218
|
return address;
|
|
1242
1219
|
} catch (error) {
|
|
1243
1220
|
console.error("Spark address derivation failed:", error);
|
|
@@ -1253,38 +1230,47 @@ async function deriveAllAddresses(seed, network = "mainnet") {
|
|
|
1253
1230
|
solana: null,
|
|
1254
1231
|
spark: null
|
|
1255
1232
|
};
|
|
1256
|
-
await loadCrypto();
|
|
1257
1233
|
try {
|
|
1258
1234
|
addresses.ethereum = deriveEthereumAddress(seed);
|
|
1259
1235
|
} catch (e) {
|
|
1260
1236
|
console.error("ETH derivation failed:", e);
|
|
1261
1237
|
}
|
|
1262
|
-
|
|
1263
|
-
deriveBitcoinAddress(seed, network)
|
|
1264
|
-
|
|
1265
|
-
|
|
1238
|
+
try {
|
|
1239
|
+
addresses.bitcoin = deriveBitcoinAddress(seed, network);
|
|
1240
|
+
} catch (e) {
|
|
1241
|
+
console.error("BTC derivation failed:", e);
|
|
1242
|
+
}
|
|
1243
|
+
try {
|
|
1244
|
+
addresses.spark = deriveSparkAddress(seed, network);
|
|
1245
|
+
} catch (e) {
|
|
1246
|
+
console.error("Spark derivation failed:", e);
|
|
1247
|
+
}
|
|
1248
|
+
try {
|
|
1249
|
+
addresses.tron = deriveTronAddress(seed);
|
|
1250
|
+
} catch (e) {
|
|
1251
|
+
console.error("TRON derivation failed:", e);
|
|
1252
|
+
}
|
|
1253
|
+
const [solResult, tonResult] = await Promise.allSettled([
|
|
1266
1254
|
deriveSolanaAddress(seed),
|
|
1267
1255
|
deriveTonAddress(seed)
|
|
1268
1256
|
]);
|
|
1269
|
-
if (
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
else
|
|
1277
|
-
|
|
1278
|
-
|
|
1257
|
+
if (solResult.status === "fulfilled") {
|
|
1258
|
+
addresses.solana = solResult.value;
|
|
1259
|
+
} else {
|
|
1260
|
+
console.error("SOL derivation failed:", solResult.reason);
|
|
1261
|
+
}
|
|
1262
|
+
if (tonResult.status === "fulfilled") {
|
|
1263
|
+
addresses.ton = tonResult.value;
|
|
1264
|
+
} else {
|
|
1265
|
+
console.error("TON derivation failed:", tonResult.reason);
|
|
1266
|
+
}
|
|
1279
1267
|
return addresses;
|
|
1280
1268
|
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
return validateMnemonic(seed, wordlist);
|
|
1269
|
+
function isValidSeed(seed) {
|
|
1270
|
+
return bip39.validateMnemonic(seed, english.wordlist);
|
|
1284
1271
|
}
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
return generateMnemonic(wordlist);
|
|
1272
|
+
function generateSeedPhrase() {
|
|
1273
|
+
return bip39.generateMnemonic(english.wordlist);
|
|
1288
1274
|
}
|
|
1289
1275
|
|
|
1290
1276
|
// src/services/ZubariWdkService.ts
|
|
@@ -1527,7 +1513,7 @@ var ZubariWdkService = class {
|
|
|
1527
1513
|
};
|
|
1528
1514
|
if (!addresses.spark) {
|
|
1529
1515
|
try {
|
|
1530
|
-
addresses.spark =
|
|
1516
|
+
addresses.spark = deriveSparkAddress(seed, this.config.network);
|
|
1531
1517
|
} catch (e) {
|
|
1532
1518
|
console.warn("Browser Spark derivation fallback failed:", e);
|
|
1533
1519
|
}
|
|
@@ -1763,13 +1749,13 @@ var ZubariWdkService = class {
|
|
|
1763
1749
|
address = deriveEthereumAddress(seed);
|
|
1764
1750
|
break;
|
|
1765
1751
|
case "bitcoin":
|
|
1766
|
-
address =
|
|
1752
|
+
address = deriveBitcoinAddress(seed, this.config.network);
|
|
1767
1753
|
break;
|
|
1768
1754
|
case "tron":
|
|
1769
|
-
address =
|
|
1755
|
+
address = deriveTronAddress(seed);
|
|
1770
1756
|
break;
|
|
1771
1757
|
case "spark":
|
|
1772
|
-
address =
|
|
1758
|
+
address = deriveSparkAddress(seed, this.config.network);
|
|
1773
1759
|
break;
|
|
1774
1760
|
case "solana":
|
|
1775
1761
|
address = await deriveSolanaAddress(seed);
|