@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
30 lines • 1.58 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.sendSolana = exports.delegateSolana = void 0;
const expect_1 = __importDefault(require("expect"));
const speculos_1 = require("../speculos");
const DeviceLabels_1 = require("../enum/DeviceLabels");
const Device_1 = require("../enum/Device");
const types_devices_1 = require("@ledgerhq/types-devices");
async function delegateSolana(delegatingAccount) {
await (0, speculos_1.getDelegateEvents)(delegatingAccount);
await (0, speculos_1.pressBoth)();
}
exports.delegateSolana = delegateSolana;
async function sendSolana(tx) {
const events = (0, speculos_1.getSpeculosModel)() !== types_devices_1.DeviceModelId.nanoS
? await (0, speculos_1.pressUntilTextFound)(DeviceLabels_1.DeviceLabels.SIGN_TRANSACTION)
: await (0, speculos_1.pressUntilTextFound)(DeviceLabels_1.DeviceLabels.APPROVE);
const isAmountCorrect = (0, speculos_1.containsSubstringInEvent)(tx.amount, events);
(0, expect_1.default)(isAmountCorrect).toBeTruthy();
if (process.env.SPECULOS_DEVICE !== Device_1.Device.LNS) {
const isAddressCorrect = (0, speculos_1.containsSubstringInEvent)(tx.accountToCredit.parentAccount?.address ?? tx.accountToCredit.address, events);
(0, expect_1.default)(isAddressCorrect).toBeTruthy();
}
await (0, speculos_1.pressBoth)();
}
exports.sendSolana = sendSolana;
//# sourceMappingURL=solana.js.map