@zubari/sdk 0.5.3 → 0.5.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/{PayoutsProtocol-B5z8SEA-.d.ts → PayoutsProtocol-DAa-9A5C.d.ts} +8 -1
- package/dist/{PayoutsProtocol-CLiMFe54.d.mts → PayoutsProtocol-DKEQhwYH.d.mts} +8 -1
- package/dist/{TransactionService-Lr_WS6iR.d.mts → TransactionService-Cmw33HXX.d.mts} +21 -7
- package/dist/{TransactionService-BtWUjKt_.d.ts → TransactionService-DbNDRzXh.d.ts} +21 -7
- package/dist/{WalletManager-DQQwVkoa.d.ts → WalletManager-CeLlZo2y.d.ts} +23 -2
- package/dist/{WalletManager-Sbpx4E1-.d.mts → WalletManager-DIx8nENh.d.mts} +23 -2
- package/dist/{contracts-B842YprC.d.mts → contracts-JfZDzaV7.d.ts} +11 -2
- package/dist/{contracts-s_CDIruh.d.ts → contracts-pugJnFzl.d.mts} +11 -2
- package/dist/{index-CTyZlHKg.d.mts → index-c90msmwW.d.mts} +2 -1
- package/dist/{index-CTyZlHKg.d.ts → index-c90msmwW.d.ts} +2 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +202 -195
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +189 -182
- package/dist/index.mjs.map +1 -1
- package/dist/protocols/index.d.mts +2 -2
- package/dist/protocols/index.d.ts +2 -2
- package/dist/protocols/index.js +24 -11
- package/dist/protocols/index.js.map +1 -1
- package/dist/protocols/index.mjs +24 -11
- package/dist/protocols/index.mjs.map +1 -1
- package/dist/react/index.d.mts +3 -3
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +167 -154
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +154 -141
- package/dist/react/index.mjs.map +1 -1
- package/dist/services/index.d.mts +2 -2
- package/dist/services/index.d.ts +2 -2
- package/dist/services/index.js +145 -125
- package/dist/services/index.js.map +1 -1
- package/dist/services/index.mjs +132 -112
- package/dist/services/index.mjs.map +1 -1
- package/dist/storage/index.js +5 -2
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/index.mjs +5 -2
- package/dist/storage/index.mjs.map +1 -1
- package/dist/wallet/index.d.mts +3 -3
- package/dist/wallet/index.d.ts +3 -3
- package/dist/wallet/index.js +176 -184
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +163 -171
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/services/index.mjs
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { HDNodeWallet } from 'ethers';
|
|
2
|
-
import { mnemonicToSeedSync, validateMnemonic, generateMnemonic } from '@scure/bip39';
|
|
3
|
-
import { wordlist } from '@scure/bip39/wordlists/english';
|
|
4
|
-
import { HDKey } from '@scure/bip32';
|
|
5
|
-
import { bech32, base58check } from '@scure/base';
|
|
6
|
-
import { sha256 } from '@noble/hashes/sha256';
|
|
7
|
-
import { ripemd160 } from '@noble/hashes/ripemd160';
|
|
8
2
|
|
|
9
3
|
var __defProp = Object.defineProperty;
|
|
10
4
|
var __export = (target, all) => {
|
|
@@ -218,9 +212,28 @@ var WdkApiClient = class {
|
|
|
218
212
|
constructor(config) {
|
|
219
213
|
this.config = {
|
|
220
214
|
baseUrl: config.baseUrl,
|
|
221
|
-
timeout: config.timeout || 3e4
|
|
215
|
+
timeout: config.timeout || 3e4,
|
|
216
|
+
authToken: config.authToken
|
|
222
217
|
};
|
|
223
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Set or update the auth token for authenticated requests
|
|
221
|
+
*/
|
|
222
|
+
setAuthToken(token) {
|
|
223
|
+
this.config.authToken = token;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Build headers for API requests, including Authorization when available
|
|
227
|
+
*/
|
|
228
|
+
getHeaders() {
|
|
229
|
+
const headers = {
|
|
230
|
+
"Content-Type": "application/json"
|
|
231
|
+
};
|
|
232
|
+
if (this.config.authToken) {
|
|
233
|
+
headers["Authorization"] = `Bearer ${this.config.authToken}`;
|
|
234
|
+
}
|
|
235
|
+
return headers;
|
|
236
|
+
}
|
|
224
237
|
/**
|
|
225
238
|
* Generate a new BIP-39 seed phrase using Tether WDK
|
|
226
239
|
*/
|
|
@@ -228,9 +241,7 @@ var WdkApiClient = class {
|
|
|
228
241
|
try {
|
|
229
242
|
const response = await fetch(`${this.config.baseUrl}/api/wallets/wdk/generate-seed`, {
|
|
230
243
|
method: "POST",
|
|
231
|
-
headers:
|
|
232
|
-
"Content-Type": "application/json"
|
|
233
|
-
}
|
|
244
|
+
headers: this.getHeaders()
|
|
234
245
|
});
|
|
235
246
|
return await response.json();
|
|
236
247
|
} catch (error) {
|
|
@@ -247,9 +258,7 @@ var WdkApiClient = class {
|
|
|
247
258
|
try {
|
|
248
259
|
const response = await fetch(`${this.config.baseUrl}/api/wallets/wdk/validate-seed`, {
|
|
249
260
|
method: "POST",
|
|
250
|
-
headers:
|
|
251
|
-
"Content-Type": "application/json"
|
|
252
|
-
},
|
|
261
|
+
headers: this.getHeaders(),
|
|
253
262
|
body: JSON.stringify({ seed })
|
|
254
263
|
});
|
|
255
264
|
return await response.json();
|
|
@@ -267,9 +276,7 @@ var WdkApiClient = class {
|
|
|
267
276
|
try {
|
|
268
277
|
const response = await fetch(`${this.config.baseUrl}/api/wallets/wdk/derive-address`, {
|
|
269
278
|
method: "POST",
|
|
270
|
-
headers:
|
|
271
|
-
"Content-Type": "application/json"
|
|
272
|
-
},
|
|
279
|
+
headers: this.getHeaders(),
|
|
273
280
|
body: JSON.stringify({ seed, chain, network })
|
|
274
281
|
});
|
|
275
282
|
return await response.json();
|
|
@@ -287,9 +294,7 @@ var WdkApiClient = class {
|
|
|
287
294
|
try {
|
|
288
295
|
const response = await fetch(`${this.config.baseUrl}/api/wallets/wdk/derive-all`, {
|
|
289
296
|
method: "POST",
|
|
290
|
-
headers:
|
|
291
|
-
"Content-Type": "application/json"
|
|
292
|
-
},
|
|
297
|
+
headers: this.getHeaders(),
|
|
293
298
|
body: JSON.stringify({ seed, network })
|
|
294
299
|
});
|
|
295
300
|
return await response.json();
|
|
@@ -307,9 +312,7 @@ var WdkApiClient = class {
|
|
|
307
312
|
try {
|
|
308
313
|
const response = await fetch(`${this.config.baseUrl}/api/wallets/wdk/send`, {
|
|
309
314
|
method: "POST",
|
|
310
|
-
headers:
|
|
311
|
-
"Content-Type": "application/json"
|
|
312
|
-
},
|
|
315
|
+
headers: this.getHeaders(),
|
|
313
316
|
body: JSON.stringify({ seed, chain, to, amount, network })
|
|
314
317
|
});
|
|
315
318
|
return await response.json();
|
|
@@ -328,9 +331,7 @@ var WdkApiClient = class {
|
|
|
328
331
|
try {
|
|
329
332
|
const response = await fetch(`${this.config.baseUrl}/api/wallets/wdk/history`, {
|
|
330
333
|
method: "POST",
|
|
331
|
-
headers:
|
|
332
|
-
"Content-Type": "application/json"
|
|
333
|
-
},
|
|
334
|
+
headers: this.getHeaders(),
|
|
334
335
|
body: JSON.stringify({ seed, chain, network, limit })
|
|
335
336
|
});
|
|
336
337
|
return await response.json();
|
|
@@ -349,9 +350,7 @@ var WdkApiClient = class {
|
|
|
349
350
|
try {
|
|
350
351
|
const response = await fetch(`${this.config.baseUrl}/api/wallets/wdk/tx-status`, {
|
|
351
352
|
method: "POST",
|
|
352
|
-
headers:
|
|
353
|
-
"Content-Type": "application/json"
|
|
354
|
-
},
|
|
353
|
+
headers: this.getHeaders(),
|
|
355
354
|
body: JSON.stringify({ txHash, chain, network })
|
|
356
355
|
});
|
|
357
356
|
return await response.json();
|
|
@@ -365,11 +364,14 @@ var WdkApiClient = class {
|
|
|
365
364
|
};
|
|
366
365
|
var DEFAULT_API_URL = process.env.NEXT_PUBLIC_API_URL || "https://ckgwifsxka.us-east-2.awsapprunner.com";
|
|
367
366
|
var wdkApiClient = null;
|
|
368
|
-
function getWdkApiClient(baseUrl) {
|
|
367
|
+
function getWdkApiClient(baseUrl, authToken) {
|
|
369
368
|
if (!wdkApiClient || baseUrl && wdkApiClient["config"].baseUrl !== baseUrl) {
|
|
370
369
|
wdkApiClient = new WdkApiClient({
|
|
371
|
-
baseUrl: baseUrl || DEFAULT_API_URL
|
|
370
|
+
baseUrl: baseUrl || DEFAULT_API_URL,
|
|
371
|
+
authToken
|
|
372
372
|
});
|
|
373
|
+
} else if (authToken !== void 0) {
|
|
374
|
+
wdkApiClient.setAuthToken(authToken);
|
|
373
375
|
}
|
|
374
376
|
return wdkApiClient;
|
|
375
377
|
}
|
|
@@ -1072,24 +1074,61 @@ __export(BrowserAddressDerivation_exports, {
|
|
|
1072
1074
|
generateSeedPhrase: () => generateSeedPhrase,
|
|
1073
1075
|
isValidSeed: () => isValidSeed
|
|
1074
1076
|
});
|
|
1077
|
+
|
|
1078
|
+
// src/config/networks.ts
|
|
1075
1079
|
var DERIVATION_PATHS = {
|
|
1076
|
-
|
|
1077
|
-
|
|
1080
|
+
bitcoin: "m/84'/0'/0'/0",
|
|
1081
|
+
ethereum: "m/44'/60'/0'/0",
|
|
1082
|
+
ton: "m/44'/607'/0'",
|
|
1083
|
+
tron: "m/44'/195'/0'/0",
|
|
1084
|
+
solana: "m/44'/501'/0'",
|
|
1085
|
+
spark: "m/44'/998'/0'/0"
|
|
1086
|
+
};
|
|
1087
|
+
|
|
1088
|
+
// src/services/BrowserAddressDerivation.ts
|
|
1089
|
+
var DERIVATION_PATHS2 = {
|
|
1090
|
+
ethereum: `${DERIVATION_PATHS.ethereum}/0`,
|
|
1091
|
+
bitcoin_mainnet: `${DERIVATION_PATHS.bitcoin}/0`,
|
|
1078
1092
|
bitcoin_testnet: "m/84'/1'/0'/0/0",
|
|
1079
|
-
ton:
|
|
1080
|
-
tron:
|
|
1081
|
-
solana:
|
|
1082
|
-
spark:
|
|
1093
|
+
ton: `${DERIVATION_PATHS.ton}/0'/0'`,
|
|
1094
|
+
tron: `${DERIVATION_PATHS.tron}/0`,
|
|
1095
|
+
solana: `${DERIVATION_PATHS.solana}/0'`,
|
|
1096
|
+
spark: `${DERIVATION_PATHS.spark}/0`
|
|
1083
1097
|
};
|
|
1098
|
+
var _crypto = null;
|
|
1099
|
+
async function loadCrypto() {
|
|
1100
|
+
if (_crypto) return _crypto;
|
|
1101
|
+
const [bip39, bip39Words, bip32, scureBase, sha256Mod, ripemd160Mod] = await Promise.all([
|
|
1102
|
+
import('@scure/bip39'),
|
|
1103
|
+
import('@scure/bip39/wordlists/english.js'),
|
|
1104
|
+
import('@scure/bip32'),
|
|
1105
|
+
import('@scure/base'),
|
|
1106
|
+
import('@noble/hashes/sha256'),
|
|
1107
|
+
import('@noble/hashes/ripemd160')
|
|
1108
|
+
]);
|
|
1109
|
+
_crypto = {
|
|
1110
|
+
mnemonicToSeedSync: bip39.mnemonicToSeedSync,
|
|
1111
|
+
validateMnemonic: bip39.validateMnemonic,
|
|
1112
|
+
generateMnemonic: bip39.generateMnemonic,
|
|
1113
|
+
wordlist: bip39Words.wordlist,
|
|
1114
|
+
HDKey: bip32.HDKey,
|
|
1115
|
+
bech32: scureBase.bech32,
|
|
1116
|
+
base58check: scureBase.base58check,
|
|
1117
|
+
sha256: sha256Mod.sha256,
|
|
1118
|
+
ripemd160: ripemd160Mod.ripemd160
|
|
1119
|
+
};
|
|
1120
|
+
return _crypto;
|
|
1121
|
+
}
|
|
1084
1122
|
function deriveEthereumAddress(seed) {
|
|
1085
|
-
const hdNode = HDNodeWallet.fromPhrase(seed, void 0,
|
|
1123
|
+
const hdNode = HDNodeWallet.fromPhrase(seed, void 0, DERIVATION_PATHS2.ethereum);
|
|
1086
1124
|
return hdNode.address;
|
|
1087
1125
|
}
|
|
1088
|
-
function deriveBitcoinAddress(seed, network = "mainnet") {
|
|
1126
|
+
async function deriveBitcoinAddress(seed, network = "mainnet") {
|
|
1089
1127
|
try {
|
|
1128
|
+
const { mnemonicToSeedSync, HDKey, sha256, ripemd160, bech32 } = await loadCrypto();
|
|
1090
1129
|
const seedBytes = mnemonicToSeedSync(seed);
|
|
1091
1130
|
const hdKey = HDKey.fromMasterSeed(seedBytes);
|
|
1092
|
-
const path = network === "testnet" ?
|
|
1131
|
+
const path = network === "testnet" ? DERIVATION_PATHS2.bitcoin_testnet : DERIVATION_PATHS2.bitcoin_mainnet;
|
|
1093
1132
|
const child = hdKey.derive(path);
|
|
1094
1133
|
if (!child.publicKey) {
|
|
1095
1134
|
throw new Error("Failed to derive public key");
|
|
@@ -1108,14 +1147,15 @@ function deriveBitcoinAddress(seed, network = "mainnet") {
|
|
|
1108
1147
|
}
|
|
1109
1148
|
async function deriveSolanaAddress(seed) {
|
|
1110
1149
|
try {
|
|
1111
|
-
const [ed25519, nacl, bs58Module] = await Promise.all([
|
|
1150
|
+
const [crypto, ed25519, nacl, bs58Module] = await Promise.all([
|
|
1151
|
+
loadCrypto(),
|
|
1112
1152
|
import('ed25519-hd-key'),
|
|
1113
1153
|
import('tweetnacl'),
|
|
1114
1154
|
import('bs58')
|
|
1115
1155
|
]);
|
|
1116
1156
|
const bs58 = bs58Module.default || bs58Module;
|
|
1117
|
-
const seedBytes = mnemonicToSeedSync(seed);
|
|
1118
|
-
const derived = ed25519.derivePath(
|
|
1157
|
+
const seedBytes = crypto.mnemonicToSeedSync(seed);
|
|
1158
|
+
const derived = ed25519.derivePath(DERIVATION_PATHS2.solana, Buffer.from(seedBytes).toString("hex"));
|
|
1119
1159
|
const keypair = nacl.sign.keyPair.fromSeed(new Uint8Array(derived.key));
|
|
1120
1160
|
return bs58.encode(keypair.publicKey);
|
|
1121
1161
|
} catch (error) {
|
|
@@ -1125,17 +1165,18 @@ async function deriveSolanaAddress(seed) {
|
|
|
1125
1165
|
}
|
|
1126
1166
|
async function deriveTonAddress(seed) {
|
|
1127
1167
|
try {
|
|
1128
|
-
const [ed25519, nacl] = await Promise.all([
|
|
1168
|
+
const [crypto, ed25519, nacl] = await Promise.all([
|
|
1169
|
+
loadCrypto(),
|
|
1129
1170
|
import('ed25519-hd-key'),
|
|
1130
1171
|
import('tweetnacl')
|
|
1131
1172
|
]);
|
|
1132
|
-
const seedBytes = mnemonicToSeedSync(seed);
|
|
1133
|
-
const derived = ed25519.derivePath(
|
|
1173
|
+
const seedBytes = crypto.mnemonicToSeedSync(seed);
|
|
1174
|
+
const derived = ed25519.derivePath(DERIVATION_PATHS2.ton, Buffer.from(seedBytes).toString("hex"));
|
|
1134
1175
|
const keypair = nacl.sign.keyPair.fromSeed(new Uint8Array(derived.key));
|
|
1135
1176
|
const publicKey = keypair.publicKey;
|
|
1136
1177
|
const workchain = 0;
|
|
1137
1178
|
const flags = 17;
|
|
1138
|
-
const hash = sha256(publicKey);
|
|
1179
|
+
const hash = crypto.sha256(publicKey);
|
|
1139
1180
|
const addressData = new Uint8Array(34);
|
|
1140
1181
|
addressData[0] = flags;
|
|
1141
1182
|
addressData[1] = workchain;
|
|
@@ -1163,9 +1204,10 @@ function crc16(data) {
|
|
|
1163
1204
|
}
|
|
1164
1205
|
return crc;
|
|
1165
1206
|
}
|
|
1166
|
-
function deriveTronAddress(seed) {
|
|
1207
|
+
async function deriveTronAddress(seed) {
|
|
1167
1208
|
try {
|
|
1168
|
-
const
|
|
1209
|
+
const { sha256, base58check } = await loadCrypto();
|
|
1210
|
+
const hdNode = HDNodeWallet.fromPhrase(seed, void 0, DERIVATION_PATHS2.tron);
|
|
1169
1211
|
const ethAddressHex = hdNode.address.slice(2).toLowerCase();
|
|
1170
1212
|
const addressBytes = new Uint8Array(21);
|
|
1171
1213
|
addressBytes[0] = 65;
|
|
@@ -1179,11 +1221,12 @@ function deriveTronAddress(seed) {
|
|
|
1179
1221
|
throw error;
|
|
1180
1222
|
}
|
|
1181
1223
|
}
|
|
1182
|
-
function deriveSparkAddress(seed, network = "mainnet") {
|
|
1224
|
+
async function deriveSparkAddress(seed, network = "mainnet") {
|
|
1183
1225
|
try {
|
|
1226
|
+
const { mnemonicToSeedSync, HDKey, sha256, ripemd160, bech32 } = await loadCrypto();
|
|
1184
1227
|
const seedBytes = mnemonicToSeedSync(seed);
|
|
1185
1228
|
const hdKey = HDKey.fromMasterSeed(seedBytes);
|
|
1186
|
-
const child = hdKey.derive(
|
|
1229
|
+
const child = hdKey.derive(DERIVATION_PATHS2.spark);
|
|
1187
1230
|
if (!child.publicKey) {
|
|
1188
1231
|
throw new Error("Failed to derive public key");
|
|
1189
1232
|
}
|
|
@@ -1208,46 +1251,37 @@ async function deriveAllAddresses(seed, network = "mainnet") {
|
|
|
1208
1251
|
solana: null,
|
|
1209
1252
|
spark: null
|
|
1210
1253
|
};
|
|
1254
|
+
await loadCrypto();
|
|
1211
1255
|
try {
|
|
1212
1256
|
addresses.ethereum = deriveEthereumAddress(seed);
|
|
1213
1257
|
} catch (e) {
|
|
1214
1258
|
console.error("ETH derivation failed:", e);
|
|
1215
1259
|
}
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
}
|
|
1221
|
-
try {
|
|
1222
|
-
addresses.spark = deriveSparkAddress(seed, network);
|
|
1223
|
-
} catch (e) {
|
|
1224
|
-
console.error("Spark derivation failed:", e);
|
|
1225
|
-
}
|
|
1226
|
-
try {
|
|
1227
|
-
addresses.tron = deriveTronAddress(seed);
|
|
1228
|
-
} catch (e) {
|
|
1229
|
-
console.error("TRON derivation failed:", e);
|
|
1230
|
-
}
|
|
1231
|
-
const [solResult, tonResult] = await Promise.allSettled([
|
|
1260
|
+
const [btcResult, sparkResult, tronResult, solResult, tonResult] = await Promise.allSettled([
|
|
1261
|
+
deriveBitcoinAddress(seed, network),
|
|
1262
|
+
deriveSparkAddress(seed, network),
|
|
1263
|
+
deriveTronAddress(seed),
|
|
1232
1264
|
deriveSolanaAddress(seed),
|
|
1233
1265
|
deriveTonAddress(seed)
|
|
1234
1266
|
]);
|
|
1235
|
-
if (
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1267
|
+
if (btcResult.status === "fulfilled") addresses.bitcoin = btcResult.value;
|
|
1268
|
+
else console.error("BTC derivation failed:", btcResult.reason);
|
|
1269
|
+
if (sparkResult.status === "fulfilled") addresses.spark = sparkResult.value;
|
|
1270
|
+
else console.error("Spark derivation failed:", sparkResult.reason);
|
|
1271
|
+
if (tronResult.status === "fulfilled") addresses.tron = tronResult.value;
|
|
1272
|
+
else console.error("TRON derivation failed:", tronResult.reason);
|
|
1273
|
+
if (solResult.status === "fulfilled") addresses.solana = solResult.value;
|
|
1274
|
+
else console.error("SOL derivation failed:", solResult.reason);
|
|
1275
|
+
if (tonResult.status === "fulfilled") addresses.ton = tonResult.value;
|
|
1276
|
+
else console.error("TON derivation failed:", tonResult.reason);
|
|
1245
1277
|
return addresses;
|
|
1246
1278
|
}
|
|
1247
|
-
function isValidSeed(seed) {
|
|
1279
|
+
async function isValidSeed(seed) {
|
|
1280
|
+
const { validateMnemonic, wordlist } = await loadCrypto();
|
|
1248
1281
|
return validateMnemonic(seed, wordlist);
|
|
1249
1282
|
}
|
|
1250
|
-
function generateSeedPhrase() {
|
|
1283
|
+
async function generateSeedPhrase() {
|
|
1284
|
+
const { generateMnemonic, wordlist } = await loadCrypto();
|
|
1251
1285
|
return generateMnemonic(wordlist);
|
|
1252
1286
|
}
|
|
1253
1287
|
|
|
@@ -1491,7 +1525,7 @@ var ZubariWdkService = class {
|
|
|
1491
1525
|
};
|
|
1492
1526
|
if (!addresses.spark) {
|
|
1493
1527
|
try {
|
|
1494
|
-
addresses.spark = deriveSparkAddress(seed, this.config.network);
|
|
1528
|
+
addresses.spark = await deriveSparkAddress(seed, this.config.network);
|
|
1495
1529
|
} catch (e) {
|
|
1496
1530
|
console.warn("Browser Spark derivation fallback failed:", e);
|
|
1497
1531
|
}
|
|
@@ -1592,11 +1626,6 @@ var ZubariWdkService = class {
|
|
|
1592
1626
|
async sendTransaction(seed, chain, to, amount) {
|
|
1593
1627
|
await this.initialize();
|
|
1594
1628
|
const startTime = Date.now();
|
|
1595
|
-
console.log(`[ZubariWdkService] Sending ${chain} transaction`, {
|
|
1596
|
-
to: `${to.slice(0, 10)}...${to.slice(-6)}`,
|
|
1597
|
-
amount,
|
|
1598
|
-
network: this.config.network
|
|
1599
|
-
});
|
|
1600
1629
|
try {
|
|
1601
1630
|
const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/send`, {
|
|
1602
1631
|
method: "POST",
|
|
@@ -1616,10 +1645,6 @@ var ZubariWdkService = class {
|
|
|
1616
1645
|
console.warn(`[ZubariWdkService] Invalid ${chain} tx hash format:`, txHash);
|
|
1617
1646
|
}
|
|
1618
1647
|
}
|
|
1619
|
-
console.log(`[ZubariWdkService] ${chain} transaction ${data.success ? "SUCCESS" : "FAILED"}`, {
|
|
1620
|
-
txHash: txHash ? `${txHash.slice(0, 16)}...` : "N/A",
|
|
1621
|
-
elapsed: `${elapsed}ms`
|
|
1622
|
-
});
|
|
1623
1648
|
if (!data.success) {
|
|
1624
1649
|
const errorCode2 = parseChainError(chain, data.error || "");
|
|
1625
1650
|
return {
|
|
@@ -1642,12 +1667,6 @@ var ZubariWdkService = class {
|
|
|
1642
1667
|
const errorData = await response.json().catch(() => ({}));
|
|
1643
1668
|
const errorMessage = errorData.error || `HTTP ${response.status}`;
|
|
1644
1669
|
const errorCode = parseChainError(chain, errorMessage);
|
|
1645
|
-
console.error(`[ZubariWdkService] ${chain} transaction FAILED`, {
|
|
1646
|
-
status: response.status,
|
|
1647
|
-
error: errorMessage,
|
|
1648
|
-
errorCode,
|
|
1649
|
-
elapsed: `${elapsed}ms`
|
|
1650
|
-
});
|
|
1651
1670
|
return {
|
|
1652
1671
|
success: false,
|
|
1653
1672
|
error: errorMessage,
|
|
@@ -1655,14 +1674,8 @@ var ZubariWdkService = class {
|
|
|
1655
1674
|
chain
|
|
1656
1675
|
};
|
|
1657
1676
|
} catch (error) {
|
|
1658
|
-
const elapsed = Date.now() - startTime;
|
|
1659
1677
|
const errorMessage = error instanceof Error ? error.message : "Transaction failed";
|
|
1660
1678
|
const errorCode = parseChainError(chain, errorMessage);
|
|
1661
|
-
console.error(`[ZubariWdkService] ${chain} transaction ERROR`, {
|
|
1662
|
-
error: errorMessage,
|
|
1663
|
-
errorCode,
|
|
1664
|
-
elapsed: `${elapsed}ms`
|
|
1665
|
-
});
|
|
1666
1679
|
return {
|
|
1667
1680
|
success: false,
|
|
1668
1681
|
error: errorMessage,
|
|
@@ -1708,15 +1721,22 @@ var ZubariWdkService = class {
|
|
|
1708
1721
|
// Private Helper Methods
|
|
1709
1722
|
// ==========================================
|
|
1710
1723
|
getDerivationPath(chain) {
|
|
1711
|
-
const
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1724
|
+
const basePath = DERIVATION_PATHS[chain];
|
|
1725
|
+
if (chain === "bitcoin" && this.config.network === "testnet") {
|
|
1726
|
+
return "m/84'/1'/0'/0/0";
|
|
1727
|
+
}
|
|
1728
|
+
switch (chain) {
|
|
1729
|
+
case "ton":
|
|
1730
|
+
return `${basePath}/0'/0'`;
|
|
1731
|
+
case "solana":
|
|
1732
|
+
return `${basePath}/0'`;
|
|
1733
|
+
case "bitcoin":
|
|
1734
|
+
case "ethereum":
|
|
1735
|
+
case "tron":
|
|
1736
|
+
case "spark":
|
|
1737
|
+
default:
|
|
1738
|
+
return `${basePath}/0`;
|
|
1739
|
+
}
|
|
1720
1740
|
}
|
|
1721
1741
|
getChainSymbol(chain) {
|
|
1722
1742
|
const symbols = {
|
|
@@ -1741,13 +1761,13 @@ var ZubariWdkService = class {
|
|
|
1741
1761
|
address = deriveEthereumAddress(seed);
|
|
1742
1762
|
break;
|
|
1743
1763
|
case "bitcoin":
|
|
1744
|
-
address = deriveBitcoinAddress(seed, this.config.network);
|
|
1764
|
+
address = await deriveBitcoinAddress(seed, this.config.network);
|
|
1745
1765
|
break;
|
|
1746
1766
|
case "tron":
|
|
1747
|
-
address = deriveTronAddress(seed);
|
|
1767
|
+
address = await deriveTronAddress(seed);
|
|
1748
1768
|
break;
|
|
1749
1769
|
case "spark":
|
|
1750
|
-
address = deriveSparkAddress(seed, this.config.network);
|
|
1770
|
+
address = await deriveSparkAddress(seed, this.config.network);
|
|
1751
1771
|
break;
|
|
1752
1772
|
case "solana":
|
|
1753
1773
|
address = await deriveSolanaAddress(seed);
|