Skip to content

Commit

Permalink
Merge pull request #6983 from Zondax/feat/add-ton-jettons
Browse files Browse the repository at this point in the history
Add support for ton and jettons
  • Loading branch information
hedi-edelbloute authored Jul 5, 2024
2 parents 586e638 + 14236ac commit 4e76658
Show file tree
Hide file tree
Showing 106 changed files with 4,028 additions and 139 deletions.
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
45 changes: 22 additions & 23 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -96,29 +96,28 @@ libs/ledger-live-common/src/wallet-api/ @ledgerhq/wallet-api
libs/test-utils/ @ledgerhq/wallet-api

# Devices team
apps/cli/src/commands/devices @ledgerhq/live-devices
**/src/renderer/screens/manager/ @ledgerhq/live-devices
**/screens/CustomImage @ledgerhq/live-devices
**/components/CustomImage @ledgerhq/live-devices
**/SyncOnboarding/** @ledgerhq/live-devices
apps/**/components/DeviceAction/ @ledgerhq/live-devices
apps/ledger-live-mobile/src/screens/MyLedger*/ @ledgerhq/live-devices
apps/ledger-live-mobile/src/newArch/features/FirmwareUpdate/ @ledgerhq/live-devices
apps/web-tools/repl/ @ledgerhq/live-devices
libs/**/devices/ @ledgerhq/live-devices
libs/**/hw-transport-*/ @ledgerhq/live-devices
libs/**/react-native-*/ @ledgerhq/live-devices
libs/**/swift-*/ @ledgerhq/live-devices
libs/**/types-devices/ @ledgerhq/live-devices
libs/ledger-live-common/src/apps/ @ledgerhq/live-devices
libs/ledger-live-common/src/hw/ @ledgerhq/live-devices
libs/ledger-live-common/src/manager/ @ledgerhq/live-devices
libs/ledger-live-common/src/device/ @ledgerhq/live-devices
libs/ledger-live-common/src/device-react/ @ledgerhq/live-devices
libs/ledger-live-common/src/device-core/ @ledgerhq/live-devices
libs/device-core/ @ledgerhq/live-devices
libs/device-react/ @ledgerhq/live-devices
libs/speculos-transport/ @ledgerhq/live-devices
apps/cli/src/commands/devices @ledgerhq/live-devices
**/src/renderer/screens/manager/ @ledgerhq/live-devices
**/screens/CustomImage @ledgerhq/live-devices
**/components/CustomImage @ledgerhq/live-devices
**/SyncOnboarding/** @ledgerhq/live-devices
apps/**/components/DeviceAction/ @ledgerhq/live-devices
apps/ledger-live-mobile/src/screens/MyLedger*/ @ledgerhq/live-devices
apps/ledger-live-mobile/src/newArch/features/FirmwareUpdate/ @ledgerhq/live-devices
apps/web-tools/repl/ @ledgerhq/live-devices
libs/**/devices/ @ledgerhq/live-devices
libs/**/hw-transport-*/ @ledgerhq/live-devices
libs/**/react-native-*/ @ledgerhq/live-devices
libs/**/swift-*/ @ledgerhq/live-devices
libs/**/types-devices/ @ledgerhq/live-devices
libs/ledger-live-common/src/apps/ @ledgerhq/live-devices
libs/ledger-live-common/src/hw/ @ledgerhq/live-devices
libs/ledger-live-common/src/manager/ @ledgerhq/live-devices
libs/ledger-live-common/src/device/ @ledgerhq/live-devices
libs/ledger-live-common/src/deviceSDK/ @ledgerhq/live-devices
libs/device-core/ @ledgerhq/live-devices
libs/device-react/ @ledgerhq/live-devices
libs/speculos-transport/ @ledgerhq/live-devices

# Recover team
apps/ledger-live-desktop/src/renderer/components/RecoverBanner/ @ledgerhq/recover-software
Expand Down
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 @@ -91,6 +91,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 @@ -90,4 +90,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 @@ -79,6 +79,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => {
const blastSepolia = useFeature("currencyBlastSepolia");
const scroll = useFeature("currencyScroll");
const scrollSepolia = useFeature("currencyScrollSepolia");
const ton = useFeature("currencyTon");

const featureFlaggedCurrencies = useMemo(
(): Partial<Record<CryptoCurrencyId, Feature<unknown> | null>> => ({
Expand Down Expand Up @@ -121,6 +122,7 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => {
neon_evm: neonEvm,
lukso,
linea,
ton,
linea_sepolia: lineaSepolia,
blast,
blast_sepolia: blastSepolia,
Expand Down Expand Up @@ -167,6 +169,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 @@ -5714,6 +5718,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.
],
};
12 changes: 12 additions & 0 deletions 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 (14.0.1):
- 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][email protected]/node_modules/expo-image-manipulator/ios`)"
- "ExpoKeepAwake (from `../../../node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/node_modules/expo-keep-awake/ios`)"
- "ExpoModulesCore (from `../../../node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/expo-modules-core`)"
- "ExpoRandom (from `../../../node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/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][email protected]/node_modules/expo-keep-awake/ios"
ExpoModulesCore:
:path: "../../../node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/expo-modules-core"
ExpoRandom:
:path: "../../../node_modules/.pnpm/[email protected][email protected][email protected][email protected][email protected]/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: 099ddce39b39ffb984b45118d031e8713e962a50
FBLazyVector: f64d1e2ea739b4d8f7e4740cde18089cd97fe864
FBReactNativeSpec: 7351d9daa8a692bc3af6eb00a56e4cdb07403431
Firebase: 5f8193dff4b5b7c5d5ef72ae54bb76c08e2b841d
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 @@ -142,6 +142,7 @@
"expo-keep-awake": "~12.8.2",
"expo-modules-autolinking": "^1.10.2",
"expo-modules-core": "^1.11.8",
"expo-random": "^14.0.1",
"fuse.js": "^6.4.6",
"hoist-non-react-statics": "3.3.2",
"i18next": "20.6.1",
Expand All @@ -168,6 +169,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
Loading

0 comments on commit 4e76658

Please sign in to comment.