Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TON integration #7394

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
757de54
feat(ton): add initial definitions
carlosala Nov 28, 2023
bc3cac8
feat(ton): add hw-getAddress and hw-signMessage
carlosala Dec 1, 2023
cb79341
feat(ton): add currencyBridge
carlosala Jan 15, 2024
b19df36
feat(ton): add accountBridge
carlosala Jan 15, 2024
89f4ba6
feat(ton): add LLD integration
carlosala Jan 15, 2024
76b56f2
feat(ton): add LLM integration
carlosala Jan 15, 2024
8eb8b81
test(ton): add bridge integration test
carlosala Jan 17, 2024
da98b76
test(ton): add ton specs
carlosala Jan 23, 2024
3c36b7a
feat(patches): `buffer` add `Buffer.subarray` polyfill
carlosala Jan 15, 2024
0ee1fac
fix(ton): disable testnet
carlosala Jan 24, 2024
ffb9ff9
chore: bump pnpm-lock
carlosala Jan 24, 2024
4bd91de
chore: add changeset
carlosala Jan 24, 2024
6bddfe5
refac(ton): move ton to coin-framework
ayelenmurano Apr 9, 2024
88755d5
chore(ton): Delete unused imports
ayelenmurano Apr 26, 2024
f911d13
fix(ton): Rebase adjustments
ayelenmurano May 7, 2024
02e4c09
feat(ton): add initial definitions
carlosala Nov 28, 2023
899df6a
chore: bump pnpm-lock
carlosala Jan 24, 2024
a179138
refac(ton): move ton to coin-framework
ayelenmurano Apr 9, 2024
a5c7c3a
TO REMOVE enable testnet and currency
ayelenmurano Apr 10, 2024
bb9dbda
feat(ton): add initial jetton deffinition
ayelenmurano Apr 10, 2024
b59ead1
TO REMOVE add test jettons
ayelenmurano Apr 10, 2024
a7a373a
--wip-- [skip ci]
ayelenmurano Apr 10, 2024
52189a5
feat(ton): add sync support jettons
ayelenmurano Apr 11, 2024
733ab1b
fix(ton): display pending operations
ayelenmurano Apr 12, 2024
5b0e72b
feat(ton): add jettons data
ayelenmurano Apr 16, 2024
cb30ee1
feat(ton): add ability to sign jetton transfers (in process)
ayelenmurano Apr 16, 2024
1545694
fix(ton): add a missing import
ayelenmurano Apr 16, 2024
db7b4a0
feat(ton): sync sub accounts pending op and adjust token transfers
ayelenmurano Apr 18, 2024
2252c5a
chore(ton): fix a typo
ayelenmurano Apr 26, 2024
e33412f
feat(lld): Use msg hash to search the tx in the explorer
ayelenmurano Apr 26, 2024
8811a29
feat(lld): don't allow to send a comment in a token transfer
ayelenmurano Apr 26, 2024
69020fc
style(ton): lint
ayelenmurano Apr 26, 2024
1b2f5ec
feat(ton): adjust jettons data
ayelenmurano Apr 26, 2024
9c5c7b2
chore(ton): delete comments
ayelenmurano Apr 29, 2024
f9d3423
refact(ton): use isTokenAccount from coin-framework and clean code
ayelenmurano May 6, 2024
79d32ad
feat(ton): rebase adjustment
ayelenmurano May 7, 2024
6060dba
feat(ton): add tests and run lint and typecheck commands
ayelenmurano May 14, 2024
e6d3f50
feat(ton): adjust jetton transfer fees, refactor get transaction status
ayelenmurano May 17, 2024
08e91ea
feat(ton): add jetton icons
ayelenmurano May 21, 2024
f28d91d
feat(ton): add custom config for ton
ayelenmurano May 24, 2024
7016bc7
add changeset
ayelenmurano May 29, 2024
e83cd27
refactor(ton): rebase adjustments
ayelenmurano May 30, 2024
11c8a25
feat(ton): Adjust test changes
ayelenmurano May 30, 2024
b305751
feat(ton): add usdt as jetton
ayelenmurano May 30, 2024
f15deb6
refactor(ton): rebase adjustments
ayelenmurano May 30, 2024
5da03b1
refactor(ton): solve comments
ayelenmurano Jun 10, 2024
50dbf9e
refactor(ton): code style adjustments
ayelenmurano Jun 11, 2024
443ed1d
refactor(ton): solve comments
ayelenmurano Jun 12, 2024
073822f
feat(ton): Add NOT as jetton and add MEM icon
ayelenmurano Jun 13, 2024
3d06c04
refactor(ton): add fees payed in the last step, move comment entry to…
ayelenmurano Jun 17, 2024
c117a43
fix(ton): add a missing package and fix an import
ayelenmurano Jun 18, 2024
f081688
Add unit tests
ayelenmurano Jun 25, 2024
717788c
refactor(ton): solve comments and adjust mobile version
ayelenmurano Jun 27, 2024
c913abc
refactor(ton): rebase adjustments and adjust jetton decimals
ayelenmurano Jun 27, 2024
372c10f
refactor(ton): Delete a condition
ayelenmurano Jul 3, 2024
02e5dcd
refactor(ton): run lint:fix command
ayelenmurano Jul 3, 2024
08aca46
feat(ton): adjust endpoints to ledger reverse proxy
ayelenmurano Jul 3, 2024
4987814
feat(ton): delete jetton integration
ayelenmurano Jul 4, 2024
5efe391
feat(ton): snapshot update
rllola Jul 4, 2024
7141649
feat(ton): add fees as suboperation on IN txs and update snapshot
ayelenmurano Jul 11, 2024
d3f1df0
feat(ton): downgrade expo-random and add deleted icons
ayelenmurano Jul 15, 2024
5fc15d5
feat(ton): solve mobile issue on android
ayelenmurano Jul 17, 2024
3445486
fix: rebase issues
emmanuelm41 Jul 22, 2024
958bf92
fix: pnpm lock and podfile.lock
emmanuelm41 Jul 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .changeset/eleven-hotels-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"@ledgerhq/types-cryptoassets": patch
"@ledgerhq/cryptoassets": patch
"@ledgerhq/types-live": patch
"@ledgerhq/crypto-icons-ui": patch
"@actions/turbo-affected": patch
"@ledgerhq/coin-ton": patch
"ledger-live-desktop": patch
"live-mobile": patch
"@ledgerhq/live-common": patch
"@ledgerhq/coin-framework": patch
"@ledgerhq/live-cli": patch
---

