@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
29 lines • 1.4 kB
JavaScript
import expect from "expect";
import { pressBoth, pressUntilTextFound, containsSubstringInEvent, waitFor, getSpeculosModel, } from "../speculos";
import { DeviceLabels } from "../enum/DeviceLabels";
import { Device } from "../enum/Device";
import { DeviceModelId } from "@ledgerhq/types-devices";
export async function sendEVM(tx) {
const events = getSpeculosModel() !== DeviceModelId.nanoS
? await pressUntilTextFound(DeviceLabels.SIGN_TRANSACTION)
: await pressUntilTextFound(DeviceLabels.ACCEPT);
const isAmountCorrect = containsSubstringInEvent(tx.amount, events);
expect(isAmountCorrect).toBeTruthy();
if (tx.accountToCredit.ensName && process.env.SPECULOS_DEVICE !== Device.LNS) {
const isENSNameCorrect = containsSubstringInEvent(tx.accountToCredit.ensName, events);
expect(isENSNameCorrect).toBeTruthy();
}
else {
const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
expect(isAddressCorrect).toBeTruthy();
}
await pressBoth();
}
export async function sendEvmNFT(tx) {
await waitFor(DeviceLabels.REVIEW_OPERATION);
const events = await pressUntilTextFound(DeviceLabels.ACCEPT);
const isAddressCorrect = containsSubstringInEvent(tx.accountToCredit.address, events);
expect(isAddressCorrect).toBeTruthy();
await pressBoth();
}
//# sourceMappingURL=evm.js.map