@ledgerhq/coin-icon
Version:
Ledger Icon Coin integration
36 lines • 1.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.assignFromAccountRaw = exports.assignToAccountRaw = exports.fromIconResourcesRaw = exports.toIconResourcesRaw = void 0;
const bignumber_js_1 = require("bignumber.js");
function toIconResourcesRaw(resources) {
const { nonce, votingPower, totalDelegated } = resources;
return {
nonce,
votingPower: votingPower.toString(),
totalDelegated: totalDelegated.toString(),
};
}
exports.toIconResourcesRaw = toIconResourcesRaw;
function fromIconResourcesRaw(rawResources) {
const { nonce, votingPower, totalDelegated } = rawResources;
return {
nonce,
votingPower: new bignumber_js_1.BigNumber(votingPower || 0),
totalDelegated: new bignumber_js_1.BigNumber(totalDelegated || 0),
};
}
exports.fromIconResourcesRaw = fromIconResourcesRaw;
function assignToAccountRaw(account, accountRaw) {
const iconAccount = account;
if (iconAccount.iconResources) {
accountRaw.iconResources = toIconResourcesRaw(iconAccount.iconResources);
}
}
exports.assignToAccountRaw = assignToAccountRaw;
function assignFromAccountRaw(accountRaw, account) {
const iconResourcesRaw = accountRaw.iconResources;
if (iconResourcesRaw)
account.iconResources = fromIconResourcesRaw(iconResourcesRaw);
}
exports.assignFromAccountRaw = assignFromAccountRaw;
//# sourceMappingURL=serialization.js.map