forked from LedgerHQ/ledger-live
-
Notifications
You must be signed in to change notification settings - Fork 0
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/solana tokens support #2
Open
mikhd
wants to merge
10
commits into
develop
Choose a base branch
from
feat/solana-tokens-support
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cba7310
feat: add serialization of TokenAccount extra fields [coin-framework]
mikhd 655c09c
feat: add burn operation type
mikhd 5d7f7ed
feat: enable solana spl tokens import
mikhd c46972f
feat: finish solana tokens integration into bridge [coin-solana]
mikhd aefc5c5
chore: update solana bridge and speculos tests
mikhd 1c8454c
feat: display solana tokens in LLD
mikhd b1b822d
feat: display solana tokens in LLM
mikhd 6771ce5
chore(LLC): add token account serialization test
mikhd 1e1e4a1
chore: add changeset
mikhd abded20
fix(LLD, LLM): token summary and device screens
mikhd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,11 @@ | ||
--- | ||
"@ledgerhq/cryptoassets": minor | ||
"@ledgerhq/types-live": minor | ||
"@ledgerhq/coin-solana": minor | ||
"ledger-live-desktop": minor | ||
"live-mobile": minor | ||
"@ledgerhq/live-common": minor | ||
"@ledgerhq/coin-framework": minor | ||
--- | ||
|
||
Solana spl tokens support |
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ export const supportLinkByTokenType = { | |
trc20: "https://support.ledger.com/article/360013062159-zd", | ||
asa: "https://support.ledger.com/article/360015896040-zd", | ||
nfts: "https://support.ledger.com/article/4404389453841-zd", | ||
// spl: "Solana spl tokens. TODO: to be defined", | ||
}; | ||
|
||
const errors: Record<string, string> = { | ||
|
@@ -153,6 +154,7 @@ export const urls = { | |
}, | ||
solana: { | ||
staking: "https://support.ledger.com/article/4731749170461-zd", | ||
splTokenInfo: "Solana spl tokens link TODO: to be defined", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
recipient_info: "https://support.ledger.com", | ||
ledgerByFigmentTC: | ||
"https://cdn.figment.io/legal/Current%20Ledger_Online%20Staking%20Delgation%20Services%20Agreement.pdf", | ||
|
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
29 changes: 27 additions & 2 deletions
29
apps/ledger-live-desktop/src/renderer/families/solana/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 |
---|---|---|
@@ -1,5 +1,30 @@ | ||
import React from "react"; | ||
import { Trans } from "react-i18next"; | ||
import { SolanaAccount, SolanaTokenAccount } from "@ledgerhq/live-common/families/solana/types"; | ||
import { isTokenAccountFrozen } from "@ledgerhq/live-common/families/solana/logic"; | ||
import { SubAccount } from "@ledgerhq/types-live"; | ||
|
||
import Box from "~/renderer/components/Box"; | ||
import Alert from "~/renderer/components/Alert"; | ||
import AccountSubHeader from "../../components/AccountSubHeader/index"; | ||
export default function SolanaAccountSubHeader() { | ||
return <AccountSubHeader family="Solana" team="Solana Labs"></AccountSubHeader>; | ||
|
||
type Account = SolanaAccount | SolanaTokenAccount | SubAccount; | ||
|
||
type Props = { | ||
account: Account; | ||
}; | ||
|
||
export default function SolanaAccountSubHeader({ account }: Props) { | ||
return ( | ||
<> | ||
{isTokenAccountFrozen(account) && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To check if it's the right position we want |
||
<Box mb={10}> | ||
<Alert type="warning"> | ||
<Trans i18nKey="solana.token.frozenStateWarning" /> | ||
</Alert> | ||
</Box> | ||
)} | ||
<AccountSubHeader family="Solana" team="Solana Labs"></AccountSubHeader> | ||
</> | ||
); | ||
} |
67 changes: 67 additions & 0 deletions
67
apps/ledger-live-desktop/src/renderer/families/solana/TransactionConfirmFields.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,67 @@ | ||
import React, { useMemo } from "react"; | ||
import { getDeviceTransactionConfig } from "@ledgerhq/live-common/transaction/index"; | ||
import { SolanaFamily } from "./types"; | ||
import Alert from "~/renderer/components/Alert"; | ||
import { Trans } from "react-i18next"; | ||
import ConfirmTitle from "~/renderer/components/TransactionConfirm/ConfirmTitle"; | ||
import LinkWithExternalIcon from "~/renderer/components/LinkWithExternalIcon"; | ||
import Box from "~/renderer/components/Box"; | ||
import { openURL } from "~/renderer/linking"; | ||
import { useLocalizedUrl } from "~/renderer/hooks/useLocalizedUrls"; | ||
import { urls } from "~/config/urls"; | ||
|
||
const Title: TitleComponent = props => { | ||
const { transaction, account, parentAccount, status } = props; | ||
const transferTokenHelpUrl = useLocalizedUrl(urls.solana.splTokenInfo); | ||
|
||
const fields = getDeviceTransactionConfig({ | ||
account, | ||
parentAccount, | ||
transaction, | ||
status, | ||
}); | ||
|
||
const typeTransaction: string | undefined = useMemo(() => { | ||
const typeField = fields.find(field => field.label && field.label === "Type"); | ||
|
||
if (typeField && typeField.type === "text" && typeField.value) { | ||
return typeField.value; | ||
} | ||
}, [fields]); | ||
|
||
if (transaction.model.commandDescriptor?.command.kind === "token.transfer") { | ||
return ( | ||
<Box | ||
flexDirection="column" | ||
alignItems="center" | ||
gap={4} | ||
mb={4} | ||
justifyContent="center" | ||
className="title-test-transfer" | ||
> | ||
<ConfirmTitle title={undefined} typeTransaction={typeTransaction} {...props} /> | ||
<Alert type="warning"> | ||
<Trans i18nKey="solana.token.transferWarning"> | ||
<LinkWithExternalIcon | ||
color="palette.warning.c60" | ||
onClick={() => openURL(transferTokenHelpUrl)} | ||
/> | ||
</Trans> | ||
</Alert> | ||
</Box> | ||
); | ||
} | ||
|
||
return <ConfirmTitle title={undefined} typeTransaction={typeTransaction} {...props} />; | ||
}; | ||
|
||
type TransactionConfirmFields = SolanaFamily["transactionConfirmFields"]; | ||
type TitleComponent = NonNullable<NonNullable<TransactionConfirmFields>["title"]>; | ||
|
||
const transactionConfirmFields: TransactionConfirmFields = { | ||
// footer: Footer, // is not shown without manifestId | ||
// fieldComponents, | ||
title: Title, | ||
}; | ||
|
||
export default transactionConfirmFields; |
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
28 changes: 26 additions & 2 deletions
28
apps/ledger-live-mobile/src/families/solana/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 |
---|---|---|
@@ -1,8 +1,32 @@ | ||
import React from "react"; | ||
import { Trans } from "react-i18next"; | ||
import { SubAccount } from "@ledgerhq/types-live"; | ||
import { Box, Alert, Text } from "@ledgerhq/native-ui"; | ||
import { isTokenAccountFrozen } from "@ledgerhq/live-common/families/solana/logic"; | ||
import { SolanaAccount, SolanaTokenAccount } from "@ledgerhq/live-common/families/solana/types"; | ||
import AccountSubHeader from "~/components/AccountSubHeader"; | ||
|
||
function SolanaAccountSubHeader() { | ||
return <AccountSubHeader family="Solana" team="Solana Labs" />; | ||
type Account = SolanaAccount | SolanaTokenAccount | SubAccount; | ||
|
||
type Props = { | ||
account: Account; | ||
}; | ||
|
||
function SolanaAccountSubHeader({ account }: Props) { | ||
return ( | ||
<> | ||
{isTokenAccountFrozen(account) && ( | ||
<Box mt={6}> | ||
<Alert type="warning"> | ||
<Text variant="body"> | ||
<Trans i18nKey="solana.token.frozenStateWarning" /> | ||
</Text> | ||
</Alert> | ||
</Box> | ||
)} | ||
<AccountSubHeader family="Solana" team="Solana Labs" /> | ||
</> | ||
); | ||
} | ||
|
||
export default SolanaAccountSubHeader; |
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
46 changes: 46 additions & 0 deletions
46
apps/ledger-live-mobile/src/families/solana/TransactionConfirmFields.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,46 @@ | ||
import invariant from "invariant"; | ||
import React from "react"; | ||
import { Linking, View } from "react-native"; | ||
import { Trans } from "react-i18next"; | ||
import { Link } from "@ledgerhq/native-ui"; | ||
import { DeviceTransactionField } from "@ledgerhq/live-common/transaction/index"; | ||
import { | ||
SolanaAccount, | ||
SolanaTokenAccount, | ||
Transaction, | ||
TransactionStatus, | ||
} from "@ledgerhq/live-common/families/solana/types"; | ||
import Alert from "~/components/Alert"; | ||
import { urls } from "~/utils/urls"; | ||
import LText from "~/components/LText"; | ||
|
||
type SolanaFieldComponentProps = { | ||
account: SolanaAccount | SolanaTokenAccount; | ||
parentAccount: SolanaAccount | undefined | null; | ||
transaction: Transaction; | ||
status: TransactionStatus; | ||
field: DeviceTransactionField; | ||
}; | ||
|
||
const Warning = ({ transaction }: SolanaFieldComponentProps) => { | ||
invariant(transaction.family === "solana", "solana transaction"); | ||
if (transaction.model.commandDescriptor?.command.kind === "token.transfer") { | ||
return ( | ||
<View> | ||
<Alert type="hint"> | ||
<LText> | ||
<Trans i18nKey="solana.token.transferWarning"> | ||
<Link onPress={() => Linking.openURL(urls.solana.splTokenInfo)} type="color" /> | ||
</Trans> | ||
</LText> | ||
</Alert> | ||
</View> | ||
); | ||
} | ||
return null; | ||
}; | ||
|
||
export default { | ||
warning: Warning, | ||
fieldComponents: {}, | ||
}; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing support article link