@ledgerhq/coin-ton 0.15.0 → 0.15.1-nightly.1
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 +1 -1
- package/.unimportedrc.json +2 -1
- package/CHANGELOG.md +16 -0
- package/lib/{__tests__/integration/bridge.integration.test.d.ts → test/bridge.dataset.d.ts} +2 -2
- package/lib/test/bridge.dataset.d.ts.map +1 -0
- package/lib/{__tests__/integration/bridge.integration.test.js → test/bridge.dataset.js} +4 -4
- package/lib/test/bridge.dataset.js.map +1 -0
- package/lib/transaction.d.ts.map +1 -1
- package/lib/transaction.js +44 -0
- package/lib/transaction.js.map +1 -1
- package/lib/types.d.ts +40 -2
- package/lib/types.d.ts.map +1 -1
- package/lib-es/{__tests__/integration/bridge.integration.test.d.ts → test/bridge.dataset.d.ts} +2 -2
- package/lib-es/test/bridge.dataset.d.ts.map +1 -0
- package/lib-es/{__tests__/integration/bridge.integration.test.js → test/bridge.dataset.js} +4 -4
- package/lib-es/test/bridge.dataset.js.map +1 -0
- package/lib-es/transaction.d.ts.map +1 -1
- package/lib-es/transaction.js +44 -0
- package/lib-es/transaction.js.map +1 -1
- package/lib-es/types.d.ts +40 -2
- package/lib-es/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/{__tests__/integration/bridge.integration.test.ts → test/bridge.dataset.ts} +4 -4
- package/src/transaction.ts +44 -0
- package/src/transaction.unit.test.ts +71 -8
- package/src/types.ts +52 -2
- package/lib/__tests__/fixtures/api.fixtures.d.ts +0 -4
- package/lib/__tests__/fixtures/api.fixtures.d.ts.map +0 -1
- package/lib/__tests__/fixtures/api.fixtures.js +0 -37
- package/lib/__tests__/fixtures/api.fixtures.js.map +0 -1
- package/lib/__tests__/fixtures/common.fixtures.d.ts +0 -32
- package/lib/__tests__/fixtures/common.fixtures.d.ts.map +0 -1
- package/lib/__tests__/fixtures/common.fixtures.js +0 -176
- package/lib/__tests__/fixtures/common.fixtures.js.map +0 -1
- package/lib/__tests__/integration/bridge.integration.test.d.ts.map +0 -1
- package/lib/__tests__/integration/bridge.integration.test.js.map +0 -1
- package/lib/__tests__/unit/api.unit.test.d.ts +0 -2
- package/lib/__tests__/unit/api.unit.test.d.ts.map +0 -1
- package/lib/__tests__/unit/api.unit.test.js +0 -77
- package/lib/__tests__/unit/api.unit.test.js.map +0 -1
- package/lib/__tests__/unit/broadcast.unit.test.d.ts +0 -2
- package/lib/__tests__/unit/broadcast.unit.test.d.ts.map +0 -1
- package/lib/__tests__/unit/broadcast.unit.test.js +0 -37
- package/lib/__tests__/unit/broadcast.unit.test.js.map +0 -1
- package/lib/__tests__/unit/createTransaction.unit.test.d.ts +0 -2
- package/lib/__tests__/unit/createTransaction.unit.test.d.ts.map +0 -1
- package/lib/__tests__/unit/createTransaction.unit.test.js +0 -25
- package/lib/__tests__/unit/createTransaction.unit.test.js.map +0 -1
- package/lib/__tests__/unit/deviceTransactionConfig.unit.test.d.ts +0 -2
- package/lib/__tests__/unit/deviceTransactionConfig.unit.test.d.ts.map +0 -1
- package/lib/__tests__/unit/deviceTransactionConfig.unit.test.js +0 -111
- package/lib/__tests__/unit/deviceTransactionConfig.unit.test.js.map +0 -1
- package/lib/__tests__/unit/estimateMaxSpendable.unit.test.d.ts +0 -2
- package/lib/__tests__/unit/estimateMaxSpendable.unit.test.d.ts.map +0 -1
- package/lib/__tests__/unit/estimateMaxSpendable.unit.test.js +0 -30
- package/lib/__tests__/unit/estimateMaxSpendable.unit.test.js.map +0 -1
- package/lib/__tests__/unit/getTransactionStatus.unit.test.d.ts +0 -2
- package/lib/__tests__/unit/getTransactionStatus.unit.test.d.ts.map +0 -1
- package/lib/__tests__/unit/getTransactionStatus.unit.test.js +0 -120
- package/lib/__tests__/unit/getTransactionStatus.unit.test.js.map +0 -1
- package/lib/__tests__/unit/hw-getAddress.unit.test.d.ts +0 -2
- package/lib/__tests__/unit/hw-getAddress.unit.test.d.ts.map +0 -1
- package/lib/__tests__/unit/hw-getAddress.unit.test.js +0 -54
- package/lib/__tests__/unit/hw-getAddress.unit.test.js.map +0 -1
- package/lib/__tests__/unit/logic.unit.test.d.ts +0 -2
- package/lib/__tests__/unit/logic.unit.test.d.ts.map +0 -1
- package/lib/__tests__/unit/logic.unit.test.js +0 -18
- package/lib/__tests__/unit/logic.unit.test.js.map +0 -1
- package/lib/__tests__/unit/prepareTransaction.unit.test.d.ts +0 -2
- package/lib/__tests__/unit/prepareTransaction.unit.test.d.ts.map +0 -1
- package/lib/__tests__/unit/prepareTransaction.unit.test.js +0 -109
- package/lib/__tests__/unit/prepareTransaction.unit.test.js.map +0 -1
- package/lib/__tests__/unit/signOperation.unit.test.d.ts +0 -2
- package/lib/__tests__/unit/signOperation.unit.test.d.ts.map +0 -1
- package/lib/__tests__/unit/signOperation.unit.test.js +0 -72
- package/lib/__tests__/unit/signOperation.unit.test.js.map +0 -1
- package/lib/__tests__/unit/txn.unit.test.d.ts +0 -2
- package/lib/__tests__/unit/txn.unit.test.d.ts.map +0 -1
- package/lib/__tests__/unit/txn.unit.test.js +0 -298
- package/lib/__tests__/unit/txn.unit.test.js.map +0 -1
- package/lib/__tests__/unit/utils.unit.test.d.ts +0 -2
- package/lib/__tests__/unit/utils.unit.test.d.ts.map +0 -1
- package/lib/__tests__/unit/utils.unit.test.js +0 -211
- package/lib/__tests__/unit/utils.unit.test.js.map +0 -1
- package/lib/transaction.unit.test.d.ts +0 -2
- package/lib/transaction.unit.test.d.ts.map +0 -1
- package/lib/transaction.unit.test.js +0 -600
- package/lib/transaction.unit.test.js.map +0 -1
- package/lib-es/__tests__/fixtures/api.fixtures.d.ts +0 -4
- package/lib-es/__tests__/fixtures/api.fixtures.d.ts.map +0 -1
- package/lib-es/__tests__/fixtures/api.fixtures.js +0 -34
- package/lib-es/__tests__/fixtures/api.fixtures.js.map +0 -1
- package/lib-es/__tests__/fixtures/common.fixtures.d.ts +0 -32
- package/lib-es/__tests__/fixtures/common.fixtures.d.ts.map +0 -1
- package/lib-es/__tests__/fixtures/common.fixtures.js +0 -170
- package/lib-es/__tests__/fixtures/common.fixtures.js.map +0 -1
- package/lib-es/__tests__/integration/bridge.integration.test.d.ts.map +0 -1
- package/lib-es/__tests__/integration/bridge.integration.test.js.map +0 -1
- package/lib-es/__tests__/unit/api.unit.test.d.ts +0 -2
- package/lib-es/__tests__/unit/api.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/unit/api.unit.test.js +0 -52
- package/lib-es/__tests__/unit/api.unit.test.js.map +0 -1
- package/lib-es/__tests__/unit/broadcast.unit.test.d.ts +0 -2
- package/lib-es/__tests__/unit/broadcast.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/unit/broadcast.unit.test.js +0 -32
- package/lib-es/__tests__/unit/broadcast.unit.test.js.map +0 -1
- package/lib-es/__tests__/unit/createTransaction.unit.test.d.ts +0 -2
- package/lib-es/__tests__/unit/createTransaction.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/unit/createTransaction.unit.test.js +0 -20
- package/lib-es/__tests__/unit/createTransaction.unit.test.js.map +0 -1
- package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.d.ts +0 -2
- package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.js +0 -106
- package/lib-es/__tests__/unit/deviceTransactionConfig.unit.test.js.map +0 -1
- package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.d.ts +0 -2
- package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.js +0 -25
- package/lib-es/__tests__/unit/estimateMaxSpendable.unit.test.js.map +0 -1
- package/lib-es/__tests__/unit/getTransactionStatus.unit.test.d.ts +0 -2
- package/lib-es/__tests__/unit/getTransactionStatus.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/unit/getTransactionStatus.unit.test.js +0 -115
- package/lib-es/__tests__/unit/getTransactionStatus.unit.test.js.map +0 -1
- package/lib-es/__tests__/unit/hw-getAddress.unit.test.d.ts +0 -2
- package/lib-es/__tests__/unit/hw-getAddress.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/unit/hw-getAddress.unit.test.js +0 -49
- package/lib-es/__tests__/unit/hw-getAddress.unit.test.js.map +0 -1
- package/lib-es/__tests__/unit/logic.unit.test.d.ts +0 -2
- package/lib-es/__tests__/unit/logic.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/unit/logic.unit.test.js +0 -16
- package/lib-es/__tests__/unit/logic.unit.test.js.map +0 -1
- package/lib-es/__tests__/unit/prepareTransaction.unit.test.d.ts +0 -2
- package/lib-es/__tests__/unit/prepareTransaction.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/unit/prepareTransaction.unit.test.js +0 -81
- package/lib-es/__tests__/unit/prepareTransaction.unit.test.js.map +0 -1
- package/lib-es/__tests__/unit/signOperation.unit.test.d.ts +0 -2
- package/lib-es/__tests__/unit/signOperation.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/unit/signOperation.unit.test.js +0 -67
- package/lib-es/__tests__/unit/signOperation.unit.test.js.map +0 -1
- package/lib-es/__tests__/unit/txn.unit.test.d.ts +0 -2
- package/lib-es/__tests__/unit/txn.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/unit/txn.unit.test.js +0 -293
- package/lib-es/__tests__/unit/txn.unit.test.js.map +0 -1
- package/lib-es/__tests__/unit/utils.unit.test.d.ts +0 -2
- package/lib-es/__tests__/unit/utils.unit.test.d.ts.map +0 -1
- package/lib-es/__tests__/unit/utils.unit.test.js +0 -186
- package/lib-es/__tests__/unit/utils.unit.test.js.map +0 -1
- package/lib-es/transaction.unit.test.d.ts +0 -2
- package/lib-es/transaction.unit.test.d.ts.map +0 -1
- package/lib-es/transaction.unit.test.js +0 -595
- package/lib-es/transaction.unit.test.js.map +0 -1
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { AmountRequired, InvalidAddress, InvalidAddressBecauseDestinationIsAlsoSource, NotEnoughBalance, RecipientRequired, } from "@ledgerhq/errors";
|
|
2
|
-
import BigNumber from "bignumber.js";
|
|
3
|
-
import { TonCommentInvalid, TonExcessFee } from "../../errors";
|
|
4
|
-
import getTransactionStatus from "../../getTransactionStatus";
|
|
5
|
-
import { account, transaction as baseTransaction, jettonTransaction, } from "../fixtures/common.fixtures";
|
|
6
|
-
describe("getTransactionStatus", () => {
|
|
7
|
-
describe("Recipient", () => {
|
|
8
|
-
it("should detect the missing recipient and have an error", async () => {
|
|
9
|
-
const transaction = { ...baseTransaction, recipient: "" };
|
|
10
|
-
const res = await getTransactionStatus(account, transaction);
|
|
11
|
-
expect(res.errors).toEqual(expect.objectContaining({
|
|
12
|
-
recipient: new RecipientRequired(),
|
|
13
|
-
}));
|
|
14
|
-
});
|
|
15
|
-
it("should detect the incorrect recipient and have an error", async () => {
|
|
16
|
-
const transaction = { ...baseTransaction, recipient: "isInvalid" };
|
|
17
|
-
const res = await getTransactionStatus(account, transaction);
|
|
18
|
-
expect(res.errors).toEqual(expect.objectContaining({
|
|
19
|
-
recipient: new InvalidAddress("", {
|
|
20
|
-
currencyName: account.currency.name,
|
|
21
|
-
}),
|
|
22
|
-
}));
|
|
23
|
-
});
|
|
24
|
-
it("should detect the recipient and the sender are the same and have an error", async () => {
|
|
25
|
-
const transaction = {
|
|
26
|
-
...baseTransaction,
|
|
27
|
-
recipient: "UQDzd8aeBOU-jqYw_ZSuZjceI5p-F4b7HMprAsUJAtRPbMol",
|
|
28
|
-
};
|
|
29
|
-
const res = await getTransactionStatus(account, transaction);
|
|
30
|
-
expect(res.errors).toEqual(expect.objectContaining({
|
|
31
|
-
recipient: new InvalidAddressBecauseDestinationIsAlsoSource("", {
|
|
32
|
-
currencyName: account.currency.name,
|
|
33
|
-
}),
|
|
34
|
-
}));
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
describe("Sender", () => {
|
|
38
|
-
it("should detect the sender is not correct and have an error", async () => {
|
|
39
|
-
const tempAccount = { ...account, freshAddress: "isInvalid" };
|
|
40
|
-
const res = await getTransactionStatus(tempAccount, baseTransaction);
|
|
41
|
-
expect(res.errors).toEqual(expect.objectContaining({
|
|
42
|
-
sender: new InvalidAddress(),
|
|
43
|
-
}));
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
describe("Amount", () => {
|
|
47
|
-
it("should detect the amount is missing and have an error", async () => {
|
|
48
|
-
const transaction = { ...baseTransaction, amount: new BigNumber(0) };
|
|
49
|
-
const res = await getTransactionStatus(account, transaction);
|
|
50
|
-
expect(res.errors).toEqual(expect.objectContaining({
|
|
51
|
-
amount: new AmountRequired(),
|
|
52
|
-
}));
|
|
53
|
-
});
|
|
54
|
-
it("should detect the amount is greater than the spendable amount and have an error", async () => {
|
|
55
|
-
const transaction = {
|
|
56
|
-
...baseTransaction,
|
|
57
|
-
amount: BigNumber(1000000002),
|
|
58
|
-
fees: new BigNumber("20"),
|
|
59
|
-
};
|
|
60
|
-
const res = await getTransactionStatus(account, transaction);
|
|
61
|
-
expect(res.errors).toEqual(expect.objectContaining({
|
|
62
|
-
amount: new NotEnoughBalance(),
|
|
63
|
-
}));
|
|
64
|
-
});
|
|
65
|
-
it("should detect the amount is greater than the spendable amount of the token account and have an error", async () => {
|
|
66
|
-
const transaction = {
|
|
67
|
-
...jettonTransaction,
|
|
68
|
-
amount: BigNumber(1000000002),
|
|
69
|
-
fees: new BigNumber("20"),
|
|
70
|
-
};
|
|
71
|
-
const res = await getTransactionStatus(account, transaction);
|
|
72
|
-
expect(res.errors).toEqual(expect.objectContaining({
|
|
73
|
-
amount: new NotEnoughBalance(),
|
|
74
|
-
}));
|
|
75
|
-
});
|
|
76
|
-
it("should detect the transaction is a jetton transfer and have a warning", async () => {
|
|
77
|
-
const transaction = {
|
|
78
|
-
...jettonTransaction,
|
|
79
|
-
amount: BigNumber(1000000002),
|
|
80
|
-
fees: new BigNumber("20"),
|
|
81
|
-
};
|
|
82
|
-
const res = await getTransactionStatus(account, transaction);
|
|
83
|
-
expect(res.warnings).toEqual(expect.objectContaining({
|
|
84
|
-
amount: new TonExcessFee(),
|
|
85
|
-
}));
|
|
86
|
-
});
|
|
87
|
-
describe("Comment", () => {
|
|
88
|
-
it("should detect the comment is not valid and have an error", async () => {
|
|
89
|
-
const transaction = {
|
|
90
|
-
...baseTransaction,
|
|
91
|
-
amount: new BigNumber("1"),
|
|
92
|
-
comment: { isEncrypted: false, text: "comment\nInvalid" },
|
|
93
|
-
};
|
|
94
|
-
const res = await getTransactionStatus(account, transaction);
|
|
95
|
-
expect(res.errors).toEqual(expect.objectContaining({
|
|
96
|
-
transaction: new TonCommentInvalid(),
|
|
97
|
-
}));
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
describe("Successful transaction", () => {
|
|
101
|
-
it("should not have errors", async () => {
|
|
102
|
-
const successfulResult = {
|
|
103
|
-
amount: baseTransaction.amount,
|
|
104
|
-
errors: {},
|
|
105
|
-
warnings: {},
|
|
106
|
-
estimatedFees: baseTransaction.fees,
|
|
107
|
-
totalSpent: baseTransaction.amount.plus(baseTransaction.fees),
|
|
108
|
-
};
|
|
109
|
-
const res = await getTransactionStatus(account, baseTransaction);
|
|
110
|
-
expect(res).toEqual(successfulResult);
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
//# sourceMappingURL=getTransactionStatus.unit.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getTransactionStatus.unit.test.js","sourceRoot":"","sources":["../../../src/__tests__/unit/getTransactionStatus.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACd,4CAA4C,EAC5C,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC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,0 @@
|
|
|
1
|
-
{"version":3,"file":"hw-getAddress.unit.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/unit/hw-getAddress.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets";
|
|
2
|
-
import resolver from "../../hw-getAddress";
|
|
3
|
-
import { getLedgerTonPath } from "../../utils";
|
|
4
|
-
const address = "0xc3f95102d5c8f2c83e49ce3acfb905edfb7f37de";
|
|
5
|
-
const publicKey = "mockedPublicKey";
|
|
6
|
-
const spyGetAddress = jest.fn().mockImplementation(async () => Promise.resolve({
|
|
7
|
-
publicKey,
|
|
8
|
-
address: address.toLowerCase(),
|
|
9
|
-
}));
|
|
10
|
-
const spyValidateAddress = jest.fn().mockImplementation(async () => Promise.resolve({
|
|
11
|
-
publicKey,
|
|
12
|
-
address: address.toLowerCase(),
|
|
13
|
-
}));
|
|
14
|
-
const mockSignerFactory = (_, fn) => fn({
|
|
15
|
-
getAddress: spyGetAddress,
|
|
16
|
-
validateAddress: spyValidateAddress,
|
|
17
|
-
signTransaction: jest.fn(),
|
|
18
|
-
});
|
|
19
|
-
describe("hw-getAddress", () => {
|
|
20
|
-
it("should return an encoded address and a public key when verifiy is false", async () => {
|
|
21
|
-
const getAddress = resolver(mockSignerFactory);
|
|
22
|
-
const response = await getAddress("deviceId", {
|
|
23
|
-
path: "44'/607'/0'/0'/0'/0'",
|
|
24
|
-
verify: false,
|
|
25
|
-
currency: getCryptoCurrencyById("ton"),
|
|
26
|
-
derivationMode: "ton",
|
|
27
|
-
});
|
|
28
|
-
expect(response.address).toBe(address);
|
|
29
|
-
expect(response.publicKey).toBe(publicKey);
|
|
30
|
-
expect(spyGetAddress).toHaveBeenCalledWith(getLedgerTonPath("44'/607'/0'/0'/0'/0'"), {
|
|
31
|
-
bounceable: false,
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
it("should return an encoded address and a public key when verifiy is true", async () => {
|
|
35
|
-
const getAddress = resolver(mockSignerFactory);
|
|
36
|
-
const response = await getAddress("deviceId", {
|
|
37
|
-
path: "44'/607'/0'/0'/0'/0'",
|
|
38
|
-
verify: true,
|
|
39
|
-
currency: getCryptoCurrencyById("ton"),
|
|
40
|
-
derivationMode: "ton",
|
|
41
|
-
});
|
|
42
|
-
expect(response.address).toBe(address);
|
|
43
|
-
expect(response.publicKey).toBe(publicKey);
|
|
44
|
-
expect(spyValidateAddress).toHaveBeenCalledWith(getLedgerTonPath("44'/607'/0'/0'/0'/0'"), {
|
|
45
|
-
bounceable: false,
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
//# sourceMappingURL=hw-getAddress.unit.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hw-getAddress.unit.test.js","sourceRoot":"","sources":["../../../src/__tests__/unit/hw-getAddress.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,OAAO,GAAG,4CAA4C,CAAC;AAC7D,MAAM,SAAS,GAAG,iBAAiB,CAAC;AACpC,MAAM,aAAa,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,KAAK,IAAI,EAAE,CAC5D,OAAO,CAAC,OAAO,CAAC;IACd,SAAS;IACT,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE;CAC/B,CAAC,CACH,CAAC;AACF,MAAM,kBAAkB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,KAAK,IAAI,EAAE,CACjE,OAAO,CAAC,OAAO,CAAC;IACd,SAAS;IACT,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE;CAC/B,CAAC,CACH,CAAC;AAEF,MAAM,iBAAiB,GA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AAQ,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3C,MAAM,CAAC,kBAAkB,CAAC,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,EAAE;YACxF,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logic.unit.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/unit/logic.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { getCryptoCurrencyById, findTokenById } from "@ledgerhq/cryptoassets";
|
|
2
|
-
import { getSyncHash } from "../../logic";
|
|
3
|
-
describe("getSyncHash", () => {
|
|
4
|
-
const currency = getCryptoCurrencyById("ton");
|
|
5
|
-
it("should provide a valid hex hash", () => {
|
|
6
|
-
// mumurhash is always returning a 32bits uint, so a 4 bytes hexa string
|
|
7
|
-
expect(getSyncHash(currency, [])).toStrictEqual(expect.stringMatching(/^0x[A-Fa-f0-9]{8}$/));
|
|
8
|
-
});
|
|
9
|
-
it("should provide a new hash if a token is added to the blacklistedTokenIds", () => {
|
|
10
|
-
const token = findTokenById("ton/jetton/eqcxe6mutqjkfngfarotkot1lzbdiix1kcixrv7nw2id_sds");
|
|
11
|
-
if (!token)
|
|
12
|
-
throw new Error("TON jetton token not found");
|
|
13
|
-
expect(getSyncHash(currency, [])).not.toEqual(getSyncHash(currency, [token.id]));
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=logic.unit.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logic.unit.test.js","sourceRoot":"","sources":["../../../src/__tests__/unit/logic.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,MAAM,QAAQ,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAE9C,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,wEAAwE;QACxE,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAC/F,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0EAA0E,EAAE,GAAG,EAAE;QAClF,MAAM,KAAK,GAAG,aAAa,CAAC,6DAA6D,CAAC,CAAC;QAC3F,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAC1D,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACnF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prepareTransaction.unit.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/unit/prepareTransaction.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import BigNumber from "bignumber.js";
|
|
2
|
-
import { estimateFee, fetchAccountInfo } from "../../bridge/bridgeHelpers/api";
|
|
3
|
-
import { setCoinConfig } from "../../config";
|
|
4
|
-
import prepareTransaction from "../../prepareTransaction";
|
|
5
|
-
import mockServer, { API_TON_ENDPOINT } from "../fixtures/api.fixtures";
|
|
6
|
-
import { account, accountInfo, transaction as baseTransaction, fees, jettonTransaction, totalFees, } from "../fixtures/common.fixtures";
|
|
7
|
-
jest.mock("../../bridge/bridgeHelpers/api");
|
|
8
|
-
describe("prepareTransaction", () => {
|
|
9
|
-
beforeAll(() => {
|
|
10
|
-
const fetchAccountInfoMock = jest.mocked(fetchAccountInfo);
|
|
11
|
-
fetchAccountInfoMock.mockReturnValue(Promise.resolve(accountInfo));
|
|
12
|
-
const fetchEstimateFeeMock = jest.mocked(estimateFee);
|
|
13
|
-
fetchEstimateFeeMock.mockReturnValue(Promise.resolve(fees));
|
|
14
|
-
setCoinConfig(() => ({
|
|
15
|
-
status: {
|
|
16
|
-
type: "active",
|
|
17
|
-
},
|
|
18
|
-
infra: {
|
|
19
|
-
API_TON_ENDPOINT: API_TON_ENDPOINT,
|
|
20
|
-
KNOWN_JETTONS: [],
|
|
21
|
-
},
|
|
22
|
-
}));
|
|
23
|
-
mockServer.listen();
|
|
24
|
-
});
|
|
25
|
-
afterAll(() => {
|
|
26
|
-
mockServer.close();
|
|
27
|
-
});
|
|
28
|
-
describe("Ton Transaction", () => {
|
|
29
|
-
it("should return the transaction with the updated amount and fees", async () => {
|
|
30
|
-
const transaction = await prepareTransaction(account, baseTransaction);
|
|
31
|
-
expect(transaction).toEqual({
|
|
32
|
-
...baseTransaction,
|
|
33
|
-
fees: totalFees,
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
it("should preserve the reference when no change is detected on the transaction", async () => {
|
|
37
|
-
const transaction = await prepareTransaction(account, { ...baseTransaction });
|
|
38
|
-
const transaction2 = await prepareTransaction(account, transaction);
|
|
39
|
-
expect(transaction).toBe(transaction2);
|
|
40
|
-
});
|
|
41
|
-
it("should create a coin transaction using the spendableBalance in the account", async () => {
|
|
42
|
-
const transaction = await prepareTransaction(account, {
|
|
43
|
-
...baseTransaction,
|
|
44
|
-
useAllAmount: true,
|
|
45
|
-
});
|
|
46
|
-
expect(transaction).toEqual({
|
|
47
|
-
...baseTransaction,
|
|
48
|
-
useAllAmount: true,
|
|
49
|
-
fees: totalFees,
|
|
50
|
-
amount: account.spendableBalance.minus(totalFees),
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
describe("Jetton Transaction", () => {
|
|
55
|
-
it("should return the transaction with the updated amount and fees", async () => {
|
|
56
|
-
const transaction = await prepareTransaction(account, jettonTransaction);
|
|
57
|
-
expect(transaction).toEqual({
|
|
58
|
-
...jettonTransaction,
|
|
59
|
-
fees: BigNumber("100000000"),
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
it("should preserve the reference when no change is detected on the transaction", async () => {
|
|
63
|
-
const transaction = await prepareTransaction(account, { ...jettonTransaction });
|
|
64
|
-
const transaction2 = await prepareTransaction(account, transaction);
|
|
65
|
-
expect(transaction).toBe(transaction2);
|
|
66
|
-
});
|
|
67
|
-
it("should create a coin transaction using the spendableBalance in the account", async () => {
|
|
68
|
-
const transaction = await prepareTransaction(account, {
|
|
69
|
-
...jettonTransaction,
|
|
70
|
-
useAllAmount: true,
|
|
71
|
-
});
|
|
72
|
-
expect(transaction).toEqual({
|
|
73
|
-
...jettonTransaction,
|
|
74
|
-
useAllAmount: true,
|
|
75
|
-
fees: BigNumber("100000000"),
|
|
76
|
-
amount: account.subAccounts?.[0].spendableBalance,
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
//# sourceMappingURL=prepareTransaction.unit.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prepareTransaction.unit.test.js","sourceRoot":"","sources":["../../../src/__tests__/unit/prepareTransaction.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,kBAAkB,MAAM,0BAA0B,CAAC;AAC1D,OAAO,UAAU,EAAE,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EACL,OAA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AAC;YAEpE,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,4EAA4E,EAAE,KAAK,IAAI,EAAE;YAC1F,MAAM,WAAW,GAAG,MAAM,kBAAkB,CAAC,OAAO,EAAE;gBACpD,GAAG,iBAAiB;gBACpB,YAAY,EAAE,IAAI;aACnB,CAAC,CAAC;YAEH,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC;gBAC1B,GAAG,iBAAiB;gBACpB,YAAY,EAAE,IAAI;gBAClB,IAAI,EAAE,SAAS,CAAC,WAAW,CAAC;gBAC5B,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,gBAAgB;aAClD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signOperation.unit.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/unit/signOperation.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { Address, Cell, beginCell, storeMessage } from "@ton/core";
|
|
2
|
-
import BigNumber from "bignumber.js";
|
|
3
|
-
import { fetchAccountInfo } from "../../bridge/bridgeHelpers/api";
|
|
4
|
-
import { buildSignOperation } from "../../signOperation";
|
|
5
|
-
import { account, accountInfo, totalFees, transaction } from "../fixtures/common.fixtures";
|
|
6
|
-
jest.mock("../../bridge/bridgeHelpers/api");
|
|
7
|
-
const spySignTransaction = jest.fn().mockImplementation(async () => Promise.resolve(beginCell()
|
|
8
|
-
.store(storeMessage({
|
|
9
|
-
info: {
|
|
10
|
-
type: "external-in",
|
|
11
|
-
dest: Address.parse("EQDzd8aeBOU-jqYw_ZSuZjceI5p-F4b7HMprAsUJAtRPbJfg"),
|
|
12
|
-
importFee: BigInt(0),
|
|
13
|
-
},
|
|
14
|
-
body: new Cell(),
|
|
15
|
-
}))
|
|
16
|
-
.endCell()));
|
|
17
|
-
const mockSignerContext = (_, fn) => {
|
|
18
|
-
return fn({
|
|
19
|
-
signTransaction: spySignTransaction,
|
|
20
|
-
getAddress: jest.fn(),
|
|
21
|
-
validateAddress: jest.fn(),
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
describe("signOperation", () => {
|
|
25
|
-
beforeAll(() => {
|
|
26
|
-
const fetchAccountInfoMock = jest.mocked(fetchAccountInfo);
|
|
27
|
-
fetchAccountInfoMock.mockReturnValue(Promise.resolve(accountInfo));
|
|
28
|
-
});
|
|
29
|
-
it("should return an optimistic operation and a signed hash returned by the app bindings", done => {
|
|
30
|
-
const signOperation = buildSignOperation(mockSignerContext);
|
|
31
|
-
const signOpObservable = signOperation({
|
|
32
|
-
account,
|
|
33
|
-
transaction: { ...transaction, fees: totalFees },
|
|
34
|
-
deviceId: "",
|
|
35
|
-
});
|
|
36
|
-
signOpObservable.subscribe(obs => {
|
|
37
|
-
if (obs.type === "signed") {
|
|
38
|
-
const { signedOperation: { signature, operation }, } = obs;
|
|
39
|
-
const { amount } = transaction;
|
|
40
|
-
expect(operation).toEqual({
|
|
41
|
-
id: "",
|
|
42
|
-
hash: "",
|
|
43
|
-
type: "OUT",
|
|
44
|
-
value: new BigNumber(amount).plus(totalFees),
|
|
45
|
-
fee: totalFees,
|
|
46
|
-
blockHash: null,
|
|
47
|
-
blockHeight: null,
|
|
48
|
-
senders: [account.freshAddress],
|
|
49
|
-
recipients: [transaction.recipient],
|
|
50
|
-
accountId: account.id,
|
|
51
|
-
date: expect.any(Date),
|
|
52
|
-
extra: {
|
|
53
|
-
comment: {
|
|
54
|
-
isEncrypted: false,
|
|
55
|
-
text: "",
|
|
56
|
-
},
|
|
57
|
-
explorerHash: "",
|
|
58
|
-
lt: "",
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
expect(signature).toBe("te6cckEBAQEASAAAi4gB5u+NPAnKfR1MYfspXMxuPEc0/C8N9jmU1gWKEgWontgEQA83fGngTlPo6mMP2UrmY3HiOafheG+xzKawLFCQLUT2wCDSMh+F");
|
|
62
|
-
done();
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
//# sourceMappingURL=signOperation.unit.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signOperation.unit.test.js","sourceRoot":"","sources":["../../../src/__tests__/unit/signOperation.unit.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE3F,IAAI,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;AAE5C,MAAM,kBAAkB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,KAAK,IAAI,EAAE,CACjE,OAAO,CAAC,OAAO,CACb,SAAS,EAAE;KACR,KAAK,CACJ,YAAY,CAAC;IACX,IAAI,EAAE;QACJ,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC;QACvE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;KACrB;IACD,IAAI,EAAE,IAAI,IAAI,EAAE;CACjB,CAAC,CACH;KACA,OAAO,EAAE,CACb,CACF,CAAC;AAEF,MAAM,iBAAiB,GAA6B,CAClD,CAAS,EACT,EAAqC,EACrC,EAAE;IACF,OAAO,EAAE,CAAC;QACR,eAAe,EAAE,kBAAkB;QACnC,UAAU,EAAE,I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