UNPKG

@ledgerhq/coin-hedera

Version:
55 lines 2.18 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.toHederaResourcesRaw = toHederaResourcesRaw; exports.fromHederaResourcesRaw = fromHederaResourcesRaw; exports.assignToAccountRaw = assignToAccountRaw; exports.assignFromAccountRaw = assignFromAccountRaw; const bignumber_js_1 = __importDefault(require("bignumber.js")); function toHederaResourcesRaw(resources) { const { maxAutomaticTokenAssociations, isAutoTokenAssociationEnabled } = resources; const delegation = resources.delegation ? { nodeId: resources.delegation.nodeId, delegated: resources.delegation.delegated.toString(), pendingReward: resources.delegation.pendingReward.toString(), } : null; return { maxAutomaticTokenAssociations, isAutoTokenAssociationEnabled, delegation, }; } function fromHederaResourcesRaw(rawResources) { const { maxAutomaticTokenAssociations, isAutoTokenAssociationEnabled } = rawResources; const delegation = rawResources.delegation ? { nodeId: rawResources.delegation.nodeId, delegated: new bignumber_js_1.default(rawResources.delegation.delegated), pendingReward: new bignumber_js_1.default(rawResources.delegation.pendingReward), } : null; return { maxAutomaticTokenAssociations, isAutoTokenAssociationEnabled, delegation, }; } function assignToAccountRaw(account, accountRaw) { const hederaAccount = account; const hederaAccountRaw = accountRaw; if (hederaAccount.hederaResources) { hederaAccountRaw.hederaResources = toHederaResourcesRaw(hederaAccount.hederaResources); } } function assignFromAccountRaw(accountRaw, account) { const hederaAccount = account; const hederaAccountRaw = accountRaw; if (hederaAccountRaw.hederaResources) { hederaAccount.hederaResources = fromHederaResourcesRaw(hederaAccountRaw.hederaResources); } } //# sourceMappingURL=serialization.js.map