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

Tron USDT #345

Merged
merged 28 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5b781ad
feat: tron core logic added
siandreev Dec 19, 2024
3651f42
Merge branch 'main' into feature/trx-usdt
siandreev Dec 20, 2024
534c4c8
feat: tron usdt page added
siandreev Dec 20, 2024
04fb8cf
feat: add tron receive notification
siandreev Dec 20, 2024
3257dc8
fix: send notification tron
siandreev Dec 23, 2024
65718e8
fix: send tron usdt implemented
siandreev Dec 23, 2024
1d773b8
fix: copy address in header
siandreev Dec 23, 2024
6973fc2
feat: enable tron in dev menu
siandreev Dec 23, 2024
5390bf2
Merge branch 'main' into feature/trx-usdt
siandreev Dec 23, 2024
092af39
Merge branch 'feature/2fa' into feature/trx-usdt
siandreev Dec 24, 2024
2a7e1d0
chore: solve merge conflicts
siandreev Dec 24, 2024
c9c5b01
Merge branch 'feature/2fa' into feature/trx-usdt
siandreev Dec 25, 2024
79a9e62
fix: tron activity
siandreev Dec 26, 2024
9f5733a
Merge branch 'feature/2fa' into feature/trx-usdt
siandreev Dec 26, 2024
ed9e0f9
fix: usdt history for desktop
siandreev Dec 26, 2024
b4577b4
Merge branch 'feature/2fa' into feature/trx-usdt
siandreev Dec 26, 2024
6a2069d
fix: usdt history filters
siandreev Dec 26, 2024
3f5a874
fix: usdt dev settings
siandreev Dec 26, 2024
7100880
Merge branch 'feature/2fa' into feature/trx-usdt
siandreev Dec 27, 2024
0ab64aa
feat: usdt trc20 for mobile layout
siandreev Dec 27, 2024
2625367
fix: support disable tron feature from the backend
siandreev Dec 27, 2024
abf84e1
fix: add tron usdt to tokens order settings
siandreev Dec 27, 2024
56b37a0
feat: mobile home screen, copy tron address
siandreev Dec 27, 2024
0468bb1
fix: check whether tron is enabled or not when new wallets are creating
siandreev Dec 27, 2024
a61c951
chore: ext build
siandreev Jan 6, 2025
5c9036b
fix: transfer notification for tron in twa
siandreev Jan 6, 2025
2692faf
Merge branch 'main' into feature/trx-usdt
KuznetsovNikita Jan 7, 2025
15803ab
Hide export tron in case of account bip39
KuznetsovNikita Jan 7, 2025
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
1 change: 1 addition & 0 deletions apps/desktop/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ REACT_APP_TONCONSOLE_API=https://dev-pro.tonconsole.com
REACT_APP_TG_BOT_ID=6345183204
REACT_APP_TG_BOT_ORIGIN=https://tonkeeper.com
REACT_APP_STONFI_REFERRAL_ADDRESS=UQCthC8ICK7K8Hkfm9smblLFroKrYrEMwZuoD4Nbm5LswUnc
REACT_APP_TRON_API_KEY=
5 changes: 4 additions & 1 deletion apps/desktop/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import { useGlobalPreferencesQuery } from '@tonkeeper/uikit/dist/state/global-pr
import { DesktopManageMultisigsPage } from '@tonkeeper/uikit/dist/desktop-pages/manage-multisig-wallets/DesktopManageMultisigs';
import { useGlobalSetup } from '@tonkeeper/uikit/dist/state/globalSetup';
import { DesktopMultisigOrdersPage } from '@tonkeeper/uikit/dist/desktop-pages/multisig-orders/DesktopMultisigOrders';
import { TronApi } from '@tonkeeper/core/dist/tronApi';

