UNPKG

@ledgerhq/coin-icon

Version:
77 lines 3.32 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createFixtureOperation = exports.createFixtureTransaction = 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 abandonseed_1 = require("@ledgerhq/cryptoassets/abandonseed"); const index_1 = require("@ledgerhq/coin-framework/account/index"); function createFixtureAccount(account) { const currency = (0, currencies_1.listCryptoCurrencies)(true).find(c => c.id === "icon"); const iconResources = account?.iconResources || { nonce: 0, votingPower: (0, bignumber_js_1.default)(0), totalDelegated: (0, bignumber_js_1.default)(0), }; const freshAddress = { address: "hx1234567890abcdef", derivationPath: "derivation_path", }; const id = faker_1.faker.string.uuid(); const seedIdentifier = faker_1.faker.string.uuid(); const index = faker_1.faker.number.int(); return { type: "Account", id, seedIdentifier, derivationMode: "", index, 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: [], iconResources, }; } exports.createFixtureAccount = createFixtureAccount; function createFixtureTransaction(tx) { return { amount: tx?.amount || new bignumber_js_1.default(0), recipient: tx?.recipient || (0, abandonseed_1.getAbandonSeedAddress)("icon"), mode: tx?.mode || "send", family: "icon", fees: tx?.fees || undefined, }; } exports.createFixtureTransaction = createFixtureTransaction; function createFixtureOperation(operation) { return { id: operation?.id || faker_1.faker.string.uuid(), hash: operation?.hash || faker_1.faker.string.uuid(), type: operation?.type || "OUT", value: operation?.value || new bignumber_js_1.default(faker_1.faker.string.numeric()), fee: operation?.fee || new bignumber_js_1.default(0), 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: {}, }; } exports.createFixtureOperation = createFixtureOperation; //# sourceMappingURL=bridge.fixture.js.map