@ledgerhq/coin-multiversx
Version:
Ledger MultiversX Coin integration
65 lines • 2.35 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.toOperationExtraRaw = exports.fromOperationExtraRaw = exports.assignFromAccountRaw = exports.assignToAccountRaw = exports.fromMultiversXResourcesRaw = exports.toMultiversXResourcesRaw = void 0;
const bignumber_js_1 = __importDefault(require("bignumber.js"));
const types_1 = require("./types");
function toMultiversXResourcesRaw(r) {
const { nonce, delegations, isGuarded } = r;
return {
nonce,
delegations,
isGuarded,
};
}
exports.toMultiversXResourcesRaw = toMultiversXResourcesRaw;
function fromMultiversXResourcesRaw(r) {
const { nonce, delegations, isGuarded } = r;
return {
nonce,
delegations,
isGuarded,
};
}
exports.fromMultiversXResourcesRaw = fromMultiversXResourcesRaw;
function assignToAccountRaw(account, accountRaw) {
const multiversxAccount = account;
if (multiversxAccount.multiversxResources) {
accountRaw.multiversxResources = toMultiversXResourcesRaw(multiversxAccount.multiversxResources);
}
}
exports.assignToAccountRaw = assignToAccountRaw;
function assignFromAccountRaw(accountRaw, account) {
const multiversxResourcesRaw = accountRaw.multiversxResources;
if (multiversxResourcesRaw)
account.multiversxResources =
fromMultiversXResourcesRaw(multiversxResourcesRaw);
}
exports.assignFromAccountRaw = assignFromAccountRaw;
function fromOperationExtraRaw(extraRaw) {
const extra = {};
if (!(0, types_1.isMultiversXOperationExtraRaw)(extraRaw)) {
// All fields might be undefined
return extra;
}
if (extraRaw.amount) {
extra.amount = new bignumber_js_1.default(extraRaw.amount);
}
return extra;
}
exports.fromOperationExtraRaw = fromOperationExtraRaw;
function toOperationExtraRaw(extra) {
const extraRaw = {};
if (!(0, types_1.isMultiversXOperationExtra)(extra)) {
// All fields might be undefined
return extraRaw;
}
if (extra.amount) {
extraRaw.amount = extra.amount.toString();
}
return extraRaw;
}
exports.toOperationExtraRaw = toOperationExtraRaw;
//# sourceMappingURL=serialization.js.map