@getpara/core-sdk 2.0.0-fc.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ParaCore.js +1111 -316
- package/dist/cjs/constants.js +10 -1
- package/dist/cjs/index.js +23 -3
- package/dist/cjs/shares/KeyContainer.js +3 -3
- package/dist/cjs/shares/enclave.js +287 -0
- package/dist/cjs/shares/shareDistribution.js +16 -1
- package/dist/cjs/transmission/transmissionUtils.js +4 -3
- package/dist/cjs/types/{theme.js → assets.js} +2 -2
- package/dist/cjs/types/coreApi.js +7 -2
- package/dist/cjs/types/events.js +2 -0
- package/dist/cjs/types/index.js +0 -21
- package/dist/cjs/types/popup.js +1 -0
- package/dist/cjs/utils/config.js +108 -0
- package/dist/cjs/utils/index.js +5 -1
- package/dist/cjs/utils/onRamps.js +2 -3
- package/dist/cjs/utils/wallet.js +18 -0
- package/dist/cjs/{types/onRamps.js → utils/window.js} +17 -12
- package/dist/esm/ParaCore.js +1115 -320
- package/dist/esm/constants.js +7 -1
- package/dist/esm/index.js +24 -5
- package/dist/esm/shares/KeyContainer.js +3 -3
- package/dist/esm/shares/enclave.js +247 -0
- package/dist/esm/shares/shareDistribution.js +16 -1
- package/dist/esm/transmission/transmissionUtils.js +4 -3
- package/dist/esm/types/coreApi.js +7 -2
- package/dist/esm/types/events.js +2 -0
- package/dist/esm/types/index.js +0 -16
- package/dist/esm/types/popup.js +1 -0
- package/dist/esm/utils/config.js +86 -0
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/utils/onRamps.js +2 -3
- package/dist/esm/utils/wallet.js +17 -0
- package/dist/esm/utils/window.js +16 -0
- package/dist/types/ParaCore.d.ts +90 -19
- package/dist/types/PlatformUtils.d.ts +2 -1
- package/dist/types/constants.d.ts +3 -0
- package/dist/types/index.d.ts +6 -4
- package/dist/types/shares/enclave.d.ts +83 -0
- package/dist/types/shares/shareDistribution.d.ts +4 -2
- package/dist/types/types/assets.d.ts +14 -0
- package/dist/types/types/config.d.ts +3 -2
- package/dist/types/types/coreApi.d.ts +47 -7
- package/dist/types/types/events.d.ts +7 -2
- package/dist/types/types/index.d.ts +0 -4
- package/dist/types/types/methods.d.ts +56 -12
- package/dist/types/types/popup.d.ts +2 -1
- package/dist/types/types/wallet.d.ts +8 -4
- package/dist/types/utils/config.d.ts +7 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types/utils/onRamps.d.ts +9 -10
- package/dist/types/utils/wallet.d.ts +1 -0
- package/dist/types/utils/window.d.ts +2 -0
- package/package.json +3 -3
- package/dist/cjs/types/recovery.js +0 -34
- package/dist/esm/types/onRamps.js +0 -11
- package/dist/esm/types/recovery.js +0 -12
- package/dist/types/types/onRamps.d.ts +0 -10
- package/dist/types/types/recovery.d.ts +0 -7
- package/dist/types/types/theme.d.ts +0 -12
- /package/dist/esm/types/{theme.js → assets.js} +0 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var config_exports = {};
|
|
19
|
+
__export(config_exports, {
|
|
20
|
+
validateBalancesConfig: () => validateBalancesConfig
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(config_exports);
|
|
23
|
+
var import_user_management_client = require("@getpara/user-management-client");
|
|
24
|
+
function validateBalancesConfig(obj) {
|
|
25
|
+
if (!obj || typeof obj !== "object") {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (!obj.displayType || obj.displayType !== "AGGREGATED" && obj.displayType !== "CUSTOM_ASSET") {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if (obj.displayType === "AGGREGATED") {
|
|
32
|
+
if (obj.excludeStandardAssets !== void 0 && typeof obj.excludeStandardAssets !== "boolean") {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (obj.additionalAssets !== void 0) {
|
|
36
|
+
if (!Array.isArray(obj.additionalAssets)) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
for (const asset of obj.additionalAssets) {
|
|
40
|
+
if (!validateCustomAsset(asset)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const hasPriceUrl = typeof asset.priceUrl === "string" && asset.priceUrl.trim();
|
|
44
|
+
const hasPrice = asset.price && typeof asset.price === "object" && typeof asset.price.value === "number" && asset.price.value > 0 && typeof asset.price.currency === "string" && asset.price.currency.trim();
|
|
45
|
+
if (!hasPriceUrl && !hasPrice) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
if (hasPriceUrl && hasPrice) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
if (obj.displayType === "CUSTOM_ASSET") {
|
|
56
|
+
if (!obj.asset) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (!validateCustomAsset(obj.asset)) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
const hasPriceUrl = typeof obj.asset.priceUrl === "string" && obj.asset.priceUrl.trim();
|
|
63
|
+
const hasPrice = obj.asset.price && typeof obj.asset.price === "object" && typeof obj.asset.price.value === "number" && obj.asset.price.value > 0 && typeof obj.asset.price.currency === "string" && obj.asset.price.currency.trim();
|
|
64
|
+
if (hasPriceUrl && hasPrice) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
function validateCustomAsset(obj) {
|
|
72
|
+
if (!obj || typeof obj !== "object") {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
if (typeof obj.name !== "string" || !obj.name.trim() || typeof obj.symbol !== "string" || !obj.symbol.trim()) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
if (!Array.isArray(obj.implementations) || obj.implementations.length === 0) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
for (const network of obj.implementations) {
|
|
82
|
+
if (!network || typeof network !== "object") {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
if (typeof network.network === "string") {
|
|
86
|
+
if (!import_user_management_client.NETWORKS.includes(network.network)) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if (typeof network.contractAddress !== "string" || !network.contractAddress.trim()) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
} else if (typeof network.network === "object") {
|
|
93
|
+
if (typeof network.network.name !== "string" || !network.network.name.trim() || typeof network.network.rpcUrl !== "string" || !network.network.rpcUrl.trim() || typeof network.network.evmChainId !== "string" || !network.network.evmChainId.trim()) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
if (network.contractAddress !== void 0 && (typeof network.contractAddress !== "string" || !network.contractAddress.trim())) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
106
|
+
0 && (module.exports = {
|
|
107
|
+
validateBalancesConfig
|
|
108
|
+
});
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
15
15
|
var utils_exports = {};
|
|
16
16
|
module.exports = __toCommonJS(utils_exports);
|
|
17
17
|
__reExport(utils_exports, require("./autobind.js"), module.exports);
|
|
18
|
+
__reExport(utils_exports, require("./config.js"), module.exports);
|
|
18
19
|
__reExport(utils_exports, require("./events.js"), module.exports);
|
|
19
20
|
__reExport(utils_exports, require("./formatting.js"), module.exports);
|
|
20
21
|
__reExport(utils_exports, require("./json.js"), module.exports);
|
|
@@ -25,9 +26,11 @@ __reExport(utils_exports, require("./polling.js"), module.exports);
|
|
|
25
26
|
__reExport(utils_exports, require("./types.js"), module.exports);
|
|
26
27
|
__reExport(utils_exports, require("./url.js"), module.exports);
|
|
27
28
|
__reExport(utils_exports, require("./wallet.js"), module.exports);
|
|
29
|
+
__reExport(utils_exports, require("./window.js"), module.exports);
|
|
28
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
29
31
|
0 && (module.exports = {
|
|
30
32
|
...require("./autobind.js"),
|
|
33
|
+
...require("./config.js"),
|
|
31
34
|
...require("./events.js"),
|
|
32
35
|
...require("./formatting.js"),
|
|
33
36
|
...require("./json.js"),
|
|
@@ -37,5 +40,6 @@ __reExport(utils_exports, require("./wallet.js"), module.exports);
|
|
|
37
40
|
...require("./polling.js"),
|
|
38
41
|
...require("./types.js"),
|
|
39
42
|
...require("./url.js"),
|
|
40
|
-
...require("./wallet.js")
|
|
43
|
+
...require("./wallet.js"),
|
|
44
|
+
...require("./window.js")
|
|
41
45
|
});
|
|
@@ -24,7 +24,6 @@ __export(onRamps_exports, {
|
|
|
24
24
|
toAssetInfoArray: () => toAssetInfoArray
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(onRamps_exports);
|
|
27
|
-
var import_user_management_client = require("@getpara/user-management-client");
|
|
28
27
|
function toAssetInfoArray(data) {
|
|
29
28
|
const result = [];
|
|
30
29
|
Object.keys(data).forEach((walletType) => {
|
|
@@ -76,8 +75,8 @@ function getOnRampAssets(data, {
|
|
|
76
75
|
];
|
|
77
76
|
}
|
|
78
77
|
const NETWORK_PREFIXES = {
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
COSMOS: "cosmos",
|
|
79
|
+
NOBLE: "noble"
|
|
81
80
|
};
|
|
82
81
|
function getNetworkPrefix(network) {
|
|
83
82
|
return NETWORK_PREFIXES[network];
|
package/dist/cjs/utils/wallet.js
CHANGED
|
@@ -45,6 +45,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
45
45
|
var wallet_exports = {};
|
|
46
46
|
__export(wallet_exports, {
|
|
47
47
|
WalletSchemeTypeMap: () => WalletSchemeTypeMap,
|
|
48
|
+
currentWalletIdsEq: () => currentWalletIdsEq,
|
|
48
49
|
entityToWallet: () => entityToWallet,
|
|
49
50
|
getEquivalentTypes: () => getEquivalentTypes,
|
|
50
51
|
getSchemes: () => getSchemes,
|
|
@@ -114,7 +115,10 @@ function getEquivalentTypes(types) {
|
|
|
114
115
|
return getWalletTypes(getSchemes(Array.isArray(types) ? types : [types]));
|
|
115
116
|
}
|
|
116
117
|
function entityToWallet(w) {
|
|
118
|
+
var _a;
|
|
117
119
|
return __spreadProps(__spreadValues({}, w), {
|
|
120
|
+
createdAt: typeof w.createdAt === "string" ? w.createdAt : w.createdAt.toISOString(),
|
|
121
|
+
lastUsedAt: typeof w.lastUsedAt === "string" ? w.lastUsedAt : (_a = w.lastUsedAt) == null ? void 0 : _a.toISOString(),
|
|
118
122
|
scheme: w.scheme,
|
|
119
123
|
type: w.type,
|
|
120
124
|
pregenIdentifierType: w.pregenIdentifierType
|
|
@@ -143,9 +147,23 @@ function mergeCurrentWalletIds(original, additional) {
|
|
|
143
147
|
function newUuid() {
|
|
144
148
|
return uuid.v4();
|
|
145
149
|
}
|
|
150
|
+
function currentWalletIdsEq(a, b) {
|
|
151
|
+
if (!a && !b) return true;
|
|
152
|
+
if (!a || !b) return false;
|
|
153
|
+
const aKeys = Object.keys(a);
|
|
154
|
+
const bKeys = Object.keys(b);
|
|
155
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
156
|
+
return aKeys.every((key) => {
|
|
157
|
+
var _a, _b;
|
|
158
|
+
const aIds = ((_a = a[key]) == null ? void 0 : _a.sort()) || [];
|
|
159
|
+
const bIds = ((_b = b[key]) == null ? void 0 : _b.sort()) || [];
|
|
160
|
+
return aIds.length === bIds.length && aIds.every((id, index) => id === bIds[index]);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
146
163
|
// Annotate the CommonJS export names for ESM import in node:
|
|
147
164
|
0 && (module.exports = {
|
|
148
165
|
WalletSchemeTypeMap,
|
|
166
|
+
currentWalletIdsEq,
|
|
149
167
|
entityToWallet,
|
|
150
168
|
getEquivalentTypes,
|
|
151
169
|
getSchemes,
|
|
@@ -15,19 +15,24 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var
|
|
19
|
-
__export(
|
|
20
|
-
|
|
18
|
+
var window_exports = {};
|
|
19
|
+
__export(window_exports, {
|
|
20
|
+
isPortal: () => isPortal
|
|
21
21
|
});
|
|
22
|
-
module.exports = __toCommonJS(
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
module.exports = __toCommonJS(window_exports);
|
|
23
|
+
var import_url = require("./url.js");
|
|
24
|
+
function isPortal(ctx, env) {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
if (typeof window === "undefined") return false;
|
|
27
|
+
const normalizedUrl = (_b = (_a = window.location) == null ? void 0 : _a.host) == null ? void 0 : _b.replace("getpara", "usecapsule");
|
|
28
|
+
const isOnPortalDomain = (0, import_url.getPortalBaseURL)(env ? { env } : ctx).includes(normalizedUrl);
|
|
29
|
+
if (!isOnPortalDomain) return false;
|
|
30
|
+
const isInIframe = window.parent !== window && !window.opener;
|
|
31
|
+
const isInPopup = window.opener && window.parent === window;
|
|
32
|
+
const isDirectAccess = window.parent === window && !window.opener;
|
|
33
|
+
return isInIframe || isInPopup || isDirectAccess;
|
|
34
|
+
}
|
|
30
35
|
// Annotate the CommonJS export names for ESM import in node:
|
|
31
36
|
0 && (module.exports = {
|
|
32
|
-
|
|
37
|
+
isPortal
|
|
33
38
|
});
|