Skip to content

Commit

Permalink
Merge pull request #8224 from LedgerHQ/support/qaa-306
Browse files Browse the repository at this point in the history
[QAA-306] ♻️ Refacto speculos interations
  • Loading branch information
VicAlbr authored Oct 29, 2024
2 parents 18973b7 + e58237c commit c894871
Show file tree
Hide file tree
Showing 10 changed files with 225 additions and 346 deletions.
9 changes: 9 additions & 0 deletions apps/ledger-live-desktop/tests/enum/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ export class Account {
undefined,
1,
);

static readonly POL_1 = new Account(
Currency.POL,
"Polygon 1",
Expand All @@ -344,6 +345,14 @@ export class Account {
0,
);

static readonly POL_2 = new Account(
Currency.POL,
"Polygon 2",
"0x43047a5023D55a8658Fcb1c1Cea468311AdAA3Ad",
undefined,
1,
);

static readonly BSC_1 = new Account(
Currency.BSC,
"Binance Smart Chain 1",
Expand Down
235 changes: 48 additions & 187 deletions apps/ledger-live-desktop/tests/enum/AppInfos.ts
Original file line number Diff line number Diff line change
@@ -1,192 +1,53 @@
import { DeviceLabels } from "./DeviceLabels";

export class AppInfos {
constructor(
public readonly name: string,
public readonly sendPattern?: DeviceLabels[],
public readonly receivePattern?: DeviceLabels[],
public readonly delegatePattern?: DeviceLabels[],
) {}

static readonly BITCOIN = new AppInfos(
"Bitcoin",
[
DeviceLabels.AMOUNT,
DeviceLabels.ADDRESS,
DeviceLabels.CONTINUE,
DeviceLabels.REJECT,
DeviceLabels.SIGN,
],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);

static readonly BITCOIN_TESTNET = new AppInfos(
"Bitcoin Test",
[
DeviceLabels.AMOUNT,
DeviceLabels.ADDRESS,
DeviceLabels.CONTINUE,
DeviceLabels.REJECT,
DeviceLabels.SIGN,
],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);

static readonly DOGECOIN = new AppInfos(
"Dogecoin",
[DeviceLabels.AMOUNT, DeviceLabels.ADDRESS, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);

static readonly ETHEREUM = new AppInfos(
"Ethereum",
[DeviceLabels.AMOUNT, DeviceLabels.TO, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);

static readonly ETHEREUM_HOLESKY = new AppInfos(
"Ethereum Holesky",
[DeviceLabels.AMOUNT, DeviceLabels.TO, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);

static readonly ETHEREUM_SEPOLIA = new AppInfos(
"Ethereum Sepolia",
[DeviceLabels.AMOUNT, DeviceLabels.TO, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);

static readonly ETHEREUM_CLASSIC = new AppInfos(
"Ethereum Classic",
[DeviceLabels.AMOUNT, DeviceLabels.TO, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);

static readonly SOLANA = new AppInfos(
"Solana",
[DeviceLabels.TRANSFER, DeviceLabels.RECIPIENT, DeviceLabels.APPROVE, DeviceLabels.REJECT],
[DeviceLabels.PUBKEY, DeviceLabels.APPROVE, DeviceLabels.REJECT],
[DeviceLabels.DELEGATE_FROM, DeviceLabels.DEPOSIT, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);

static readonly POLKADOT = new AppInfos(
"Polkadot",
[DeviceLabels.DEST, DeviceLabels.AMOUNT, DeviceLabels.CAPS_APPROVE, DeviceLabels.CAPS_REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.CAPS_APPROVE, DeviceLabels.CAPS_REJECT],
);

static readonly TRON = new AppInfos(
"Tron",
[DeviceLabels.AMOUNT, DeviceLabels.TO, DeviceLabels.SIGN, DeviceLabels.CANCEL],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.CANCEL],
);

static readonly RIPPLE = new AppInfos(
"Ripple",
[DeviceLabels.AMOUNT, DeviceLabels.DESTINATION, DeviceLabels.SIGN, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);

static readonly CARDANO = new AppInfos(
"Cardano",
[DeviceLabels.SEND, DeviceLabels.SEND_TO_ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.CONFIRM, DeviceLabels.REJECT],
);

static readonly STELLAR = new AppInfos(
"Stellar",
[DeviceLabels.SEND, DeviceLabels.DESTINATION, DeviceLabels.FINALIZE, DeviceLabels.CANCEL],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);

static readonly BITCOIN_CASH = new AppInfos(
"Bitcoin Cash",
[DeviceLabels.AMOUNT, DeviceLabels.ADDRESS, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);

static readonly ALGORAND = new AppInfos(
"Algorand",
[
DeviceLabels.AMOUNT,
DeviceLabels.RECEIVER,
DeviceLabels.CAPS_APPROVE,
DeviceLabels.CAPS_REJECT,
],
[DeviceLabels.ADDRESS, DeviceLabels.CAPS_APPROVE, DeviceLabels.CAPS_REJECT],
);

static readonly COSMOS = new AppInfos(
"Cosmos",
[DeviceLabels.AMOUNT, DeviceLabels.TO, DeviceLabels.CAPS_APPROVE, DeviceLabels.CAPS_REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.CAPS_APPROVE, DeviceLabels.CAPS_REJECT],
[
DeviceLabels.PLEASE_REVIEW,
DeviceLabels.AMOUNT,
DeviceLabels.CAPS_APPROVE,
DeviceLabels.CAPS_REJECT,
],
);

static readonly TEZOS = new AppInfos(
"Tezos",
[DeviceLabels.AMOUNT, DeviceLabels.DESTINATION, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);

static readonly POLYGON = new AppInfos(
"Polygon",
[DeviceLabels.AMOUNT, DeviceLabels.ADDRESS, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);

static readonly BINANCE_SMART_CHAIN = new AppInfos(
"Binance Smart Chain",
[DeviceLabels.AMOUNT, DeviceLabels.ADDRESS, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);

static readonly TON = new AppInfos(
"Ton",
[DeviceLabels.AMOUNT, DeviceLabels.TO, DeviceLabels.APPROVE, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);

static readonly NEAR = new AppInfos(
"Near",
[DeviceLabels.AMOUNT, DeviceLabels.DESTINATION, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.WALLET_ID, DeviceLabels.APPROVE, DeviceLabels.REJECT],
[
DeviceLabels.VIEW_HEADER,
DeviceLabels.RECEIVER,
DeviceLabels.CONTINUE_TO_ACTION,
DeviceLabels.VIEW_ACTION,
DeviceLabels.METHOD_NAME,
DeviceLabels.DEPOSIT,
DeviceLabels.REJECT,
DeviceLabels.SIGN,
],
);

static readonly MULTIVERSE_X = new AppInfos(
"Multiverse X",
[DeviceLabels.AMOUNT, DeviceLabels.DESTINATION, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);

static readonly OSMOSIS = new AppInfos(
"Osmosis",
[DeviceLabels.AMOUNT, DeviceLabels.DESTINATION, DeviceLabels.ACCEPT, DeviceLabels.REJECT],
[DeviceLabels.ADDRESS, DeviceLabels.APPROVE, DeviceLabels.REJECT],
);
constructor(public readonly name: string) {}

static readonly BITCOIN = new AppInfos("Bitcoin");

static readonly BITCOIN_TESTNET = new AppInfos("Bitcoin Test");

static readonly DOGECOIN = new AppInfos("Dogecoin");

static readonly ETHEREUM = new AppInfos("Ethereum");

static readonly ETHEREUM_HOLESKY = new AppInfos("Ethereum Holesky");

static readonly ETHEREUM_SEPOLIA = new AppInfos("Ethereum Sepolia");

static readonly ETHEREUM_CLASSIC = new AppInfos("Ethereum Classic");

static readonly SOLANA = new AppInfos("Solana");

static readonly POLKADOT = new AppInfos("Polkadot");

static readonly TRON = new AppInfos("Tron");

static readonly RIPPLE = new AppInfos("Ripple");

static readonly CARDANO = new AppInfos("Cardano");

static readonly STELLAR = new AppInfos("Stellar");

static readonly BITCOIN_CASH = new AppInfos("Bitcoin Cash");

static readonly ALGORAND = new AppInfos("Algorand");

static readonly COSMOS = new AppInfos("Cosmos");

static readonly TEZOS = new AppInfos("Tezos");

static readonly POLYGON = new AppInfos("Polygon");

static readonly BINANCE_SMART_CHAIN = new AppInfos("Binance Smart Chain");

static readonly TON = new AppInfos("Ton");

static readonly NEAR = new AppInfos("Near");

static readonly MULTIVERSE_X = new AppInfos("Multiverse X");

static readonly OSMOSIS = new AppInfos("Osmosis");

static readonly LS = new AppInfos("LedgerSync");

static readonly EXCHANGE = new AppInfos("Exchange", [
DeviceLabels.SEND,
DeviceLabels.GET,
DeviceLabels.FEES,
DeviceLabels.ACCEPT,
DeviceLabels.REJECT,
]);
static readonly EXCHANGE = new AppInfos("Exchange");
}
5 changes: 5 additions & 0 deletions apps/ledger-live-desktop/tests/enum/DeviceLabels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ export enum DeviceLabels {
DEPOSIT = "Deposit",
DELEGATE_FROM = "Delegate from",
PLEASE_REVIEW = "Please review",
VALUE = "Value",
CONNECT_WITH = "Connect with",
MAKE_SURE_TO_USE = "Make sure to use",
YOUR_CRYPTO_ACCOUNTS = "Your crypto accounts",
TURN_ON_SYNC = "Turn on sync?",
}
Loading

0 comments on commit c894871

Please sign in to comment.