nexa-wallet-sdk 0.3.2 → 0.3.3
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.cjs +32 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +19 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +32 -32
- package/dist/index.mjs.map +1 -1
- package/dist/index.web.mjs +32 -32
- package/dist/index.web.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -144,7 +144,7 @@ $parcel$export(module.exports, "rostrumProvider", () => $b5bfd17fdf06d231$export
|
|
|
144
144
|
$parcel$export(module.exports, "AccountKeysUtils", () => $4d68f29c39c1a3e4$export$94f569bf4eb0f6f6);
|
|
145
145
|
// @ts-ignore
|
|
146
146
|
var $2dd241e44b9dc3c2$exports = {};
|
|
147
|
-
$2dd241e44b9dc3c2$exports = JSON.parse("{\"name\":\"nexa-wallet-sdk\",\"version\":\"0.3.
|
|
147
|
+
$2dd241e44b9dc3c2$exports = JSON.parse("{\"name\":\"nexa-wallet-sdk\",\"version\":\"0.3.3\",\"type\":\"module\",\"source\":\"src/index.ts\",\"types\":\"dist/index.d.ts\",\"main\":\"dist/index.cjs\",\"module\":\"dist/index.mjs\",\"browser\":\"dist/index.web.mjs\",\"exports\":{\"types\":\"./dist/index.d.ts\",\"node\":{\"import\":\"./dist/index.mjs\",\"require\":\"./dist/index.cjs\"},\"browser\":\"./dist/index.web.mjs\",\"default\":\"./dist/index.mjs\"},\"scripts\":{\"build\":\"parcel build\",\"lint\":\"eslint .\",\"fix-lint\":\"eslint --fix .\",\"dev\":\"parcel watch\",\"test\":\"vitest run\",\"clean\":\"rm -rf dist .parcel-cache\",\"docs\":\"typedoc\"},\"repository\":{\"type\":\"git\",\"url\":\"git+ssh://git@gitlab.com/nexa/wallet-sdk-ts.git\"},\"keywords\":[\"nexa\",\"wallet\",\"web3\",\"crypto\",\"dapp\",\"walletcomms\",\"walletsdk\"],\"contributors\":[{\"name\":\"Dolaned\"},{\"name\":\"Griffith\"},{\"name\":\"Vgrunner\"},{\"name\":\"myendy\"}],\"author\":\"Dolaned\",\"license\":\"MIT\",\"bugs\":{\"url\":\"https://gitlab.com/nexa/wallet-sdk-ts/issues\"},\"homepage\":\"https://gitlab.com/nexa/wallet-sdk-ts#readme\",\"description\":\"Wallet SDK for the Nexa blockchain\",\"devDependencies\":{\"@parcel/packager-ts\":\"^2.15.4\",\"@parcel/transformer-typescript-types\":\"^2.15.4\",\"@types/lodash-es\":\"^4.17.12\",\"@types/node\":\"^22.13.1\",\"eslint\":\"^9.20.1\",\"parcel\":\"^2.15.4\",\"typedoc\":\"^0.28.7\",\"typedoc-plugin-markdown\":\"^4.7.0\",\"typedoc-plugin-rename-defaults\":\"^0.7.3\",\"typescript\":\"^5.8.3\",\"typescript-eslint\":\"^8.24.1\",\"vitest\":\"^3.0.8\"},\"targets\":{\"main\":{\"context\":\"node\",\"outputFormat\":\"commonjs\",\"distDir\":\"dist\",\"isLibrary\":true,\"includeNodeModules\":[\"lodash-es\"]},\"module\":{\"context\":\"node\",\"outputFormat\":\"esmodule\",\"distDir\":\"dist\",\"isLibrary\":true},\"browser\":{\"context\":\"browser\",\"outputFormat\":\"esmodule\",\"distDir\":\"dist\",\"isLibrary\":true}},\"dependencies\":{\"@vgrunner/electrum-cash\":\"^2.0.12\",\"bip39\":\"^3.1.0\",\"js-big-decimal\":\"^2.2.0\",\"libnexa-ts\":\"^1.0.5\",\"lodash-es\":\"^4.17.21\"},\"files\":[\"dist\"],\"directories\":{\"test\":\"tests\"},\"@parcel/resolver-default\":{\"packageExports\":true}}");
|
|
148
148
|
|
|
149
149
|
|
|
150
150
|
|
|
@@ -363,13 +363,11 @@ const $b5bfd17fdf06d231$export$eaa49f0478d81b9d = new $b5bfd17fdf06d231$export$b
|
|
|
363
363
|
var $54dde1e65fb8e5b8$export$2e2bcd8739ae039 = $54dde1e65fb8e5b8$var$isNil;
|
|
364
364
|
|
|
365
365
|
|
|
366
|
+
|
|
366
367
|
class $f8a48da5c0b6346a$export$c54c8796e94a37a0 {
|
|
367
368
|
get transactions() {
|
|
368
369
|
return this._transactions;
|
|
369
370
|
}
|
|
370
|
-
set transactions(value) {
|
|
371
|
-
this._transactions = value;
|
|
372
|
-
}
|
|
373
371
|
constructor(_bip44Account){
|
|
374
372
|
this._tokenBalances = {};
|
|
375
373
|
this._transactions = new Map();
|
|
@@ -392,6 +390,17 @@ class $f8a48da5c0b6346a$export$c54c8796e94a37a0 {
|
|
|
392
390
|
set tokenBalances(value) {
|
|
393
391
|
this._tokenBalances = value;
|
|
394
392
|
}
|
|
393
|
+
async fetchAndClassifyTransactions(transactionAddress, fromHeight) {
|
|
394
|
+
const transactions = await (0, $0d59d2bcffd646c5$export$a2ed4b531376a5a4)([
|
|
395
|
+
transactionAddress
|
|
396
|
+
], fromHeight ?? 0);
|
|
397
|
+
const txPromises = Array.from(transactions.txs.values()).map((tx)=>(0, $0d59d2bcffd646c5$export$9c6f4f51acbc89b9)(tx, [
|
|
398
|
+
transactionAddress
|
|
399
|
+
]));
|
|
400
|
+
const txEntities = await Promise.all(txPromises);
|
|
401
|
+
for (let txEntity of txEntities)this.transactions.set(txEntity.txId, txEntity);
|
|
402
|
+
return this.transactions;
|
|
403
|
+
}
|
|
395
404
|
}
|
|
396
405
|
|
|
397
406
|
|
|
@@ -413,7 +422,7 @@ class $cf960f437fe63027$export$2e2bcd8739ae039 extends (0, $f8a48da5c0b6346a$exp
|
|
|
413
422
|
return this._accountKey.address;
|
|
414
423
|
}
|
|
415
424
|
getNewChangeAddress() {
|
|
416
|
-
return this.
|
|
425
|
+
return this.getNewAddress();
|
|
417
426
|
}
|
|
418
427
|
get accountIndexes() {
|
|
419
428
|
return {
|
|
@@ -440,22 +449,12 @@ class $cf960f437fe63027$export$2e2bcd8739ae039 extends (0, $f8a48da5c0b6346a$exp
|
|
|
440
449
|
super.tokenBalances = (0, $0d59d2bcffd646c5$export$dec515296f176dbe)(tokenBalances);
|
|
441
450
|
}
|
|
442
451
|
getKeyFromAddress(address) {
|
|
452
|
+
if (address !== this._accountKey.address) throw new Error(`Address ${address} does not belong to this account`);
|
|
443
453
|
return this._accountKey;
|
|
444
454
|
}
|
|
445
455
|
async getTransactions(fromHeight, address) {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
address ?? this._accountKey.address
|
|
449
|
-
], fromHeight ?? 0);
|
|
450
|
-
for (let tx of transactions.txs.values()){
|
|
451
|
-
let t = await (0, $0d59d2bcffd646c5$export$9c6f4f51acbc89b9)(tx, [
|
|
452
|
-
address ?? this._accountKey.address
|
|
453
|
-
]);
|
|
454
|
-
txPromises.push(t);
|
|
455
|
-
}
|
|
456
|
-
await Promise.all(txPromises);
|
|
457
|
-
for (let txEntity of txPromises)this.transactions.set(txEntity.txId, txEntity);
|
|
458
|
-
return this.transactions;
|
|
456
|
+
const transactionAddress = address ?? this._accountKey.address;
|
|
457
|
+
return this.fetchAndClassifyTransactions(transactionAddress, fromHeight);
|
|
459
458
|
}
|
|
460
459
|
getAddresses() {
|
|
461
460
|
return [
|
|
@@ -465,6 +464,9 @@ class $cf960f437fe63027$export$2e2bcd8739ae039 extends (0, $f8a48da5c0b6346a$exp
|
|
|
465
464
|
hasChangeAddresses() {
|
|
466
465
|
return false;
|
|
467
466
|
}
|
|
467
|
+
getPrimaryAddressKey() {
|
|
468
|
+
return this._accountKey;
|
|
469
|
+
}
|
|
468
470
|
}
|
|
469
471
|
|
|
470
472
|
|
|
@@ -544,6 +546,11 @@ class $1c49a4fffc97409b$export$2e2bcd8739ae039 extends (0, $f8a48da5c0b6346a$exp
|
|
|
544
546
|
hasChangeAddresses() {
|
|
545
547
|
return true; // BIP44 accounts always support change addresses
|
|
546
548
|
}
|
|
549
|
+
getPrimaryAddressKey() {
|
|
550
|
+
// For DefaultAccount, return the first receive key as the primary key
|
|
551
|
+
if (this._accountKeys.receiveKeys.length === 0) throw new Error("No receive keys available in account");
|
|
552
|
+
return this._accountKeys.receiveKeys[0];
|
|
553
|
+
}
|
|
547
554
|
}
|
|
548
555
|
|
|
549
556
|
|
|
@@ -566,7 +573,7 @@ class $0b557605c0e99621$export$2e2bcd8739ae039 extends (0, $f8a48da5c0b6346a$exp
|
|
|
566
573
|
return this._accountKey.address;
|
|
567
574
|
}
|
|
568
575
|
getNewChangeAddress() {
|
|
569
|
-
return this.
|
|
576
|
+
return this.getNewAddress();
|
|
570
577
|
}
|
|
571
578
|
get accountIndexes() {
|
|
572
579
|
return {
|
|
@@ -593,22 +600,12 @@ class $0b557605c0e99621$export$2e2bcd8739ae039 extends (0, $f8a48da5c0b6346a$exp
|
|
|
593
600
|
super.tokenBalances = (0, $0d59d2bcffd646c5$export$dec515296f176dbe)(tokenBalances);
|
|
594
601
|
}
|
|
595
602
|
getKeyFromAddress(address) {
|
|
603
|
+
if (address !== this._accountKey.address) throw new Error(`Address ${address} does not belong to this account`);
|
|
596
604
|
return this._accountKey;
|
|
597
605
|
}
|
|
598
606
|
async getTransactions(fromHeight, address) {
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
address ?? this._accountKey.address
|
|
602
|
-
], fromHeight ?? 0);
|
|
603
|
-
for (let tx of transactions.txs.values()){
|
|
604
|
-
let t = await (0, $0d59d2bcffd646c5$export$9c6f4f51acbc89b9)(tx, [
|
|
605
|
-
address ?? this._accountKey.address
|
|
606
|
-
]);
|
|
607
|
-
txPromises.push(t);
|
|
608
|
-
}
|
|
609
|
-
await Promise.all(txPromises);
|
|
610
|
-
for (let txEntity of txPromises)this.transactions.set(txEntity.txId, txEntity);
|
|
611
|
-
return this.transactions;
|
|
607
|
+
const transactionAddress = address ?? this._accountKey.address;
|
|
608
|
+
return this.fetchAndClassifyTransactions(transactionAddress, fromHeight);
|
|
612
609
|
}
|
|
613
610
|
getAddresses() {
|
|
614
611
|
return [
|
|
@@ -618,6 +615,9 @@ class $0b557605c0e99621$export$2e2bcd8739ae039 extends (0, $f8a48da5c0b6346a$exp
|
|
|
618
615
|
hasChangeAddresses() {
|
|
619
616
|
return false;
|
|
620
617
|
}
|
|
618
|
+
getPrimaryAddressKey() {
|
|
619
|
+
return this._accountKey;
|
|
620
|
+
}
|
|
621
621
|
}
|
|
622
622
|
|
|
623
623
|
|