@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
112 lines • 3.77 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createFixtureAccount = exports.createFixtureTokenAccount = exports.createFixtureCryptoCurrency = void 0;
const bignumber_js_1 = __importDefault(require("bignumber.js"));
const cryptoassets_1 = require("@ledgerhq/cryptoassets");
function createFixtureCryptoCurrency(family) {
return {
type: "CryptoCurrency",
id: "testCoinId",
coinType: 8008,
name: "MyCoin",
managerAppName: "MyCoin",
ticker: "MYC",
scheme: "mycoin",
color: "#ff0000",
family,
units: [
{
name: "MYC",
code: "MYC",
magnitude: 8,
},
{
name: "SmallestUnit",
code: "SMALLESTUNIT",
magnitude: 0,
},
],
explorerViews: [
{
address: "https://mycoinexplorer.com/account/$address",
tx: "https://mycoinexplorer.com/transaction/$hash",
token: "https://mycoinexplorer.com/token/$contractAddress/?a=$address",
},
],
};
}
exports.createFixtureCryptoCurrency = createFixtureCryptoCurrency;
const defaultEthCryptoFamily = cryptoassets_1.cryptocurrenciesById["ethereum"];
const defaultERC20USDTToken = (0, cryptoassets_1.findTokenById)("ethereum/erc20/usd_tether__erc20_");
function createFixtureTokenAccount(id = "00", token = defaultERC20USDTToken) {
return {
type: "TokenAccount",
id: `js:2:ethereum:0x${id}:+ethereum%2Ferc20%2Fusd_tether__erc20_`,
parentId: `js:2:ethereum:0x0${id}:`,
token,
balance: new bignumber_js_1.default("51281813126095913"),
spendableBalance: new bignumber_js_1.default("51281813126095913"),
creationDate: new Date(),
operationsCount: 0,
operations: [],
pendingOperations: [],
balanceHistoryCache: {
HOUR: {
balances: [],
latestDate: undefined,
},
DAY: {
balances: [],
latestDate: undefined,
},
WEEK: {
balances: [],
latestDate: undefined,
},
},
swapHistory: [],
};
}
exports.createFixtureTokenAccount = createFixtureTokenAccount;
function createFixtureAccount(id = "00", currency = defaultEthCryptoFamily) {
return {
type: "Account",
id: `js:2:${currency.id}:0x0${id}:`,
seedIdentifier: "0x01",
derivationMode: "ethM",
index: 0,
freshAddress: "0x01",
freshAddressPath: "44'/60'/0'/0/0",
used: false,
balance: new bignumber_js_1.default("51281813126095913"),
spendableBalance: new bignumber_js_1.default("51281813126095913"),
creationDate: new Date(),
blockHeight: 8168983,
currency,
xpub: currency.family === "bitcoin" ? "testxpub" : undefined,
operationsCount: 0,
operations: [],
pendingOperations: [],
lastSyncDate: new Date(),
balanceHistoryCache: {
HOUR: {
balances: [],
latestDate: undefined,
},
DAY: {
balances: [],
latestDate: undefined,
},
WEEK: {
balances: [],
latestDate: undefined,
},
},
swapHistory: [],
};
}
exports.createFixtureAccount = createFixtureAccount;
//# sourceMappingURL=cryptoCurrencies.js.map