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

fix(aptos): enhancements corrections #8798

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
4 changes: 0 additions & 4 deletions apps/ledger-live-desktop/static/i18n/en/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2352,10 +2352,6 @@
"ethereumGasPrice": "Gas price",
"ethereumMaxFee": "Max Fee ({{unitName}})",
"ethereumPriorityFee": "Max Priority Fee ({{unitName}})",
"aptosGasFee": "Gas Fee",
"aptosGasLimit": "Gas Limit",
"aptosGasPrice": "Gas Price (OCTAS)",
"aptosSetOptimalGas": "SET OPTIMAL GAS",
"nextBlock": "Next block",
"suggested": "Suggested",
"unitPerByte": "{{unit}} per byte",
Expand Down
8 changes: 4 additions & 4 deletions apps/ledger-live-desktop/tests/specs/speculos/send.tx.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { test } from "../../fixtures/common";
import { Account } from "@ledgerhq/live-common/e2e/enum/Account";
import { Fee } from "@ledgerhq/live-common/e2e/enum/Fee";
import { OperationType } from "@ledgerhq/live-common/e2e/enum/OperationType";
import { Transaction } from "@ledgerhq/live-common/e2e/models/Transaction";
import { getEnv } from "@ledgerhq/live-env";
import { addBugLink, addTmsLink } from "tests/utils/allureUtils";
import { CLI } from "tests/utils/cliUtils";
import { test } from "../../fixtures/common";
import { addTmsLink, addBugLink } from "tests/utils/allureUtils";
import { getDescription } from "../../utils/customJsonReporter";
import { CLI } from "tests/utils/cliUtils";
import { getEnv } from "@ledgerhq/live-env";

//Warning 🚨: XRP Tests may fail due to API HTTP 429 issue - Jira: LIVE-14237

Expand Down
15 changes: 3 additions & 12 deletions apps/ledger-live-mobile/src/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -2559,8 +2559,7 @@
"gasLimit": "Gas Limit",
"id": "Id",
"autoClaimedRewards": "Auto Claimed Rewards",
"stakedAmount": "Staked amount",
"version": "Version"
"stakedAmount": "Staked amount"
},
"multipleAddresses": "Why multiple addresses?",
"tokenName": "Token Name",
Expand Down Expand Up @@ -3775,6 +3774,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 Expand Up @@ -3821,16 +3821,7 @@
"title": "Choose unit"
},
"networkInfo": "Choose the amount of network fees to include in the transaction. The amount of fees affects the processing speed of the transaction",
"networkInfoMaxFees": "This is the maximum amount that you could pay for this transaction. Any difference between the Max network fees and the actual fees will be refunded.",
"aptos": {
"options": "Options",
"gasLimit": "Gas Limit",
"gasPrice": "Gas Price (OCTAS)",
"sequenceNumber": "Sequence Number",
"expTimestamp": "Exp. Timestamp",
"setOptimalGas": "Set optimal gas",
"resetSettings": "Reset settings"
}
"networkInfoMaxFees": "This is the maximum amount that you could pay for this transaction. Any difference between the Max network fees and the actual fees will be refunded."
},
"verification": {
"streaming": {
Expand Down
6 changes: 3 additions & 3 deletions libs/ledger-live-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@
"@types/react": "^18.2.21",
"@types/uuid": "^8.3.4",
"benchmark": "^2.1.4",
"buffer": "6.0.3",
"camelcase": "^6.2.1",
"cross-env": "^7.0.3",
"env-cmd": "*",
Expand All @@ -295,8 +294,9 @@
"ts-jest": "^29.1.1",
"ts-node": "^10.4.0",
"typescript": "5.1.3",
"undici": "6.19.2",
"uuid": "^8.3.2",
"ws": "7"
"ws": "7",
"buffer": "6.0.3",
"undici": "6.19.2"
}
}
44 changes: 22 additions & 22 deletions libs/ledger-live-common/src/__tests__/test-helpers/bridge.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
import { AmountRequired, InvalidAddress, RecipientRequired } from "@ledgerhq/errors";
import { getDefaultAccountName } from "@ledgerhq/live-wallet/accountName";
import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
import type {
Account,
AccountBridge,
AccountLike,
AccountRawLike,
CurrenciesData,
DatasetTest,
SubAccount,
SyncConfig,
TransactionCommon,
TransactionStatusCommon,
} from "@ledgerhq/types-live";
import { BigNumber } from "bignumber.js";
import invariant from "invariant";
import { BigNumber } from "bignumber.js";
import { reduce, filter, map } from "rxjs/operators";
import flatMap from "lodash/flatMap";
import omit from "lodash/omit";
import { firstValueFrom } from "rxjs";
import { filter, map, reduce } from "rxjs/operators";
import { InvalidAddress, RecipientRequired, AmountRequired } from "@ledgerhq/errors";
import {
fromAccountRaw,
toAccountRaw,
decodeAccountId,
encodeAccountId,
flattenAccounts,
fromAccountRaw,
isAccountBalanceUnconfirmed,
toAccountRaw,
} from "../../account";
import { getAccountBridge, getCurrencyBridge } from "../../bridge";
import { getCryptoCurrencyById } from "../../currencies";
import { getOperationAmountNumber } from "../../operation";
import { fromTransactionRaw, toTransactionRaw, toTransactionStatusRaw } from "../../transaction";
import { getAccountBridge, getCurrencyBridge } from "../../bridge";
import { mockDeviceWithAPDUs, releaseMockDevice } from "./mockDevice";
import type {
Account,
AccountBridge,
AccountLike,
AccountRawLike,
SubAccount,
SyncConfig,
DatasetTest,
CurrenciesData,
TransactionCommon,
TransactionStatusCommon,
} from "@ledgerhq/types-live";
import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
import { firstValueFrom } from "rxjs";
import { getDefaultAccountName } from "@ledgerhq/live-wallet/accountName";

