@ledgerhq/live-cli 24.26.0-nightly.4 → 24.26.0-nightly.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/lib/cli.js +45 -24
- package/package.json +2 -2
package/lib/cli.js
CHANGED
|
@@ -519675,7 +519675,7 @@ var require_package7 = __commonJS({
|
|
|
519675
519675
|
module2.exports = {
|
|
519676
519676
|
name: "@ledgerhq/live-common",
|
|
519677
519677
|
description: "Common ground for the Ledger Live apps",
|
|
519678
|
-
version: "34.51.0-nightly.
|
|
519678
|
+
version: "34.51.0-nightly.5",
|
|
519679
519679
|
repository: {
|
|
519680
519680
|
type: "git",
|
|
519681
519681
|
url: "https://github.com/LedgerHQ/ledger-live.git"
|
|
@@ -520012,7 +520012,7 @@ var require_package8 = __commonJS({
|
|
|
520012
520012
|
"package.json"(exports2, module2) {
|
|
520013
520013
|
module2.exports = {
|
|
520014
520014
|
name: "@ledgerhq/live-cli",
|
|
520015
|
-
version: "24.26.0-nightly.
|
|
520015
|
+
version: "24.26.0-nightly.5",
|
|
520016
520016
|
description: "ledger-live CLI version",
|
|
520017
520017
|
repository: {
|
|
520018
520018
|
type: "git",
|
|
@@ -590281,6 +590281,13 @@ async function submitPreApprovalTransaction(currency24, partyId, { serialized },
|
|
|
590281
590281
|
updateId: data12.update_id
|
|
590282
590282
|
};
|
|
590283
590283
|
}
|
|
590284
|
+
async function getTransferPreApproval(currency24, partyId) {
|
|
590285
|
+
const { data: data12 } = await gatewayNetwork({
|
|
590286
|
+
method: "GET",
|
|
590287
|
+
url: `${getGatewayUrl(currency24)}/v1/node/${getNodeId(currency24)}/party/${partyId}/transfer-preapproval`
|
|
590288
|
+
});
|
|
590289
|
+
return data12;
|
|
590290
|
+
}
|
|
590284
590291
|
|
|
590285
590292
|
// ../../libs/coin-modules/coin-canton/lib-es/common-logic/transaction/broadcast.js
|
|
590286
590293
|
var useGateway = (currency24) => config_default3.getCoinConfig(currency24).useGateway === true;
|
|
@@ -590593,8 +590600,12 @@ var isAccountOnboarded = async (currency24, publicKey3) => {
|
|
|
590593
590600
|
return { isOnboarded: false };
|
|
590594
590601
|
}
|
|
590595
590602
|
};
|
|
590596
|
-
var isAccountAuthorized = async (
|
|
590597
|
-
|
|
590603
|
+
var isAccountAuthorized = async (currency24, partyId) => {
|
|
590604
|
+
const { expires_at, receiver: receiver2 } = await getTransferPreApproval(currency24, partyId);
|
|
590605
|
+
const isReceiver = receiver2 === partyId;
|
|
590606
|
+
const isExpired = new Date(expires_at) < /* @__PURE__ */ new Date();
|
|
590607
|
+
const isAuthorized = !isExpired && isReceiver;
|
|
590608
|
+
return isAuthorized;
|
|
590598
590609
|
};
|
|
590599
590610
|
var buildOnboardAccount = (signerContext4) => (currency24, deviceId, account3) => new import_rxjs17.Observable((o41) => {
|
|
590600
590611
|
async function main2() {
|
|
@@ -590627,7 +590638,7 @@ var buildOnboardAccount = (signerContext4) => (currency24, deviceId, account3) =
|
|
|
590627
590638
|
var buildAuthorizePreapproval = (signerContext4) => (currency24, deviceId, account3, partyId) => new import_rxjs17.Observable((o41) => {
|
|
590628
590639
|
async function main2() {
|
|
590629
590640
|
o41.next({ status: AuthorizeStatus.INIT });
|
|
590630
|
-
const isAuthorized = await isAccountAuthorized(
|
|
590641
|
+
const isAuthorized = await isAccountAuthorized(currency24, partyId);
|
|
590631
590642
|
if (!isAuthorized) {
|
|
590632
590643
|
o41.next({ status: AuthorizeStatus.PREPARE });
|
|
590633
590644
|
const preparedTransaction = await preparePreApprovalTransaction(currency24, partyId);
|
|
@@ -590749,7 +590760,7 @@ function makeGetAccountShape3(signerContext4) {
|
|
|
590749
590760
|
const newOperations = filterOperations(transactionData.operations, accountId2, xpubOrAddress);
|
|
590750
590761
|
operations4 = mergeOps(oldOperations, newOperations);
|
|
590751
590762
|
}
|
|
590752
|
-
const isAuthorized = await isAccountAuthorized(
|
|
590763
|
+
const isAuthorized = await isAccountAuthorized(currency24, xpubOrAddress);
|
|
590753
590764
|
const used = isAuthorized && totalBalance.gt(0);
|
|
590754
590765
|
const blockHeight = await getLedgerEnd(currency24);
|
|
590755
590766
|
const creationDate = operations4.length > 0 ? new Date(Math.min(...operations4.map((op) => op.date.getTime()))) : /* @__PURE__ */ new Date();
|
|
@@ -775336,7 +775347,8 @@ var createDummyTokenTransferTx = (address3) => {
|
|
|
775336
775347
|
recipientDescriptor: {
|
|
775337
775348
|
walletAddress: randomAddresses[1],
|
|
775338
775349
|
tokenAccAddress: randomAddresses[2],
|
|
775339
|
-
shouldCreateAsAssociatedTokenAccount: true
|
|
775350
|
+
shouldCreateAsAssociatedTokenAccount: true,
|
|
775351
|
+
userInputType: "sol"
|
|
775340
775352
|
},
|
|
775341
775353
|
tokenProgram: PARSED_PROGRAMS.SPL_TOKEN
|
|
775342
775354
|
},
|
|
@@ -775359,7 +775371,8 @@ var createDummyTokenApproveTx = (address3) => {
|
|
|
775359
775371
|
recipientDescriptor: {
|
|
775360
775372
|
walletAddress: randomAddresses[1],
|
|
775361
775373
|
tokenAccAddress: randomAddresses[2],
|
|
775362
|
-
shouldCreateAsAssociatedTokenAccount: true
|
|
775374
|
+
shouldCreateAsAssociatedTokenAccount: true,
|
|
775375
|
+
userInputType: "sol"
|
|
775363
775376
|
},
|
|
775364
775377
|
owner: address3,
|
|
775365
775378
|
amount: 0,
|
|
@@ -775611,7 +775624,8 @@ var deriveTokenTransferCommandDescriptor = async (mainAccount, tx, model, api7)
|
|
|
775611
775624
|
const defaultRecipientDescriptor = {
|
|
775612
775625
|
shouldCreateAsAssociatedTokenAccount: false,
|
|
775613
775626
|
tokenAccAddress: "",
|
|
775614
|
-
walletAddress: ""
|
|
775627
|
+
walletAddress: "",
|
|
775628
|
+
userInputType: "sol"
|
|
775615
775629
|
};
|
|
775616
775630
|
const tokenRecipientOrError = errors.recipient ? errors.recipient : await getTokenRecipient(tx.recipient, mintAddress, tokenProgram, api7);
|
|
775617
775631
|
if (!errors.recipient && tokenRecipientOrError instanceof Error) {
|
|
@@ -775708,7 +775722,8 @@ async function getTokenRecipient(recipientAddress, mintAddress, tokenProgram, ap
|
|
|
775708
775722
|
descriptor: {
|
|
775709
775723
|
walletAddress: recipientAddress,
|
|
775710
775724
|
shouldCreateAsAssociatedTokenAccount,
|
|
775711
|
-
tokenAccAddress: recipientAssociatedTokenAccountAddress
|
|
775725
|
+
tokenAccAddress: recipientAssociatedTokenAccountAddress,
|
|
775726
|
+
userInputType: "sol"
|
|
775712
775727
|
},
|
|
775713
775728
|
recipientAccInfo: associatedTokenAccount
|
|
775714
775729
|
};
|
|
@@ -775724,7 +775739,8 @@ async function getTokenRecipient(recipientAddress, mintAddress, tokenProgram, ap
|
|
|
775724
775739
|
descriptor: {
|
|
775725
775740
|
walletAddress: recipientTokenAccount.owner.toBase58(),
|
|
775726
775741
|
shouldCreateAsAssociatedTokenAccount: false,
|
|
775727
|
-
tokenAccAddress: recipientAddress
|
|
775742
|
+
tokenAccAddress: recipientAddress,
|
|
775743
|
+
userInputType: "ata"
|
|
775728
775744
|
},
|
|
775729
775745
|
recipientAccInfo: recipientTokenAccount
|
|
775730
775746
|
};
|
|
@@ -775823,7 +775839,8 @@ async function deriveCreateApproveCommandDescriptor(mainAccount, tx, model, api7
|
|
|
775823
775839
|
const defaultRecipientDescriptor = {
|
|
775824
775840
|
shouldCreateAsAssociatedTokenAccount: false,
|
|
775825
775841
|
tokenAccAddress: "",
|
|
775826
|
-
walletAddress: ""
|
|
775842
|
+
walletAddress: "",
|
|
775843
|
+
userInputType: "sol"
|
|
775827
775844
|
};
|
|
775828
775845
|
const tokenRecipientOrError = errors.recipient ? errors.recipient : await getTokenRecipient(tx.recipient, mintAddress, tokenProgram, api7);
|
|
775829
775846
|
if (!errors.recipient && tokenRecipientOrError instanceof Error) {
|
|
@@ -777908,14 +777925,16 @@ function getResolution(transaction, deviceModelId, certificateSignatureKind) {
|
|
|
777908
777925
|
createATA: {
|
|
777909
777926
|
address: command4.recipientDescriptor.walletAddress,
|
|
777910
777927
|
mintAddress: command4.mintAddress
|
|
777911
|
-
}
|
|
777928
|
+
},
|
|
777929
|
+
userInputType: command4.recipientDescriptor.userInputType
|
|
777912
777930
|
};
|
|
777913
777931
|
}
|
|
777914
777932
|
return {
|
|
777915
777933
|
deviceModelId,
|
|
777916
777934
|
certificateSignatureKind,
|
|
777917
777935
|
tokenInternalId: command4.tokenId,
|
|
777918
|
-
tokenAddress: command4.recipientDescriptor.tokenAccAddress
|
|
777936
|
+
tokenAddress: command4.recipientDescriptor.tokenAccAddress,
|
|
777937
|
+
userInputType: command4.recipientDescriptor.userInputType
|
|
777919
777938
|
};
|
|
777920
777939
|
}
|
|
777921
777940
|
case "token.createATA": {
|
|
@@ -778800,6 +778819,7 @@ var P1_CONFIRM4 = 1;
|
|
|
778800
778819
|
var P2_INIT = 0;
|
|
778801
778820
|
var P2_EXTEND = 1;
|
|
778802
778821
|
var P2_MORE5 = 2;
|
|
778822
|
+
var P2_USER_INPUT_ATA = 8;
|
|
778803
778823
|
var MAX_PAYLOAD = 255;
|
|
778804
778824
|
var LEDGER_CLA3 = 224;
|
|
778805
778825
|
var INS8 = {
|
|
@@ -778862,18 +778882,20 @@ var Solana = class {
|
|
|
778862
778882
|
*
|
|
778863
778883
|
* @param path a BIP32 path
|
|
778864
778884
|
* @param txBuffer serialized transaction
|
|
778885
|
+
* @param userInputType optional user input type (ata or sol, for the case of token transfers)
|
|
778865
778886
|
*
|
|
778866
778887
|
* @returns an object with the signature field
|
|
778867
778888
|
*
|
|
778868
778889
|
* @example
|
|
778869
778890
|
* solana.signTransaction("44'/501'/0'", txBuffer).then(r => r.signature)
|
|
778870
778891
|
*/
|
|
778871
|
-
async signTransaction(path4, txBuffer) {
|
|
778892
|
+
async signTransaction(path4, txBuffer, userInputType) {
|
|
778872
778893
|
const pathBuffer = this.pathToBuffer(path4);
|
|
778873
778894
|
const pathsCountBuffer = Buffer.alloc(1);
|
|
778874
778895
|
pathsCountBuffer.writeUInt8(1, 0);
|
|
778875
778896
|
const payload = Buffer.concat([pathsCountBuffer, pathBuffer, txBuffer]);
|
|
778876
|
-
const
|
|
778897
|
+
const p2Flag = userInputType === "ata" ? P2_USER_INPUT_ATA : void 0;
|
|
778898
|
+
const signatureBuffer = await this.sendToDevice(INS8.SIGN, P1_CONFIRM4, payload, p2Flag);
|
|
778877
778899
|
return {
|
|
778878
778900
|
signature: signatureBuffer
|
|
778879
778901
|
};
|
|
@@ -778955,9 +778977,8 @@ var Solana = class {
|
|
|
778955
778977
|
return buf2;
|
|
778956
778978
|
}
|
|
778957
778979
|
// send chunked if payload size exceeds maximum for a call
|
|
778958
|
-
async sendToDevice(instruction, p1, payload) {
|
|
778980
|
+
async sendToDevice(instruction, p1, payload, p210 = P2_INIT) {
|
|
778959
778981
|
const acceptStatusList = [StatusCodes.OK, EXTRA_STATUS_CODES.BLIND_SIGNATURE_REQUIRED];
|
|
778960
|
-
let p210 = P2_INIT;
|
|
778961
778982
|
let payload_offset = 0;
|
|
778962
778983
|
if (payload.length > MAX_PAYLOAD) {
|
|
778963
778984
|
while (payload.length - payload_offset > MAX_PAYLOAD) {
|
|
@@ -779664,7 +779685,7 @@ var LegacySignerSolana = class {
|
|
|
779664
779685
|
}
|
|
779665
779686
|
}
|
|
779666
779687
|
}
|
|
779667
|
-
return this.signer.signTransaction(path4, tx);
|
|
779688
|
+
return this.signer.signTransaction(path4, tx, resolution?.userInputType);
|
|
779668
779689
|
}
|
|
779669
779690
|
signMessage(path4, messageHex) {
|
|
779670
779691
|
return this.signer.signOffchainMessage(path4, Buffer.from(messageHex, "hex"));
|
|
@@ -822852,19 +822873,19 @@ async function withApi2(execute2) {
|
|
|
822852
822873
|
var getAllBalancesCached = makeLRUCache(async (owner) => withApi2(async (api7) => await api7.getAllBalances({
|
|
822853
822874
|
owner
|
|
822854
822875
|
})), (owner) => owner, minutes(1));
|
|
822855
|
-
function
|
|
822876
|
+
function hasMoveCallWithFunction(functionName, block2) {
|
|
822856
822877
|
if (block2?.kind === "ProgrammableTransaction") {
|
|
822857
|
-
const move = block2.transactions.find((item) => "MoveCall" in item);
|
|
822858
|
-
return move
|
|
822878
|
+
const move = block2.transactions.find((item) => "MoveCall" in item && item["MoveCall"].function === functionName);
|
|
822879
|
+
return Boolean(move);
|
|
822859
822880
|
} else {
|
|
822860
822881
|
return false;
|
|
822861
822882
|
}
|
|
822862
822883
|
}
|
|
822863
822884
|
function isStaking(block2) {
|
|
822864
|
-
return
|
|
822885
|
+
return hasMoveCallWithFunction("request_add_stake", block2);
|
|
822865
822886
|
}
|
|
822866
822887
|
function isUnstaking(block2) {
|
|
822867
|
-
return
|
|
822888
|
+
return hasMoveCallWithFunction("request_withdraw_stake", block2);
|
|
822868
822889
|
}
|
|
822869
822890
|
var getAccountBalances = async (addr) => {
|
|
822870
822891
|
const balances = await getAllBalancesCached(addr);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/live-cli",
|
|
3
|
-
"version": "24.26.0-nightly.
|
|
3
|
+
"version": "24.26.0-nightly.5",
|
|
4
4
|
"description": "ledger-live CLI version",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"tsup": "7.3.0",
|
|
59
59
|
"yaml": "2.8.1",
|
|
60
60
|
"@ledgerhq/types-cryptoassets": "^7.29.0-nightly.0",
|
|
61
|
-
"@ledgerhq/types-live": "^6.87.0-nightly.
|
|
61
|
+
"@ledgerhq/types-live": "^6.87.0-nightly.2"
|
|
62
62
|
},
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"directory": "dist"
|