@getpara/core-sdk 1.12.0 → 2.0.0-alpha.10
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 +942 -975
- package/dist/cjs/constants.js +7 -1
- package/dist/cjs/index.js +15 -3
- package/dist/cjs/types/coreApi.js +74 -0
- package/dist/cjs/types/events.js +1 -0
- package/dist/cjs/types/index.js +4 -2
- package/dist/cjs/types/{params.js → methods.js} +2 -2
- package/dist/cjs/utils/autobind.js +41 -0
- package/dist/cjs/utils/formatting.js +0 -12
- package/dist/cjs/utils/index.js +10 -0
- package/dist/cjs/utils/json.js +37 -0
- package/dist/cjs/utils/listeners.js +2 -11
- package/dist/cjs/utils/phone.js +73 -0
- package/dist/cjs/utils/types.js +29 -0
- package/dist/cjs/utils/url.js +34 -2
- package/dist/cjs/utils/wallet.js +30 -17
- package/dist/esm/ParaCore.js +959 -980
- package/dist/esm/constants.js +5 -1
- package/dist/esm/index.js +12 -3
- package/dist/esm/types/coreApi.js +52 -0
- package/dist/esm/types/events.js +1 -0
- package/dist/esm/types/index.js +2 -1
- package/dist/esm/utils/autobind.js +19 -0
- package/dist/esm/utils/formatting.js +0 -10
- package/dist/esm/utils/index.js +5 -0
- package/dist/esm/utils/json.js +15 -0
- package/dist/esm/utils/listeners.js +2 -11
- package/dist/esm/utils/phone.js +39 -0
- package/dist/esm/utils/types.js +7 -0
- package/dist/esm/utils/url.js +15 -2
- package/dist/esm/utils/wallet.js +27 -16
- package/dist/types/ParaCore.d.ts +100 -391
- package/dist/types/PlatformUtils.d.ts +3 -3
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/external/userManagementClient.d.ts +1 -1
- package/dist/types/index.d.ts +5 -3
- package/dist/types/types/config.d.ts +4 -24
- package/dist/types/types/coreApi.d.ts +475 -0
- package/dist/types/types/events.d.ts +4 -1
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types/types/methods.d.ts +148 -0
- package/dist/types/types/onRamps.d.ts +3 -3
- package/dist/types/types/wallet.d.ts +4 -4
- package/dist/types/utils/autobind.d.ts +1 -0
- package/dist/types/utils/formatting.d.ts +2 -4
- package/dist/types/utils/index.d.ts +5 -0
- package/dist/types/utils/json.d.ts +1 -0
- package/dist/types/utils/onRamps.d.ts +3 -3
- package/dist/types/utils/phone.d.ts +11 -0
- package/dist/types/utils/types.d.ts +2 -0
- package/dist/types/utils/url.d.ts +2 -1
- package/dist/types/utils/wallet.d.ts +9 -7
- package/package.json +4 -3
- package/dist/types/types/params.d.ts +0 -73
- /package/dist/esm/types/{params.js → methods.js} +0 -0
package/dist/cjs/utils/wallet.js
CHANGED
|
@@ -51,24 +51,25 @@ __export(wallet_exports, {
|
|
|
51
51
|
getWalletTypes: () => getWalletTypes,
|
|
52
52
|
isPregenIdentifierMatch: () => isPregenIdentifierMatch,
|
|
53
53
|
isWalletSupported: () => isWalletSupported,
|
|
54
|
+
mergeCurrentWalletIds: () => mergeCurrentWalletIds,
|
|
54
55
|
migrateWallet: () => migrateWallet,
|
|
55
|
-
newUuid: () => newUuid
|
|
56
|
+
newUuid: () => newUuid,
|
|
57
|
+
supportedWalletTypesEq: () => supportedWalletTypesEq
|
|
56
58
|
});
|
|
57
59
|
module.exports = __toCommonJS(wallet_exports);
|
|
58
60
|
var uuid = __toESM(require("uuid"));
|
|
59
|
-
var
|
|
60
|
-
var import_formatting = require("./formatting.js");
|
|
61
|
+
var import_phone = require("./phone.js");
|
|
61
62
|
const WalletSchemeTypeMap = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
DKLS: {
|
|
64
|
+
EVM: true,
|
|
65
|
+
COSMOS: true
|
|
65
66
|
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
CGGMP: {
|
|
68
|
+
EVM: true,
|
|
69
|
+
COSMOS: true
|
|
69
70
|
},
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
ED25519: {
|
|
72
|
+
SOLANA: true
|
|
72
73
|
}
|
|
73
74
|
};
|
|
74
75
|
function isPregenIdentifierMatch(a, b, type) {
|
|
@@ -79,7 +80,7 @@ function isPregenIdentifierMatch(a, b, type) {
|
|
|
79
80
|
case "EMAIL":
|
|
80
81
|
return a.toLowerCase() === b.toLowerCase();
|
|
81
82
|
case "PHONE":
|
|
82
|
-
return (0,
|
|
83
|
+
return (0, import_phone.formatPhoneNumber)(a) === (0, import_phone.formatPhoneNumber)(b);
|
|
83
84
|
case "CUSTOM_ID":
|
|
84
85
|
return a === b;
|
|
85
86
|
default:
|
|
@@ -94,7 +95,7 @@ function isWalletSupported(types, wallet) {
|
|
|
94
95
|
}
|
|
95
96
|
function getSchemes(types) {
|
|
96
97
|
return Object.keys(WalletSchemeTypeMap).filter((scheme) => {
|
|
97
|
-
if (scheme ===
|
|
98
|
+
if (scheme === "CGGMP") {
|
|
98
99
|
return false;
|
|
99
100
|
}
|
|
100
101
|
return (Array.isArray(types) ? types : Object.keys(types)).some((type) => WalletSchemeTypeMap[scheme][type]);
|
|
@@ -110,7 +111,7 @@ function getWalletTypes(schemes) {
|
|
|
110
111
|
];
|
|
111
112
|
}
|
|
112
113
|
function getEquivalentTypes(types) {
|
|
113
|
-
return getWalletTypes(getSchemes(
|
|
114
|
+
return getWalletTypes(getSchemes(Array.isArray(types) ? types : [types]));
|
|
114
115
|
}
|
|
115
116
|
function entityToWallet(w) {
|
|
116
117
|
return __spreadProps(__spreadValues({}, w), {
|
|
@@ -122,13 +123,23 @@ function entityToWallet(w) {
|
|
|
122
123
|
function migrateWallet(obj) {
|
|
123
124
|
if (["USER", "PREGEN"].includes(obj.type)) {
|
|
124
125
|
obj.isPregen = obj.type === "PREGEN";
|
|
125
|
-
obj.type = obj.scheme ===
|
|
126
|
+
obj.type = obj.scheme === "ED25519" ? "SOLANA" : "EVM";
|
|
126
127
|
}
|
|
127
128
|
if (!!obj.scheme && !obj.type) {
|
|
128
|
-
obj.type = obj.scheme ===
|
|
129
|
+
obj.type = obj.scheme === "ED25519" ? "SOLANA" : "EVM";
|
|
129
130
|
}
|
|
130
131
|
return obj;
|
|
131
132
|
}
|
|
133
|
+
function supportedWalletTypesEq(a, b) {
|
|
134
|
+
return a.length === b.length && a.every(({ type, optional }, index) => b[index].type === type && b[index].optional === optional);
|
|
135
|
+
}
|
|
136
|
+
function mergeCurrentWalletIds(original, additional) {
|
|
137
|
+
return [.../* @__PURE__ */ new Set([...Object.keys(original), ...Object.keys(additional)])].reduce((acc, key) => {
|
|
138
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
139
|
+
[key]: [.../* @__PURE__ */ new Set([...original[key] || [], ...additional[key] || []])]
|
|
140
|
+
});
|
|
141
|
+
}, {});
|
|
142
|
+
}
|
|
132
143
|
function newUuid() {
|
|
133
144
|
return uuid.v4();
|
|
134
145
|
}
|
|
@@ -141,6 +152,8 @@ function newUuid() {
|
|
|
141
152
|
getWalletTypes,
|
|
142
153
|
isPregenIdentifierMatch,
|
|
143
154
|
isWalletSupported,
|
|
155
|
+
mergeCurrentWalletIds,
|
|
144
156
|
migrateWallet,
|
|
145
|
-
newUuid
|
|
157
|
+
newUuid,
|
|
158
|
+
supportedWalletTypesEq
|
|
146
159
|
});
|