UNPKG

@ledgerhq/coin-aptos

Version:
140 lines 5.21 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createFixtureTransactionWithSubAccount = exports.createFixtureTransaction = exports.createFixtureAccountWithSubAccount = exports.createFixtureAccount = void 0; const bignumber_js_1 = __importDefault(require("bignumber.js")); const faker_1 = require("@faker-js/faker"); const currencies_1 = require("@ledgerhq/cryptoassets/currencies"); const index_1 = require("@ledgerhq/coin-framework/account/index"); const currency = (0, currencies_1.getCryptoCurrencyById)("aptos"); function createFixtureAccount(account) { const freshAddress = { address: "address", derivationPath: "derivation_path", }; return { type: "Account", id: faker_1.faker.string.uuid(), seedIdentifier: faker_1.faker.string.uuid(), derivationMode: "", index: faker_1.faker.number.int(), freshAddress: freshAddress.address, freshAddressPath: freshAddress.derivationPath, used: true, balance: new bignumber_js_1.default(0), spendableBalance: new bignumber_js_1.default(0), creationDate: faker_1.faker.date.past(), blockHeight: faker_1.faker.number.int({ min: 100_000, max: 200_000 }), currency, operationsCount: 0, operations: [], pendingOperations: [], lastSyncDate: new Date(), balanceHistoryCache: index_1.emptyHistoryCache, swapHistory: [], aptosResources: { stakingPositions: [], activeBalance: (0, bignumber_js_1.default)(0), inactiveBalance: (0, bignumber_js_1.default)(0), pendingInactiveBalance: (0, bignumber_js_1.default)(0), }, ...account, }; } exports.createFixtureAccount = createFixtureAccount; function createFixtureAccountWithSubAccount(tokenType, account) { const freshAddress = { address: "address", derivationPath: "derivation_path", }; const id = faker_1.faker.string.uuid(); return { type: "Account", id, seedIdentifier: faker_1.faker.string.uuid(), derivationMode: "", index: faker_1.faker.number.int(), freshAddress: freshAddress.address, freshAddressPath: freshAddress.derivationPath, used: true, balance: new bignumber_js_1.default(0), spendableBalance: new bignumber_js_1.default(0), creationDate: faker_1.faker.date.past(), blockHeight: faker_1.faker.number.int({ min: 100_000, max: 200_000 }), currency, operationsCount: 0, operations: [], pendingOperations: [], lastSyncDate: new Date(), balanceHistoryCache: index_1.emptyHistoryCache, swapHistory: [], subAccounts: [ { id: "1", parentId: id, type: "TokenAccount", token: { type: "TokenCurrency", id: "aptToken", contractAddress: "contract_address", parentCurrency: currency, tokenType, }, balance: (0, bignumber_js_1.default)(1000), spendableBalance: (0, bignumber_js_1.default)(1000), creationDate: new Date(), operationsCount: 0, operations: [], pendingOperations: [], balanceHistoryCache: index_1.emptyHistoryCache, swapHistory: [], }, ], aptosResources: { stakingPositions: [], activeBalance: (0, bignumber_js_1.default)(0), inactiveBalance: (0, bignumber_js_1.default)(0), pendingInactiveBalance: (0, bignumber_js_1.default)(0), }, ...account, }; } exports.createFixtureAccountWithSubAccount = createFixtureAccountWithSubAccount; function createFixtureTransaction(tx) { const transaction = { amount: new bignumber_js_1.default(0), recipient: "recipient", useAllAmount: false, family: "aptos", mode: "send", fees: null, options: { maxGasAmount: (0, bignumber_js_1.default)(0).toString(), gasUnitPrice: (0, bignumber_js_1.default)(0).toString(), }, ...tx, }; return transaction; } exports.createFixtureTransaction = createFixtureTransaction; function createFixtureTransactionWithSubAccount(tx) { const transaction = { amount: new bignumber_js_1.default(0), recipient: "recipient", useAllAmount: false, family: "aptos", mode: "send", fees: null, options: { maxGasAmount: (0, bignumber_js_1.default)(0).toString(), gasUnitPrice: (0, bignumber_js_1.default)(0).toString(), }, subAccountId: "1", ...tx, }; return transaction; } exports.createFixtureTransactionWithSubAccount = createFixtureTransactionWithSubAccount; //# sourceMappingURL=bridge.fixture.js.map