@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
26 lines (22 loc) • 1.03 kB
text/typescript
import { containsSubstringInEvent, getDelegateEvents, pressUntilTextFound } from "../speculos";
import { isTouchDevice } from "../speculosAppVersion";
import { Delegate } from "../models/Delegate";
import expect from "expect";
import { longPressAndRelease } from "../deviceInteraction/TouchDeviceSimulator";
import { DeviceLabels } from "../enum/DeviceLabels";
import { withDeviceController } from "../deviceInteraction/DeviceController";
export const delegateCelo = withDeviceController(
({ getButtonsController }) =>
async (delegatingAccount: Delegate) => {
const buttons = getButtonsController();
const events = await getDelegateEvents(delegatingAccount);
const isAmountCorrect = containsSubstringInEvent(delegatingAccount.amount, events);
expect(isAmountCorrect).toBeTruthy();
if (isTouchDevice()) {
await pressUntilTextFound(DeviceLabels.HOLD_TO_SIGN);
await longPressAndRelease(DeviceLabels.HOLD_TO_SIGN, 3);
} else {
await buttons.both();
}
},
);