@ledgerhq/coin-icon
Version:
Ledger Icon Coin integration
75 lines • 3.03 kB
JavaScript
;
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 abandonseed_1 = require("@ledgerhq/cryptoassets/abandonseed");
const currencies_1 = require("@ledgerhq/cryptoassets/currencies");
const index_1 = require("@ledgerhq/ledger-wallet-framework/account/index");
const bignumber_js_1 = __importDefault(require("bignumber.js"));
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 = "icon:fixture-account";
const seedIdentifier = "fixture-seed";
const index = 0;
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: new Date("2024-01-01"),
blockHeight: 100_000,
currency,
operationsCount: account?.operationsCount || 0,
operations: account?.operations || [],
pendingOperations: account?.pendingOperations || [],
lastSyncDate: new Date(),
balanceHistoryCache: index_1.emptyHistoryCache,
swapHistory: [],
iconResources,
};
}
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,
};
}
function createFixtureOperation(operation) {
return {
id: operation?.id || "icon:fixture-op",
hash: operation?.hash || "0x" + "0".repeat(64),
type: operation?.type || "OUT",
value: operation?.value || new bignumber_js_1.default(0),
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 || "icon:fixture-account",
date: operation?.date || new Date("2024-01-01"),
extra: {},
};
}
//# sourceMappingURL=bridge.fixture.js.map