-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6983 from Zondax/feat/add-ton-jettons
Add support for ton and jettons
- Loading branch information
Showing
106 changed files
with
4,028 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,4 +90,5 @@ setSupportedCurrencies([ | |
"blast_sepolia", | ||
"scroll", | ||
"scroll_sepolia", | ||
"ton", | ||
]); |
6 changes: 6 additions & 0 deletions
6
apps/ledger-live-desktop/src/renderer/families/ton/AccountSubHeader.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | ||
} |
51 changes: 51 additions & 0 deletions
51
apps/ledger-live-desktop/src/renderer/families/ton/CommentField.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
41 changes: 41 additions & 0 deletions
41
apps/ledger-live-desktop/src/renderer/families/ton/SendRecipientFields.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
27
apps/ledger-live-desktop/src/renderer/families/ton/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
31 changes: 31 additions & 0 deletions
31
apps/ledger-live-desktop/src/renderer/families/ton/operationDetails.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
@@ -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): | ||
|
@@ -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) | ||
|
@@ -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`) | ||
|
@@ -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: | ||
|
@@ -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: | ||
|
@@ -1818,6 +1828,7 @@ SPEC CHECKSUMS: | |
ExpoImageManipulator: c1d7cb865eacd620a35659f3da34c70531f10b59 | ||
ExpoKeepAwake: 0f5cad99603a3268e50af9a6eb8b76d0d9ac956c | ||
ExpoModulesCore: 61dc57c6e2a35f2f84baf488146db624e03af4cd | ||
ExpoRandom: 099ddce39b39ffb984b45118d031e8713e962a50 | ||
FBLazyVector: f64d1e2ea739b4d8f7e4740cde18089cd97fe864 | ||
FBReactNativeSpec: 7351d9daa8a692bc3af6eb00a56e4cdb07403431 | ||
Firebase: 5f8193dff4b5b7c5d5ef72ae54bb76c08e2b841d | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.