UNPKG

@ledgerhq/coin-stellar

Version:
117 lines 4.54 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 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.getCryptoCurrencyById)("stellar"); function createFixtureAccount(account) { const freshAddress = { address: "GD6QELUZPSKPRWVXOQ3F6GBF4OBRMCHO5PHREXH4ZRTPJAG7V5MD7JGX", 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: account?.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: [], }; } exports.createFixtureAccount = createFixtureAccount; function createFixtureTransaction(tx) { let transaction = { amount: tx?.amount || new bignumber_js_1.default(0), recipient: tx?.recipient || (0, abandonseed_1.getAbandonSeedAddress)("stellar"), useAllAmount: tx?.useAllAmount || false, family: "stellar", mode: tx?.mode || "send", networkInfo: tx?.networkInfo || undefined, fees: tx?.fees || null, baseReserve: tx?.baseReserve || null, memoType: tx?.memoType || null, memoValue: tx?.memoValue || null, }; if (tx?.assetCode) { transaction = { ...transaction, assetCode: tx.assetCode, }; } if (tx?.assetIssuer) { transaction = { ...transaction, assetIssuer: tx.assetIssuer, }; } return transaction; } exports.createFixtureTransaction = createFixtureTransaction; function createFixtureOperation(operation) { let extra = { assetAmount: operation?.extra?.assetAmount || undefined, ledgerOpType: operation?.extra?.ledgerOpType || "IN", blockTime: operation?.extra?.blockTime || faker_1.faker.date.past(), index: operation?.id ?? "0", }; if (operation?.extra?.pagingToken) { extra = { ...extra, pagingToken: operation.extra.pagingToken, }; } if (operation?.extra?.assetCode) { extra = { ...extra, assetCode: operation.extra.assetCode, }; } if (operation?.extra?.assetIssuer) { extra = { ...extra, assetIssuer: operation.extra.assetIssuer, }; } if (operation?.extra?.memo) { extra = { ...extra, memo: operation.extra.memo, }; } 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, }; } exports.createFixtureOperation = createFixtureOperation; //# sourceMappingURL=bridge.fixture.js.map