@ledgerhq/coin-elrond
Version:
Ledger MultiversX Coin integration
64 lines • 2.25 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.fromElrondResourcesRaw = exports.toElrondResourcesRaw = void 0;
const bignumber_js_1 = __importDefault(require("bignumber.js"));
const types_1 = require("./types");
function toElrondResourcesRaw(r) {
const { nonce, delegations, isGuarded } = r;
return {
nonce,
delegations,
isGuarded,
};
}
exports.toElrondResourcesRaw = toElrondResourcesRaw;
function fromElrondResourcesRaw(r) {
const { nonce, delegations, isGuarded } = r;
return {
nonce,
delegations,
isGuarded,
};
}
exports.fromElrondResourcesRaw = fromElrondResourcesRaw;
function assignToAccountRaw(account, accountRaw) {
const elrondAccount = account;
if (elrondAccount.elrondResources) {
accountRaw.elrondResources = toElrondResourcesRaw(elrondAccount.elrondResources);
}
}
exports.assignToAccountRaw = assignToAccountRaw;
function assignFromAccountRaw(accountRaw, account) {
const elrondResourcesRaw = accountRaw.elrondResources;
if (elrondResourcesRaw)
account.elrondResources = fromElrondResourcesRaw(elrondResourcesRaw);
}
exports.assignFromAccountRaw = assignFromAccountRaw;
function fromOperationExtraRaw(extraRaw) {
const extra = {};
if (!(0, types_1.isElrondOperationExtraRaw)(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.isElrondOperationExtra)(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