UNPKG

@ledgerhq/coin-aptos

Version:
130 lines 4.14 kB
import BigNumber from "bignumber.js"; import { faker } from "@faker-js/faker"; import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies"; import { emptyHistoryCache } from "@ledgerhq/coin-framework/account/index"; const currency = getCryptoCurrencyById("aptos"); export function createFixtureAccount(account) { const freshAddress = { address: "address", derivationPath: "derivation_path", }; return { type: "Account", id: faker.string.uuid(), seedIdentifier: faker.string.uuid(), derivationMode: "", index: faker.number.int(), freshAddress: freshAddress.address, freshAddressPath: freshAddress.derivationPath, used: true, balance: new BigNumber(0), spendableBalance: new BigNumber(0), creationDate: faker.date.past(), blockHeight: faker.number.int({ min: 100_000, max: 200_000 }), currency, operationsCount: 0, operations: [], pendingOperations: [], lastSyncDate: new Date(), balanceHistoryCache: emptyHistoryCache, swapHistory: [], aptosResources: { stakingPositions: [], activeBalance: BigNumber(0), inactiveBalance: BigNumber(0), pendingInactiveBalance: BigNumber(0), }, ...account, }; } export function createFixtureAccountWithSubAccount(tokenType, account) { const freshAddress = { address: "address", derivationPath: "derivation_path", }; const id = faker.string.uuid(); return { type: "Account", id, seedIdentifier: faker.string.uuid(), derivationMode: "", index: faker.number.int(), freshAddress: freshAddress.address, freshAddressPath: freshAddress.derivationPath, used: true, balance: new BigNumber(0), spendableBalance: new BigNumber(0), creationDate: faker.date.past(), blockHeight: faker.number.int({ min: 100_000, max: 200_000 }), currency, operationsCount: 0, operations: [], pendingOperations: [], lastSyncDate: new Date(), balanceHistoryCache: emptyHistoryCache, swapHistory: [], subAccounts: [ { id: "1", parentId: id, type: "TokenAccount", token: { type: "TokenCurrency", id: "aptToken", contractAddress: "contract_address", parentCurrency: currency, tokenType, }, balance: BigNumber(1000), spendableBalance: BigNumber(1000), creationDate: new Date(), operationsCount: 0, operations: [], pendingOperations: [], balanceHistoryCache: emptyHistoryCache, swapHistory: [], }, ], aptosResources: { stakingPositions: [], activeBalance: BigNumber(0), inactiveBalance: BigNumber(0), pendingInactiveBalance: BigNumber(0), }, ...account, }; } export function createFixtureTransaction(tx) { const transaction = { amount: new BigNumber(0), recipient: "recipient", useAllAmount: false, family: "aptos", mode: "send", fees: null, options: { maxGasAmount: BigNumber(0).toString(), gasUnitPrice: BigNumber(0).toString(), }, ...tx, }; return transaction; } export function createFixtureTransactionWithSubAccount(tx) { const transaction = { amount: new BigNumber(0), recipient: "recipient", useAllAmount: false, family: "aptos", mode: "send", fees: null, options: { maxGasAmount: BigNumber(0).toString(), gasUnitPrice: BigNumber(0).toString(), }, subAccountId: "1", ...tx, }; return transaction; } //# sourceMappingURL=bridge.fixture.js.map