add support for ton
15 changes: 15 additions & 0 deletions .changeset/mean-trees-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"@ledgerhq/types-cryptoassets": minor
"@ledgerhq/cryptoassets": minor
"@ledgerhq/types-live": minor
"@ledgerhq/crypto-icons-ui": minor
"ledger-live-desktop": minor
"live-mobile": minor
"@ledgerhq/live-common": minor
"@ledgerhq/coin-framework": minor
"@ledgerhq/live-config": minor
"@ledgerhq/live-cli": minor
"@ledgerhq/live-env": minor
---

Support for TON blockchain
1 change: 1 addition & 0 deletions apps/cli/src/live-common-setup-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ setSupportedCurrencies([
"lukso",
"filecoin",
"linea",
"ton",
"linea_sepolia",
"blast",
"blast_sepolia",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,5 @@ setSupportedCurrencies([
"blast_sepolia",
"scroll",
"scroll_sepolia",
"ton",
]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from "react";
import AccountSubHeader from "../../components/AccountSubHeader/index";

export default function TonAccountSubHeader() {
return <AccountSubHeader family="TON" team="Zondax"></AccountSubHeader>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { getAccountBridge } from "@ledgerhq/live-common/bridge/index";
import { Transaction, TransactionStatus } from "@ledgerhq/live-common/families/ton/types";
import { Account } from "@ledgerhq/types-live";
import invariant from "invariant";
import React, { useCallback } from "react";
import { useTranslation } from "react-i18next";
import Input from "~/renderer/components/Input";

const CommentField = ({
onChange,
account,
transaction,
status,
}: {
onChange: (a: Transaction) => void;
account: Account;
transaction: Transaction;
status: TransactionStatus;
}) => {
invariant(transaction.family === "ton", "Comment: TON family expected");

const { t } = useTranslation();

const bridge = getAccountBridge(account);

const onCommentFieldChange = useCallback(
(value: string) => {
onChange(
bridge.updateTransaction(transaction, {
comment: { isEncrypted: false, text: value ?? "" },
}),
);
},
[onChange, transaction, bridge],
);

// We use transaction as an error here.
// on the ledger-live mobile
return (
<Input
warning={status.warnings.comment}
error={status.errors.comment}
value={transaction.comment.text}
placeholder={t("families.ton.commentPlaceholder")}
onChange={onCommentFieldChange}
spellCheck="false"
/>
);
};

export default CommentField;
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Transaction, TransactionStatus } from "@ledgerhq/live-common/families/ton/types";
import { Account } from "@ledgerhq/types-live";
import React from "react";
import { Trans } from "react-i18next";
import Box from "~/renderer/components/Box";
import Label from "~/renderer/components/Label";
import LabelInfoTooltip from "~/renderer/components/LabelInfoTooltip";
import CommentField from "./CommentField";

const Root = (props: {
account: Account;
transaction: Transaction;
status: TransactionStatus;
onChange: (a: Transaction) => void;
trackProperties?: object;
}) => {
return (
<Box flow={1}>
<Box mb={10}>
<Label>
<LabelInfoTooltip text={<Trans i18nKey="errors.TonCommentInvalid.title" />}>
<span>
<Trans i18nKey="families.ton.comment" />
</span>
</LabelInfoTooltip>
</Label>
</Box>
<Box mb={15} horizontal grow alignItems="center" justifyContent="space-between">
<Box grow={1}>
<CommentField {...props} />
</Box>
</Box>
</Box>
);
};
export default {
component: Root,
// Transaction is used here to prevent user to forward
// If he format a comment incorrectly
fields: ["comment", "transaction"],
};
27 changes: 27 additions & 0 deletions apps/ledger-live-desktop/src/renderer/families/ton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {
TonOperation,
Transaction,
TransactionStatus,
} from "@ledgerhq/live-common/families/ton/types";
import { Account } from "@ledgerhq/types-live";
import { LLDCoinFamily } from "../types";
import AccountSubHeader from "./AccountSubHeader";
import sendRecipientFields from "./SendRecipientFields";
import operationDetails from "./operationDetails";

const family: LLDCoinFamily<Account, Transaction, TransactionStatus, TonOperation> = {
operationDetails,
AccountSubHeader,
sendRecipientFields,
getTransactionExplorer: (explorerView, operation) =>
explorerView &&
explorerView.tx &&
explorerView.tx.replace(
"$hash",
operation.extra.explorerHash && operation.extra.explorerHash !== ""
? operation.extra.explorerHash
: `by-msg-hash/${operation.hash}`,
),
};

export default family;
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { TonOperation } from "@ledgerhq/live-common/families/ton/types";
import React from "react";
import { Trans } from "react-i18next";
import Ellipsis from "~/renderer/components/Ellipsis";
import {
OpDetailsData,
OpDetailsSection,
OpDetailsTitle,
} from "~/renderer/drawers/OperationDetails/styledComponents";

type OperationDetailsExtraProps = {
operation: TonOperation;
};

const OperationDetailsExtra = ({ operation }: OperationDetailsExtraProps) => {
const { extra } = operation;
return !extra.comment.text ? null : (
<OpDetailsSection key={extra.comment.text}>
<OpDetailsTitle>
<Trans i18nKey={`families.ton.comment`} />
</OpDetailsTitle>
<OpDetailsData>
<Ellipsis>{extra.comment.text}</Ellipsis>
</OpDetailsData>
</OpDetailsSection>
);
};

export default {
OperationDetailsExtra,
};
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => {
const scroll = useFeature("currencyScroll");
const scrollSepolia = useFeature("currencyScrollSepolia");
const icon = useFeature("currencyIcon");
const ton = useFeature("currencyTon");

const featureFlaggedCurrencies = useMemo(
(): Partial<Record<CryptoCurrencyId, Feature<unknown> | null>> => ({
Expand Down Expand Up @@ -122,6 +123,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => {
neon_evm: neonEvm,
lukso,
linea,
ton,
linea_sepolia: lineaSepolia,
blast,
blast_sepolia: blastSepolia,
Expand Down Expand Up @@ -169,6 +171,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => {
neonEvm,
lukso,
linea,
ton,
lineaSepolia,
blast,
blastSepolia,
Expand Down
7 changes: 7 additions & 0 deletions apps/ledger-live-desktop/static/i18n/en/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -5174,6 +5174,10 @@
"memo": "Memo",
"memoWarningText": "When using a Memo, carefully verify the type used with the recipient"
},
"ton": {
"commentPlaceholder": "Optional",
"comment": "Comment"
},
"stellar": {
"memo": "Memo",
"memoType": {
Expand Down Expand Up @@ -5720,6 +5724,9 @@
"title": "Sequence number error",
"description": "Please close the window and try again later"
},
"TonCommentInvalid": {
"title": "Comment must not exceed 120 characters without special characters"
},
"CantScanQRCode": {
"title": "Couldn't scan this QR code: auto-verification not supported by this address"
},
Expand Down
2 changes: 2 additions & 0 deletions apps/ledger-live-mobile/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ module.exports = {
"@babel/plugin-transform-named-capturing-groups-regex",
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-transform-class-static-block",
"@babel/plugin-transform-flow-strip-types",
["@babel/plugin-transform-private-methods", { loose: true }],
"react-native-reanimated/plugin", // react-native-reanimated/plugin has to be listed last.
],
};
14 changes: 13 additions & 1 deletion apps/ledger-live-mobile/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ PODS:
- React-NativeModulesApple
- React-RCTAppDelegate
- ReactCommon/turbomodule/core
- ExpoRandom (13.6.0):
- ExpoModulesCore
- FBLazyVector (0.73.6)
- FBReactNativeSpec (0.73.6):
- RCT-Folly (= 2022.05.16.00)
Expand Down Expand Up @@ -1098,6 +1100,8 @@ PODS:
- React-Core
- react-native-fast-crypto (2.2.0):
- React
- react-native-fast-pbkdf2 (0.3.1):
- React-Core
- react-native-flipper (0.163.0):
- React-Core
- react-native-flipper-performance-plugin (0.4.0):
Expand Down Expand Up @@ -1418,6 +1422,7 @@ DEPENDENCIES:
- "ExpoImageManipulator (from `../../../node_modules/.pnpm/[email protected][email protected][email protected]_@[email protected]._sgbzbk7nfhtlihtns5cja4huei/node_modules/expo-image-manipulator/ios`)"
- "ExpoKeepAwake (from `../../../node_modules/.pnpm/[email protected][email protected][email protected]_@[email protected]_react_gqhplzyroote7enqgwhytprwhq/node_modules/expo-keep-awake/ios`)"
- "ExpoModulesCore (from `../../../node_modules/.pnpm/[email protected][email protected]_@[email protected][email protected][email protected]/node_modules/expo-modules-core`)"
- "ExpoRandom (from `../../../node_modules/.pnpm/[email protected][email protected][email protected]_@[email protected]_react@18._74hzmsxcfy4hq2gp3ztpqsecuu/node_modules/expo-random/ios`)"
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
- FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`)
- Flipper (= 0.201.0)
Expand Down Expand Up @@ -1474,6 +1479,7 @@ DEPENDENCIES:
- react-native-ble-plx (from `../node_modules/react-native-ble-plx`)
- react-native-config (from `../node_modules/react-native-config`)
- react-native-fast-crypto (from `../node_modules/react-native-fast-crypto`)
- react-native-fast-pbkdf2 (from `../node_modules/react-native-fast-pbkdf2`)
- react-native-flipper (from `../node_modules/react-native-flipper`)
- react-native-flipper-performance-plugin (from `../node_modules/react-native-flipper-performance-plugin`)
- react-native-get-random-values (from `../node_modules/react-native-get-random-values`)
Expand Down Expand Up @@ -1607,6 +1613,8 @@ EXTERNAL SOURCES:
:path: "../../../node_modules/.pnpm/[email protected][email protected][email protected]_@[email protected]_react_gqhplzyroote7enqgwhytprwhq/node_modules/expo-keep-awake/ios"
ExpoModulesCore:
:path: "../../../node_modules/.pnpm/[email protected][email protected]_@[email protected][email protected][email protected]/node_modules/expo-modules-core"
ExpoRandom:
:path: "../../../node_modules/.pnpm/[email protected][email protected][email protected]_@[email protected]_react@18._74hzmsxcfy4hq2gp3ztpqsecuu/node_modules/expo-random/ios"
FBLazyVector:
:path: "../node_modules/react-native/Libraries/FBLazyVector"
FBReactNativeSpec:
Expand Down Expand Up @@ -1670,6 +1678,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-config"
react-native-fast-crypto:
:path: "../node_modules/react-native-fast-crypto"
react-native-fast-pbkdf2:
:path: "../node_modules/react-native-fast-pbkdf2"
react-native-flipper:
:path: "../node_modules/react-native-flipper"
react-native-flipper-performance-plugin:
Expand Down Expand Up @@ -1818,6 +1828,7 @@ SPEC CHECKSUMS:
ExpoImageManipulator: c1d7cb865eacd620a35659f3da34c70531f10b59
ExpoKeepAwake: 0f5cad99603a3268e50af9a6eb8b76d0d9ac956c
ExpoModulesCore: 61dc57c6e2a35f2f84baf488146db624e03af4cd
ExpoRandom: f0cd58e154e463d913462f3b445870b12d1c2f12
FBLazyVector: f64d1e2ea739b4d8f7e4740cde18089cd97fe864
FBReactNativeSpec: 7351d9daa8a692bc3af6eb00a56e4cdb07403431
Firebase: 5f8193dff4b5b7c5d5ef72ae54bb76c08e2b841d
Expand All @@ -1844,7 +1855,7 @@ SPEC CHECKSUMS:
libwebp: 1786c9f4ff8a279e4dac1e8f385004d5fc253009
lottie-ios: fcb5e73e17ba4c983140b7d21095c834b3087418
lottie-react-native: 13cd0c4782c3e6bb26bfa4cc2d08bfb84f6d1ab6
MultiplatformBleAdapter: b1fddd0d499b96b607e00f0faa8e60648343dc1d
MultiplatformBleAdapter: ea8bac405ec200d0ca9de0f89afef6f06fb2abbc
nanopb: a0ba3315591a9ae0a16a309ee504766e90db0c96
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
Expand Down Expand Up @@ -1874,6 +1885,7 @@ SPEC CHECKSUMS:
react-native-ble-plx: c040d0123518e121bf4cda02061bf72644f68d15
react-native-config: 86038147314e2e6d10ea9972022aa171e6b1d4d8
react-native-fast-crypto: 5943c42466b86ad70be60d3a5f64bd22251e5d9e
react-native-fast-pbkdf2: 44d6ffa0346863e14100294004a1595ec76b2e9f
react-native-flipper: 2d552a8178d839ef378220101fb7f0cd5b2a8003
react-native-flipper-performance-plugin: 42ec5017abd26e7c5a1f527f2db92c14a90cabdb
react-native-get-random-values: 21325b2244dfa6b58878f51f9aa42821e7ba3d06
Expand Down
2 changes: 2 additions & 0 deletions apps/ledger-live-mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
"expo-keep-awake": "~12.8.2",
"expo-modules-autolinking": "^1.10.2",
"expo-modules-core": "^1.11.8",
"expo-random": "^13.6.0",
"fuse.js": "^6.4.6",
"hoist-non-react-statics": "3.3.2",
"i18next": "20.6.1",
Expand All @@ -171,6 +172,7 @@
"react-native-extra-dimensions-android": "^1.2.5",
"react-native-fast-crypto": "^2.2.0",
"react-native-fast-image": "^8.5.11",
"react-native-fast-pbkdf2": "^0.3.1",
"react-native-gesture-handler": "^2.9.0",
"react-native-get-random-values": "^1.11.0",
"react-native-haptic-feedback": "^2.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import type { Transaction as ICPTransaction } from "@ledgerhq/live-common/famili
import type { Transaction as StellarTransaction } from "@ledgerhq/live-common/families/stellar/types";
import type { Transaction as StacksTransaction } from "@ledgerhq/live-common/families/stacks/types";
import type { Transaction as CasperTransaction } from "@ledgerhq/live-common/families/casper/types";
import type { Transaction as TonTransaction } from "@ledgerhq/live-common/families/ton/types";
import BigNumber from "bignumber.js";
import { Result } from "@ledgerhq/live-common/bridge/useBridgeTransaction";
import { ScreenName } from "~/const";
Expand Down Expand Up @@ -344,4 +345,18 @@ export type SendFundsNavigatorStackParamList = {
| ScreenName.SendSelectDevice
| ScreenName.SwapForm;
};
[ScreenName.TonEditComment]: {
accountId: string;
account: Account;
parentId?: string;
transaction: TonTransaction;
currentNavigation:
| ScreenName.SignTransactionSummary
| ScreenName.SendSummary
| ScreenName.SwapForm;
nextNavigation:
| ScreenName.SignTransactionSelectDevice
| ScreenName.SendSelectDevice
| ScreenName.SwapForm;
};
};
Loading
Loading