-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add another ledger solana validator (#8563)
* feat: add ledger solana validator * add changeset * remove unnecessary code * small fic * fix tests
- Loading branch information
Showing
13 changed files
with
127 additions
and
66 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,7 @@ | ||
--- | ||
"@ledgerhq/coin-solana": minor | ||
"ledger-live-desktop": minor | ||
"@ledgerhq/live-common": minor | ||
--- | ||
|
||
add another ledger solana validator |
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
34 changes: 0 additions & 34 deletions
34
...ger-live-desktop/src/renderer/families/solana/shared/components/LedgerByFigmentTCLink.tsx
This file was deleted.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
...ger-live-desktop/src/renderer/families/solana/shared/components/LedgerValidatorTCLink.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 from "react"; | ||
import LinkWithExternalIcon from "~/renderer/components/LinkWithExternalIcon"; | ||
import { useTranslation } from "react-i18next"; | ||
import { urls } from "~/config/urls"; | ||
import { openURL } from "~/renderer/linking"; | ||
import { | ||
LEDGER_VALIDATORS_VOTE_ACCOUNTS, | ||
LEDGER_VALIDATOR_BY_FIGMENT, | ||
LEDGER_VALIDATOR_BY_CHORUS_ONE, | ||
} from "@ledgerhq/live-common/families/solana/staking"; | ||
|
||
import { Transaction } from "@ledgerhq/live-common/families/solana/types"; | ||
type Props = { | ||
transaction: Transaction; | ||
}; | ||
export default function LedgerValidatorTCLink({ transaction }: Props) { | ||
const { t } = useTranslation(); | ||
if (!shouldShowTC(transaction)) return null; | ||
|
||
const data = getTCInfo(transaction); | ||
if (!data) return null; | ||
|
||
const openLedgerValidatorTC = () => openURL(data.url); | ||
return <LinkWithExternalIcon label={t(data.label)} onClick={openLedgerValidatorTC} />; | ||
} | ||
const shouldShowTC = ({ model }: Transaction) => { | ||
switch (model.kind) { | ||
case "stake.createAccount": | ||
return LEDGER_VALIDATORS_VOTE_ACCOUNTS.includes(model.uiState.delegate.voteAccAddress); | ||
case "stake.delegate": | ||
return LEDGER_VALIDATORS_VOTE_ACCOUNTS.includes(model.uiState.voteAccAddr); | ||
default: | ||
break; | ||
} | ||
return false; | ||
}; | ||
|
||
const getTCInfo = ({ model }: Transaction) => { | ||
const TC_INFO: Record<string, { label: string; url: string }> = { | ||
[LEDGER_VALIDATOR_BY_CHORUS_ONE.voteAccount]: { | ||
label: "solana.delegation.ledgerByChorusOneTC", | ||
url: urls.solana.ledgerByChorusOneTC, | ||
}, | ||
[LEDGER_VALIDATOR_BY_FIGMENT.voteAccount]: { | ||
label: "solana.delegation.ledgerByFigmentTC", | ||
url: urls.solana.ledgerByFigmentTC, | ||
}, | ||
}; | ||
|
||
switch (model.kind) { | ||
case "stake.createAccount": | ||
return TC_INFO[model.uiState.delegate.voteAccAddress]; | ||
case "stake.delegate": | ||
return TC_INFO[model.uiState.voteAccAddr]; | ||
default: | ||
break; | ||
} | ||
return null; | ||
}; |
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