-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: solana tokens support [LIVE-12069] (#8119)
* feat: add serialization of TokenAccount extra fields [coin-framework] * feat: add burn operation type * feat: enable solana spl tokens import * feat: finish solana tokens integration into bridge [coin-solana] * chore: update solana bridge and speculos tests * feat: display solana tokens in LLD * feat: display solana tokens in LLM * chore(LLC): add token account serialization test * chore: add changeset * fix(LLD, LLM): token summary and device screens * fix: non existing param used for SPL Tokens * fix: wrong chainId for spl tokens Used the import:cal-tokens to update only spl data * fix: lint issue on missing break * chore: update bridge integration test snapshot for solana * chore: update spl token snapshot * feat: add solana testnet and devnet in supported currencies list * fix: spl priority fees and transaction confirmation with blockHeight * chore: add support links * test: fix with solana testnet and devnet addition * chore: remove comments from review comments * fix: wallet-api spl usage * fix: wallet-api spl token support * test: fix test expectation * test: fix wrong findTokenById call and param * test: fix missing account type * feat: add trusted name resolution for signTransaction * feat: update warning message for LNS * feat: clear sign SPL token address * fix: add error handling for older app versions and unsupported device firmware versions * chore: updated doc * chore: remove unused semver dep * fix: use cal token id for spl and contractAddress instead of manual split on id to get the mint address * fix: replace chainId in spl data by network to get the currencyId from the CAL instead of static data in code * feat: add better error for sol * feat: LLM better error on send validate * test: update sol common snapshot * fix: update following review comments * fix: specify public_key_id to get the correct pki certificate * fix: error or warn if wrong spl address used * fix: error messages and add a warning specific message * test: skip broken frozen test * fix(solana): lld display account if enough balance and display warning if not enough fund for sending token Signed-off-by: Stéphane Prohaszka <[email protected]> * fix: typecheck for new solana amount fields Signed-off-by: Stéphane Prohaszka <[email protected]> * fix: when sending token, consider spendable balance zero as noteoungbalance Signed-off-by: Stéphane Prohaszka <[email protected]> --------- Signed-off-by: Stéphane Prohaszka <[email protected]> Co-authored-by: Mikhail <[email protected]> Co-authored-by: Stéphane Prohaszka <[email protected]>
- Loading branch information
1 parent
bca2b55
commit 41b153a
Showing
84 changed files
with
2,010 additions
and
340 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,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
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
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) && ( | ||
<Box mb={10}> | ||
<Alert type="warning"> | ||
<Trans i18nKey="solana.token.frozenStateWarning" /> | ||
</Alert> | ||
</Box> | ||
)} | ||
<AccountSubHeader family="Solana" team="Solana Labs"></AccountSubHeader> | ||
</> | ||
); | ||
} |
37 changes: 37 additions & 0 deletions
37
apps/ledger-live-desktop/src/renderer/families/solana/SendAmountFields.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,37 @@ | ||
import React from "react"; | ||
import Alert from "~/renderer/components/Alert"; | ||
import { Flex } from "@ledgerhq/react-ui"; | ||
import TranslatedError from "~/renderer/components/TranslatedError"; | ||
import { Account } from "@ledgerhq/types-live"; | ||
import type { Transaction, TransactionStatus } from "@ledgerhq/live-common/families/solana/types"; | ||
|
||
type Props = { | ||
account: Account; | ||
updateTransaction: (updater: (t: Transaction) => Transaction) => void; | ||
onChange: (t: Transaction) => void; | ||
transaction: Transaction; | ||
status: TransactionStatus; | ||
}; | ||
|
||
/** | ||
* SendAmountFields | ||
* | ||
* This component renders an alert message when the user has insufficient fund | ||
* to complete a transaction. | ||
* | ||
*/ | ||
const SendAmountFields = ({ status }: Props) => { | ||
if (!status.errors.fee) return null; | ||
return ( | ||
<Flex> | ||
<Alert type="warning" data-testid="insufficient-funds-warning"> | ||
<TranslatedError error={status.errors.fee} /> | ||
</Alert> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default { | ||
component: SendAmountFields, | ||
fields: [], | ||
}; |
59 changes: 59 additions & 0 deletions
59
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,59 @@ | ||
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 Box from "~/renderer/components/Box"; | ||
import { openURL } from "~/renderer/linking"; | ||
import { useLocalizedUrl } from "~/renderer/hooks/useLocalizedUrls"; | ||
import { urls } from "~/config/urls"; | ||
import { DeviceModelId } from "@ledgerhq/devices"; | ||
import { Link } from "@ledgerhq/react-ui"; | ||
|
||
const Title: TitleComponent = props => { | ||
const { transaction, account, parentAccount, status, device } = 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" && | ||
device.modelId === DeviceModelId.nanoS | ||
) { | ||
return ( | ||
<Box flexDirection="column" alignItems="center" gap={4} mb={4} justifyContent="center"> | ||
<ConfirmTitle title={undefined} typeTransaction={typeTransaction} {...props} /> | ||
<Alert type="warning"> | ||
<Trans i18nKey="solana.token.transferWarning"> | ||
<Link 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 = { | ||
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
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.
41b153a
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.
[Bot] Daily non-reg on develop with 'Nitrogen' ✅ 60 txs ❌ 9 txs 💰 20 miss funds ($606.61) ⏲ 17min 59s
8 critical spec errors
Spec Casper failed!
Spec injective failed!
Spec Polygon zkEVM Testnet failed!
Spec Klaytn failed!
Spec Solana failed!
Spec Stacks failed!
Spec Stellar failed!
Spec VeChain VTHO failed!
❌ 9 mutation errors
Please increase the account target to at least 2 accounts
Please increase the account target to at least 2 accounts
Please increase the account target to at least 2 accounts
Please increase the account target to at least 2 accounts
Portfolio ($606.61) – Details of the 76 currencies
0x246FFDB387F1F8c48072E1C13443540017bC71b7
TM4WJOS4MZ2TD775W7GSXZMBUF74YT6SKSBXCZY3N7OUIAPXE54MZ5FCD4
0xc9ce406c17508f44ed2f1dbd62e0a0363a4335afe2e77dd9d174fffb346293be
tb1qva8ex44kkad8gz4m7yukmc9hdvhml29ych5esm
qqp902dx65k2tn6m7u5lzlyhz28l6s74fqf77n2zhd
AUL61mtqtWafcbRPxKERSqsHyV3MwACYkp
XhdcCVQwH46kmGHw4kH9ZXwquH59SE2QBx
dgb1qkglz2cqxrrl5jmx906yzg6cjtm945zvzxuzqkd
DPMKt6FSk3UXjNya2PKQBiHj4S1W2YiFRh
RREFiv7NjMwJLHcjRU5issiP9sCF5P6PKw
ltc1qj9r8yejpw8q56vhfv4aufcqm2rq08v2pzcfv2s
t1SDpcaNZmbCH5TCCb5vNAh5bXs3isDtA5h
znZg6CYHWANNq6haNXodYfaypHSEoxxPKQE
osmo1rs97j43nfyvc689y5rjvnnhrq3tes6ghn8m44l
desmos1rs97j43nfyvc689y5rjvnnhrq3tes6gh0y9454
dydx1rs97j43nfyvc689y5rjvnnhrq3tes6ghj9xpr6
umee1rs97j43nfyvc689y5rjvnnhrq3tes6ghf2468l
persistence1rs97j43nfyvc689y5rjvnnhrq3tes6gh4swkdf
quick1rs97j43nfyvc689y5rjvnnhrq3tes6ghscch6l
onomy1rs97j43nfyvc689y5rjvnnhrq3tes6ghpaunjg
sei1rs97j43nfyvc689y5rjvnnhrq3tes6ghksen9v
stars1rs97j43nfyvc689y5rjvnnhrq3tes6gh0qlcgu
core1rs97j43nfyvc689y5rjvnnhrq3tes6ghgjs7yk
mantra1rs97j43nfyvc689y5rjvnnhrq3tes6ghshzpqh
cro14zpaxs3msrdnx5ch3m3y3yue0wwwevrf2hmwra
xion1rs97j43nfyvc689y5rjvnnhrq3tes6ghe4j84x
zen1rs97j43nfyvc689y5rjvnnhrq3tes6ghp36y0u
erd18n5sk95fq9dtgdsa9m9q5ddp66ch9cq5lpjflwn5j9z8x2e9h0qqrvk5qp
0x7584df0780C5eB83b26aE55abBc265014f8bf897
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0xb6E8b0371A15CDadF1D8EdA34F78870A5e688B25
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0x60A4E7657D8df28594ac4A06CDe01E18E948a892
0.0.3663977
f2ed4c9253d3aca7d679bfa9f528d13e85c7f522b8857e094c850a157b750209
hxdd614da5f057ce32185619f98edd81445a946ea5
0573d7a9c745fa9fe224b080832aa93d740760b94f192c9c141c709945e9aaaf
tz1aDK1uFAmnUXZ7KJPEmcCEFeYHiVZ56zVF
UQDL7vAIogYGacmfO0xTS1bwPEMJNh1g1Jliwq2p-qWkS1J0
0xc4B17901FECf86932c3bb296BB00E7c6816Fd416
r9etPtq3oboweMPju5gdYufmvwhH2euz8z
Performance ⏲ 17min 59s
Time spent for each spec: (total across mutations)