@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
19 lines • 1.03 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.deriveAccountIdForManifest = void 0;
const constants_1 = require("../../wallet-api/constants");
const semver_1 = __importDefault(require("semver"));
/** The dapp connector "v3" uses the ledger live account ID to find the correct account. Live app and dapp browser manifests require wallet API ID. */
function deriveAccountIdForManifest(accountId, walletApiAccountId, manifest) {
const isDapp = "dapp" in manifest;
if (isDapp && manifest.apiVersion && semver_1.default.satisfies(constants_1.WALLET_API_VERSION, manifest.apiVersion)) {
return accountId;
}
/** Assume dapp browser <=v2 or live app, fallback to wallet ID. */
return walletApiAccountId;
}
exports.deriveAccountIdForManifest = deriveAccountIdForManifest;
//# sourceMappingURL=deriveAccountIdForManifest.js.map