@ledgerhq/live-cli 24.26.1-nightly.0 → 24.26.1-nightly.2
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/lib/cli.js +168 -55
- package/package.json +1 -1
package/lib/cli.js
CHANGED
|
@@ -515377,7 +515377,7 @@ var require_package7 = __commonJS({
|
|
|
515377
515377
|
module2.exports = {
|
|
515378
515378
|
name: "@ledgerhq/live-common",
|
|
515379
515379
|
description: "Common ground for the Ledger Live apps",
|
|
515380
|
-
version: "34.52.0-nightly.
|
|
515380
|
+
version: "34.52.0-nightly.2",
|
|
515381
515381
|
repository: {
|
|
515382
515382
|
type: "git",
|
|
515383
515383
|
url: "https://github.com/LedgerHQ/ledger-live.git"
|
|
@@ -515711,7 +515711,7 @@ var require_package8 = __commonJS({
|
|
|
515711
515711
|
"package.json"(exports2, module2) {
|
|
515712
515712
|
module2.exports = {
|
|
515713
515713
|
name: "@ledgerhq/live-cli",
|
|
515714
|
-
version: "24.26.1-nightly.
|
|
515714
|
+
version: "24.26.1-nightly.2",
|
|
515715
515715
|
description: "ledger-live CLI version",
|
|
515716
515716
|
repository: {
|
|
515717
515717
|
type: "git",
|
|
@@ -575111,6 +575111,10 @@ var OP_EQUALVERIFY = 136;
|
|
|
575111
575111
|
var OP_CHECKSIG = 172;
|
|
575112
575112
|
var ZCASH_ACTIVATION_HEIGHTS = {
|
|
575113
575113
|
// https://zcash.readthedocs.io/en/latest/rtd_pages/nu_dev_guide.html
|
|
575114
|
+
//
|
|
575115
|
+
// https://zips.z.cash/zip-0255
|
|
575116
|
+
// https://github.com/zcash/zcash/releases/tag/v6.10.0
|
|
575117
|
+
NU6_1: 3146400,
|
|
575114
575118
|
// https://zips.z.cash/zip-0253
|
|
575115
575119
|
NU6: 2726400,
|
|
575116
575120
|
// https://zips.z.cash/zip-0252
|
|
@@ -576880,7 +576884,9 @@ var defaultsSignTransaction = {
|
|
|
576880
576884
|
};
|
|
576881
576885
|
var getZcashBranchId = (blockHeight) => {
|
|
576882
576886
|
const branchId = Buffer.alloc(4);
|
|
576883
|
-
if (!blockHeight || blockHeight >= ZCASH_ACTIVATION_HEIGHTS.
|
|
576887
|
+
if (!blockHeight || blockHeight >= ZCASH_ACTIVATION_HEIGHTS.NU6_1) {
|
|
576888
|
+
branchId.writeUInt32LE(1307332080, 0);
|
|
576889
|
+
} else if (blockHeight >= ZCASH_ACTIVATION_HEIGHTS.NU6) {
|
|
576884
576890
|
branchId.writeUInt32LE(3370586197, 0);
|
|
576885
576891
|
} else if (blockHeight >= ZCASH_ACTIVATION_HEIGHTS.NU5) {
|
|
576886
576892
|
branchId.writeUInt32LE(3268858036, 0);
|
|
@@ -586505,6 +586511,9 @@ function createApi(config4) {
|
|
|
586505
586511
|
},
|
|
586506
586512
|
getRewards(_address, _cursor) {
|
|
586507
586513
|
throw new Error("getRewards is not supported");
|
|
586514
|
+
},
|
|
586515
|
+
getValidators(_cursor) {
|
|
586516
|
+
throw new Error("getValidators is not supported");
|
|
586508
586517
|
}
|
|
586509
586518
|
};
|
|
586510
586519
|
}
|
|
@@ -621482,11 +621491,13 @@ function extractType(asset, op) {
|
|
|
621482
621491
|
return asset.parents[op.hash].type;
|
|
621483
621492
|
return "NONE";
|
|
621484
621493
|
}
|
|
621485
|
-
function computeValue(asset, op
|
|
621486
|
-
if (
|
|
621487
|
-
return BigInt(op.fee.toFixed(0));
|
|
621488
|
-
if (asset.type === "native" && op.type === "OUT")
|
|
621494
|
+
function computeValue(asset, op) {
|
|
621495
|
+
if (asset.type === "native" && ["OUT", "FEES"].includes(op.type)) {
|
|
621489
621496
|
return BigInt(op.value.toFixed(0)) - BigInt(op.fee.toFixed(0));
|
|
621497
|
+
}
|
|
621498
|
+
if (asset.type === "token" && op.hash in asset.parents) {
|
|
621499
|
+
return BigInt(asset.parents[op.hash].value.toFixed(0));
|
|
621500
|
+
}
|
|
621490
621501
|
return BigInt(op.value.toFixed(0));
|
|
621491
621502
|
}
|
|
621492
621503
|
function toOperation(asset, op) {
|
|
@@ -621497,7 +621508,7 @@ function toOperation(asset, op) {
|
|
|
621497
621508
|
assetInfo.type = extractStandard(op);
|
|
621498
621509
|
}
|
|
621499
621510
|
const type4 = extractType(asset, op);
|
|
621500
|
-
const value2 = computeValue(asset, op
|
|
621511
|
+
const value2 = computeValue(asset, op);
|
|
621501
621512
|
return {
|
|
621502
621513
|
id: op.id,
|
|
621503
621514
|
type: type4,
|
|
@@ -621515,8 +621526,16 @@ function toOperation(asset, op) {
|
|
|
621515
621526
|
date: op.date
|
|
621516
621527
|
},
|
|
621517
621528
|
details: {
|
|
621518
|
-
|
|
621519
|
-
|
|
621529
|
+
sequence: op.transactionSequenceNumber,
|
|
621530
|
+
status: op.hasFailed ? "failed" : "success",
|
|
621531
|
+
...asset.type === "token" ? {
|
|
621532
|
+
ledgerOpType: op.type,
|
|
621533
|
+
assetAmount: op.value.toFixed(0),
|
|
621534
|
+
assetSenders: op.senders,
|
|
621535
|
+
assetRecipients: op.recipients,
|
|
621536
|
+
parentSenders: asset.parents[op.hash]?.senders ?? [],
|
|
621537
|
+
parentRecipients: asset.parents[op.hash]?.recipients ?? []
|
|
621538
|
+
} : {}
|
|
621520
621539
|
}
|
|
621521
621540
|
};
|
|
621522
621541
|
}
|
|
@@ -621524,16 +621543,22 @@ async function listOperations2(currency24, address3, minHeight) {
|
|
|
621524
621543
|
const explorerApi2 = getExplorerApi(currency24);
|
|
621525
621544
|
const { lastCoinOperations, lastTokenOperations, lastNftOperations } = await explorerApi2.getLastOperations(currency24, address3, `js:2:${currency24.id}:${address3}:`, minHeight);
|
|
621526
621545
|
const isNativeOperation = (coinOperation) => ![...lastTokenOperations, ...lastNftOperations].map((op) => op.hash).includes(coinOperation.hash);
|
|
621527
|
-
const isTokenOperation = (coinOperation) => lastTokenOperations.map((op) => op.hash).includes(coinOperation.hash);
|
|
621546
|
+
const isTokenOperation = (coinOperation) => [...lastTokenOperations, ...lastNftOperations].map((op) => op.hash).includes(coinOperation.hash);
|
|
621528
621547
|
const parents = Object.fromEntries(lastCoinOperations.filter(isTokenOperation).map((op) => [op.hash, op]));
|
|
621529
621548
|
const nativeOperations = lastCoinOperations.filter(isNativeOperation).map((op) => toOperation({ type: "native" }, op));
|
|
621530
|
-
const tokenOperations = lastTokenOperations.map((op) => toOperation({ type: "token", owner: address3, parents }, op));
|
|
621531
|
-
const hasValidType = (operation) => [
|
|
621532
|
-
|
|
621533
|
-
|
|
621534
|
-
|
|
621535
|
-
""
|
|
621536
|
-
|
|
621549
|
+
const tokenOperations = [...lastTokenOperations, ...lastNftOperations].map((op) => toOperation({ type: "token", owner: address3, parents }, op));
|
|
621550
|
+
const hasValidType = (operation) => [
|
|
621551
|
+
"NONE",
|
|
621552
|
+
"FEES",
|
|
621553
|
+
"IN",
|
|
621554
|
+
"OUT",
|
|
621555
|
+
"DELEGATE",
|
|
621556
|
+
"UNDELEGATE",
|
|
621557
|
+
"REDELEGATE",
|
|
621558
|
+
"NFT_IN",
|
|
621559
|
+
"NFT_OUT"
|
|
621560
|
+
].includes(operation.type);
|
|
621561
|
+
return [nativeOperations.concat(tokenOperations).filter(hasValidType), ""];
|
|
621537
621562
|
}
|
|
621538
621563
|
|
|
621539
621564
|
// ../../libs/coin-modules/coin-evm/lib-es/logic/craftTransaction.js
|
|
@@ -817930,9 +817955,6 @@ function transactionToOperation3(accountId2, address3, transaction) {
|
|
|
817930
817955
|
value: getOperationAmount(address3, transaction, coinType)
|
|
817931
817956
|
};
|
|
817932
817957
|
}
|
|
817933
|
-
function absoluteAmount(balanceChange) {
|
|
817934
|
-
return new import_bignumber302.BigNumber(balanceChange?.amount || 0).abs();
|
|
817935
|
-
}
|
|
817936
817958
|
function toBlockInfo(checkpoint) {
|
|
817937
817959
|
const info6 = {
|
|
817938
817960
|
height: Number(checkpoint.sequenceNumber),
|
|
@@ -817950,25 +817972,31 @@ function toBlockInfo(checkpoint) {
|
|
|
817950
817972
|
return info6;
|
|
817951
817973
|
}
|
|
817952
817974
|
function toBlockTransaction(transaction) {
|
|
817975
|
+
const operationFee = getOperationFee(transaction);
|
|
817953
817976
|
return {
|
|
817954
817977
|
hash: transaction.digest,
|
|
817955
817978
|
failed: transaction.effects?.status.status !== "success",
|
|
817956
|
-
operations: transaction.balanceChanges?.flatMap((change2) => toBlockOperation(transaction, change2)) || [],
|
|
817957
|
-
fees: BigInt(
|
|
817979
|
+
operations: transaction.balanceChanges?.flatMap((change2) => toBlockOperation(transaction, change2, operationFee)) || [],
|
|
817980
|
+
fees: BigInt(operationFee.toString()),
|
|
817958
817981
|
feesPayer: transaction.transaction?.data.sender || ""
|
|
817959
817982
|
};
|
|
817960
817983
|
}
|
|
817961
|
-
function
|
|
817984
|
+
function removeFeesFromAmountForNative(change2, fees2) {
|
|
817985
|
+
if (change2.coinType === DEFAULT_COIN_TYPE)
|
|
817986
|
+
return (0, import_bignumber302.BigNumber)(change2.amount).plus(fees2);
|
|
817987
|
+
return (0, import_bignumber302.BigNumber)(change2.amount);
|
|
817988
|
+
}
|
|
817989
|
+
function toBlockOperation(transaction, change2, fees2) {
|
|
817962
817990
|
if (typeof change2.owner === "string" || !("AddressOwner" in change2.owner))
|
|
817963
817991
|
return [];
|
|
817964
817992
|
const address3 = change2.owner.AddressOwner;
|
|
817965
817993
|
const operationType = getOperationType9(address3, transaction);
|
|
817966
|
-
function transferOp(peer) {
|
|
817994
|
+
function transferOp(peer, amount) {
|
|
817967
817995
|
const op = {
|
|
817968
817996
|
type: "transfer",
|
|
817969
817997
|
address: address3,
|
|
817970
817998
|
asset: toSuiAsset(change2.coinType),
|
|
817971
|
-
amount
|
|
817999
|
+
amount
|
|
817972
818000
|
};
|
|
817973
818001
|
if (peer)
|
|
817974
818002
|
op.peer = peer;
|
|
@@ -817976,9 +818004,13 @@ function toBlockOperation(transaction, change2) {
|
|
|
817976
818004
|
}
|
|
817977
818005
|
switch (operationType) {
|
|
817978
818006
|
case "IN":
|
|
817979
|
-
return [
|
|
818007
|
+
return [
|
|
818008
|
+
transferOp(getOperationSenders2(transaction.transaction?.data).at(0), BigInt(change2.amount))
|
|
818009
|
+
];
|
|
817980
818010
|
case "OUT":
|
|
817981
|
-
return [
|
|
818011
|
+
return [
|
|
818012
|
+
transferOp(getOperationRecipients2(transaction.transaction?.data).at(0), BigInt(removeFeesFromAmountForNative(change2, fees2).toString()))
|
|
818013
|
+
];
|
|
817982
818014
|
case "DELEGATE":
|
|
817983
818015
|
case "UNDELEGATE":
|
|
817984
818016
|
return [
|
|
@@ -817987,11 +818019,18 @@ function toBlockOperation(transaction, change2) {
|
|
|
817987
818019
|
operationType,
|
|
817988
818020
|
address: change2.owner.AddressOwner,
|
|
817989
818021
|
asset: toSuiAsset(change2.coinType),
|
|
817990
|
-
amount: BigInt(
|
|
818022
|
+
amount: BigInt(removeFeesFromAmountForNative(change2, fees2).toString())
|
|
817991
818023
|
}
|
|
817992
818024
|
];
|
|
817993
818025
|
default:
|
|
817994
|
-
return [
|
|
818026
|
+
return [
|
|
818027
|
+
{
|
|
818028
|
+
type: "transfer",
|
|
818029
|
+
address: address3,
|
|
818030
|
+
asset: toSuiAsset(change2.coinType),
|
|
818031
|
+
amount: BigInt(change2.amount)
|
|
818032
|
+
}
|
|
818033
|
+
];
|
|
817995
818034
|
}
|
|
817996
818035
|
}
|
|
817997
818036
|
function toSuiAsset(coinType) {
|
|
@@ -818277,7 +818316,8 @@ var network_default3 = {
|
|
|
818277
818316
|
paymentInfo: paymentInfo3,
|
|
818278
818317
|
createTransaction: createTransaction25,
|
|
818279
818318
|
executeTransactionBlock,
|
|
818280
|
-
getStakes: getStakes2
|
|
818319
|
+
getStakes: getStakes2,
|
|
818320
|
+
getValidators: getValidators6
|
|
818281
818321
|
};
|
|
818282
818322
|
|
|
818283
818323
|
// ../../libs/coin-modules/coin-sui/lib-es/logic/craftTransaction.js
|
|
@@ -828591,6 +828631,9 @@ function createApi2(config4) {
|
|
|
828591
828631
|
},
|
|
828592
828632
|
getRewards(_address, _cursor) {
|
|
828593
828633
|
throw new Error("getRewards is not supported");
|
|
828634
|
+
},
|
|
828635
|
+
getValidators(_cursor) {
|
|
828636
|
+
throw new Error("getValidators is not supported");
|
|
828594
828637
|
}
|
|
828595
828638
|
};
|
|
828596
828639
|
}
|
|
@@ -829535,7 +829578,10 @@ function createApi3(config4) {
|
|
|
829535
829578
|
getTransactionStatus: {
|
|
829536
829579
|
throwIfPendingOperation: true
|
|
829537
829580
|
}
|
|
829538
|
-
})
|
|
829581
|
+
}),
|
|
829582
|
+
getValidators(_cursor) {
|
|
829583
|
+
throw new Error("getValidators is not supported");
|
|
829584
|
+
}
|
|
829539
829585
|
};
|
|
829540
829586
|
}
|
|
829541
829587
|
async function craft2(transactionIntent, customFees) {
|
|
@@ -829649,6 +829695,9 @@ function createApi4(config4) {
|
|
|
829649
829695
|
},
|
|
829650
829696
|
getRewards(_address, _cursor) {
|
|
829651
829697
|
throw new Error("getRewards is not supported");
|
|
829698
|
+
},
|
|
829699
|
+
getValidators(_cursor) {
|
|
829700
|
+
throw new Error("getValidators is not supported");
|
|
829652
829701
|
}
|
|
829653
829702
|
};
|
|
829654
829703
|
}
|
|
@@ -829692,6 +829741,9 @@ function createApi5(config4, currencyId) {
|
|
|
829692
829741
|
getRewards(_address, _cursor) {
|
|
829693
829742
|
throw new Error("getRewards is not supported");
|
|
829694
829743
|
},
|
|
829744
|
+
getValidators(_cursor) {
|
|
829745
|
+
throw new Error("getValidators is not supported");
|
|
829746
|
+
},
|
|
829695
829747
|
getSequence: (address3) => getSequence(currency24, address3),
|
|
829696
829748
|
validateIntent: (intent, customFees) => validateIntent(currency24, intent, customFees),
|
|
829697
829749
|
getTokenFromAsset: (asset) => getTokenFromAsset(currency24, asset),
|
|
@@ -849783,6 +849835,9 @@ function createApi6(config4) {
|
|
|
849783
849835
|
},
|
|
849784
849836
|
getRewards(_address, _cursor) {
|
|
849785
849837
|
throw new Error("getRewards is not supported");
|
|
849838
|
+
},
|
|
849839
|
+
getValidators(_cursor) {
|
|
849840
|
+
throw new Error("getValidators is not supported");
|
|
849786
849841
|
}
|
|
849787
849842
|
};
|
|
849788
849843
|
}
|
|
@@ -850121,6 +850176,9 @@ var getNetworkAlpacaApi = (networkFamily) => ({
|
|
|
850121
850176
|
},
|
|
850122
850177
|
getRewards(_address, _cursor) {
|
|
850123
850178
|
throw new Error("getRewards is not supported");
|
|
850179
|
+
},
|
|
850180
|
+
getValidators(_cursor) {
|
|
850181
|
+
throw new Error("getValidators is not supported");
|
|
850124
850182
|
}
|
|
850125
850183
|
});
|
|
850126
850184
|
|
|
@@ -850138,6 +850196,25 @@ function extractBalance(balances, type4) {
|
|
|
850138
850196
|
value: 0n
|
|
850139
850197
|
};
|
|
850140
850198
|
}
|
|
850199
|
+
function isStringArray(value2) {
|
|
850200
|
+
return Array.isArray(value2) && value2.every((item) => typeof item === "string");
|
|
850201
|
+
}
|
|
850202
|
+
function cleanedOperation(operation) {
|
|
850203
|
+
if (!operation.extra)
|
|
850204
|
+
return operation;
|
|
850205
|
+
const extraToClean = /* @__PURE__ */ new Set([
|
|
850206
|
+
"assetReference",
|
|
850207
|
+
"assetAmount",
|
|
850208
|
+
"assetOwner",
|
|
850209
|
+
"assetSenders",
|
|
850210
|
+
"assetRecipients",
|
|
850211
|
+
"parentSenders",
|
|
850212
|
+
"parentRecipients",
|
|
850213
|
+
"ledgerOpType"
|
|
850214
|
+
]);
|
|
850215
|
+
const cleanedExtra = Object.fromEntries(Object.entries(operation.extra).filter(([key2]) => !extraToClean.has(key2)));
|
|
850216
|
+
return { ...operation, extra: cleanedExtra };
|
|
850217
|
+
}
|
|
850141
850218
|
function adaptCoreOperationToLiveOperation(accountId2, op) {
|
|
850142
850219
|
const opType = op.type;
|
|
850143
850220
|
const extra = {};
|
|
@@ -850147,6 +850224,18 @@ function adaptCoreOperationToLiveOperation(accountId2, op) {
|
|
|
850147
850224
|
if (op.details?.assetAmount !== void 0) {
|
|
850148
850225
|
extra.assetAmount = op.details.assetAmount;
|
|
850149
850226
|
}
|
|
850227
|
+
if (isStringArray(op.details?.assetSenders)) {
|
|
850228
|
+
extra.assetSenders = op.details?.assetSenders;
|
|
850229
|
+
}
|
|
850230
|
+
if (isStringArray(op.details?.assetRecipients)) {
|
|
850231
|
+
extra.assetRecipients = op.details?.assetRecipients;
|
|
850232
|
+
}
|
|
850233
|
+
if (isStringArray(op.details?.parentSenders)) {
|
|
850234
|
+
extra.parentSenders = op.details?.parentSenders;
|
|
850235
|
+
}
|
|
850236
|
+
if (isStringArray(op.details?.parentRecipients)) {
|
|
850237
|
+
extra.parentRecipients = op.details?.parentRecipients;
|
|
850238
|
+
}
|
|
850150
850239
|
if (op.asset?.type !== "native") {
|
|
850151
850240
|
extra.assetReference = "assetReference" in (op.asset ?? {}) ? op.asset.assetReference : "";
|
|
850152
850241
|
extra.assetOwner = "assetOwner" in (op.asset ?? {}) ? op.asset.assetOwner : "";
|
|
@@ -850164,8 +850253,8 @@ function adaptCoreOperationToLiveOperation(accountId2, op) {
|
|
|
850164
850253
|
fee: bnFees,
|
|
850165
850254
|
blockHash: op.tx.block.hash,
|
|
850166
850255
|
blockHeight: op.tx.block.height,
|
|
850167
|
-
senders: op.senders,
|
|
850168
|
-
recipients: op.recipients,
|
|
850256
|
+
senders: extra.parentSenders ?? op.senders,
|
|
850257
|
+
recipients: extra.parentRecipients ?? op.recipients,
|
|
850169
850258
|
date: op.tx.date,
|
|
850170
850259
|
transactionSequenceNumber: op.details?.sequence,
|
|
850171
850260
|
hasFailed: op.details?.status === "failed",
|
|
@@ -850315,12 +850404,15 @@ function buildTokenAccount({ parentAccountId, assetBalance, token, operations: o
|
|
|
850315
850404
|
const id7 = encodeTokenAccountId(parentAccountId, token);
|
|
850316
850405
|
const balance2 = new import_bignumber356.default(assetBalance.value.toString() || "0");
|
|
850317
850406
|
const spendableBalance = new import_bignumber356.default(assetBalance.value.toString()).minus(new import_bignumber356.default(assetBalance.locked?.toString() || "0"));
|
|
850318
|
-
const tokenOperations = operations4.map((op) => ({
|
|
850407
|
+
const tokenOperations = operations4.map((op) => cleanedOperation({
|
|
850319
850408
|
...op,
|
|
850320
850409
|
id: encodeOperationId(id7, op.hash, op.extra?.ledgerOpType),
|
|
850321
850410
|
accountId: id7,
|
|
850322
850411
|
type: op.extra?.ledgerOpType,
|
|
850323
|
-
|
|
850412
|
+
contract: token.contractAddress,
|
|
850413
|
+
value: op.extra?.assetAmount ? new import_bignumber356.default(op.extra?.assetAmount) : op.value,
|
|
850414
|
+
senders: op.extra?.assetSenders ?? op.senders,
|
|
850415
|
+
recipients: op.extra?.assetRecipients ?? op.recipients
|
|
850324
850416
|
}));
|
|
850325
850417
|
return {
|
|
850326
850418
|
type: "TokenAccount",
|
|
@@ -850338,15 +850430,14 @@ function buildTokenAccount({ parentAccountId, assetBalance, token, operations: o
|
|
|
850338
850430
|
// calculated in the jsHelpers
|
|
850339
850431
|
};
|
|
850340
850432
|
}
|
|
850341
|
-
async function buildSubAccounts4({
|
|
850433
|
+
async function buildSubAccounts4({ accountId: accountId2, allTokenAssetsBalances, syncConfig, operations: operations4, getTokenFromAsset: getTokenFromAsset3 }) {
|
|
850342
850434
|
const { blacklistedTokenIds = [] } = syncConfig;
|
|
850343
|
-
const allTokens = listTokensForCryptoCurrency(currency24);
|
|
850344
850435
|
const tokenAccounts = [];
|
|
850345
|
-
if (
|
|
850436
|
+
if (allTokenAssetsBalances.length === 0 || !getTokenFromAsset3) {
|
|
850346
850437
|
return tokenAccounts;
|
|
850347
850438
|
}
|
|
850348
850439
|
for (const balance2 of allTokenAssetsBalances) {
|
|
850349
|
-
const token =
|
|
850440
|
+
const token = await getTokenFromAsset3(balance2.asset);
|
|
850350
850441
|
if (token && !blacklistedTokenIds.includes(token.id)) {
|
|
850351
850442
|
tokenAccounts.push(buildTokenAccount({
|
|
850352
850443
|
parentAccountId: accountId2,
|
|
@@ -850358,8 +850449,35 @@ async function buildSubAccounts4({ currency: currency24, accountId: accountId2,
|
|
|
850358
850449
|
}
|
|
850359
850450
|
return tokenAccounts;
|
|
850360
850451
|
}
|
|
850452
|
+
function mergeSubAccounts5(oldSubAccounts, newSubAccounts) {
|
|
850453
|
+
if (!oldSubAccounts.length) {
|
|
850454
|
+
return newSubAccounts;
|
|
850455
|
+
}
|
|
850456
|
+
const oldSubAccountsById = Object.fromEntries(oldSubAccounts.map((account3) => [account3.id, account3]));
|
|
850457
|
+
const newSubAccountsToAdd = [];
|
|
850458
|
+
for (const newSubAccount of newSubAccounts) {
|
|
850459
|
+
const existingSubAccount = oldSubAccountsById[newSubAccount.id];
|
|
850460
|
+
if (!existingSubAccount) {
|
|
850461
|
+
newSubAccountsToAdd.push(newSubAccount);
|
|
850462
|
+
continue;
|
|
850463
|
+
}
|
|
850464
|
+
const operations4 = mergeOps(existingSubAccount.operations, newSubAccount.operations);
|
|
850465
|
+
oldSubAccountsById[newSubAccount.id] = {
|
|
850466
|
+
...existingSubAccount,
|
|
850467
|
+
balance: newSubAccount.balance,
|
|
850468
|
+
spendableBalance: newSubAccount.spendableBalance,
|
|
850469
|
+
operations: operations4,
|
|
850470
|
+
operationsCount: operations4.length
|
|
850471
|
+
};
|
|
850472
|
+
}
|
|
850473
|
+
const updatedOldSubAccounts = Object.values(oldSubAccountsById);
|
|
850474
|
+
return [...updatedOldSubAccounts, ...newSubAccountsToAdd];
|
|
850475
|
+
}
|
|
850361
850476
|
|
|
850362
850477
|
// ../../libs/ledger-live-common/lib-es/bridge/generic-alpaca/getAccountShape.js
|
|
850478
|
+
function isNftCoreOp(operation) {
|
|
850479
|
+
return typeof operation.details?.ledgerOpType === "string" && ["NFT_IN", "NFT_OUT"].includes(operation.details?.ledgerOpType);
|
|
850480
|
+
}
|
|
850363
850481
|
function genericGetAccountShape(network, kind) {
|
|
850364
850482
|
return async (info6, syncConfig) => {
|
|
850365
850483
|
const { address: address3, initialAccount, currency: currency24, derivationMode } = info6;
|
|
@@ -850394,29 +850512,24 @@ function genericGetAccountShape(network, kind) {
|
|
|
850394
850512
|
paginationParams.lastPagingToken = lastPagingToken;
|
|
850395
850513
|
}
|
|
850396
850514
|
const [newCoreOps] = await alpacaApi.listOperations(address3, paginationParams);
|
|
850397
|
-
const newOps = newCoreOps.map((op) => adaptCoreOperationToLiveOperation(accountId2, op));
|
|
850398
|
-
const
|
|
850399
|
-
const
|
|
850400
|
-
mergedOps.forEach((operation) => {
|
|
850401
|
-
if (operation?.extra?.assetReference && operation?.extra?.assetOwner && !["OPT_IN", "OPT_OUT"].includes(operation.type)) {
|
|
850402
|
-
assetOperations.push(operation);
|
|
850403
|
-
}
|
|
850404
|
-
});
|
|
850405
|
-
const subAccounts = await buildSubAccounts4({
|
|
850406
|
-
currency: currency24,
|
|
850515
|
+
const newOps = newCoreOps.filter((op) => !isNftCoreOp(op)).map((op) => adaptCoreOperationToLiveOperation(accountId2, op));
|
|
850516
|
+
const newAssetOperations = newOps.filter((operation) => operation?.extra?.assetReference && operation?.extra?.assetOwner && !["OPT_IN", "OPT_OUT"].includes(operation.type));
|
|
850517
|
+
const newSubAccounts = await buildSubAccounts4({
|
|
850407
850518
|
accountId: accountId2,
|
|
850408
850519
|
allTokenAssetsBalances,
|
|
850409
850520
|
syncConfig,
|
|
850410
|
-
operations:
|
|
850521
|
+
operations: newAssetOperations,
|
|
850411
850522
|
getTokenFromAsset: alpacaApi.getTokenFromAsset
|
|
850412
850523
|
});
|
|
850413
|
-
const
|
|
850414
|
-
|
|
850415
|
-
|
|
850524
|
+
const subAccounts = mergeSubAccounts5(initialAccount?.subAccounts ?? [], newSubAccounts);
|
|
850525
|
+
const newOpsWithSubs = newOps.map((op) => {
|
|
850526
|
+
const subOperations = inferSubOperations(op.hash, newSubAccounts);
|
|
850527
|
+
return cleanedOperation({
|
|
850416
850528
|
...op,
|
|
850417
850529
|
subOperations
|
|
850418
|
-
};
|
|
850530
|
+
});
|
|
850419
850531
|
});
|
|
850532
|
+
const operations4 = mergeOps(oldOps, newOpsWithSubs);
|
|
850420
850533
|
const res = {
|
|
850421
850534
|
id: accountId2,
|
|
850422
850535
|
xpub: address3,
|