UNPKG

@ledgerhq/coin-tezos

Version:
83 lines 3.69 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createFixtureAccount = createFixtureAccount; exports.createFixtureTransaction = createFixtureTransaction; exports.createFixtureOperation = createFixtureOperation; const bignumber_js_1 = __importDefault(require("bignumber.js")); const faker_1 = require("@faker-js/faker"); const abandonseed_1 = require("@ledgerhq/cryptoassets/abandonseed"); const currencies_1 = require("@ledgerhq/cryptoassets/currencies"); const index_1 = require("@ledgerhq/coin-framework/account/index"); const currency = (0, currencies_1.listCryptoCurrencies)(true).find(c => c.id === "tezos"); function createFixtureAccount(account) { const tezosResources = account?.tezosResources || { revealed: account?.tezosResources?.revealed || true, counter: account?.tezosResources?.counter || faker_1.faker.number.int(), }; const freshAddress = { // Value coming from taquito.io documentation address: "tz1VSUr8wwNhLAzempoch5d6hLRiTh8Cjcjb", 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: account?.freshAddress || freshAddress.address, freshAddressPath: freshAddress.derivationPath, used: true, balance: account?.balance || new bignumber_js_1.default(0), spendableBalance: account?.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: account?.operationsCount || 0, operations: account?.operations || [], pendingOperations: account?.pendingOperations || [], lastSyncDate: new Date(), balanceHistoryCache: index_1.emptyHistoryCache, swapHistory: [], tezosResources, }; } function createFixtureTransaction(tx) { return { amount: tx?.amount || new bignumber_js_1.default(0), recipient: tx?.recipient || (0, abandonseed_1.getAbandonSeedAddress)("tezos"), useAllAmount: tx?.useAllAmount || false, family: "tezos", mode: tx?.mode || "send", networkInfo: tx?.networkInfo || undefined, fees: tx?.fees || undefined, gasLimit: tx?.gasLimit || undefined, storageLimit: tx?.storageLimit || undefined, estimatedFees: tx?.estimatedFees || undefined, taquitoError: tx?.taquitoError || undefined, }; } function createFixtureOperation(operation) { const extra = { id: operation?.extra?.id || 0, }; return { id: operation?.id || faker_1.faker.string.uuid(), hash: operation?.hash || faker_1.faker.string.uuid(), type: operation?.type || "ACTIVATE", value: operation?.value || new bignumber_js_1.default(faker_1.faker.string.numeric()), fee: operation?.fee || new bignumber_js_1.default(0), // senders & recipients addresses senders: operation?.senders || [], recipients: operation?.recipients || [], blockHeight: operation?.blockHeight || undefined, blockHash: operation?.blockHash || undefined, accountId: operation?.accountId || faker_1.faker.string.uuid(), date: operation?.date || faker_1.faker.date.past(), extra, }; } //# sourceMappingURL=bridge.fixture.js.map