@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
42 lines • 1.46 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getChainSpecificRules = getChainSpecificRules;
exports.getTokenFromAsset = getTokenFromAsset;
exports.getAssetFromToken = getAssetFromToken;
const state_1 = require("@ledgerhq/cryptoassets/state");
const types_1 = require("@ledgerhq/coin-stellar/types");
const logic_1 = require("@ledgerhq/coin-stellar/logic");
function getChainSpecificRules() {
return {
getAccountShape: (address) => {
// NOTE: https://github.com/LedgerHQ/ledger-live/pull/2058
if (address === logic_1.STELLAR_BURN_ADDRESS) {
throw new types_1.StellarBurnAddressError();
}
},
getTransactionStatus: {
throwIfPendingOperation: true,
},
};
}
async function getTokenFromAsset(asset) {
const assetId = asset.type !== "native" && "assetReference" in asset && "assetOwner" in asset
? `${asset.assetReference}:${asset.assetOwner}`
: "";
return await (0, state_1.getCryptoAssetsStore)().findTokenById(`stellar/asset/${assetId}`);
}
function getAssetFromToken(token) {
return {
type: token.tokenType,
assetReference: token.name,
assetOwner: token.contractAddress,
name: token.name,
unit: token.units[0],
};
}
exports.default = {
getTokenFromAsset,
getAssetFromToken,
getChainSpecificRules,
};
//# sourceMappingURL=bridge.js.map