@ledgerhq/coin-canton
Version:
41 lines • 1.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isCantonAccount = isCantonAccount;
exports.assignToAccountRaw = assignToAccountRaw;
exports.assignFromAccountRaw = assignFromAccountRaw;
function isCantonAccount(account) {
return "cantonResources" in account;
}
function toResourcesRaw(r) {
const { isOnboarded, instrumentUtxoCounts, pendingTransferProposals, publicKey, xpub } = r;
return {
isOnboarded: isOnboarded,
instrumentUtxoCounts,
pendingTransferProposals,
...(publicKey ? { publicKey } : {}),
...(xpub ? { xpub } : {}),
};
}
function fromResourcesRaw(r) {
return {
isOnboarded: r.isOnboarded,
instrumentUtxoCounts: r.instrumentUtxoCounts,
pendingTransferProposals: r.pendingTransferProposals,
...(r.publicKey ? { publicKey: r.publicKey } : {}),
...(r.xpub ? { xpub: r.xpub } : {}),
};
}
// Guard on the source only: the serializer passes a freshly-built destination
// with no cantonResources yet, so a destination guard would drop the block. LIVE-34585
function assignToAccountRaw(account, accountRaw) {
if (isCantonAccount(account) && account.cantonResources) {
accountRaw.cantonResources = toResourcesRaw(account.cantonResources);
}
}
function assignFromAccountRaw(accountRaw, account) {
const { cantonResources } = accountRaw;
if (cantonResources) {
account.cantonResources = fromResourcesRaw(cantonResources);
}
}
//# sourceMappingURL=serialization.js.map