Skip to content

Commit

Permalink
Feat/integrate aptos (#8396)
Browse files Browse the repository at this point in the history
Integrate Aptos blockchain

---------

Co-authored-by: Vladyslav Belyokhin <[email protected]>
Co-authored-by: Vladyslav Belyokhin <[email protected]>
Co-authored-by: Vladyslav Makarian <[email protected]>
Co-authored-by: João Martins <[email protected]>
Co-authored-by: Oleksii <[email protected]>
Co-authored-by: João Martins <[email protected]>
Co-authored-by: João Guimarães <[email protected]>
Co-authored-by: Pedro Semeano <[email protected]>
Co-authored-by: Victor <[email protected]>
Co-authored-by: João Guimarães <[email protected]>
Co-authored-by: Samy RABAH-MONTAROU <[email protected]>
  • Loading branch information
12 people authored Jan 7, 2025
1 parent 77105fd commit d98a964
Show file tree
Hide file tree
Showing 91 changed files with 6,423 additions and 63 deletions.
16 changes: 16 additions & 0 deletions .changeset/fast-comics-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"@ledgerhq/types-cryptoassets": minor
"@ledgerhq/cryptoassets": minor
"@ledgerhq/hw-app-aptos": minor
"@ledgerhq/types-live": minor
"@ledgerhq/crypto-icons-ui": minor
"@actions/turbo-affected": minor
"ledger-live-desktop": minor
"live-mobile": minor
"@ledgerhq/live-common": minor
"@ledgerhq/coin-framework": minor
"@ledgerhq/live-cli": minor
"@ledgerhq/live-env": minor
---

Support for Aptos blockchain
2 changes: 2 additions & 0 deletions apps/cli/src/live-common-setup-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { WALLET_API_VERSION } from "@ledgerhq/live-common/wallet-api/constants";
setWalletAPIVersion(WALLET_API_VERSION);

setSupportedCurrencies([
"aptos",
"aptos_testnet",
"bitcoin",
"ethereum",
"bsc",
Expand Down
1 change: 1 addition & 0 deletions apps/ledger-live-desktop/scripts/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = (path, options) => {
"@solana/codecs-numbers",
"@solana/codecs-strings",
"@solana/options",
"@aptos-labs/aptos-client",
]);

if (pkgNamesToTarget.has(pkg.name)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ setSupportedCurrencies([
"songbird",
"flare",
"near",
"aptos",
"aptos_testnet",
"icon",
"icon_berlin_testnet",
"optimism",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import IconFees from "~/renderer/icons/Fees";
import IconTrash from "~/renderer/icons/Trash";
import IconLink from "~/renderer/icons/LinkIcon";
import IconCoins from "~/renderer/icons/Coins";
import IconCheck from "~/renderer/icons/Check";
import Freeze from "~/renderer/icons/Freeze";
import Unfreeze from "~/renderer/icons/Unfreeze";
import Box from "~/renderer/components/Box";
Expand Down Expand Up @@ -120,6 +121,7 @@ const iconsComponent = {
STAKE: IconDelegate,
UNSTAKE: IconUndelegate,
WITHDRAW_UNSTAKED: IconCoins,
UNKNOWN: IconCheck,
};
class ConfirmationCheck extends PureComponent<{
marketColor: string;
Expand Down
5 changes: 5 additions & 0 deletions apps/ledger-live-desktop/src/renderer/families/aptos/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { AptosFamily } from "./types";

const family: AptosFamily = {};

export default family;
14 changes: 14 additions & 0 deletions apps/ledger-live-desktop/src/renderer/families/aptos/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {
AptosAccount,
Transaction,
TransactionStatus,
} from "@ledgerhq/live-common/families/aptos/types";
import { Operation } from "@ledgerhq/types-live";
import { FieldComponentProps, LLDCoinFamily } from "../types";

export type AptosFamily = LLDCoinFamily<AptosAccount, Transaction, TransactionStatus, Operation>;
export type AptosFieldComponentProps = FieldComponentProps<
AptosAccount,
Transaction,
TransactionStatus
>;
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const listSupportedTokens = () =>
const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => {
const mock = useEnv("MOCK");

const aptos = useFeature("currencyAptos");
const aptosTestnet = useFeature("currencyAptosTestnet");
const axelar = useFeature("currencyAxelar");
const stargaze = useFeature("currencyStargaze");
const secretNetwork = useFeature("currencySecretNetwork");
Expand Down Expand Up @@ -89,6 +91,8 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => {

const featureFlaggedCurrencies = useMemo(
(): Partial<Record<CryptoCurrencyId, Feature<unknown> | null>> => ({
aptos,
aptos_testnet: aptosTestnet,
axelar,
stargaze,
secret_network: secretNetwork,
Expand Down Expand Up @@ -142,6 +146,8 @@ const StepChooseCurrency = ({ currency, setCurrency }: StepProps) => {
xion,
}),
[
aptos,
aptosTestnet,
axelar,
stargaze,
secretNetwork,
Expand Down
13 changes: 12 additions & 1 deletion apps/ledger-live-desktop/static/i18n/en/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,8 @@
"withdrawUnbondedAmount": "Withdrawn Amount",
"palletMethod": "Method",
"transferAmount": "Transfer Amount",
"validatorsCount": "Validators ({{number}})"
"validatorsCount": "Validators ({{number}})",
"version": "Version"
}
},
"operationList": {
Expand Down Expand Up @@ -5815,6 +5816,16 @@
"title": "Account not scanned by full node",
"description": "Please configure your full node to scan for the accounts associated with this device. Your full node must first scan the blockchain for this account before you can add it to your portfolio."
},
"SequenceNumberTooNew": {
"title": "Sequence number too new"
},
"SequenceNumberTooOld": {
"title": "Sequence number too old",
"description": "Sequence number too old"
},
"TransactionExpired": {
"title": "Transaction expired"
},
"SwapRateExpiredError": {
"title": "Rate Expired",
"description": "Exchange rate expired. Please refresh and try again."
Expand Down
7 changes: 7 additions & 0 deletions apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ const transactionE2E = [
transaction: new Transaction(Account.XRP_1, Account.XRP_2, "0.0001", undefined, "noTag"),
xrayTicket: "B2CQA-2816",
},
/*
TODO: https://ledgerhq.atlassian.net/browse/LIVE-15624 needs to be done to enable it
{
transaction: new Transaction(Account.APTOS_1, Account.APTOS_2, "0.0001"),
xrayTicket: "B2CQA-2920",
},
*/
];

const tokenTransactionInvalid = [
Expand Down
1 change: 1 addition & 0 deletions apps/ledger-live-mobile/scripts/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = (path, options) => {
"@solana/codecs-numbers",
"@solana/codecs-strings",
"@solana/options",
"@aptos-labs/aptos-client",
]);

if (pkgNamesToTarget.has(pkg.name)) {
Expand Down
2 changes: 2 additions & 0 deletions apps/ledger-live-mobile/src/live-common-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ setSupportedCurrencies([
"casper",
"neon_evm",
"lukso",
"aptos",
"aptos_testnet",
"linea",
"linea_sepolia",
"blast",
Expand Down
13 changes: 13 additions & 0 deletions apps/ledger-live-mobile/src/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,18 @@
"title": "Invalid Provider",
"description": "You have to change \"My Ledger provider\" setting. To change it, open Ledger Live \"Settings\", select \"Experimental features\", and then select a different provider."
},
"GasLessThanEstimate": {
"title": "This may be too low. Please increase"
},
"SequenceNumberTooNew": {
"title": "Sequence number too new"
},
"SequenceNumberTooOld": {
"title": "Sequence number too old"
},
"TransactionExpired": {
"title": "Transaction expired"
},
"SequenceNumberError": {
"title": "Sequence number error",
"description": "Please close the window and try again later"
Expand Down Expand Up @@ -3768,6 +3780,7 @@
"to": "To",
"infoTotalTitle": "Total debit",
"infoTotalDesc": "Includes transaction amount and the selected network fees",
"gasFee": "Gas fee",
"gasLimit": "Gas limit",
"gasPrice": "Gas price",
"maxFee": "Max fee",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export default function AddAccountsSelectCrypto({ navigation, route }: Props) {

const mock = useEnv("MOCK");

const aptos = useFeature("currencyAptos");
const aptosTestnet = useFeature("currencyAptosTestnet");
const axelar = useFeature("currencyAxelar");
const stargaze = useFeature("currencyStargaze");
const secretNetwork = useFeature("currencySecretNetwork");
Expand Down Expand Up @@ -111,6 +113,8 @@ export default function AddAccountsSelectCrypto({ navigation, route }: Props) {

const featureFlaggedCurrencies = useMemo(
(): Partial<Record<CryptoCurrencyId, Feature<unknown> | null>> => ({
aptos,
aptos_testnet: aptosTestnet,
axelar,
stargaze,
umee,
Expand Down Expand Up @@ -164,6 +168,8 @@ export default function AddAccountsSelectCrypto({ navigation, route }: Props) {
xion,
}),
[
aptos,
aptosTestnet,
axelar,
stargaze,
umee,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ exports[`formatCurrencyUnit with custom options with locale de-DE should correct

exports[`formatCurrencyUnit with custom options with locale de-DE should correctly format Algorand unit (ALGO) 1`] = `"12.345.678.900,000000- -ALGO"`;

exports[`formatCurrencyUnit with custom options with locale de-DE should correctly format Aptos (Testnet) unit (APT) 1`] = `"123.456.789,00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale de-DE should correctly format Aptos unit (APT) 1`] = `"123.456.789,00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale de-DE should correctly format Arbitrum Sepolia unit (ether) 1`] = `"0,012345678900000000- -𝚝ETH"`;

exports[`formatCurrencyUnit with custom options with locale de-DE should correctly format Arbitrum unit (ETH) 1`] = `"0,012345678900000000- -ETH"`;
Expand Down Expand Up @@ -340,6 +344,10 @@ exports[`formatCurrencyUnit with custom options with locale en-US should correct

exports[`formatCurrencyUnit with custom options with locale en-US should correctly format Algorand unit (ALGO) 1`] = `"12,345,678,900.000000- -ALGO"`;

exports[`formatCurrencyUnit with custom options with locale en-US should correctly format Aptos (Testnet) unit (APT) 1`] = `"123,456,789.00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale en-US should correctly format Aptos unit (APT) 1`] = `"123,456,789.00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale en-US should correctly format Arbitrum Sepolia unit (ether) 1`] = `"0.012345678900000000- -𝚝ETH"`;

exports[`formatCurrencyUnit with custom options with locale en-US should correctly format Arbitrum unit (ETH) 1`] = `"0.012345678900000000- -ETH"`;
Expand Down Expand Up @@ -674,6 +682,10 @@ exports[`formatCurrencyUnit with custom options with locale es-ES should correct

exports[`formatCurrencyUnit with custom options with locale es-ES should correctly format Algorand unit (ALGO) 1`] = `"12.345.678.900,000000- -ALGO"`;

exports[`formatCurrencyUnit with custom options with locale es-ES should correctly format Aptos (Testnet) unit (APT) 1`] = `"123.456.789,00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale es-ES should correctly format Aptos unit (APT) 1`] = `"123.456.789,00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale es-ES should correctly format Arbitrum Sepolia unit (ether) 1`] = `"0,012345678900000000- -𝚝ETH"`;

exports[`formatCurrencyUnit with custom options with locale es-ES should correctly format Arbitrum unit (ETH) 1`] = `"0,012345678900000000- -ETH"`;
Expand Down Expand Up @@ -1008,6 +1020,10 @@ exports[`formatCurrencyUnit with custom options with locale fr-FR should correct

exports[`formatCurrencyUnit with custom options with locale fr-FR should correctly format Algorand unit (ALGO) 1`] = `"12 345 678 900,000000- -ALGO"`;

exports[`formatCurrencyUnit with custom options with locale fr-FR should correctly format Aptos (Testnet) unit (APT) 1`] = `"123 456 789,00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale fr-FR should correctly format Aptos unit (APT) 1`] = `"123 456 789,00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale fr-FR should correctly format Arbitrum Sepolia unit (ether) 1`] = `"0,012345678900000000- -𝚝ETH"`;

exports[`formatCurrencyUnit with custom options with locale fr-FR should correctly format Arbitrum unit (ETH) 1`] = `"0,012345678900000000- -ETH"`;
Expand Down Expand Up @@ -1342,6 +1358,10 @@ exports[`formatCurrencyUnit with custom options with locale ja-JP should correct

exports[`formatCurrencyUnit with custom options with locale ja-JP should correctly format Algorand unit (ALGO) 1`] = `"12,345,678,900.000000- -ALGO"`;

exports[`formatCurrencyUnit with custom options with locale ja-JP should correctly format Aptos (Testnet) unit (APT) 1`] = `"123,456,789.00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale ja-JP should correctly format Aptos unit (APT) 1`] = `"123,456,789.00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale ja-JP should correctly format Arbitrum Sepolia unit (ether) 1`] = `"0.012345678900000000- -𝚝ETH"`;

exports[`formatCurrencyUnit with custom options with locale ja-JP should correctly format Arbitrum unit (ETH) 1`] = `"0.012345678900000000- -ETH"`;
Expand Down Expand Up @@ -1676,6 +1696,10 @@ exports[`formatCurrencyUnit with custom options with locale ko-KR should correct

exports[`formatCurrencyUnit with custom options with locale ko-KR should correctly format Algorand unit (ALGO) 1`] = `"12,345,678,900.000000- -ALGO"`;

exports[`formatCurrencyUnit with custom options with locale ko-KR should correctly format Aptos (Testnet) unit (APT) 1`] = `"123,456,789.00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale ko-KR should correctly format Aptos unit (APT) 1`] = `"123,456,789.00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale ko-KR should correctly format Arbitrum Sepolia unit (ether) 1`] = `"0.012345678900000000- -𝚝ETH"`;

exports[`formatCurrencyUnit with custom options with locale ko-KR should correctly format Arbitrum unit (ETH) 1`] = `"0.012345678900000000- -ETH"`;
Expand Down Expand Up @@ -2010,6 +2034,10 @@ exports[`formatCurrencyUnit with custom options with locale pt-BR should correct

exports[`formatCurrencyUnit with custom options with locale pt-BR should correctly format Algorand unit (ALGO) 1`] = `"12.345.678.900,000000- -ALGO"`;

exports[`formatCurrencyUnit with custom options with locale pt-BR should correctly format Aptos (Testnet) unit (APT) 1`] = `"123.456.789,00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale pt-BR should correctly format Aptos unit (APT) 1`] = `"123.456.789,00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale pt-BR should correctly format Arbitrum Sepolia unit (ether) 1`] = `"0,012345678900000000- -𝚝ETH"`;

exports[`formatCurrencyUnit with custom options with locale pt-BR should correctly format Arbitrum unit (ETH) 1`] = `"0,012345678900000000- -ETH"`;
Expand Down Expand Up @@ -2344,6 +2372,10 @@ exports[`formatCurrencyUnit with custom options with locale ru-RU should correct

exports[`formatCurrencyUnit with custom options with locale ru-RU should correctly format Algorand unit (ALGO) 1`] = `"12 345 678 900,000000- -ALGO"`;

exports[`formatCurrencyUnit with custom options with locale ru-RU should correctly format Aptos (Testnet) unit (APT) 1`] = `"123 456 789,00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale ru-RU should correctly format Aptos unit (APT) 1`] = `"123 456 789,00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale ru-RU should correctly format Arbitrum Sepolia unit (ether) 1`] = `"0,012345678900000000- -𝚝ETH"`;

exports[`formatCurrencyUnit with custom options with locale ru-RU should correctly format Arbitrum unit (ETH) 1`] = `"0,012345678900000000- -ETH"`;
Expand Down Expand Up @@ -2678,6 +2710,10 @@ exports[`formatCurrencyUnit with custom options with locale tr-TR should correct

exports[`formatCurrencyUnit with custom options with locale tr-TR should correctly format Algorand unit (ALGO) 1`] = `"12.345.678.900,000000- -ALGO"`;

exports[`formatCurrencyUnit with custom options with locale tr-TR should correctly format Aptos (Testnet) unit (APT) 1`] = `"123.456.789,00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale tr-TR should correctly format Aptos unit (APT) 1`] = `"123.456.789,00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale tr-TR should correctly format Arbitrum Sepolia unit (ether) 1`] = `"0,012345678900000000- -𝚝ETH"`;

exports[`formatCurrencyUnit with custom options with locale tr-TR should correctly format Arbitrum unit (ETH) 1`] = `"0,012345678900000000- -ETH"`;
Expand Down Expand Up @@ -3012,6 +3048,10 @@ exports[`formatCurrencyUnit with custom options with locale zh-CN should correct

exports[`formatCurrencyUnit with custom options with locale zh-CN should correctly format Algorand unit (ALGO) 1`] = `"12,345,678,900.000000- -ALGO"`;

exports[`formatCurrencyUnit with custom options with locale zh-CN should correctly format Aptos (Testnet) unit (APT) 1`] = `"123,456,789.00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale zh-CN should correctly format Aptos unit (APT) 1`] = `"123,456,789.00000000- -APT"`;

exports[`formatCurrencyUnit with custom options with locale zh-CN should correctly format Arbitrum Sepolia unit (ether) 1`] = `"0.012345678900000000- -𝚝ETH"`;

exports[`formatCurrencyUnit with custom options with locale zh-CN should correctly format Arbitrum unit (ETH) 1`] = `"0.012345678900000000- -ETH"`;
Expand Down Expand Up @@ -3346,6 +3386,10 @@ exports[`formatCurrencyUnit with default options should correctly format Akroma

exports[`formatCurrencyUnit with default options should correctly format Algorand unit (ALGO) 1`] = `"12,345,678,900"`;

exports[`formatCurrencyUnit with default options should correctly format Aptos (Testnet) unit (APT) 1`] = `"123,456,789"`;

exports[`formatCurrencyUnit with default options should correctly format Aptos unit (APT) 1`] = `"123,456,789"`;

exports[`formatCurrencyUnit with default options should correctly format Arbitrum Sepolia unit (ether) 1`] = `"0.0123456"`;

exports[`formatCurrencyUnit with default options should correctly format Arbitrum unit (ETH) 1`] = `"0.0123456"`;
Expand Down
3 changes: 3 additions & 0 deletions libs/coin-framework/src/derivation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ const modes: Readonly<Record<DerivationMode, ModeSpec>> = Object.freeze({
startsAt: 1,
tag: "third-party",
},
aptos: {
overridesDerivation: "44'/637'/<account>'/0'/0'",
},
ton: {
overridesDerivation: "44'/607'/0'/0'/<account>'/0'",
},
Expand Down
20 changes: 20 additions & 0 deletions libs/env/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@ const envDefinitions = {
parser: stringParser,
desc: "Rosetta API for ICP",
},
APTOS_API_ENDPOINT: {
def: "https://apt.coin.ledger.com/node/v1",
parser: stringParser,
desc: "API enpoint for Aptos",
},
APTOS_TESTNET_API_ENDPOINT: {
def: "https://apt.coin.ledger-stg.com/node/v1",
parser: stringParser,
desc: "API enpoint for Aptos",
},
APTOS_INDEXER_ENDPOINT: {
def: "https://apt.coin.ledger.com/node/v1/graphql",
parser: stringParser,
desc: "Indexer endpoint for Aptos",
},
APTOS_TESTNET_INDEXER_ENDPOINT: {
def: "https://apt.coin.ledger-stg.com/node/v1/graphql",
parser: stringParser,
desc: "Indexer endpoint for Aptos",
},
API_CASPER_INDEXER_ENDPOINT: {
parser: stringParser,
def: "https://casper.coin.ledger.com/indexer",
Expand Down
Loading

0 comments on commit d98a964

Please sign in to comment.