@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
69 lines • 3.95 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LiveAppManifestSchema = exports.LiveAppManifestDappSchema = exports.LiveAppManifestParamsNetworkSchema = exports.DappProvidersSchema = exports.PlatformTokenStandard = exports.PlatformCurrencyType = exports.PLATFORM_FAMILIES_ENUM = exports.PLATFORM_FAMILIES = exports.FAMILIES_MAPPING_LL_TO_PLATFORM = exports.FAMILIES_MAPPING_PLATFORM_TO_LL = void 0;
const live_app_sdk_1 = require("@ledgerhq/live-app-sdk");
Object.defineProperty(exports, "PLATFORM_FAMILIES_ENUM", { enumerable: true, get: function () { return live_app_sdk_1.FAMILIES; } });
const zod_1 = require("zod");
const helpers_1 = require("../helpers");
exports.FAMILIES_MAPPING_PLATFORM_TO_LL = {
ethereum: "evm",
ripple: "xrp",
};
exports.FAMILIES_MAPPING_LL_TO_PLATFORM = (0, helpers_1.reverseRecord)(exports.FAMILIES_MAPPING_PLATFORM_TO_LL);
/**
* this is a hack to add the "evm" family to the list of supported families of
* the deprecated @ledgerhq/live-app-sdk, still used by some live apps.
* Since "evm" will be (is) the new family of original currencies under the
* "ethereum" family, following the "ethereum" / "evm" families merge
* (and removal of the "ethereum" family)
*/
exports.PLATFORM_FAMILIES = [
...Object.values(live_app_sdk_1.FAMILIES),
...Object.values(exports.FAMILIES_MAPPING_PLATFORM_TO_LL),
];
var live_app_sdk_2 = require("@ledgerhq/live-app-sdk");
Object.defineProperty(exports, "PlatformCurrencyType", { enumerable: true, get: function () { return live_app_sdk_2.CurrencyType; } });
Object.defineProperty(exports, "PlatformTokenStandard", { enumerable: true, get: function () { return live_app_sdk_2.TokenStandard; } });
exports.DappProvidersSchema = zod_1.z.enum(["evm"]);
exports.LiveAppManifestParamsNetworkSchema = zod_1.z.object({
currency: zod_1.z.string().min(1),
chainID: zod_1.z.number(),
nodeURL: zod_1.z.string().optional(),
});
exports.LiveAppManifestDappSchema = zod_1.z.object({
provider: exports.DappProvidersSchema,
networks: zod_1.z.array(exports.LiveAppManifestParamsNetworkSchema),
nanoApp: zod_1.z.string().min(1),
dependencies: zod_1.z.array(zod_1.z.string()).optional(),
});
exports.LiveAppManifestSchema = zod_1.z.strictObject({
id: zod_1.z.string().trim().min(1),
author: zod_1.z.string().optional(),
private: zod_1.z.boolean().optional(),
cacheBustingId: zod_1.z.number().optional(),
nocache: zod_1.z.boolean().optional(),
name: zod_1.z.string().trim().min(1),
url: zod_1.z.string().trim().min(1),
dapp: exports.LiveAppManifestDappSchema.optional(),
homepageUrl: zod_1.z.string().trim().min(1),
supportUrl: zod_1.z.string().optional(),
icon: zod_1.z.string().nullable().optional(),
platforms: zod_1.z.array(zod_1.z.enum(["ios", "android", "desktop"])).min(1),
apiVersion: zod_1.z.string().trim().min(1),
manifestVersion: zod_1.z.string().trim().min(1),
branch: zod_1.z.enum(["stable", "experimental", "soon", "debug"]),
permissions: zod_1.z.array(zod_1.z.string().trim()).optional(),
domains: zod_1.z.array(zod_1.z.string().trim()).min(1),
categories: zod_1.z.array(zod_1.z.string().trim()).min(1),
currencies: zod_1.z.union([zod_1.z.array(zod_1.z.string().trim()).min(1), zod_1.z.literal("*")]),
visibility: zod_1.z.enum(["complete", "searchable", "deep"]),
highlight: zod_1.z.boolean().optional(),
featureFlags: zod_1.z.union([zod_1.z.array(zod_1.z.string().trim()), zod_1.z.literal("*")]).optional(),
content: zod_1.z.object({
cta: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
subtitle: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
shortDescription: zod_1.z.record(zod_1.z.string(), zod_1.z.string().trim().min(1)),
description: zod_1.z.record(zod_1.z.string(), zod_1.z.string().trim().min(1)),
}),
});
//# sourceMappingURL=types.js.map