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

feat(ton): Ton bot tests #33

Open
wants to merge 61 commits into
base: feat/add-ton-jettons
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
d8b88d1
feat(ton): add initial definitions
carlosala Nov 28, 2023
2ad8249
feat(ton): add hw-getAddress and hw-signMessage
carlosala Dec 1, 2023
2cdb15e
feat(ton): add currencyBridge
carlosala Jan 15, 2024
f5308b0
feat(ton): add accountBridge
carlosala Jan 15, 2024
33e84dd
feat(ton): add LLD integration
carlosala Jan 15, 2024
5cdee08
feat(ton): add LLM integration
carlosala Jan 15, 2024
8e6f916
test(ton): add bridge integration test
carlosala Jan 17, 2024
44028ef
test(ton): add ton specs
carlosala Jan 23, 2024
9fb75ff
feat(patches): `buffer` add `Buffer.subarray` polyfill
carlosala Jan 15, 2024
a324704
fix(ton): disable testnet
carlosala Jan 24, 2024
c4a2543
chore: bump pnpm-lock
carlosala Jan 24, 2024
4465407
chore: add changeset
carlosala Jan 24, 2024
d038ba2
refac(ton): move ton to coin-framework
ayelenmurano Apr 9, 2024
c5a2586
chore(ton): Delete unused imports
ayelenmurano Apr 26, 2024
fdb84fa
fix(ton): Rebase adjustments
ayelenmurano May 7, 2024
643cec5
feat(ton): add initial definitions
carlosala Nov 28, 2023
bd9bb5b
chore: bump pnpm-lock
carlosala Jan 24, 2024
74fae7e
refac(ton): move ton to coin-framework
ayelenmurano Apr 9, 2024
fab74a3
TO REMOVE enable testnet and currency
ayelenmurano Apr 10, 2024
c040013
feat(ton): add initial jetton deffinition
ayelenmurano Apr 10, 2024
6c51434
TO REMOVE add test jettons
ayelenmurano Apr 10, 2024
939aab0
--wip-- [skip ci]
ayelenmurano Apr 10, 2024
54f3321
feat(ton): add sync support jettons
ayelenmurano Apr 11, 2024
707586a
fix(ton): display pending operations
ayelenmurano Apr 12, 2024
ea28df1
feat(ton): add jettons data
ayelenmurano Apr 16, 2024
02c4bc1
feat(ton): add ability to sign jetton transfers (in process)
ayelenmurano Apr 16, 2024
c2fc43e
fix(ton): add a missing import
ayelenmurano Apr 16, 2024
0b40c76
feat(ton): sync sub accounts pending op and adjust token transfers
ayelenmurano Apr 18, 2024
595d7ed
chore(ton): fix a typo
ayelenmurano Apr 26, 2024
a909c60
feat(lld): Use msg hash to search the tx in the explorer
ayelenmurano Apr 26, 2024
9ff2a6c
feat(lld): don't allow to send a comment in a token transfer
ayelenmurano Apr 26, 2024
bea2e09
style(ton): lint
ayelenmurano Apr 26, 2024
a06dfda
feat(ton): adjust jettons data
ayelenmurano Apr 26, 2024
7a57b70
chore(ton): delete comments
ayelenmurano Apr 29, 2024
e55163c
refact(ton): use isTokenAccount from coin-framework and clean code
ayelenmurano May 6, 2024
e83c4dc
feat(ton): rebase adjustment
ayelenmurano May 7, 2024
4319d54
feat(ton): add tests and run lint and typecheck commands
ayelenmurano May 14, 2024
03bb59a
feat(ton): adjust jetton transfer fees, refactor get transaction status
ayelenmurano May 17, 2024
8dd4e2d
feat(ton): add jetton icons
ayelenmurano May 21, 2024
7f378f3
feat(ton): add custom config for ton
ayelenmurano May 24, 2024
0deca7d
add changeset
ayelenmurano May 29, 2024
6c881f1
refactor(ton): rebase adjustments
ayelenmurano May 30, 2024
9f37d64
feat(ton): Adjust test changes
ayelenmurano May 30, 2024
afcbf3c
feat(ton): add usdt as jetton
ayelenmurano May 30, 2024
94999e1
refactor(ton): rebase adjustments
ayelenmurano May 30, 2024
abeac84
refactor(ton): solve comments
ayelenmurano Jun 10, 2024
bb4701c
refactor(ton): code style adjustments
ayelenmurano Jun 11, 2024
fc4dcbd
refactor(ton): solve comments
ayelenmurano Jun 12, 2024
39e74d6
feat(ton): Add NOT as jetton and add MEM icon
ayelenmurano Jun 13, 2024
a7b2c07
refactor(ton): add fees payed in the last step, move comment entry to…
ayelenmurano Jun 17, 2024
4ff80ec
fix(ton): add a missing package and fix an import
ayelenmurano Jun 18, 2024
e7152e4
Add unit tests
ayelenmurano Jun 25, 2024
9bf795a
refactor(ton): solve comments and adjust mobile version
ayelenmurano Jun 27, 2024
33521ea
refactor(ton): rebase adjustments and adjust jetton decimals
ayelenmurano Jun 27, 2024
3b96a9c
WIP bot tests
ayelenmurano Jul 3, 2024
38d12d1
refactor(ton): Delete a condition
ayelenmurano Jul 3, 2024
95cfd4a
refactor(ton): run lint:fix command
ayelenmurano Jul 3, 2024
65b6f7f
feat(ton): adjust endpoints to ledger reverse proxy
ayelenmurano Jul 3, 2024
084965c
feat(ton): remove tokens related code
rllola Jul 4, 2024
af132dc
feat(ton): delete jetton integration
ayelenmurano Jul 4, 2024
45d10db
Merge branch 'feat/add-ton-jettons' into ton-bot-tests
rllola Jul 4, 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 @@ -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 @@ -1416,6 +1420,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 @@ -1472,6 +1477,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 @@ -1604,6 +1610,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 @@ -1667,6 +1675,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 @@ -1813,6 +1823,7 @@ SPEC CHECKSUMS:
ExpoImageManipulator: c1d7cb865eacd620a35659f3da34c70531f10b59
ExpoKeepAwake: 0f5cad99603a3268e50af9a6eb8b76d0d9ac956c
ExpoModulesCore: 61dc57c6e2a35f2f84baf488146db624e03af4cd
ExpoRandom: 099ddce39b39ffb984b45118d031e8713e962a50
FBLazyVector: f64d1e2ea739b4d8f7e4740cde18089cd97fe864
FBReactNativeSpec: 7351d9daa8a692bc3af6eb00a56e4cdb07403431
Firebase: 5f8193dff4b5b7c5d5ef72ae54bb76c08e2b841d
Expand Down Expand Up @@ -1869,6 +1880,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 @@ -140,6 +140,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 @@ -166,6 +167,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;
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import type { Transaction as RippleTransaction } from "@ledgerhq/live-common/fam
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 { Device } from "@ledgerhq/live-common/hw/actions/types";
import { Account, Operation, SignedOperation } from "@ledgerhq/types-live";
import BigNumber from "bignumber.js";
Expand Down Expand Up @@ -310,4 +311,18 @@ export type SignTransactionNavigatorParamList = {
| 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