@ledgerhq/coin-algorand
Version:
Ledger Algorand Coin integration
103 lines • 3.98 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.acceptTransaction = void 0;
const specs_1 = require("@ledgerhq/coin-framework/bot/specs");
const state_1 = require("@ledgerhq/cryptoassets/state");
const deviceTransactionConfig_1 = require("./deviceTransactionConfig");
const tokens_1 = require("./tokens");
exports.acceptTransaction = (0, specs_1.deviceActionFlow)({
steps: [
{
title: "Txn Type",
button: specs_1.SpeculosButton.RIGHT,
expectedValue: ({ transaction }) => (transaction.subAccountId ? "Asset xfer" : "Payment"),
},
{
title: "Asset xfer",
button: specs_1.SpeculosButton.RIGHT,
},
{
title: "Payment",
button: specs_1.SpeculosButton.RIGHT,
},
{
title: "Fee",
button: specs_1.SpeculosButton.RIGHT,
expectedValue: ({ account, status }) => (0, specs_1.formatDeviceAmount)(account.currency, status.estimatedFees),
},
{
title: "Asset ID",
button: specs_1.SpeculosButton.RIGHT,
expectedValue: async ({ transaction }) => {
const id = transaction.assetId
? (0, tokens_1.extractTokenId)(transaction.assetId)
: transaction.subAccountId
? (0, tokens_1.extractTokenId)(transaction.subAccountId)
: "";
const token = await (0, state_1.getCryptoAssetsStore)().findTokenById((0, tokens_1.addPrefixToken)(id));
// 34 is max character displayable by nano.
return token ? (0, deviceTransactionConfig_1.displayTokenValue)(token).substring(0, 34) : `#${id}`;
},
},
{
title: "Asset amt",
button: specs_1.SpeculosButton.RIGHT,
expectedValue: ({ transaction, status }) => transaction.mode === "optIn" ? "0" : status.amount.toString(),
},
{
title: "Sender",
button: specs_1.SpeculosButton.RIGHT,
},
{
title: "Receiver",
button: specs_1.SpeculosButton.RIGHT,
expectedValue: ({ transaction }) => transaction.recipient,
},
{
title: "Asset dst",
button: specs_1.SpeculosButton.RIGHT,
expectedValue: ({ transaction }) => transaction.recipient,
},
{
title: "Amount",
button: specs_1.SpeculosButton.RIGHT,
expectedValue: async ({ account, status, transaction }) => {
switch (transaction.mode) {
case "claimReward":
return "0";
case "optIn": {
const token = await (0, state_1.getCryptoAssetsStore)().findTokenById(transaction?.assetId || "");
if (token) {
return (0, specs_1.formatDeviceAmount)(token, status.amount, {
forceFloating: token.units[0].magnitude > 0 ? true : false,
});
}
return "0";
}
}
return (0, specs_1.formatDeviceAmount)(account.currency, status.amount);
},
},
{
title: "APPROVE",
button: specs_1.SpeculosButton.BOTH,
},
{
title: "Sign",
button: specs_1.SpeculosButton.BOTH,
},
{
title: "Review",
button: specs_1.SpeculosButton.RIGHT,
},
{
title: "Genesis ID",
button: specs_1.SpeculosButton.RIGHT,
}, // Only on testnet
{
title: "Genesis hash",
button: specs_1.SpeculosButton.RIGHT,
}, // Only on testnet
],
});
//# sourceMappingURL=speculos-deviceActions.js.map