@multiplatform.one/web3 7.25.0 → 7.26.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/core/family.cjs +88 -0
- package/dist/cjs/core/family.native.js +115 -0
- package/dist/cjs/core/family.native.js.map +1 -0
- package/dist/cjs/core/index.cjs +41 -0
- package/dist/cjs/core/index.native.js +44 -0
- package/dist/cjs/core/index.native.js.map +1 -0
- package/dist/cjs/core/message.cjs +89 -0
- package/dist/cjs/core/message.native.js +104 -0
- package/dist/cjs/core/message.native.js.map +1 -0
- package/dist/cjs/core/names.cjs +51 -0
- package/dist/cjs/core/names.native.js +95 -0
- package/dist/cjs/core/names.native.js.map +1 -0
- package/dist/cjs/core/react.cjs +48 -0
- package/dist/cjs/core/react.native.js +52 -0
- package/dist/cjs/core/react.native.js.map +1 -0
- package/dist/cjs/core/store.cjs +450 -0
- package/dist/cjs/core/store.native.js +637 -0
- package/dist/cjs/core/store.native.js.map +1 -0
- package/dist/cjs/core/types.cjs +18 -0
- package/dist/cjs/core/types.native.js +21 -0
- package/dist/cjs/core/types.native.js.map +1 -0
- package/dist/cjs/index.cjs +2 -1
- package/dist/cjs/index.native.js +1 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/core/family.mjs +62 -0
- package/dist/esm/core/family.mjs.map +1 -0
- package/dist/esm/core/family.native.js +86 -0
- package/dist/esm/core/family.native.js.map +1 -0
- package/dist/esm/core/index.mjs +7 -0
- package/dist/esm/core/index.mjs.map +1 -0
- package/dist/esm/core/index.native.js +7 -0
- package/dist/esm/core/index.native.js.map +1 -0
- package/dist/esm/core/message.mjs +63 -0
- package/dist/esm/core/message.mjs.map +1 -0
- package/dist/esm/core/message.native.js +75 -0
- package/dist/esm/core/message.native.js.map +1 -0
- package/dist/esm/core/names.mjs +25 -0
- package/dist/esm/core/names.mjs.map +1 -0
- package/dist/esm/core/names.native.js +66 -0
- package/dist/esm/core/names.native.js.map +1 -0
- package/dist/esm/core/react.mjs +21 -0
- package/dist/esm/core/react.mjs.map +1 -0
- package/dist/esm/core/react.native.js +22 -0
- package/dist/esm/core/react.native.js.map +1 -0
- package/dist/esm/core/store.mjs +424 -0
- package/dist/esm/core/store.mjs.map +1 -0
- package/dist/esm/core/store.native.js +608 -0
- package/dist/esm/core/store.native.js.map +1 -0
- package/dist/esm/core/types.mjs +2 -0
- package/dist/esm/core/types.mjs.map +1 -0
- package/dist/esm/core/types.native.js +2 -0
- package/dist/esm/core/types.native.js.map +1 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +1 -0
- package/dist/esm/index.native.js.map +1 -1
- package/dist/jsx/core/family.mjs +62 -0
- package/dist/jsx/core/family.mjs.map +1 -0
- package/dist/jsx/core/family.native.js +115 -0
- package/dist/jsx/core/family.native.js.map +1 -0
- package/dist/jsx/core/index.mjs +7 -0
- package/dist/jsx/core/index.mjs.map +1 -0
- package/dist/jsx/core/index.native.js +44 -0
- package/dist/jsx/core/index.native.js.map +1 -0
- package/dist/jsx/core/message.mjs +63 -0
- package/dist/jsx/core/message.mjs.map +1 -0
- package/dist/jsx/core/message.native.js +104 -0
- package/dist/jsx/core/message.native.js.map +1 -0
- package/dist/jsx/core/names.mjs +25 -0
- package/dist/jsx/core/names.mjs.map +1 -0
- package/dist/jsx/core/names.native.js +95 -0
- package/dist/jsx/core/names.native.js.map +1 -0
- package/dist/jsx/core/react.mjs +21 -0
- package/dist/jsx/core/react.mjs.map +1 -0
- package/dist/jsx/core/react.native.js +52 -0
- package/dist/jsx/core/react.native.js.map +1 -0
- package/dist/jsx/core/store.mjs +424 -0
- package/dist/jsx/core/store.mjs.map +1 -0
- package/dist/jsx/core/store.native.js +637 -0
- package/dist/jsx/core/store.native.js.map +1 -0
- package/dist/jsx/core/types.mjs +2 -0
- package/dist/jsx/core/types.mjs.map +1 -0
- package/dist/jsx/core/types.native.js +21 -0
- package/dist/jsx/core/types.native.js.map +1 -0
- package/dist/jsx/index.js +1 -0
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +1 -0
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/index.native.js +1 -0
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +6 -6
- package/src/core/family.spec.ts +117 -0
- package/src/core/family.ts +103 -0
- package/src/core/imports.spec.ts +82 -0
- package/src/core/index.ts +47 -0
- package/src/core/message.spec.ts +178 -0
- package/src/core/message.ts +119 -0
- package/src/core/names.ts +29 -0
- package/src/core/react.spec.tsx +75 -0
- package/src/core/react.ts +34 -0
- package/src/core/store.spec.ts +890 -0
- package/src/core/store.ts +558 -0
- package/src/core/types.ts +96 -0
- package/src/index.ts +4 -0
- package/types/core/family.d.ts +44 -0
- package/types/core/family.d.ts.map +1 -0
- package/types/core/index.d.ts +7 -0
- package/types/core/index.d.ts.map +1 -0
- package/types/core/message.d.ts +44 -0
- package/types/core/message.d.ts.map +1 -0
- package/types/core/names.d.ts +7 -0
- package/types/core/names.d.ts.map +1 -0
- package/types/core/react.d.ts +14 -0
- package/types/core/react.d.ts.map +1 -0
- package/types/core/store.d.ts +64 -0
- package/types/core/store.d.ts.map +1 -0
- package/types/core/types.d.ts +88 -0
- package/types/core/types.d.ts.map +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
|
@@ -0,0 +1,88 @@
|
|
|
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) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var family_exports = {};
|
|
24
|
+
__export(family_exports, {
|
|
25
|
+
createFamilyRegistry: () => createFamilyRegistry,
|
|
26
|
+
defineWalletFamily: () => defineWalletFamily
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(family_exports);
|
|
29
|
+
var import_message = require("./message.cjs");
|
|
30
|
+
var import_names = require("./names.cjs");
|
|
31
|
+
function defineWalletFamily(definition) {
|
|
32
|
+
(0, import_names.assertName)("wallet family id", definition.id);
|
|
33
|
+
const aliases = [...(definition.aliases ?? [])];
|
|
34
|
+
for (const alias of aliases) {
|
|
35
|
+
(0, import_names.assertName)(`wallet family ${definition.id} alias`, alias);
|
|
36
|
+
if (alias === definition.id) {
|
|
37
|
+
throw new Error(`wallet family ${definition.id} lists its own id as an alias`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (typeof definition.label !== "string" || !definition.label.trim()) {
|
|
41
|
+
throw new Error(`wallet family ${definition.id} needs a label`);
|
|
42
|
+
}
|
|
43
|
+
const {
|
|
44
|
+
message
|
|
45
|
+
} = definition;
|
|
46
|
+
if (!message || typeof message.header !== "string" || !message.header) {
|
|
47
|
+
throw new Error(`wallet family ${definition.id} needs a message spec with a header`);
|
|
48
|
+
}
|
|
49
|
+
const connectionless = definition.connectionless === true;
|
|
50
|
+
if (connectionless && definition.driver) {
|
|
51
|
+
throw new Error(`wallet family ${definition.id} is connectionless and cannot have a driver`);
|
|
52
|
+
}
|
|
53
|
+
if (!connectionless && typeof definition.driver !== "function") {
|
|
54
|
+
throw new Error(`wallet family ${definition.id} needs a driver, or connectionless: true`);
|
|
55
|
+
}
|
|
56
|
+
return Object.freeze({
|
|
57
|
+
...definition,
|
|
58
|
+
aliases: Object.freeze(aliases),
|
|
59
|
+
connectionless,
|
|
60
|
+
message: Object.freeze({
|
|
61
|
+
...message
|
|
62
|
+
}),
|
|
63
|
+
...(definition.screens ? {
|
|
64
|
+
screens: Object.freeze([...definition.screens])
|
|
65
|
+
} : {})
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function createFamilyRegistry(families) {
|
|
69
|
+
const list = Object.freeze([...families]);
|
|
70
|
+
const names = (0, import_names.nameTable)(list);
|
|
71
|
+
const byId = new Map(list.map(family => [family.id, family]));
|
|
72
|
+
const get = family => {
|
|
73
|
+
const id = names.get(family);
|
|
74
|
+
return id === void 0 ? void 0 : byId.get(id);
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
families: list,
|
|
78
|
+
get,
|
|
79
|
+
require(family) {
|
|
80
|
+
const found = get(family);
|
|
81
|
+
if (found === void 0) {
|
|
82
|
+
throw new Error(`wallet family ${family} is not registered; registered: ${list.map(entry => entry.id).join(", ") || "none"}`);
|
|
83
|
+
}
|
|
84
|
+
return found;
|
|
85
|
+
},
|
|
86
|
+
messages: (0, import_message.createMessageRegistry)(list)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var family_exports = {};
|
|
26
|
+
__export(family_exports, {
|
|
27
|
+
createFamilyRegistry: () => createFamilyRegistry,
|
|
28
|
+
defineWalletFamily: () => defineWalletFamily
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(family_exports);
|
|
31
|
+
var import_message = require("./message.native.js");
|
|
32
|
+
var import_names = require("./names.native.js");
|
|
33
|
+
function defineWalletFamily(definition) {
|
|
34
|
+
var _definition_aliases;
|
|
35
|
+
(0, import_names.assertName)("wallet family id", definition.id);
|
|
36
|
+
var aliases = [...((_definition_aliases = definition.aliases) !== null && _definition_aliases !== void 0 ? _definition_aliases : [])];
|
|
37
|
+
var _iteratorNormalCompletion = true,
|
|
38
|
+
_didIteratorError = false,
|
|
39
|
+
_iteratorError = void 0;
|
|
40
|
+
try {
|
|
41
|
+
for (var _iterator = aliases[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
42
|
+
var alias = _step.value;
|
|
43
|
+
(0, import_names.assertName)(`wallet family ${definition.id} alias`, alias);
|
|
44
|
+
if (alias === definition.id) {
|
|
45
|
+
throw new Error(`wallet family ${definition.id} lists its own id as an alias`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
} catch (err) {
|
|
49
|
+
_didIteratorError = true;
|
|
50
|
+
_iteratorError = err;
|
|
51
|
+
} finally {
|
|
52
|
+
try {
|
|
53
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
54
|
+
_iterator.return();
|
|
55
|
+
}
|
|
56
|
+
} finally {
|
|
57
|
+
if (_didIteratorError) {
|
|
58
|
+
throw _iteratorError;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (typeof definition.label !== "string" || !definition.label.trim()) {
|
|
63
|
+
throw new Error(`wallet family ${definition.id} needs a label`);
|
|
64
|
+
}
|
|
65
|
+
var {
|
|
66
|
+
message
|
|
67
|
+
} = definition;
|
|
68
|
+
if (!message || typeof message.header !== "string" || !message.header) {
|
|
69
|
+
throw new Error(`wallet family ${definition.id} needs a message spec with a header`);
|
|
70
|
+
}
|
|
71
|
+
var connectionless = definition.connectionless === true;
|
|
72
|
+
if (connectionless && definition.driver) {
|
|
73
|
+
throw new Error(`wallet family ${definition.id} is connectionless and cannot have a driver`);
|
|
74
|
+
}
|
|
75
|
+
if (!connectionless && typeof definition.driver !== "function") {
|
|
76
|
+
throw new Error(`wallet family ${definition.id} needs a driver, or connectionless: true`);
|
|
77
|
+
}
|
|
78
|
+
return Object.freeze({
|
|
79
|
+
...definition,
|
|
80
|
+
aliases: Object.freeze(aliases),
|
|
81
|
+
connectionless,
|
|
82
|
+
message: Object.freeze({
|
|
83
|
+
...message
|
|
84
|
+
}),
|
|
85
|
+
...(definition.screens ? {
|
|
86
|
+
screens: Object.freeze([...definition.screens])
|
|
87
|
+
} : {})
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function createFamilyRegistry(families) {
|
|
91
|
+
var list = Object.freeze([...families]);
|
|
92
|
+
var names = (0, import_names.nameTable)(list);
|
|
93
|
+
var byId = new Map(list.map(function (family) {
|
|
94
|
+
return [family.id, family];
|
|
95
|
+
}));
|
|
96
|
+
var get = function get2(family) {
|
|
97
|
+
var id = names.get(family);
|
|
98
|
+
return id === void 0 ? void 0 : byId.get(id);
|
|
99
|
+
};
|
|
100
|
+
return {
|
|
101
|
+
families: list,
|
|
102
|
+
get,
|
|
103
|
+
require(family) {
|
|
104
|
+
var found = get(family);
|
|
105
|
+
if (found === void 0) {
|
|
106
|
+
throw new Error(`wallet family ${family} is not registered; registered: ${list.map(function (entry) {
|
|
107
|
+
return entry.id;
|
|
108
|
+
}).join(", ") || "none"}`);
|
|
109
|
+
}
|
|
110
|
+
return found;
|
|
111
|
+
},
|
|
112
|
+
messages: (0, import_message.createMessageRegistry)(list)
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=family.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","family_exports","__export","createFamilyRegistry","defineWalletFamily","module","exports","import_message","require","import_names","definition","_definition_aliases","assertName","id","aliases","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Symbol","iterator","_step","next","done","alias","Error","err","return","label","trim","message","header","connectionless","driver","Object","freeze","screens"],"sources":["../../../src/core/family.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,cAAA;AAAAC,QAAA,CAAAD,cAAA;EAAAE,oBAAA,EAAAA,CAAA,KAAAA,oBAAA;EAAAC,kBAAA,EAAAA,CAAA,KAAAA;AAAA;AAEAC,MAAA,CAAAC,OAAA,GAAAV,YAIO,CAAAK,cAAA;AACP,IAAAM,cAAA,GAAsCC,OAAA;AA8B/B,IAAAC,YAAS,GAAAD,OAAA,oBAAmB;AACjC,SAAAJ,mBAAAM,UAAW;EACX,IAAAC,mBAAqB;EACrB,IAAAF,YAAW,CAAAG,UAAS,EAAS,oBAAAF,UAAA,CAAAG,EAAA;EAC3B,IAAAC,OAAA,IACA,KAAIH,mBAAU,GAAWD,UAAI,CAAAI,OAAA,cAAAH,m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B,MAAA;IACA,UAAQR,KAAA,CAAQ,iBAAAf,UAAA,CAAAG,EAAA;EACd;EACA,OAAAqB,MAAI,CAAAC,MAAU;IACZ,GAAAzB,UAAM;IAAII,OACR,EAAAoB,MAAA,CAAAC,MAAA,CAAiBrB,OAAM;IAAqFkB,cAC9G;IAAAF,OACF,EAAAI,MAAA,CAAAC,MAAA;MACA,GAAAL;IACF;IACA,IAAApB,UAAA,CAAU0B,OAAA;MACZA,OAAA,EAAAF,MAAA,CAAAC,MAAA,EACF,GAAAzB,UAAA,CAAA0B,OAAA,C","ignoreList":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
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) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var core_exports = {};
|
|
24
|
+
__export(core_exports, {
|
|
25
|
+
ConnectionProvider: () => import_react.ConnectionProvider,
|
|
26
|
+
UnsupportedClientMethodError: () => import_types.UnsupportedClientMethodError,
|
|
27
|
+
createConnectionStore: () => import_store.createConnectionStore,
|
|
28
|
+
createFamilyRegistry: () => import_family.createFamilyRegistry,
|
|
29
|
+
createMessageRegistry: () => import_message.createMessageRegistry,
|
|
30
|
+
defaultConnectionStorageKey: () => import_store.defaultConnectionStorageKey,
|
|
31
|
+
defineWalletFamily: () => import_family.defineWalletFamily,
|
|
32
|
+
formatWalletMessage: () => import_message.formatWalletMessage,
|
|
33
|
+
useConnection: () => import_react.useConnection,
|
|
34
|
+
useConnectionStore: () => import_react.useConnectionStore
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(core_exports);
|
|
37
|
+
var import_family = require("./family.cjs");
|
|
38
|
+
var import_message = require("./message.cjs");
|
|
39
|
+
var import_store = require("./store.cjs");
|
|
40
|
+
var import_react = require("./react.cjs");
|
|
41
|
+
var import_types = require("../clients/types.cjs");
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var core_exports = {};
|
|
26
|
+
__export(core_exports, {
|
|
27
|
+
ConnectionProvider: () => import_react.ConnectionProvider,
|
|
28
|
+
UnsupportedClientMethodError: () => import_types.UnsupportedClientMethodError,
|
|
29
|
+
createConnectionStore: () => import_store.createConnectionStore,
|
|
30
|
+
createFamilyRegistry: () => import_family.createFamilyRegistry,
|
|
31
|
+
createMessageRegistry: () => import_message.createMessageRegistry,
|
|
32
|
+
defaultConnectionStorageKey: () => import_store.defaultConnectionStorageKey,
|
|
33
|
+
defineWalletFamily: () => import_family.defineWalletFamily,
|
|
34
|
+
formatWalletMessage: () => import_message.formatWalletMessage,
|
|
35
|
+
useConnection: () => import_react.useConnection,
|
|
36
|
+
useConnectionStore: () => import_react.useConnectionStore
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(core_exports);
|
|
39
|
+
var import_family = require("./family.native.js");
|
|
40
|
+
var import_message = require("./message.native.js");
|
|
41
|
+
var import_store = require("./store.native.js");
|
|
42
|
+
var import_react = require("./react.native.js");
|
|
43
|
+
var import_types = require("../clients/types.native.js");
|
|
44
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","core_exports","__export","ConnectionProvider","import_react","UnsupportedClientMethodError","import_types","createConnectionStore","import_store","createFamilyRegistry","import_family","createMessageRegistry","import_message","defaultConnectionStorageKey","defineWalletFamily","formatWalletMessage","useConnection","useConnectionStore","module","exports","require"],"sources":["../../../src/core/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,YAAA;AAAAC,QAAA,CAAAD,YAAA;EAAAE,kBAAA,EAAAA,CAAA,KAAAC,YAAA,CAAAD,kBAAA;EAAAE,4BAAA,EAAAA,CAAA,KAAAC,YAAA,CAAAD,4BAAA;EAAAE,qBAAA,EAAAA,CAAA,KAAAC,YAAA,CAAAD,qBAAA;EAAAE,oBAAA,EAAAA,CAAA,KAAAC,aAAA,CAAAD,oBAAA;EAAAE,qBAAA,EAAAA,CAAA,KAAAC,cAAA,CAAAD,qBAAA;EAAAE,2BAAA,EAAAA,CAAA,KAAAL,YAAA,CAAAK,2BAAA;EAAAC,kBAAA,EAAAA,CAAA,KAAAJ,aAAA,CAAAI,kBAAA;EAAAC,mBAAA,EAAAA,CAAA,KAAAH,cAAA,CAAAG,mBAAA;EAAAC,aAAA,EAAAA,CAAA,KAAAZ,YAAA,CAAAY,aAAA;EAAAC,kBAAA,EAAAA,CAAA,KAAAb,YAAA,CAAAa;AAAA;AAGAC,MAAA,CAAAC,OAAA,GAAAvB,YAMO,CAAAK,YAAA;AACP,IAAAS,aAAA,GAAAU,OAMO;AACP,IAAAR,cAAA,GAMOQ,OAAA;AACP,IAAAZ,YAAA,GAKOY,OAAA;AAYP,IAAAhB,YAAA,GAKOgB,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,89 @@
|
|
|
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) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var message_exports = {};
|
|
24
|
+
__export(message_exports, {
|
|
25
|
+
createMessageRegistry: () => createMessageRegistry,
|
|
26
|
+
formatWalletMessage: () => formatWalletMessage
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(message_exports);
|
|
29
|
+
var import_names = require("./names.cjs");
|
|
30
|
+
function singleLine(field, value) {
|
|
31
|
+
if (value && /[\r\n]/.test(value)) {
|
|
32
|
+
throw new Error(`wallet message: ${field} must be a single line`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function pageLocation() {
|
|
36
|
+
const location = globalThis.location;
|
|
37
|
+
return {
|
|
38
|
+
host: location?.host ?? "",
|
|
39
|
+
origin: location?.origin ?? ""
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function formatWalletMessage(spec, opts, family = "wallet") {
|
|
43
|
+
const page = pageLocation();
|
|
44
|
+
const domain = opts.domain ?? page.host;
|
|
45
|
+
if (!domain) {
|
|
46
|
+
throw new Error("wallet message: no domain. Pass opts.domain; a file:// or native page has no host.");
|
|
47
|
+
}
|
|
48
|
+
const pageOrigin = page.origin && page.origin !== "null" ? page.origin : "";
|
|
49
|
+
const uri = opts.uri ?? (pageOrigin || `https://${domain}`);
|
|
50
|
+
const statement = opts.statement === void 0 ? spec.statement : opts.statement;
|
|
51
|
+
singleLine("domain", domain);
|
|
52
|
+
singleLine("uri", uri);
|
|
53
|
+
singleLine("statement", statement);
|
|
54
|
+
const lines = [`${domain} ${spec.header}`];
|
|
55
|
+
if (spec.address !== false) {
|
|
56
|
+
if (!opts.address) throw new Error(`wallet message: ${family} needs an address`);
|
|
57
|
+
lines.push(spec.normalizeAddress ? spec.normalizeAddress(opts.address) : opts.address);
|
|
58
|
+
}
|
|
59
|
+
lines.push("");
|
|
60
|
+
if (statement) lines.push(statement, "");else if (spec.keepStatementLine) lines.push("");
|
|
61
|
+
lines.push(`URI: ${uri}`, `Version: ${opts.version ?? "1"}`);
|
|
62
|
+
if (spec.chainId !== null) {
|
|
63
|
+
const chainId = spec.numericChainId ? opts.chainId ?? spec.chainId : typeof opts.chainId === "string" ? opts.chainId : spec.chainId;
|
|
64
|
+
lines.push(`Chain ID: ${chainId}`);
|
|
65
|
+
}
|
|
66
|
+
lines.push(`Nonce: ${opts.nonce}`, `Issued At: ${opts.issuedAt ?? (/* @__PURE__ */new Date()).toISOString()}`);
|
|
67
|
+
return lines.join("\n");
|
|
68
|
+
}
|
|
69
|
+
function createMessageRegistry(families) {
|
|
70
|
+
const list = [...families];
|
|
71
|
+
const names = (0, import_names.nameTable)(list);
|
|
72
|
+
const specs = new Map(list.map(family => [family.id, family.message]));
|
|
73
|
+
const spec = family => {
|
|
74
|
+
const id = names.get(family);
|
|
75
|
+
return id === void 0 ? void 0 : specs.get(id);
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
families: list.map(family => family.id),
|
|
79
|
+
resolve: family => names.get(family),
|
|
80
|
+
spec,
|
|
81
|
+
build(family, opts) {
|
|
82
|
+
const found = spec(family);
|
|
83
|
+
if (found === void 0) {
|
|
84
|
+
throw new Error(`no wallet message for family ${family}; registered: ${list.map(entry => entry.id).join(", ") || "none"}`);
|
|
85
|
+
}
|
|
86
|
+
return formatWalletMessage(found, opts, names.get(family));
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var message_exports = {};
|
|
26
|
+
__export(message_exports, {
|
|
27
|
+
createMessageRegistry: () => createMessageRegistry,
|
|
28
|
+
formatWalletMessage: () => formatWalletMessage
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(message_exports);
|
|
31
|
+
var import_names = require("./names.native.js");
|
|
32
|
+
function singleLine(field, value) {
|
|
33
|
+
if (value && /[\r\n]/.test(value)) {
|
|
34
|
+
throw new Error(`wallet message: ${field} must be a single line`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function pageLocation() {
|
|
38
|
+
var _ref, _ref1;
|
|
39
|
+
var location = globalThis.location;
|
|
40
|
+
return {
|
|
41
|
+
host: (_ref = location === null || location === void 0 ? void 0 : location.host) !== null && _ref !== void 0 ? _ref : "",
|
|
42
|
+
origin: (_ref1 = location === null || location === void 0 ? void 0 : location.origin) !== null && _ref1 !== void 0 ? _ref1 : ""
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function formatWalletMessage(spec, opts) {
|
|
46
|
+
var family = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "wallet";
|
|
47
|
+
var _opts_domain, _opts_uri, _opts_version, _opts_issuedAt;
|
|
48
|
+
var page = pageLocation();
|
|
49
|
+
var domain = (_opts_domain = opts.domain) !== null && _opts_domain !== void 0 ? _opts_domain : page.host;
|
|
50
|
+
if (!domain) {
|
|
51
|
+
throw new Error("wallet message: no domain. Pass opts.domain; a file:// or native page has no host.");
|
|
52
|
+
}
|
|
53
|
+
var pageOrigin = page.origin && page.origin !== "null" ? page.origin : "";
|
|
54
|
+
var uri = (_opts_uri = opts.uri) !== null && _opts_uri !== void 0 ? _opts_uri : pageOrigin || `https://${domain}`;
|
|
55
|
+
var statement = opts.statement === void 0 ? spec.statement : opts.statement;
|
|
56
|
+
singleLine("domain", domain);
|
|
57
|
+
singleLine("uri", uri);
|
|
58
|
+
singleLine("statement", statement);
|
|
59
|
+
var lines = [`${domain} ${spec.header}`];
|
|
60
|
+
if (spec.address !== false) {
|
|
61
|
+
if (!opts.address) throw new Error(`wallet message: ${family} needs an address`);
|
|
62
|
+
lines.push(spec.normalizeAddress ? spec.normalizeAddress(opts.address) : opts.address);
|
|
63
|
+
}
|
|
64
|
+
lines.push("");
|
|
65
|
+
if (statement) lines.push(statement, "");else if (spec.keepStatementLine) lines.push("");
|
|
66
|
+
lines.push(`URI: ${uri}`, `Version: ${(_opts_version = opts.version) !== null && _opts_version !== void 0 ? _opts_version : "1"}`);
|
|
67
|
+
if (spec.chainId !== null) {
|
|
68
|
+
var _opts_chainId;
|
|
69
|
+
var chainId = spec.numericChainId ? (_opts_chainId = opts.chainId) !== null && _opts_chainId !== void 0 ? _opts_chainId : spec.chainId : typeof opts.chainId === "string" ? opts.chainId : spec.chainId;
|
|
70
|
+
lines.push(`Chain ID: ${chainId}`);
|
|
71
|
+
}
|
|
72
|
+
lines.push(`Nonce: ${opts.nonce}`, `Issued At: ${(_opts_issuedAt = opts.issuedAt) !== null && _opts_issuedAt !== void 0 ? _opts_issuedAt : (/* @__PURE__ */new Date()).toISOString()}`);
|
|
73
|
+
return lines.join("\n");
|
|
74
|
+
}
|
|
75
|
+
function createMessageRegistry(families) {
|
|
76
|
+
var list = [...families];
|
|
77
|
+
var names = (0, import_names.nameTable)(list);
|
|
78
|
+
var specs = new Map(list.map(function (family) {
|
|
79
|
+
return [family.id, family.message];
|
|
80
|
+
}));
|
|
81
|
+
var spec = function spec2(family) {
|
|
82
|
+
var id = names.get(family);
|
|
83
|
+
return id === void 0 ? void 0 : specs.get(id);
|
|
84
|
+
};
|
|
85
|
+
return {
|
|
86
|
+
families: list.map(function (family) {
|
|
87
|
+
return family.id;
|
|
88
|
+
}),
|
|
89
|
+
resolve: function resolve(family) {
|
|
90
|
+
return names.get(family);
|
|
91
|
+
},
|
|
92
|
+
spec,
|
|
93
|
+
build(family, opts) {
|
|
94
|
+
var found = spec(family);
|
|
95
|
+
if (found === void 0) {
|
|
96
|
+
throw new Error(`no wallet message for family ${family}; registered: ${list.map(function (entry) {
|
|
97
|
+
return entry.id;
|
|
98
|
+
}).join(", ") || "none"}`);
|
|
99
|
+
}
|
|
100
|
+
return formatWalletMessage(found, opts, names.get(family));
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=message.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","message_exports","__export","createMessageRegistry","formatWalletMessage","module","exports","import_names","require","singleLine","field","test","Error","pageLocation","_ref","_ref1","location","globalThis","host","origin","spec","opts","family","arguments","length","_opts_domain","_opts_uri","_opts_version","_opts_issuedAt","page","domain","pageOrigin","uri","statement","lines","header","address","push","normalizeAddress","keepStatementLine","version","chainId","_opts_chainId","numericChainId","nonce","issuedAt","Date","toISOString","join","families","list","names","nameTable","specs","Map","map","id","message","spec2","get"],"sources":["../../../src/core/message.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,eAAA;AAAAC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OAAU;EAChC;EACEP,KAAA,CAAAG,IAAM,WAAWhB,IAAI,CAAAuB,KAAM,mBAAAhB,cAAA,GAAAP,IAAA,CAAAwB,QAAA,cAAAjB,cAAA,cAAAA,cAAA,uBAAAkB,IAAA,IAAAC,WAAA;EAC3B,OAAAb,KAAO,CAAAc,IAAO;AAAoC;AAEpD,SAAO7C,sBAAA8C,QAAA;EAAA,IACLC,IAAA,IACA,GAAAD,QAAU,CAA2B;EACrC,IACAE,KAAM,OAAQ5C,YAAM,CAAA6C,SAAA,EAAAF,IAAA;EAClB,IAAAG,KAAA,GAAM,IAAAC,GAAQ,CAAAJ,IAAK,CAAAK,GAAA,CAAM,UAAAjC,MAAA;IACzB,OAAI,CACFA,MAAA,CAAAkC,EAAM,EAAIlC,MACR,CAAAmC,OAAA,CAAyG;EAC3G;EAEF,IAAArC,IAAA,GAAO,SAAAsC,MAAApC,MAAoB;IAC7B,IAAAkC,EAAA,GAAAL,KAAA,CAAAQ,GAAA,CAAArC,MAAA;IACF,OAAAkC,EAAA,uBAAAH,KAAA,CAAAM,GAAA,CAAAH,EAAA;EACF","ignoreList":[]}
|
|
@@ -0,0 +1,51 @@
|
|
|
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) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: true
|
|
22
|
+
}), mod);
|
|
23
|
+
var names_exports = {};
|
|
24
|
+
__export(names_exports, {
|
|
25
|
+
assertName: () => assertName,
|
|
26
|
+
nameTable: () => nameTable
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(names_exports);
|
|
29
|
+
const pattern = /^[a-z][a-z0-9-]*$/;
|
|
30
|
+
function assertName(kind, name) {
|
|
31
|
+
if (typeof name !== "string" || !pattern.test(name)) {
|
|
32
|
+
throw new Error(`${kind} must be lowercase letters, digits and dashes: ${String(name)}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function nameTable(entries) {
|
|
36
|
+
const table = /* @__PURE__ */new Map();
|
|
37
|
+
const claim = (name, id) => {
|
|
38
|
+
const owner = table.get(name);
|
|
39
|
+
if (owner === void 0) table.set(name, id);else if (owner !== id) {
|
|
40
|
+
throw new Error(`wallet family name "${name}" is claimed by ${owner} and ${id}`);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
for (const entry of entries) {
|
|
44
|
+
if (table.get(entry.id) === entry.id) {
|
|
45
|
+
throw new Error(`wallet family ${entry.id} is registered twice`);
|
|
46
|
+
}
|
|
47
|
+
claim(entry.id, entry.id);
|
|
48
|
+
for (const alias of entry.aliases ?? []) claim(alias, entry.id);
|
|
49
|
+
}
|
|
50
|
+
return table;
|
|
51
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
+
value: true
|
|
24
|
+
}), mod);
|
|
25
|
+
var names_exports = {};
|
|
26
|
+
__export(names_exports, {
|
|
27
|
+
assertName: () => assertName,
|
|
28
|
+
nameTable: () => nameTable
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(names_exports);
|
|
31
|
+
var pattern = /^[a-z][a-z0-9-]*$/;
|
|
32
|
+
function assertName(kind, name) {
|
|
33
|
+
if (typeof name !== "string" || !pattern.test(name)) {
|
|
34
|
+
throw new Error(`${kind} must be lowercase letters, digits and dashes: ${String(name)}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function nameTable(entries) {
|
|
38
|
+
var table = /* @__PURE__ */new Map();
|
|
39
|
+
var claim = function claim2(name, id) {
|
|
40
|
+
var owner = table.get(name);
|
|
41
|
+
if (owner === void 0) table.set(name, id);else if (owner !== id) {
|
|
42
|
+
throw new Error(`wallet family name "${name}" is claimed by ${owner} and ${id}`);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var _iteratorNormalCompletion = true,
|
|
46
|
+
_didIteratorError = false,
|
|
47
|
+
_iteratorError = void 0;
|
|
48
|
+
try {
|
|
49
|
+
for (var _iterator = entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
50
|
+
var entry = _step.value;
|
|
51
|
+
var _entry_aliases;
|
|
52
|
+
if (table.get(entry.id) === entry.id) {
|
|
53
|
+
throw new Error(`wallet family ${entry.id} is registered twice`);
|
|
54
|
+
}
|
|
55
|
+
claim(entry.id, entry.id);
|
|
56
|
+
var _iteratorNormalCompletion1 = true,
|
|
57
|
+
_didIteratorError1 = false,
|
|
58
|
+
_iteratorError1 = void 0;
|
|
59
|
+
try {
|
|
60
|
+
for (var _iterator1 = ((_entry_aliases = entry.aliases) !== null && _entry_aliases !== void 0 ? _entry_aliases : [])[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
61
|
+
var alias = _step1.value;
|
|
62
|
+
claim(alias, entry.id);
|
|
63
|
+
}
|
|
64
|
+
} catch (err) {
|
|
65
|
+
_didIteratorError1 = true;
|
|
66
|
+
_iteratorError1 = err;
|
|
67
|
+
} finally {
|
|
68
|
+
try {
|
|
69
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
70
|
+
_iterator1.return();
|
|
71
|
+
}
|
|
72
|
+
} finally {
|
|
73
|
+
if (_didIteratorError1) {
|
|
74
|
+
throw _iteratorError1;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
} catch (err) {
|
|
80
|
+
_didIteratorError = true;
|
|
81
|
+
_iteratorError = err;
|
|
82
|
+
} finally {
|
|
83
|
+
try {
|
|
84
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
85
|
+
_iterator.return();
|
|
86
|
+
}
|
|
87
|
+
} finally {
|
|
88
|
+
if (_didIteratorError) {
|
|
89
|
+
throw _iteratorError;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return table;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=names.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","names_exports","__export","assertName","nameTable","module","exports","pattern","kind","name","test","Error","String","entries","table","Map","claim","claim2","id","owner","get","set","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","Symbol","iterator","_step","next","done","entry","_entry_aliases"],"sources":["../../../src/core/names.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,UAAA,EAAAA,CAAA,KAAAA,UAAA;EAAAC,SAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAM,CAAAC,OAAA,GAAUV,YAAA,CAAAK,aAAA;AAET,IAAAM,OAAS,sBAAgE;AAC9E,SAAIJ,UAAOA,CAAAK,IAAS,EAAAC,IAAA;EAClB,WAAMA,IAAI,KAAM,QAAO,KAAAF,OAAA,CAAAG,IAAA,CAAAD,IAAA;IACzB,UAAAE,KAAA,IAAAH,IAAA,kDAAAI,MAAA,CAAAH,IAAA;EACF;AAGO;AAGL,SAAML,SAAQA,CAAAS,OAAA;EACd,IAAAC,KAAM,kBAAsC,IAAAC,GAAA;EAC1C,IAAAC,KAAM,YAAQC,MAAUA,CAAAR,IAAI,EAAAS,EAAA;IAC5B,IAAIC,KAAA,GAAAL,KAAU,CAAAM,GAAW,CAAAX,IAAA;IAAkB,IAAAU,KAClC,UAAU,GAAAL,KAAI,CAAAO,GAAA,CAAAZ,IAAA,EAAAS,EAAA,OACrB,IAAMC,KAAI,KAAMD,EAAA;MAClB,UAAAP,KAAA,wBAAAF,IAAA,mBAAAU,KAAA,QAAAD,EAAA;IACF;EACA;EACE,IAAAI,yBAAsB,GAAM,IAAM;IAAAC,iBAAI;IAAAC,cAAA;EACpC;IACF,SAAAC,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