@ledgerhq/coin-aptos 1.4.0-nightly.2 → 1.4.0-nightly.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +13 -0
- package/lib/__tests__/api/index.test.js +67 -92
- package/lib/__tests__/api/index.test.js.map +1 -1
- package/lib/__tests__/bridge/broadcast.test.js +11 -17
- package/lib/__tests__/bridge/broadcast.test.js.map +1 -1
- package/lib/__tests__/bridge/buildTransaction.test.js +3 -12
- package/lib/__tests__/bridge/buildTransaction.test.js.map +1 -1
- package/lib/__tests__/bridge/createTransaction.test.js +2 -11
- package/lib/__tests__/bridge/createTransaction.test.js.map +1 -1
- package/lib/__tests__/bridge/estimateMaxSpendable.test.js +12 -21
- package/lib/__tests__/bridge/estimateMaxSpendable.test.js.map +1 -1
- package/lib/__tests__/bridge/getFeesForTransaction.test.js +13 -22
- package/lib/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
- package/lib/__tests__/bridge/getTransactionStatus.test.js +18 -27
- package/lib/__tests__/bridge/getTransactionStatus.test.js.map +1 -1
- package/lib/__tests__/bridge/index.test.js +3 -12
- package/lib/__tests__/bridge/index.test.js.map +1 -1
- package/lib/__tests__/bridge/prepareTransaction.test.js +22 -35
- package/lib/__tests__/bridge/prepareTransaction.test.js.map +1 -1
- package/lib/__tests__/bridge/signOperation.test.js +9 -18
- package/lib/__tests__/bridge/signOperation.test.js.map +1 -1
- package/lib/__tests__/bridge/synchronisation.test.js +46 -65
- package/lib/__tests__/bridge/synchronisation.test.js.map +1 -1
- package/lib/__tests__/bridge/transaction.test.js +14 -23
- package/lib/__tests__/bridge/transaction.test.js.map +1 -1
- package/lib/__tests__/network/index.test.js +10 -16
- package/lib/__tests__/network/index.test.js.map +1 -1
- package/lib/__tests__/signer/index.test.js +6 -17
- package/lib/__tests__/signer/index.test.js.map +1 -1
- package/lib/api/graphql/queries.d.ts.map +1 -1
- package/lib/api/graphql/queries.js +1 -0
- package/lib/api/graphql/queries.js.map +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +119 -142
- package/lib/api/index.js.map +1 -1
- package/lib/bridge/bridge.fixture.js +13 -13
- package/lib/bridge/bridge.fixture.js.map +1 -1
- package/lib/bridge/broadcast.js +3 -12
- package/lib/bridge/broadcast.js.map +1 -1
- package/lib/bridge/buildTransaction.js +3 -12
- package/lib/bridge/buildTransaction.js.map +1 -1
- package/lib/bridge/estimateMaxSpendable.js +3 -12
- package/lib/bridge/estimateMaxSpendable.js.map +1 -1
- package/lib/bridge/getFeesForTransaction.js +8 -17
- package/lib/bridge/getFeesForTransaction.js.map +1 -1
- package/lib/bridge/getTransactionStatus.js +2 -11
- package/lib/bridge/getTransactionStatus.js.map +1 -1
- package/lib/bridge/logic.js +17 -20
- package/lib/bridge/logic.js.map +1 -1
- package/lib/bridge/prepareTransaction.js +7 -13
- package/lib/bridge/prepareTransaction.js.map +1 -1
- package/lib/bridge/signOperation.js +42 -53
- package/lib/bridge/signOperation.js.map +1 -1
- package/lib/bridge/synchronisation.js +7 -17
- package/lib/bridge/synchronisation.js.map +1 -1
- package/lib/bridge/transaction.js +16 -2
- package/lib/bridge/transaction.js.map +1 -1
- package/lib/network/index.js +19 -30
- package/lib/network/index.js.map +1 -1
- package/lib/signer/index.js +3 -12
- package/lib/signer/index.js.map +1 -1
- package/lib/test/bot-specs.d.ts +2 -2
- package/lib/test/bot-specs.d.ts.map +1 -1
- package/lib/test/bot-specs.js +32 -26
- package/lib/test/bot-specs.js.map +1 -1
- package/lib/test/cli.js +5 -1
- package/lib/test/cli.js.map +1 -1
- package/lib/test/speculos-deviceActions.d.ts.map +1 -1
- package/lib/test/speculos-deviceActions.js +19 -20
- package/lib/test/speculos-deviceActions.js.map +1 -1
- package/lib-es/__tests__/api/index.test.js +67 -92
- package/lib-es/__tests__/api/index.test.js.map +1 -1
- package/lib-es/__tests__/bridge/broadcast.test.js +11 -17
- package/lib-es/__tests__/bridge/broadcast.test.js.map +1 -1
- package/lib-es/__tests__/bridge/buildTransaction.test.js +3 -12
- package/lib-es/__tests__/bridge/buildTransaction.test.js.map +1 -1
- package/lib-es/__tests__/bridge/createTransaction.test.js +2 -11
- package/lib-es/__tests__/bridge/createTransaction.test.js.map +1 -1
- package/lib-es/__tests__/bridge/estimateMaxSpendable.test.js +12 -21
- package/lib-es/__tests__/bridge/estimateMaxSpendable.test.js.map +1 -1
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.js +13 -22
- package/lib-es/__tests__/bridge/getFeesForTransaction.test.js.map +1 -1
- package/lib-es/__tests__/bridge/getTransactionStatus.test.js +18 -27
- package/lib-es/__tests__/bridge/getTransactionStatus.test.js.map +1 -1
- package/lib-es/__tests__/bridge/index.test.js +3 -12
- package/lib-es/__tests__/bridge/index.test.js.map +1 -1
- package/lib-es/__tests__/bridge/prepareTransaction.test.js +22 -35
- package/lib-es/__tests__/bridge/prepareTransaction.test.js.map +1 -1
- package/lib-es/__tests__/bridge/signOperation.test.js +9 -18
- package/lib-es/__tests__/bridge/signOperation.test.js.map +1 -1
- package/lib-es/__tests__/bridge/synchronisation.test.js +46 -65
- package/lib-es/__tests__/bridge/synchronisation.test.js.map +1 -1
- package/lib-es/__tests__/bridge/transaction.test.js +14 -23
- package/lib-es/__tests__/bridge/transaction.test.js.map +1 -1
- package/lib-es/__tests__/network/index.test.js +10 -16
- package/lib-es/__tests__/network/index.test.js.map +1 -1
- package/lib-es/__tests__/signer/index.test.js +6 -17
- package/lib-es/__tests__/signer/index.test.js.map +1 -1
- package/lib-es/api/graphql/queries.d.ts.map +1 -1
- package/lib-es/api/graphql/queries.js +1 -0
- package/lib-es/api/graphql/queries.js.map +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +119 -142
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/bridge/bridge.fixture.js +13 -13
- package/lib-es/bridge/bridge.fixture.js.map +1 -1
- package/lib-es/bridge/broadcast.js +3 -12
- package/lib-es/bridge/broadcast.js.map +1 -1
- package/lib-es/bridge/buildTransaction.js +3 -12
- package/lib-es/bridge/buildTransaction.js.map +1 -1
- package/lib-es/bridge/estimateMaxSpendable.js +3 -12
- package/lib-es/bridge/estimateMaxSpendable.js.map +1 -1
- package/lib-es/bridge/getFeesForTransaction.js +8 -17
- package/lib-es/bridge/getFeesForTransaction.js.map +1 -1
- package/lib-es/bridge/getTransactionStatus.js +2 -11
- package/lib-es/bridge/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/logic.js +17 -20
- package/lib-es/bridge/logic.js.map +1 -1
- package/lib-es/bridge/prepareTransaction.js +7 -13
- package/lib-es/bridge/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/signOperation.js +42 -53
- package/lib-es/bridge/signOperation.js.map +1 -1
- package/lib-es/bridge/synchronisation.js +7 -17
- package/lib-es/bridge/synchronisation.js.map +1 -1
- package/lib-es/bridge/transaction.js +16 -2
- package/lib-es/bridge/transaction.js.map +1 -1
- package/lib-es/network/index.js +19 -30
- package/lib-es/network/index.js.map +1 -1
- package/lib-es/signer/index.js +3 -12
- package/lib-es/signer/index.js.map +1 -1
- package/lib-es/test/bot-specs.d.ts +2 -2
- package/lib-es/test/bot-specs.d.ts.map +1 -1
- package/lib-es/test/bot-specs.js +33 -27
- package/lib-es/test/bot-specs.js.map +1 -1
- package/lib-es/test/cli.js +5 -1
- package/lib-es/test/cli.js.map +1 -1
- package/lib-es/test/speculos-deviceActions.d.ts.map +1 -1
- package/lib-es/test/speculos-deviceActions.js +20 -21
- package/lib-es/test/speculos-deviceActions.js.map +1 -1
- package/package.json +4 -3
- package/src/api/graphql/queries.ts +1 -0
- package/src/api/index.ts +1 -0
- package/src/test/bot-specs.ts +39 -33
- package/src/test/speculos-deviceActions.ts +20 -27
- package/tsconfig.json +3 -2
package/lib-es/test/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","source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YACf,YAAY,EAAE,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;SAC7D,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,YAAY;IAClC,OAAO;QACL,OAAO;QACP,aAAa;QACb,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speculos-deviceActions.d.ts","sourceRoot":"","sources":["../../src/test/speculos-deviceActions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"speculos-deviceActions.d.ts","sourceRoot":"","sources":["../../src/test/speculos-deviceActions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,oCAAoC,CAAC;AAE3D,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC,CAuC1E,CAAC"}
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import { deviceActionFlow,
|
|
2
|
-
const typeWording = {
|
|
3
|
-
send: "Send",
|
|
4
|
-
lock: "Lock",
|
|
5
|
-
unlock: "Unlock",
|
|
6
|
-
withdraw: "Withdraw",
|
|
7
|
-
vote: "Vote",
|
|
8
|
-
revoke: "Revoke",
|
|
9
|
-
activate: "Activate",
|
|
10
|
-
register: "Create Account",
|
|
11
|
-
};
|
|
1
|
+
import { deviceActionFlow, SpeculosButton } from "@ledgerhq/coin-framework/bot/specs";
|
|
12
2
|
export const acceptTransaction = deviceActionFlow({
|
|
13
3
|
steps: [
|
|
14
4
|
{
|
|
@@ -16,26 +6,35 @@ export const acceptTransaction = deviceActionFlow({
|
|
|
16
6
|
button: SpeculosButton.RIGHT,
|
|
17
7
|
},
|
|
18
8
|
{
|
|
19
|
-
title: "
|
|
9
|
+
title: "Transaction",
|
|
10
|
+
button: SpeculosButton.RIGHT,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
title: "Function",
|
|
14
|
+
button: SpeculosButton.RIGHT,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
title: "Coin Type",
|
|
18
|
+
button: SpeculosButton.RIGHT,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
title: "Receiver (1/2)",
|
|
22
|
+
button: SpeculosButton.RIGHT,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
title: "Receiver (2/2)",
|
|
20
26
|
button: SpeculosButton.RIGHT,
|
|
21
|
-
expectedValue: ({ transaction }) => {
|
|
22
|
-
return typeWording[transaction.mode];
|
|
23
|
-
},
|
|
24
27
|
},
|
|
25
28
|
{
|
|
26
29
|
title: "Amount",
|
|
27
30
|
button: SpeculosButton.RIGHT,
|
|
28
|
-
expectedValue: ({ account, status }) => formatDeviceAmount(account.currency, status.amount, {
|
|
29
|
-
forceFloating: true,
|
|
30
|
-
}),
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
|
-
title: "
|
|
33
|
+
title: "Gas Fee",
|
|
34
34
|
button: SpeculosButton.RIGHT,
|
|
35
|
-
expectedValue: ({ transaction }) => transaction.recipient,
|
|
36
35
|
},
|
|
37
36
|
{
|
|
38
|
-
title: "
|
|
37
|
+
title: "Approve",
|
|
39
38
|
button: SpeculosButton.BOTH,
|
|
40
39
|
},
|
|
41
40
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speculos-deviceActions.js","sourceRoot":"","sources":["../../src/test/speculos-deviceActions.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"speculos-deviceActions.js","sourceRoot":"","sources":["../../src/test/speculos-deviceActions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGtF,MAAM,CAAC,MAAM,iBAAiB,GAAkD,gBAAgB,CAAC;IAC/F,KAAK,EAAE;QACL;YACE,KAAK,EAAE,QAAQ;YACf,MAAM,EAAE,cAAc,CAAC,KAAK;SAC7B;QACD;YACE,KAAK,EAAE,aAAa;YACpB,MAAM,EAAE,cAAc,CAAC,KAAK;SAC7B;QACD;YACE,KAAK,EAAE,UAAU;YACjB,MAAM,EAAE,cAAc,CAAC,KAAK;SAC7B;QACD;YACE,KAAK,EAAE,WAAW;YAClB,MAAM,EAAE,cAAc,CAAC,KAAK;SAC7B;QACD;YACE,KAAK,EAAE,gBAAgB;YACvB,MAAM,EAAE,cAAc,CAAC,KAAK;SAC7B;QACD;YACE,KAAK,EAAE,gBAAgB;YACvB,MAAM,EAAE,cAAc,CAAC,KAAK;SAC7B;QACD;YACE,KAAK,EAAE,QAAQ;YACf,MAAM,EAAE,cAAc,CAAC,KAAK;SAC7B;QACD;YACE,KAAK,EAAE,SAAS;YAChB,MAAM,EAAE,cAAc,CAAC,KAAK;SAC7B;QACD;YACE,KAAK,EAAE,SAAS;YAChB,MAAM,EAAE,cAAc,CAAC,IAAI;SAC5B;KACF;CACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-aptos",
|
|
3
|
-
"version": "1.4.0-nightly.
|
|
3
|
+
"version": "1.4.0-nightly.4",
|
|
4
4
|
"description": "Ledger Aptos Coin integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -87,9 +87,10 @@
|
|
|
87
87
|
"bignumber.js": "^9.1.2",
|
|
88
88
|
"graphql": "^16.10.0",
|
|
89
89
|
"invariant": "^2.2.4",
|
|
90
|
+
"expect": "^27.4.6",
|
|
90
91
|
"lodash": "^4.17.21",
|
|
91
92
|
"rxjs": "^7.8.1",
|
|
92
|
-
"@ledgerhq/coin-framework": "^0.
|
|
93
|
+
"@ledgerhq/coin-framework": "^1.0.0-nightly.1",
|
|
93
94
|
"@ledgerhq/cryptoassets": "^13.10.0-nightly.1",
|
|
94
95
|
"@ledgerhq/devices": "8.4.4",
|
|
95
96
|
"@ledgerhq/errors": "^6.19.1",
|
|
@@ -111,7 +112,7 @@
|
|
|
111
112
|
},
|
|
112
113
|
"scripts": {
|
|
113
114
|
"clean": "rimraf lib lib-es",
|
|
114
|
-
"build": "tsc && tsc -m ES6 --outDir lib-es",
|
|
115
|
+
"build": "tsc --outDir lib --module commonjs --moduleResolution node10 && tsc -m ES6 --outDir lib-es",
|
|
115
116
|
"coverage": "jest --coverage --testPathIgnorePatterns='/bridge.integration.test.ts|node_modules|lib-es|lib/' --coveragePathIgnorePatterns='src/test|src/types|src/index.ts|src/bridge/bridge.fixture.ts' --passWithNoTests && mv coverage/coverage-final.json coverage/coverage-aptos.json",
|
|
116
117
|
"prewatch": "pnpm build",
|
|
117
118
|
"watch": "tsc --watch",
|
package/src/api/index.ts
CHANGED
package/src/test/bot-specs.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import invariant from "invariant";
|
|
2
|
+
import expect from "expect";
|
|
2
3
|
import { DeviceModelId } from "@ledgerhq/devices";
|
|
4
|
+
import BigNumber from "bignumber.js";
|
|
5
|
+
import type { Transaction } from "../types";
|
|
3
6
|
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
|
4
|
-
import {
|
|
5
|
-
import { botTest, genericTestDestination, pickSiblings } from "@ledgerhq/coin-framework/bot/specs";
|
|
7
|
+
import { genericTestDestination, pickSiblings, botTest } from "@ledgerhq/coin-framework/bot/specs";
|
|
6
8
|
import type { AppSpec } from "@ledgerhq/coin-framework/bot/types";
|
|
7
9
|
import { acceptTransaction } from "./speculos-deviceActions";
|
|
8
|
-
import type { Transaction } from "../types";
|
|
9
10
|
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const maxAccountSiblings = 4;
|
|
11
|
+
const MIN_SAFE = new BigNumber(0.0001);
|
|
12
|
+
const maxAccount = 6;
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const aptosSpecs: AppSpec<Transaction> = {
|
|
15
15
|
name: "Aptos",
|
|
16
|
-
currency,
|
|
16
|
+
currency: getCryptoCurrencyById("aptos"),
|
|
17
17
|
appQuery: {
|
|
18
18
|
model: DeviceModelId.nanoSP,
|
|
19
19
|
appName: "Aptos",
|
|
20
20
|
},
|
|
21
21
|
genericDeviceAction: acceptTransaction,
|
|
22
|
-
testTimeout:
|
|
23
|
-
minViableAmount:
|
|
22
|
+
testTimeout: 6 * 60 * 1000,
|
|
23
|
+
minViableAmount: MIN_SAFE,
|
|
24
24
|
transactionCheck: ({ maxSpendable }) => {
|
|
25
|
-
invariant(maxSpendable.gt(
|
|
25
|
+
invariant(maxSpendable.gt(MIN_SAFE), "balance is too low");
|
|
26
26
|
},
|
|
27
27
|
mutations: [
|
|
28
28
|
{
|
|
@@ -31,9 +31,8 @@ const aptos: AppSpec<Transaction> = {
|
|
|
31
31
|
maxRun: 1,
|
|
32
32
|
testDestination: genericTestDestination,
|
|
33
33
|
transaction: ({ account, siblings, bridge, maxSpendable }) => {
|
|
34
|
-
invariant(maxSpendable.gt(
|
|
35
|
-
|
|
36
|
-
const sibling = pickSiblings(siblings, maxAccountSiblings);
|
|
34
|
+
invariant(maxSpendable.gt(MIN_SAFE), "balance is too low");
|
|
35
|
+
const sibling = pickSiblings(siblings, maxAccount);
|
|
37
36
|
const recipient = sibling.freshAddress;
|
|
38
37
|
const amount = maxSpendable.div(2).integerValue();
|
|
39
38
|
|
|
@@ -50,37 +49,44 @@ const aptos: AppSpec<Transaction> = {
|
|
|
50
49
|
updates,
|
|
51
50
|
};
|
|
52
51
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
|
|
53
|
+
test: ({ accountBeforeTransaction, operation, account }) => {
|
|
54
|
+
botTest("account spendable balance decreased with operation", () =>
|
|
55
|
+
expect(account.spendableBalance).toEqual(
|
|
56
|
+
accountBeforeTransaction.spendableBalance.minus(operation.value),
|
|
57
57
|
),
|
|
58
58
|
);
|
|
59
59
|
},
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
|
-
name: "
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
name: "Transfer Max",
|
|
63
|
+
feature: "sendMax",
|
|
64
|
+
maxRun: 1,
|
|
65
65
|
transaction: ({ account, siblings, bridge }) => {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
const updates: Array<Partial<Transaction>> = [
|
|
67
|
+
{
|
|
68
|
+
recipient: pickSiblings(siblings, maxAccount).freshAddress,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
useAllAmount: true,
|
|
72
|
+
},
|
|
73
|
+
];
|
|
69
74
|
|
|
70
75
|
return {
|
|
71
|
-
transaction,
|
|
72
|
-
updates
|
|
76
|
+
transaction: bridge.createTransaction(account),
|
|
77
|
+
updates,
|
|
73
78
|
};
|
|
74
79
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
});
|
|
80
|
+
testDestination: genericTestDestination,
|
|
81
|
+
test: ({ account }) => {
|
|
82
|
+
botTest("account spendable balance is zero", () =>
|
|
83
|
+
expect(account.spendableBalance.toString()).toBe("0"),
|
|
84
|
+
);
|
|
81
85
|
},
|
|
82
86
|
},
|
|
83
87
|
],
|
|
84
88
|
};
|
|
85
89
|
|
|
86
|
-
export default {
|
|
90
|
+
export default {
|
|
91
|
+
aptosSpecs,
|
|
92
|
+
};
|
|
@@ -1,23 +1,8 @@
|
|
|
1
1
|
import type { DeviceAction } from "@ledgerhq/coin-framework/bot/types";
|
|
2
2
|
import type { Transaction } from "../types";
|
|
3
|
-
import {
|
|
4
|
-
deviceActionFlow,
|
|
5
|
-
formatDeviceAmount,
|
|
6
|
-
SpeculosButton,
|
|
7
|
-
} from "@ledgerhq/coin-framework/bot/specs";
|
|
3
|
+
import { deviceActionFlow, SpeculosButton } from "@ledgerhq/coin-framework/bot/specs";
|
|
8
4
|
import { State } from "@ledgerhq/coin-framework/bot/types";
|
|
9
5
|
|
|
10
|
-
const typeWording = {
|
|
11
|
-
send: "Send",
|
|
12
|
-
lock: "Lock",
|
|
13
|
-
unlock: "Unlock",
|
|
14
|
-
withdraw: "Withdraw",
|
|
15
|
-
vote: "Vote",
|
|
16
|
-
revoke: "Revoke",
|
|
17
|
-
activate: "Activate",
|
|
18
|
-
register: "Create Account",
|
|
19
|
-
};
|
|
20
|
-
|
|
21
6
|
export const acceptTransaction: DeviceAction<Transaction, State<Transaction>> = deviceActionFlow({
|
|
22
7
|
steps: [
|
|
23
8
|
{
|
|
@@ -25,27 +10,35 @@ export const acceptTransaction: DeviceAction<Transaction, State<Transaction>> =
|
|
|
25
10
|
button: SpeculosButton.RIGHT,
|
|
26
11
|
},
|
|
27
12
|
{
|
|
28
|
-
title: "
|
|
13
|
+
title: "Transaction",
|
|
14
|
+
button: SpeculosButton.RIGHT,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
title: "Function",
|
|
18
|
+
button: SpeculosButton.RIGHT,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
title: "Coin Type",
|
|
22
|
+
button: SpeculosButton.RIGHT,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
title: "Receiver (1/2)",
|
|
26
|
+
button: SpeculosButton.RIGHT,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
title: "Receiver (2/2)",
|
|
29
30
|
button: SpeculosButton.RIGHT,
|
|
30
|
-
expectedValue: ({ transaction }) => {
|
|
31
|
-
return typeWording[transaction.mode as keyof typeof typeWording];
|
|
32
|
-
},
|
|
33
31
|
},
|
|
34
32
|
{
|
|
35
33
|
title: "Amount",
|
|
36
34
|
button: SpeculosButton.RIGHT,
|
|
37
|
-
expectedValue: ({ account, status }) =>
|
|
38
|
-
formatDeviceAmount(account.currency, status.amount, {
|
|
39
|
-
forceFloating: true,
|
|
40
|
-
}),
|
|
41
35
|
},
|
|
42
36
|
{
|
|
43
|
-
title: "
|
|
37
|
+
title: "Gas Fee",
|
|
44
38
|
button: SpeculosButton.RIGHT,
|
|
45
|
-
expectedValue: ({ transaction }) => transaction.recipient,
|
|
46
39
|
},
|
|
47
40
|
{
|
|
48
|
-
title: "
|
|
41
|
+
title: "Approve",
|
|
49
42
|
button: SpeculosButton.BOTH,
|
|
50
43
|
},
|
|
51
44
|
],
|
package/tsconfig.json
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"declaration": true,
|
|
5
5
|
"declarationMap": true,
|
|
6
|
-
"module": "commonjs",
|
|
7
6
|
"downlevelIteration": true,
|
|
8
7
|
"lib": ["es2020", "dom"],
|
|
9
8
|
"rootDir": "./src",
|
|
10
9
|
"outDir": "lib",
|
|
11
|
-
"exactOptionalPropertyTypes": true
|
|
10
|
+
"exactOptionalPropertyTypes": true,
|
|
11
|
+
"module": "esnext",
|
|
12
|
+
"moduleResolution": "bundler",
|
|
12
13
|
},
|
|
13
14
|
"include": ["src/**/*", "deviceTransactionConfig.ts", "transaction.ts"]
|
|
14
15
|
}
|