const warnDev = process.env.CI ? (..._args) => {} : (...msg) => console.warn(...msg);
// FIXME move out into DatasetTest to be defined in
Expand Down Expand Up @@ -500,7 +500,7 @@ export function testBridge<T extends TransactionCommon>(data: DatasetTest<T>): v
function expectStability(t, patch) {
const t2 = bridge.updateTransaction(t, patch);
const t3 = bridge.updateTransaction(t2, patch);
expect(t2).toStrictEqual(t3);
expect(t2).toBe(t3);
}

makeTest("ref stability on empty transaction", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ setSupportedCurrencies([
"zksync_sepolia",
"mantra",
"aptos",
"aptos_testnet",
"xion",
"aptos",
]);
LiveConfig.setConfig(liveConfig);

Expand Down
11 changes: 5 additions & 6 deletions libs/ledger-live-common/src/families/aptos/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
SimpleTransaction,
TransactionResponse,
UserTransactionResponse,
PostRequestOptions,
} from "@aptos-labs/ts-sdk";
import { getEnv } from "@ledgerhq/live-env";
import network from "@ledgerhq/live-network/network";
Expand All @@ -25,7 +26,7 @@ import type { AptosTransaction, TransactionOptions } from "../types";
import { GetAccountTransactionsData, GetAccountTransactionsDataGt } from "./graphql/queries";
import {
GetAccountTransactionsDataQuery,
GetAccountTransactionsDataQueryVariables,
GetAccountTransactionsDataGtQueryVariables,
} from "./graphql/types";

const getApiEndpoint = (currencyId: string) =>
Expand Down Expand Up @@ -140,15 +141,15 @@ export class AptosAPI {

async broadcast(signature: string): Promise<string> {
const txBytes = Uint8Array.from(Buffer.from(signature, "hex"));
const pendingTx = await post({
const pendingTx = await post<PostRequestOptions, TransactionResponse>({
contentType: MimeType.BCS_SIGNED_TRANSACTION,
aptosConfig: this.aptosClient.config,
body: txBytes,
path: "transactions",
type: AptosApiType.FULLNODE,
originMethod: "",
});
return (pendingTx.data as TransactionResponse).hash;
return pendingTx.data.hash;
}

private async getBalance(address: string): Promise<BigNumber> {
Expand Down Expand Up @@ -179,14 +180,12 @@ export class AptosAPI {

const queryResponse = await this.apolloClient.query<
GetAccountTransactionsDataQuery,
GetAccountTransactionsDataQueryVariables
GetAccountTransactionsDataGtQueryVariables
>({
query,
variables: {
address,
limit: 1000,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
gt,
},
fetchPolicy: "network-only",
Expand Down
2 changes: 0 additions & 2 deletions libs/ledger-live-common/src/families/aptos/broadcast.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Account, Operation, SignedOperation } from "@ledgerhq/types-live";
import { patchOperationWithHash } from "./../../operation";
import { AptosAPI } from "./api";
import { log } from "@ledgerhq/logs";

const broadcast = async ({
signedOperation,
Expand All @@ -12,7 +11,6 @@ const broadcast = async ({
}): Promise<Operation> => {
const { signature, operation } = signedOperation;
const hash = await new AptosAPI(account.currency.id).broadcast(signature);
log("INFO", "APTOS_OP", operation);
return patchOperationWithHash(operation, hash);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { log } from "@ledgerhq/logs";
// import { Account, AccountLike } from "@ledgerhq/types-live";
import type { DeviceTransactionField } from "../../transaction";
// import { Transaction, TransactionStatus } from "./types";
// import { methodToString } from "./msc-utils";
import BigNumber from "bignumber.js";

export const methodToString = (method: number): string => {
Expand All @@ -20,28 +16,13 @@ export type ExtraDeviceTransactionField = {
value: number | BigNumber;
};

// function getDeviceTransactionConfig({
// transaction,
// }: {
function getDeviceTransactionConfig(): Array<DeviceTransactionField> {
const fields: Array<DeviceTransactionField> = [];
fields.push({
type: "text",
label: "Type",
value: methodToString(0),
});
// fields.push({
// type: "aptos.extendedAmount",
// label: "Fee",
// value: transaction.fees,
// });
// fields.push({
// type: "aptos.extendedAmount",
// label: "Amount",
// value: transaction.amount,
// });

log("debug", `Transaction config ${JSON.stringify(fields)}`);

return fields;
}
Expand Down
14 changes: 4 additions & 10 deletions libs/ledger-live-common/src/families/aptos/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,11 @@ export const getMaxSendBalance = (
export function normalizeTransactionOptions(
options: Transaction["options"],
): Transaction["options"] {
const check = (v: any) => {
if (v === undefined || v === null || v === "") {
return undefined;
}
return v;
};
return {
maxGasAmount: check(options.maxGasAmount),
gasUnitPrice: check(options.gasUnitPrice),
sequenceNumber: check(options.sequenceNumber),
expirationTimestampSecs: check(options.expirationTimestampSecs),
maxGasAmount: options?.maxGasAmount,
gasUnitPrice: options?.gasUnitPrice,
sequenceNumber: options?.sequenceNumber,
expirationTimestampSecs: options?.expirationTimestampSecs,
};
}

Expand Down
Loading