const queryClient = new QueryClient({
defaultOptions: {
Expand Down Expand Up @@ -134,6 +135,7 @@ const langs = 'en,zh_TW,zh_CN,id,ru,it,es,uk,tr,bg,uz,bn';
declare const REACT_APP_TONCONSOLE_API: string;
declare const REACT_APP_TG_BOT_ID: string;
declare const REACT_APP_STONFI_REFERRAL_ADDRESS: string;
declare const REACT_APP_TRON_API_KEY: string;

export const Providers = () => {
const { t: tSimple, i18n } = useTranslation();
Expand Down Expand Up @@ -333,7 +335,8 @@ export const Loader: FC = () => {
ios: false,
env: {
tgAuthBotId: REACT_APP_TG_BOT_ID,
stonfiReferralAddress: REACT_APP_STONFI_REFERRAL_ADDRESS
stonfiReferralAddress: REACT_APP_STONFI_REFERRAL_ADDRESS,
tronApiKey: REACT_APP_TRON_API_KEY
},
defaultWalletVersion: WalletVersion.V5R1
};
Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/webpack.plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const plugins = [
process.env.REACT_APP_STONFI_REFERRAL_ADDRESS
),
REACT_APP_APTABASE: JSON.stringify(process.env.REACT_APP_APTABASE),
REACT_APP_APTABASE_HOST: JSON.stringify(process.env.REACT_APP_APTABASE_HOST)
REACT_APP_APTABASE_HOST: JSON.stringify(process.env.REACT_APP_APTABASE_HOST),
REACT_APP_TRON_API_KEY: JSON.stringify(process.env.REACT_APP_TRON_API_KEY)
})
];
3 changes: 2 additions & 1 deletion apps/extension/config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ module.exports = function override(config, env) {
...config.resolve.fallback,
buffer: require.resolve('buffer'),
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify')
stream: require.resolve('stream-browserify'),
'process/browser': require.resolve('process/browser')
};

config.resolve.alias = {
Expand Down
5 changes: 4 additions & 1 deletion apps/extension/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ export const Loader: FC = React.memo(() => {
hideSigner: true,
hideMam: true,
hideMultisig: true,
defaultWalletVersion: WalletVersion.V5R1
defaultWalletVersion: WalletVersion.V5R1,
env: {
tronApiKey: process.env.REACT_APP_TRON_API_KEY
}
};

return (
Expand Down
1 change: 1 addition & 0 deletions apps/tablet/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ VITE_APP_TONCONSOLE_HOST=https://pro.tonconsole.com
VITE_APP_TG_BOT_ID=6345183204
VITE_APP_TG_BOT_ORIGIN=https://tonkeeper.com
VITE_APP_STONFI_REFERRAL_ADDRESS=UQCthC8ICK7K8Hkfm9smblLFroKrYrEMwZuoD4Nbm5LswUnc
VITE_APP_TRON_API_KEY=
3 changes: 2 additions & 1 deletion apps/tablet/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ export const Loader: FC = () => {
ios: false,
env: {
tgAuthBotId: import.meta.env.VITE_APP_TG_BOT_ID,
stonfiReferralAddress: import.meta.env.VITE_APP_STONFI_REFERRAL_ADDRESS
stonfiReferralAddress: import.meta.env.VITE_APP_STONFI_REFERRAL_ADDRESS,
tronApiKey: import.meta.env.VITE_APP_TRON_API_KEY
},
defaultWalletVersion: WalletVersion.V5R1
};
Expand Down
5 changes: 4 additions & 1 deletion apps/twa/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,10 @@ export const Loader: FC<{ sdk: TwaAppSdk }> = ({ sdk }) => {
hideMam: true,
hideMultisig: true,
defaultWalletVersion: WalletVersion.V5R1,
browserLength: 4
browserLength: 4,
env: {
tronApiKey: import.meta.env.VITE_APP_TRON_API_KEY
}
};

return (
Expand Down
45 changes: 34 additions & 11 deletions apps/twa/src/components/transfer/SendNotifications.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { TransferInitParams } from '@tonkeeper/core/dist/AppSdk';
import { BLOCKCHAIN_NAME } from '@tonkeeper/core/dist/entries/crypto';
import { AssetAmount } from '@tonkeeper/core/dist/entries/crypto/asset/asset-amount';
import { toTronAsset } from '@tonkeeper/core/dist/entries/crypto/asset/constants';
import { jettonToTonAsset } from '@tonkeeper/core/dist/entries/crypto/asset/ton-asset';
import { RecipientData } from '@tonkeeper/core/dist/entries/send';
import {
Expand Down Expand Up @@ -34,7 +33,7 @@ import { useAppSdk } from '@tonkeeper/uikit/dist/hooks/appSdk';
import { openIosKeyboard } from '@tonkeeper/uikit/dist/hooks/ios';
import { useTranslation } from '@tonkeeper/uikit/dist/hooks/translation';
import { useJettonList } from '@tonkeeper/uikit/dist/state/jetton';
import { useTronBalances } from '@tonkeeper/uikit/dist/state/tron/tron';
import { useActiveTronWallet, useTronBalances } from "@tonkeeper/uikit/dist/state/tron/tron";
import BigNumber from 'bignumber.js';
import { FC, PropsWithChildren, useCallback, useEffect, useMemo, useRef, useState } from "react";
import { CSSTransition, TransitionGroup } from 'react-transition-group';
Expand All @@ -52,6 +51,8 @@ import {
RecipientTwaHeaderBlock
} from './SendNotificationHeader';
import { useAnalyticsTrack } from '@tonkeeper/uikit/dist/hooks/amplitude';
import { TRON_USDT_ASSET } from "@tonkeeper/core/dist/entries/crypto/asset/constants";
import { seeIfValidTronAddress } from "@tonkeeper/core/dist/utils/common";

const Body = styled.div`
padding: 0 16px 16px;
Expand Down Expand Up @@ -93,10 +94,10 @@ const SendContent: FC<{
}
}, []);

const { data: tronBalances } = useTronBalances();

const { mutateAsync: getAccountAsync, isLoading: isAccountLoading } = useGetToAccount();

const activeTronWallet = useActiveTronWallet();

const setRecipient = (value: RecipientData) => {
if (
amountViewState?.token?.blockchain &&
Expand All @@ -106,8 +107,8 @@ const SendContent: FC<{
}

_setRecipient(value);
if (tronBalances && value.address.blockchain === BLOCKCHAIN_NAME.TRON) {
setAmountViewState({ token: toTronAsset(tronBalances.balances[0]) });
if (activeTronWallet && value.address.blockchain === BLOCKCHAIN_NAME.TRON) {
setAmountViewState({ token: TRON_USDT_ASSET });
}
};

Expand Down Expand Up @@ -152,6 +153,9 @@ const SendContent: FC<{
};

const processTron = (address: string) => {
if (!activeTronWallet) {
return;
}
const item = { address: address, blockchain: BLOCKCHAIN_NAME.TRON } as const;

setRecipient({
Expand Down Expand Up @@ -228,10 +232,9 @@ const SendContent: FC<{
return;
}

// TODO: ENABLE TRON
// if (seeIfValidTronAddress(signature)) {
// return processTron(signature);
// }
if (seeIfValidTronAddress(signature)) {
return processTron(signature);
}

return sdk.uiEvents.emit('copy', {
method: 'copy',
Expand All @@ -258,6 +261,19 @@ const SendContent: FC<{
});
}, [amountViewState?.token, amountViewState?.coinValue]);

let acceptBlockchains: BLOCKCHAIN_NAME[] = [];
if (chain) {
if (chain === BLOCKCHAIN_NAME.TRON && !activeTronWallet) {
acceptBlockchains = [BLOCKCHAIN_NAME.TON];
} else {
acceptBlockchains = [chain];
}
} else {
acceptBlockchains = activeTronWallet
? [BLOCKCHAIN_NAME.TON, BLOCKCHAIN_NAME.TRON]
: [BLOCKCHAIN_NAME.TON];
}

return (
<Wrapper standalone={false} extension={true}>
<HideTwaMainButton />
Expand All @@ -279,7 +295,7 @@ const SendContent: FC<{
onScan={onScan}
keyboard="decimal"
isExternalLoading={isAccountLoading}
acceptBlockchains={chain ? [chain] : undefined}
acceptBlockchains={acceptBlockchains}
MainButton={RecipientTwaMainButton}
HeaderBlock={() => <RecipientTwaHeaderBlock onClose={onClose} />}
fitContent
Expand Down Expand Up @@ -348,6 +364,13 @@ export const TwaSendNotification: FC<PropsWithChildren> = ({ children }) => {
reset();
const transfer = options.params;
setChain(chain);

if (transfer.chain === BLOCKCHAIN_NAME.TRON) {
setOpen(true);
track('send_open', { from: transfer.from });
return;
}

if (transfer.address) {
getAccountAsync({ address: transfer.address }).then(account => {
setTonTransfer(makeTransferInitData(transfer, account, jettons));
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ const Loader: FC = () => {
hideMultisig: isMobile,
env: {
tgAuthBotId: import.meta.env.VITE_APP_TG_BOT_ID,
stonfiReferralAddress: import.meta.env.VITE_APP_STONFI_REFERRAL_ADDRESS
stonfiReferralAddress: import.meta.env.VITE_APP_STONFI_REFERRAL_ADDRESS,
tronApiKey: import.meta.env.VITE_APP_TRON_API_KEY
}
};

Expand Down
5 changes: 3 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"start": "tsc -w",
"sdk": "npm-run-all -p generate:*",
"generate:sdkV2": "rm -fr src/tonApiV2 && docker build -f resource/Dockerfile.apiV2 . -t tonapisdkv2 && docker run --rm --user=$(id -u):$(id -g) -v \"$PWD\":/local tonapisdkv2",
"generate:tronApi": "rm -fr src/tronApi && docker build -f resource/Dockerfile.tronApi . -t tronapisdk && docker run --rm --user=$(id -u):$(id -g) -v \"$PWD\":/local tronapisdk",
"generate:tonConsoleApi": "rm -r ./src/tonConsoleApi || true && npx openapi-typescript-codegen --input 'https://raw.githubusercontent.com/tonkeeper/tonconsole_backend/refs/heads/main/swagger.yaml?token=GHSAT0AAAAAACJYQUOCGQXJBM2BFNOB6XREZ2ZZZCA' --output ./src/tonConsoleApi",
"generate:swapsApi": "rm -r ./src/swapsApi || true && npx openapi-typescript-codegen --input 'https://raw.githubusercontent.com/tonkeeper/swaps-backend/master/swagger.yaml?token=GHSAT0AAAAAACJYQUODBKR67AB7WULZBFWEZSUUGFQ' --output ./src/swapsApi",
"generate:batteryApi": "rm -fr ./src/batteryApi && docker build -f resource/Dockerfile.batteryApi . -t batteryapi && docker run --rm --user=$(id -u):$(id -g) -v \"$PWD\":/local batteryapi",
Expand All @@ -27,13 +26,15 @@
"@ledgerhq/hw-transport-webusb": "^6.28.6",
"@ton-community/ton-ledger": "^7.2.0-pre.3",
"@ton-keychain/core": "^0.0.4",
"@ton-keychain/trx": "^0.0.7",
"@ton/core": "0.56.0",
"@ton/crypto": "3.2.0",
"@ton/ton": "^15.1.0",
"bignumber.js": "^9.1.1",
"bip39": "^3.1.0",
"ethers": "^6.6.5",
"ethers": "^6.13.4",
"query-string": "^8.1.0",
"tronweb": "^6.0.0",
"tweetnacl": "^1.0.3"
}
}
3 changes: 0 additions & 3 deletions packages/core/resource/Dockerfile.tronApi

This file was deleted.

5 changes: 5 additions & 0 deletions packages/core/src/AppSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export type TransferInitParams =
chain: BLOCKCHAIN_NAME.TON;
from: string;
})
| {
chain: BLOCKCHAIN_NAME.TRON;
from: string;
address?: string;
}
| Record<string, never>;

export type ReceiveInitParams = {
Expand Down
Loading
Loading