diff --git a/libs/coin-modules/coin-ton/src/__tests__/fixtures/common.fixtures.ts b/libs/coin-modules/coin-ton/src/__tests__/fixtures/common.fixtures.ts index 3b4eb895e0d5..4a1a08715e5b 100644 --- a/libs/coin-modules/coin-ton/src/__tests__/fixtures/common.fixtures.ts +++ b/libs/coin-modules/coin-ton/src/__tests__/fixtures/common.fixtures.ts @@ -90,7 +90,15 @@ export const tonTransactionResponse: TonTransactionsList = { total_fees: "0", prev_trans_hash: "", prev_trans_lt: "", - description: "", + description: { + aborted: true, + destroyed: false, + compute_ph: { + success: false, + exit_code: -14, + }, + credit_first: true, + }, block_ref: null, in_msg: { source: "0:959EAA8BD0E3A2662D814278D51A6F997946207D48478008BEBE7F45F3EF781F", diff --git a/libs/coin-modules/coin-ton/src/__tests__/integration/bridge.integration.test.ts b/libs/coin-modules/coin-ton/src/__tests__/integration/bridge.integration.test.ts index 87174f210f94..f258b6399605 100644 --- a/libs/coin-modules/coin-ton/src/__tests__/integration/bridge.integration.test.ts +++ b/libs/coin-modules/coin-ton/src/__tests__/integration/bridge.integration.test.ts @@ -123,12 +123,6 @@ export const dataset: DatasetTest = { }, }; -// describe("Ton bridge", () => { -// test.todo( -// "This is an empty test to make jest command pass. Remove it once there is a real test.", -// ); -// }); - /** * NOTE: if tests are added to this file, * like done in libs/coin-polkadot/src/bridge.integration.test.ts for example, diff --git a/libs/coin-modules/coin-ton/src/bridge/bridgeHelpers/api.types.ts b/libs/coin-modules/coin-ton/src/bridge/bridgeHelpers/api.types.ts index d022225b172d..adab71fdbc62 100644 --- a/libs/coin-modules/coin-ton/src/bridge/bridgeHelpers/api.types.ts +++ b/libs/coin-modules/coin-ton/src/bridge/bridgeHelpers/api.types.ts @@ -78,6 +78,22 @@ interface TonBlock { prev_blocks: BlockReference[]; } +interface TrComputePhase { + exit_code: number; + success: boolean; +} + +interface TonDescription { + aborted: boolean; + compute_ph: TrComputePhase; + credit_first: boolean; + storage_ph?: unknown; + credit_ph?: unknown; + action?: unknown; + bounce?: unknown; + destroyed: boolean; +} + export interface TonTransaction { account: string; hash: string; @@ -88,7 +104,7 @@ export interface TonTransaction { total_fees: string; prev_trans_hash: string; prev_trans_lt: string; - description: unknown; + description: TonDescription; block_ref: { workchain: number; shard: string; diff --git a/libs/coin-modules/coin-ton/src/bridge/bridgeHelpers/txn.ts b/libs/coin-modules/coin-ton/src/bridge/bridgeHelpers/txn.ts index 1672ad1d6cf4..e8b19084275c 100644 --- a/libs/coin-modules/coin-ton/src/bridge/bridgeHelpers/txn.ts +++ b/libs/coin-modules/coin-ton/src/bridge/bridgeHelpers/txn.ts @@ -1,4 +1,5 @@ import { encodeOperationId } from "@ledgerhq/coin-framework/operation"; +import { Operation } from "@ledgerhq/types-live"; import { Address } from "@ton/ton"; import BigNumber from "bignumber.js"; import { TonOperation } from "../../types"; @@ -71,32 +72,38 @@ export function mapTxToOps( const date = new Date(tx.now * 1000); // now is defined in seconds const hash = tx.in_msg?.hash ?? tx.hash; // this is the hash we know in signature time + const hasFailed = + tx.description.compute_ph.success === false && tx.description.compute_ph.exit_code !== 0; + if (isReceiving) { + let subOperations: Operation[] | undefined; if (tx.total_fees !== "0") { // these are small amount of fees payed when receiving // we don't want to show them in the charts - ops.push({ - id: encodeOperationId(accountId, hash, "NONE"), - hash, - type: "NONE", - value: BigNumber(tx.total_fees), - fee: BigNumber(0), - blockHeight: tx.mc_block_seqno ?? 1, - blockHash: null, - hasFailed: false, - accountId, - senders: [accountAddr], - recipients: [], - date, - extra: { - lt: tx.lt, - explorerHash: tx.hash, - comment: { - isEncrypted: false, - text: "", + subOperations = [ + { + id: encodeOperationId(accountId, hash, "NONE"), + hash, + type: "NONE", + value: BigNumber(tx.total_fees), + fee: BigNumber(0), + blockHeight: tx.mc_block_seqno ?? 1, + blockHash: null, + hasFailed, + accountId, + senders: [accountAddr], + recipients: [], + date, + extra: { + lt: tx.lt, + explorerHash: tx.hash, + comment: { + isEncrypted: false, + text: "", + }, }, }, - }); + ]; } ops.push({ id: encodeOperationId(accountId, hash, "IN"), @@ -106,7 +113,7 @@ export function mapTxToOps( fee: BigNumber(tx.total_fees), blockHeight: tx.mc_block_seqno ?? 1, blockHash: null, - hasFailed: false, + hasFailed, accountId, senders: getFriendlyAddress(addressBook, tx.in_msg?.source), recipients: [accountAddr], @@ -122,6 +129,7 @@ export function mapTxToOps( : "", }, }, + subOperations, }); } @@ -130,11 +138,11 @@ export function mapTxToOps( id: encodeOperationId(accountId, hash, "OUT"), hash: tx.out_msgs[0].hash, // this hash matches with in_msg.hash of IN transaction type: "OUT", - value: BigNumber(tx.out_msgs[0].value ?? 0).plus(BigNumber(tx.total_fees)), + value: BigNumber(tx.out_msgs[0].value ?? 0), fee: BigNumber(tx.total_fees), blockHeight: tx.mc_block_seqno ?? 1, blockHash: null, - hasFailed: false, + hasFailed, accountId, senders: [accountAddr], recipients: getFriendlyAddress(addressBook, tx.out_msgs[0].destination), diff --git a/libs/ledger-live-common/src/families/ton/__snapshots__/bridge.integration.test.ts.snap b/libs/ledger-live-common/src/families/ton/__snapshots__/bridge.integration.test.ts.snap index 0f683e9b8392..441fa5b3e922 100644 --- a/libs/ledger-live-common/src/families/ton/__snapshots__/bridge.integration.test.ts.snap +++ b/libs/ledger-live-common/src/families/ton/__snapshots__/bridge.integration.test.ts.snap @@ -10,7 +10,7 @@ exports[`ton currency bridge scanAccounts ton seed 1 1`] = ` "freshAddressPath": "44'/607'/0'/0'/0'/0'", "id": "js:2:ton:86196cb40cd25e9e696bc808e3f2c074ce0b39f2a2a9d482a68eafef86e4a060:ton", "index": 0, - "operationsCount": 9, + "operationsCount": 6, "pendingOperations": [], "seedIdentifier": "86196cb40cd25e9e696bc808e3f2c074ce0b39f2a2a9d482a68eafef86e4a060", "spendableBalance": "933174896", @@ -65,7 +65,7 @@ exports[`ton currency bridge scanAccounts ton seed 1 2`] = ` "UQCOvQLYvTcbi5tL9MaDNzuVl3-J3vATimNm9yO5XPafLfV4", ], "type": "OUT", - "value": "55547465", + "value": "50000000", }, { "accountId": "js:2:ton:86196cb40cd25e9e696bc808e3f2c074ce0b39f2a2a9d482a68eafef86e4a060:ton", @@ -92,29 +92,6 @@ exports[`ton currency bridge scanAccounts ton seed 1 2`] = ` "type": "IN", "value": "21509565", }, - { - "accountId": "js:2:ton:86196cb40cd25e9e696bc808e3f2c074ce0b39f2a2a9d482a68eafef86e4a060:ton", - "blockHash": null, - "blockHeight": 37795026, - "extra": { - "comment": { - "isEncrypted": false, - "text": "", - }, - "explorerHash": "zlj5W9f4F4rHDFHzdC3gSa+nKcgobho4MV8JzZWkzoE=", - "lt": "46398669000001", - }, - "fee": "0", - "hasFailed": false, - "hash": "4dDNdHb5JwpES6VYZS6ZyKSDnNNk0i37CLF6sYqD7oc=", - "id": "js:2:ton:86196cb40cd25e9e696bc808e3f2c074ce0b39f2a2a9d482a68eafef86e4a060:ton-4dDNdHb5JwpES6VYZS6ZyKSDnNNk0i37CLF6sYqD7oc=-NONE", - "recipients": [], - "senders": [ - "UQCOvQLYvTcbi5tL9MaDNzuVl3-J3vATimNm9yO5XPafLfV4", - ], - "type": "NONE", - "value": "396411", - }, { "accountId": "js:2:ton:86196cb40cd25e9e696bc808e3f2c074ce0b39f2a2a9d482a68eafef86e4a060:ton", "blockHash": null, @@ -138,7 +115,7 @@ exports[`ton currency bridge scanAccounts ton seed 1 2`] = ` "UQCOvQLYvTcbi5tL9MaDNzuVl3-J3vATimNm9yO5XPafLfV4", ], "type": "OUT", - "value": "52474733", + "value": "50000000", }, { "accountId": "js:2:ton:86196cb40cd25e9e696bc808e3f2c074ce0b39f2a2a9d482a68eafef86e4a060:ton", @@ -165,29 +142,6 @@ exports[`ton currency bridge scanAccounts ton seed 1 2`] = ` "type": "IN", "value": "21509565", }, - { - "accountId": "js:2:ton:86196cb40cd25e9e696bc808e3f2c074ce0b39f2a2a9d482a68eafef86e4a060:ton", - "blockHash": null, - "blockHeight": 37795087, - "extra": { - "comment": { - "isEncrypted": false, - "text": "", - }, - "explorerHash": "3QMpehQMIEz1L9i2RR8NlQ8MEhtIW8OlN9DBmm5PtyM=", - "lt": "46398745000001", - }, - "fee": "0", - "hasFailed": false, - "hash": "ExoMI/oYFVbPvh+Q52cf2Pyq0aL4jSpuwen8nmOvGBo=", - "id": "js:2:ton:86196cb40cd25e9e696bc808e3f2c074ce0b39f2a2a9d482a68eafef86e4a060:ton-ExoMI/oYFVbPvh+Q52cf2Pyq0aL4jSpuwen8nmOvGBo=-NONE", - "recipients": [], - "senders": [ - "UQCOvQLYvTcbi5tL9MaDNzuVl3-J3vATimNm9yO5XPafLfV4", - ], - "type": "NONE", - "value": "396410", - }, { "accountId": "js:2:ton:86196cb40cd25e9e696bc808e3f2c074ce0b39f2a2a9d482a68eafef86e4a060:ton", "blockHash": null, @@ -213,29 +167,6 @@ exports[`ton currency bridge scanAccounts ton seed 1 2`] = ` "type": "IN", "value": "1", }, - { - "accountId": "js:2:ton:86196cb40cd25e9e696bc808e3f2c074ce0b39f2a2a9d482a68eafef86e4a060:ton", - "blockHash": null, - "blockHeight": 37794992, - "extra": { - "comment": { - "isEncrypted": false, - "text": "", - }, - "explorerHash": "XxJMiFGk4BHIwNWy1w4ZdenPc0Bh2No+tpUEIi6sycs=", - "lt": "46398628000001", - }, - "fee": "0", - "hasFailed": false, - "hash": "f73qoft8iF7ANKH32Mq0cRGO9STLYlhuOFVXPQE1jI0=", - "id": "js:2:ton:86196cb40cd25e9e696bc808e3f2c074ce0b39f2a2a9d482a68eafef86e4a060:ton-f73qoft8iF7ANKH32Mq0cRGO9STLYlhuOFVXPQE1jI0=-NONE", - "recipients": [], - "senders": [ - "UQCOvQLYvTcbi5tL9MaDNzuVl3-J3vATimNm9yO5XPafLfV4", - ], - "type": "NONE", - "value": "84142", - }, { "accountId": "js:2:ton:86196cb40cd25e9e696bc808e3f2c074ce0b39f2a2a9d482a68eafef86e4a060:ton", "blockHash": null, diff --git a/libs/ledger-live-common/src/generated/bridge/js.ts b/libs/ledger-live-common/src/generated/bridge/js.ts index 0b0cdfe2a2e7..7693661a58bb 100644 --- a/libs/ledger-live-common/src/generated/bridge/js.ts +++ b/libs/ledger-live-common/src/generated/bridge/js.ts @@ -7,7 +7,6 @@ import filecoin from "../../families/filecoin/bridge/js"; import hedera from "../../families/hedera/bridge/js"; import internet_computer from "../../families/internet_computer/bridge/js"; import stacks from "../../families/stacks/bridge/js"; -import ton from "../../families/ton/bridge/js"; import vechain from "../../families/vechain/bridge/js"; import { bridge as algorand } from "../../families/algorand/setup"; import { bridge as bitcoin } from "../../families/bitcoin/setup"; @@ -32,7 +31,6 @@ export default { hedera, internet_computer, stacks, - ton, vechain, algorand, bitcoin, diff --git a/libs/ledger-live-common/src/generated/deviceTransactionConfig.ts b/libs/ledger-live-common/src/generated/deviceTransactionConfig.ts index e95c272231dc..e1536922edb2 100644 --- a/libs/ledger-live-common/src/generated/deviceTransactionConfig.ts +++ b/libs/ledger-live-common/src/generated/deviceTransactionConfig.ts @@ -7,8 +7,6 @@ import filecoin from "../families/filecoin/deviceTransactionConfig"; import hedera from "../families/hedera/deviceTransactionConfig"; import internet_computer from "../families/internet_computer/deviceTransactionConfig"; import stacks from "../families/stacks/deviceTransactionConfig"; -import ton from "../families/ton/deviceTransactionConfig"; -import tron from "../families/tron/deviceTransactionConfig"; import algorand from "@ledgerhq/coin-algorand/deviceTransactionConfig"; import bitcoin from "@ledgerhq/coin-bitcoin/deviceTransactionConfig"; import cardano from "@ledgerhq/coin-cardano/deviceTransactionConfig"; @@ -32,7 +30,6 @@ export default { hedera, internet_computer, stacks, - ton, algorand, bitcoin, cardano, diff --git a/libs/ledger-live-common/src/generated/hw-getAddress.ts b/libs/ledger-live-common/src/generated/hw-getAddress.ts index 1382b4058095..db449c03701e 100644 --- a/libs/ledger-live-common/src/generated/hw-getAddress.ts +++ b/libs/ledger-live-common/src/generated/hw-getAddress.ts @@ -7,8 +7,6 @@ import filecoin from "../families/filecoin/hw-getAddress"; import hedera from "../families/hedera/hw-getAddress"; import internet_computer from "../families/internet_computer/hw-getAddress"; import stacks from "../families/stacks/hw-getAddress"; -import ton from "../families/ton/hw-getAddress"; -import tron from "../families/tron/hw-getAddress"; import vechain from "../families/vechain/hw-getAddress"; import { resolver as algorand } from "../families/algorand/setup"; import { resolver as bitcoin } from "../families/bitcoin/setup"; @@ -33,7 +31,6 @@ export default { hedera, internet_computer, stacks, - ton, vechain, algorand, bitcoin, diff --git a/libs/ledger-live-common/src/generated/specs.ts b/libs/ledger-live-common/src/generated/specs.ts index 9e7955efb50c..faf9f3a1e434 100644 --- a/libs/ledger-live-common/src/generated/specs.ts +++ b/libs/ledger-live-common/src/generated/specs.ts @@ -7,8 +7,6 @@ import filecoin from "../families/filecoin/specs"; import hedera from "../families/hedera/specs"; import internet_computer from "../families/internet_computer/specs"; import stacks from "../families/stacks/specs"; -import ton from "../families/ton/specs"; -import tron from "../families/tron/specs"; import vechain from "../families/vechain/specs"; import algorand from "@ledgerhq/coin-algorand/specs"; import bitcoin from "@ledgerhq/coin-bitcoin/specs"; @@ -33,7 +31,6 @@ export default { hedera, internet_computer, stacks, - ton, vechain, algorand, bitcoin, diff --git a/libs/ledger-live-common/src/generated/transaction.ts b/libs/ledger-live-common/src/generated/transaction.ts index 76f6708bc5c6..a6a8cccc43db 100644 --- a/libs/ledger-live-common/src/generated/transaction.ts +++ b/libs/ledger-live-common/src/generated/transaction.ts @@ -7,8 +7,6 @@ import filecoin from "../families/filecoin/transaction"; import hedera from "../families/hedera/transaction"; import internet_computer from "../families/internet_computer/transaction"; import stacks from "../families/stacks/transaction"; -import ton from "../families/ton/transaction"; -import tron from "../families/tron/transaction"; import vechain from "../families/vechain/transaction"; import algorand from "@ledgerhq/coin-algorand/transaction"; import bitcoin from "@ledgerhq/coin-bitcoin/transaction"; @@ -33,7 +31,6 @@ export default { hedera, internet_computer, stacks, - ton, vechain, algorand, bitcoin,