@hashgraphonline/standards-sdk 0.0.58 → 0.0.59
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/es/hcs-10/base-client.d.ts +2 -1
- package/dist/es/hcs-10/base-client.d.ts.map +1 -1
- package/dist/es/hcs-10/browser.d.ts +1 -1
- package/dist/es/hcs-10/browser.d.ts.map +1 -1
- package/dist/es/hcs-10/sdk.d.ts +2 -2
- package/dist/es/hcs-10/sdk.d.ts.map +1 -1
- package/dist/es/hcs-10/types.d.ts +1 -18
- package/dist/es/hcs-10/types.d.ts.map +1 -1
- package/dist/es/standards-sdk.es10.js +11 -8
- package/dist/es/standards-sdk.es10.js.map +1 -1
- package/dist/es/standards-sdk.es100.js +144 -17
- package/dist/es/standards-sdk.es100.js.map +1 -1
- package/dist/es/standards-sdk.es101.js +86 -39
- package/dist/es/standards-sdk.es101.js.map +1 -1
- package/dist/es/standards-sdk.es102.js +79 -13
- package/dist/es/standards-sdk.es102.js.map +1 -1
- package/dist/es/standards-sdk.es103.js +28 -57
- package/dist/es/standards-sdk.es103.js.map +1 -1
- package/dist/es/standards-sdk.es104.js +5 -1288
- package/dist/es/standards-sdk.es104.js.map +1 -1
- package/dist/es/standards-sdk.es105.js +153 -26
- package/dist/es/standards-sdk.es105.js.map +1 -1
- package/dist/es/standards-sdk.es106.js +22 -5
- package/dist/es/standards-sdk.es106.js.map +1 -1
- package/dist/es/standards-sdk.es107.js +781 -147
- package/dist/es/standards-sdk.es107.js.map +1 -1
- package/dist/es/standards-sdk.es108.js +166 -785
- package/dist/es/standards-sdk.es108.js.map +1 -1
- package/dist/es/standards-sdk.es109.js +2 -2
- package/dist/es/standards-sdk.es110.js +19 -25
- package/dist/es/standards-sdk.es110.js.map +1 -1
- package/dist/es/standards-sdk.es111.js +24 -23
- package/dist/es/standards-sdk.es111.js.map +1 -1
- package/dist/es/standards-sdk.es112.js +23 -35
- package/dist/es/standards-sdk.es112.js.map +1 -1
- package/dist/es/standards-sdk.es113.js +36 -19
- package/dist/es/standards-sdk.es113.js.map +1 -1
- package/dist/es/standards-sdk.es12.js.map +1 -1
- package/dist/es/standards-sdk.es26.js +10 -10
- package/dist/es/standards-sdk.es27.js +1 -1
- package/dist/es/standards-sdk.es5.js +12 -8
- package/dist/es/standards-sdk.es5.js.map +1 -1
- package/dist/es/standards-sdk.es65.js +3 -3
- package/dist/es/standards-sdk.es73.js +2 -2
- package/dist/es/standards-sdk.es74.js +2 -2
- package/dist/es/standards-sdk.es77.js +3 -34
- package/dist/es/standards-sdk.es77.js.map +1 -1
- package/dist/es/standards-sdk.es78.js +2 -33
- package/dist/es/standards-sdk.es78.js.map +1 -1
- package/dist/es/standards-sdk.es79.js +2 -9
- package/dist/es/standards-sdk.es79.js.map +1 -1
- package/dist/es/standards-sdk.es8.js +7 -2
- package/dist/es/standards-sdk.es8.js.map +1 -1
- package/dist/es/standards-sdk.es80.js +32 -32
- package/dist/es/standards-sdk.es80.js.map +1 -1
- package/dist/es/standards-sdk.es81.js +33 -3
- package/dist/es/standards-sdk.es81.js.map +1 -1
- package/dist/es/standards-sdk.es82.js +9 -2
- package/dist/es/standards-sdk.es82.js.map +1 -1
- package/dist/es/standards-sdk.es83.js +34 -2
- package/dist/es/standards-sdk.es83.js.map +1 -1
- package/dist/es/standards-sdk.es84.js +419 -2
- package/dist/es/standards-sdk.es84.js.map +1 -1
- package/dist/es/standards-sdk.es85.js +2 -419
- package/dist/es/standards-sdk.es85.js.map +1 -1
- package/dist/es/standards-sdk.es86.js +120 -2
- package/dist/es/standards-sdk.es86.js.map +1 -1
- package/dist/es/standards-sdk.es87.js +2 -120
- package/dist/es/standards-sdk.es87.js.map +1 -1
- package/dist/es/standards-sdk.es88.js +185 -74
- package/dist/es/standards-sdk.es88.js.map +1 -1
- package/dist/es/standards-sdk.es89.js +433 -18
- package/dist/es/standards-sdk.es89.js.map +1 -1
- package/dist/es/standards-sdk.es90.js +21 -144
- package/dist/es/standards-sdk.es90.js.map +1 -1
- package/dist/es/standards-sdk.es91.js +130 -82
- package/dist/es/standards-sdk.es91.js.map +1 -1
- package/dist/es/standards-sdk.es92.js +13 -169
- package/dist/es/standards-sdk.es92.js.map +1 -1
- package/dist/es/standards-sdk.es93.js +23 -189
- package/dist/es/standards-sdk.es93.js.map +1 -1
- package/dist/es/standards-sdk.es94.js +24 -433
- package/dist/es/standards-sdk.es94.js.map +1 -1
- package/dist/es/standards-sdk.es95.js +12 -16
- package/dist/es/standards-sdk.es95.js.map +1 -1
- package/dist/es/standards-sdk.es96.js +31 -126
- package/dist/es/standards-sdk.es96.js.map +1 -1
- package/dist/es/standards-sdk.es97.js +9 -9
- package/dist/es/standards-sdk.es97.js.map +1 -1
- package/dist/es/standards-sdk.es98.js +54 -22
- package/dist/es/standards-sdk.es98.js.map +1 -1
- package/dist/es/standards-sdk.es99.js +1280 -20
- package/dist/es/standards-sdk.es99.js.map +1 -1
- package/dist/umd/hcs-10/base-client.d.ts +2 -1
- package/dist/umd/hcs-10/base-client.d.ts.map +1 -1
- package/dist/umd/hcs-10/browser.d.ts +1 -1
- package/dist/umd/hcs-10/browser.d.ts.map +1 -1
- package/dist/umd/hcs-10/sdk.d.ts +2 -2
- package/dist/umd/hcs-10/sdk.d.ts.map +1 -1
- package/dist/umd/hcs-10/types.d.ts +1 -18
- package/dist/umd/hcs-10/types.d.ts.map +1 -1
- package/dist/umd/standards-sdk.umd.js +1 -1
- package/dist/umd/standards-sdk.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,24 +1,151 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { version } from "./standards-sdk.es87.js";
|
|
2
|
+
import { defineProperties } from "./standards-sdk.es103.js";
|
|
3
|
+
function stringify(value) {
|
|
4
|
+
if (value == null) {
|
|
5
|
+
return "null";
|
|
6
|
+
}
|
|
7
|
+
if (Array.isArray(value)) {
|
|
8
|
+
return "[ " + value.map(stringify).join(", ") + " ]";
|
|
9
|
+
}
|
|
10
|
+
if (value instanceof Uint8Array) {
|
|
11
|
+
const HEX = "0123456789abcdef";
|
|
12
|
+
let result = "0x";
|
|
13
|
+
for (let i = 0; i < value.length; i++) {
|
|
14
|
+
result += HEX[value[i] >> 4];
|
|
15
|
+
result += HEX[value[i] & 15];
|
|
13
16
|
}
|
|
14
|
-
return
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
if (typeof value === "object" && typeof value.toJSON === "function") {
|
|
20
|
+
return stringify(value.toJSON());
|
|
21
|
+
}
|
|
22
|
+
switch (typeof value) {
|
|
23
|
+
case "boolean":
|
|
24
|
+
case "symbol":
|
|
25
|
+
return value.toString();
|
|
26
|
+
case "bigint":
|
|
27
|
+
return BigInt(value).toString();
|
|
28
|
+
case "number":
|
|
29
|
+
return value.toString();
|
|
30
|
+
case "string":
|
|
31
|
+
return JSON.stringify(value);
|
|
32
|
+
case "object": {
|
|
33
|
+
const keys = Object.keys(value);
|
|
34
|
+
keys.sort();
|
|
35
|
+
return "{ " + keys.map((k) => `${stringify(k)}: ${stringify(value[k])}`).join(", ") + " }";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return `[ COULD NOT SERIALIZE ]`;
|
|
39
|
+
}
|
|
40
|
+
function isError(error, code) {
|
|
41
|
+
return error && error.code === code;
|
|
42
|
+
}
|
|
43
|
+
function makeError(message, code, info) {
|
|
44
|
+
let shortMessage = message;
|
|
45
|
+
{
|
|
46
|
+
const details = [];
|
|
47
|
+
if (info) {
|
|
48
|
+
if ("message" in info || "code" in info || "name" in info) {
|
|
49
|
+
throw new Error(`value will overwrite populated values: ${stringify(info)}`);
|
|
50
|
+
}
|
|
51
|
+
for (const key in info) {
|
|
52
|
+
if (key === "shortMessage") {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const value = info[key];
|
|
56
|
+
details.push(key + "=" + stringify(value));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
details.push(`code=${code}`);
|
|
60
|
+
details.push(`version=${version}`);
|
|
61
|
+
if (details.length) {
|
|
62
|
+
message += " (" + details.join(", ") + ")";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
let error;
|
|
66
|
+
switch (code) {
|
|
67
|
+
case "INVALID_ARGUMENT":
|
|
68
|
+
error = new TypeError(message);
|
|
69
|
+
break;
|
|
70
|
+
case "NUMERIC_FAULT":
|
|
71
|
+
case "BUFFER_OVERRUN":
|
|
72
|
+
error = new RangeError(message);
|
|
73
|
+
break;
|
|
74
|
+
default:
|
|
75
|
+
error = new Error(message);
|
|
76
|
+
}
|
|
77
|
+
defineProperties(error, { code });
|
|
78
|
+
if (info) {
|
|
79
|
+
Object.assign(error, info);
|
|
80
|
+
}
|
|
81
|
+
if (error.shortMessage == null) {
|
|
82
|
+
defineProperties(error, { shortMessage });
|
|
15
83
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
84
|
+
return error;
|
|
85
|
+
}
|
|
86
|
+
function assert(check, message, code, info) {
|
|
87
|
+
if (!check) {
|
|
88
|
+
throw makeError(message, code, info);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function assertArgument(check, message, name, value) {
|
|
92
|
+
assert(check, message, "INVALID_ARGUMENT", { argument: name, value });
|
|
93
|
+
}
|
|
94
|
+
function assertArgumentCount(count, expectedCount, message) {
|
|
95
|
+
if (message == null) {
|
|
96
|
+
message = "";
|
|
97
|
+
}
|
|
98
|
+
if (message) {
|
|
99
|
+
message = ": " + message;
|
|
100
|
+
}
|
|
101
|
+
assert(count >= expectedCount, "missing argument" + message, "MISSING_ARGUMENT", {
|
|
102
|
+
count,
|
|
103
|
+
expectedCount
|
|
104
|
+
});
|
|
105
|
+
assert(count <= expectedCount, "too many arguments" + message, "UNEXPECTED_ARGUMENT", {
|
|
106
|
+
count,
|
|
107
|
+
expectedCount
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
["NFD", "NFC", "NFKD", "NFKC"].reduce((accum, form) => {
|
|
111
|
+
try {
|
|
112
|
+
if ("test".normalize(form) !== "test") {
|
|
113
|
+
throw new Error("bad");
|
|
114
|
+
}
|
|
115
|
+
;
|
|
116
|
+
if (form === "NFD") {
|
|
117
|
+
const check = String.fromCharCode(233).normalize("NFD");
|
|
118
|
+
const expected = String.fromCharCode(101, 769);
|
|
119
|
+
if (check !== expected) {
|
|
120
|
+
throw new Error("broken");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
accum.push(form);
|
|
124
|
+
} catch (error) {
|
|
125
|
+
}
|
|
126
|
+
return accum;
|
|
127
|
+
}, []);
|
|
128
|
+
function assertPrivate(givenGuard, guard, className) {
|
|
129
|
+
if (className == null) {
|
|
130
|
+
className = "";
|
|
131
|
+
}
|
|
132
|
+
if (givenGuard !== guard) {
|
|
133
|
+
let method = className, operation = "new";
|
|
134
|
+
if (className) {
|
|
135
|
+
method += ".";
|
|
136
|
+
operation += " " + className;
|
|
137
|
+
}
|
|
138
|
+
assert(false, `private constructor; use ${method}from* methods`, "UNSUPPORTED_OPERATION", {
|
|
139
|
+
operation
|
|
140
|
+
});
|
|
19
141
|
}
|
|
20
142
|
}
|
|
21
143
|
export {
|
|
22
|
-
|
|
144
|
+
assert,
|
|
145
|
+
assertArgument,
|
|
146
|
+
assertArgumentCount,
|
|
147
|
+
assertPrivate,
|
|
148
|
+
isError,
|
|
149
|
+
makeError
|
|
23
150
|
};
|
|
24
151
|
//# sourceMappingURL=standards-sdk.es100.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es100.js","sources":["../../node_modules/ethers/lib.esm/abi/coders/null.js"],"sourcesContent":["import { Coder } from \"./abstract-coder.js\";\nconst Empty = new Uint8Array([]);\n/**\n * @_ignore\n */\nexport class NullCoder extends Coder {\n constructor(localName) {\n super(\"null\", \"\", localName, false);\n }\n defaultValue() {\n return null;\n }\n encode(writer, value) {\n if (value != null) {\n this._throwError(\"not null\", value);\n }\n return writer.writeBytes(Empty);\n }\n decode(reader) {\n reader.readBytes(0);\n return null;\n }\n}\n//# sourceMappingURL=null.js.map"],"names":[],"mappings":";AACA,MAAM,QAAQ,IAAI,WAAW,EAAE;AAIxB,MAAM,kBAAkB,MAAM;AAAA,EACjC,YAAY,WAAW;AACnB,UAAM,QAAQ,IAAI,WAAW,KAAK;AAAA,EAC1C;AAAA,EACI,eAAe;AACX,WAAO;AAAA,EACf;AAAA,EACI,OAAO,QAAQ,OAAO;AAClB,QAAI,SAAS,MAAM;AACf,WAAK,YAAY,YAAY,KAAK;AAAA,IAC9C;AACQ,WAAO,OAAO,WAAW,KAAK;AAAA,EACtC;AAAA,EACI,OAAO,QAAQ;AACX,WAAO,UAAU,CAAC;AAClB,WAAO;AAAA,EACf;AACA;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es100.js","sources":["../../node_modules/ethers/lib.esm/utils/errors.js"],"sourcesContent":["/**\n * All errors in ethers include properties to ensure they are both\n * human-readable (i.e. ``.message``) and machine-readable (i.e. ``.code``).\n *\n * The [[isError]] function can be used to check the error ``code`` and\n * provide a type guard for the properties present on that error interface.\n *\n * @_section: api/utils/errors:Errors [about-errors]\n */\nimport { version } from \"../_version.js\";\nimport { defineProperties } from \"./properties.js\";\nfunction stringify(value) {\n if (value == null) {\n return \"null\";\n }\n if (Array.isArray(value)) {\n return \"[ \" + (value.map(stringify)).join(\", \") + \" ]\";\n }\n if (value instanceof Uint8Array) {\n const HEX = \"0123456789abcdef\";\n let result = \"0x\";\n for (let i = 0; i < value.length; i++) {\n result += HEX[value[i] >> 4];\n result += HEX[value[i] & 0xf];\n }\n return result;\n }\n if (typeof (value) === \"object\" && typeof (value.toJSON) === \"function\") {\n return stringify(value.toJSON());\n }\n switch (typeof (value)) {\n case \"boolean\":\n case \"symbol\":\n return value.toString();\n case \"bigint\":\n return BigInt(value).toString();\n case \"number\":\n return (value).toString();\n case \"string\":\n return JSON.stringify(value);\n case \"object\": {\n const keys = Object.keys(value);\n keys.sort();\n return \"{ \" + keys.map((k) => `${stringify(k)}: ${stringify(value[k])}`).join(\", \") + \" }\";\n }\n }\n return `[ COULD NOT SERIALIZE ]`;\n}\n/**\n * Returns true if the %%error%% matches an error thrown by ethers\n * that matches the error %%code%%.\n *\n * In TypeScript environments, this can be used to check that %%error%%\n * matches an EthersError type, which means the expected properties will\n * be set.\n *\n * @See [ErrorCodes](api:ErrorCode)\n * @example\n * try {\n * // code....\n * } catch (e) {\n * if (isError(e, \"CALL_EXCEPTION\")) {\n * // The Type Guard has validated this object\n * console.log(e.data);\n * }\n * }\n */\nexport function isError(error, code) {\n return (error && error.code === code);\n}\n/**\n * Returns true if %%error%% is a [[CallExceptionError].\n */\nexport function isCallException(error) {\n return isError(error, \"CALL_EXCEPTION\");\n}\n/**\n * Returns a new Error configured to the format ethers emits errors, with\n * the %%message%%, [[api:ErrorCode]] %%code%% and additional properties\n * for the corresponding EthersError.\n *\n * Each error in ethers includes the version of ethers, a\n * machine-readable [[ErrorCode]], and depending on %%code%%, additional\n * required properties. The error message will also include the %%message%%,\n * ethers version, %%code%% and all additional properties, serialized.\n */\nexport function makeError(message, code, info) {\n let shortMessage = message;\n {\n const details = [];\n if (info) {\n if (\"message\" in info || \"code\" in info || \"name\" in info) {\n throw new Error(`value will overwrite populated values: ${stringify(info)}`);\n }\n for (const key in info) {\n if (key === \"shortMessage\") {\n continue;\n }\n const value = (info[key]);\n // try {\n details.push(key + \"=\" + stringify(value));\n // } catch (error: any) {\n // console.log(\"MMM\", error.message);\n // details.push(key + \"=[could not serialize object]\");\n // }\n }\n }\n details.push(`code=${code}`);\n details.push(`version=${version}`);\n if (details.length) {\n message += \" (\" + details.join(\", \") + \")\";\n }\n }\n let error;\n switch (code) {\n case \"INVALID_ARGUMENT\":\n error = new TypeError(message);\n break;\n case \"NUMERIC_FAULT\":\n case \"BUFFER_OVERRUN\":\n error = new RangeError(message);\n break;\n default:\n error = new Error(message);\n }\n defineProperties(error, { code });\n if (info) {\n Object.assign(error, info);\n }\n if (error.shortMessage == null) {\n defineProperties(error, { shortMessage });\n }\n return error;\n}\n/**\n * Throws an EthersError with %%message%%, %%code%% and additional error\n * %%info%% when %%check%% is falsish..\n *\n * @see [[api:makeError]]\n */\nexport function assert(check, message, code, info) {\n if (!check) {\n throw makeError(message, code, info);\n }\n}\n/**\n * A simple helper to simply ensuring provided arguments match expected\n * constraints, throwing if not.\n *\n * In TypeScript environments, the %%check%% has been asserted true, so\n * any further code does not need additional compile-time checks.\n */\nexport function assertArgument(check, message, name, value) {\n assert(check, message, \"INVALID_ARGUMENT\", { argument: name, value: value });\n}\nexport function assertArgumentCount(count, expectedCount, message) {\n if (message == null) {\n message = \"\";\n }\n if (message) {\n message = \": \" + message;\n }\n assert(count >= expectedCount, \"missing argument\" + message, \"MISSING_ARGUMENT\", {\n count: count,\n expectedCount: expectedCount\n });\n assert(count <= expectedCount, \"too many arguments\" + message, \"UNEXPECTED_ARGUMENT\", {\n count: count,\n expectedCount: expectedCount\n });\n}\nconst _normalizeForms = [\"NFD\", \"NFC\", \"NFKD\", \"NFKC\"].reduce((accum, form) => {\n try {\n // General test for normalize\n /* c8 ignore start */\n if (\"test\".normalize(form) !== \"test\") {\n throw new Error(\"bad\");\n }\n ;\n /* c8 ignore stop */\n if (form === \"NFD\") {\n const check = String.fromCharCode(0xe9).normalize(\"NFD\");\n const expected = String.fromCharCode(0x65, 0x0301);\n /* c8 ignore start */\n if (check !== expected) {\n throw new Error(\"broken\");\n }\n /* c8 ignore stop */\n }\n accum.push(form);\n }\n catch (error) { }\n return accum;\n}, []);\n/**\n * Throws if the normalization %%form%% is not supported.\n */\nexport function assertNormalize(form) {\n assert(_normalizeForms.indexOf(form) >= 0, \"platform missing String.prototype.normalize\", \"UNSUPPORTED_OPERATION\", {\n operation: \"String.prototype.normalize\", info: { form }\n });\n}\n/**\n * Many classes use file-scoped values to guard the constructor,\n * making it effectively private. This facilitates that pattern\n * by ensuring the %%givenGaurd%% matches the file-scoped %%guard%%,\n * throwing if not, indicating the %%className%% if provided.\n */\nexport function assertPrivate(givenGuard, guard, className) {\n if (className == null) {\n className = \"\";\n }\n if (givenGuard !== guard) {\n let method = className, operation = \"new\";\n if (className) {\n method += \".\";\n operation += \" \" + className;\n }\n assert(false, `private constructor; use ${method}from* methods`, \"UNSUPPORTED_OPERATION\", {\n operation\n });\n }\n}\n//# sourceMappingURL=errors.js.map"],"names":[],"mappings":";;AAWA,SAAS,UAAU,OAAO;AACtB,MAAI,SAAS,MAAM;AACf,WAAO;AAAA,EACf;AACI,MAAI,MAAM,QAAQ,KAAK,GAAG;AACtB,WAAO,OAAQ,MAAM,IAAI,SAAS,EAAG,KAAK,IAAI,IAAI;AAAA,EAC1D;AACI,MAAI,iBAAiB,YAAY;AAC7B,UAAM,MAAM;AACZ,QAAI,SAAS;AACb,aAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACnC,gBAAU,IAAI,MAAM,CAAC,KAAK,CAAC;AAC3B,gBAAU,IAAI,MAAM,CAAC,IAAI,EAAG;AAAA,IACxC;AACQ,WAAO;AAAA,EACf;AACI,MAAI,OAAQ,UAAW,YAAY,OAAQ,MAAM,WAAY,YAAY;AACrE,WAAO,UAAU,MAAM,QAAQ;AAAA,EACvC;AACI,UAAQ,OAAQ,OAAM;AAAA,IAClB,KAAK;AAAA,IACL,KAAK;AACD,aAAO,MAAM,SAAU;AAAA,IAC3B,KAAK;AACD,aAAO,OAAO,KAAK,EAAE,SAAU;AAAA,IACnC,KAAK;AACD,aAAQ,MAAO,SAAU;AAAA,IAC7B,KAAK;AACD,aAAO,KAAK,UAAU,KAAK;AAAA,IAC/B,KAAK,UAAU;AACX,YAAM,OAAO,OAAO,KAAK,KAAK;AAC9B,WAAK,KAAM;AACX,aAAO,OAAO,KAAK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AA,EACT;AACA;","x_google_ignoreList":[0]}
|
|
@@ -1,47 +1,94 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { defineProperties } from "./standards-sdk.es105.js";
|
|
7
|
-
import { getBigInt, mask, toTwos, fromTwos } from "./standards-sdk.es107.js";
|
|
8
|
-
const BN_0 = BigInt(0);
|
|
9
|
-
const BN_1 = BigInt(1);
|
|
10
|
-
const BN_MAX_UINT256 = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
11
|
-
class NumberCoder extends Coder {
|
|
12
|
-
constructor(size, signed, localName) {
|
|
13
|
-
const name = (signed ? "int" : "uint") + size * 8;
|
|
14
|
-
super(name, name, localName, false);
|
|
15
|
-
__publicField(this, "size");
|
|
16
|
-
__publicField(this, "signed");
|
|
17
|
-
defineProperties(this, { size, signed }, { size: "number", signed: "boolean" });
|
|
18
|
-
}
|
|
19
|
-
defaultValue() {
|
|
20
|
-
return 0;
|
|
21
|
-
}
|
|
22
|
-
encode(writer, _value) {
|
|
23
|
-
let value = getBigInt(Typed.dereference(_value, this.type));
|
|
24
|
-
let maxUintValue = mask(BN_MAX_UINT256, WordSize * 8);
|
|
25
|
-
if (this.signed) {
|
|
26
|
-
let bounds = mask(maxUintValue, this.size * 8 - 1);
|
|
27
|
-
if (value > bounds || value < -(bounds + BN_1)) {
|
|
28
|
-
this._throwError("value out-of-bounds", _value);
|
|
29
|
-
}
|
|
30
|
-
value = toTwos(value, 8 * WordSize);
|
|
31
|
-
} else if (value < BN_0 || value > mask(maxUintValue, this.size * 8)) {
|
|
32
|
-
this._throwError("value out-of-bounds", _value);
|
|
1
|
+
import { assert, assertArgument } from "./standards-sdk.es100.js";
|
|
2
|
+
function _getBytes(value, name, copy) {
|
|
3
|
+
if (value instanceof Uint8Array) {
|
|
4
|
+
if (copy) {
|
|
5
|
+
return new Uint8Array(value);
|
|
33
6
|
}
|
|
34
|
-
return
|
|
7
|
+
return value;
|
|
35
8
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
9
|
+
if (typeof value === "string" && value.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)) {
|
|
10
|
+
const result = new Uint8Array((value.length - 2) / 2);
|
|
11
|
+
let offset = 2;
|
|
12
|
+
for (let i = 0; i < result.length; i++) {
|
|
13
|
+
result[i] = parseInt(value.substring(offset, offset + 2), 16);
|
|
14
|
+
offset += 2;
|
|
40
15
|
}
|
|
41
|
-
return
|
|
16
|
+
return result;
|
|
42
17
|
}
|
|
18
|
+
assertArgument(false, "invalid BytesLike value", name || "value", value);
|
|
19
|
+
}
|
|
20
|
+
function getBytes(value, name) {
|
|
21
|
+
return _getBytes(value, name, false);
|
|
22
|
+
}
|
|
23
|
+
function getBytesCopy(value, name) {
|
|
24
|
+
return _getBytes(value, name, true);
|
|
25
|
+
}
|
|
26
|
+
function isHexString(value, length) {
|
|
27
|
+
if (typeof value !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
if (typeof length === "number" && value.length !== 2 + 2 * length) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
if (length === true && value.length % 2 !== 0) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
const HexCharacters = "0123456789abcdef";
|
|
39
|
+
function hexlify(data) {
|
|
40
|
+
const bytes = getBytes(data);
|
|
41
|
+
let result = "0x";
|
|
42
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
43
|
+
const v = bytes[i];
|
|
44
|
+
result += HexCharacters[(v & 240) >> 4] + HexCharacters[v & 15];
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
function concat(datas) {
|
|
49
|
+
return "0x" + datas.map((d) => hexlify(d).substring(2)).join("");
|
|
50
|
+
}
|
|
51
|
+
function dataSlice(data, start, end) {
|
|
52
|
+
const bytes = getBytes(data);
|
|
53
|
+
if (end != null && end > bytes.length) {
|
|
54
|
+
assert(false, "cannot slice beyond data bounds", "BUFFER_OVERRUN", {
|
|
55
|
+
buffer: bytes,
|
|
56
|
+
length: bytes.length,
|
|
57
|
+
offset: end
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return hexlify(bytes.slice(start == null ? 0 : start, end == null ? bytes.length : end));
|
|
61
|
+
}
|
|
62
|
+
function zeroPad(data, length, left) {
|
|
63
|
+
const bytes = getBytes(data);
|
|
64
|
+
assert(length >= bytes.length, "padding exceeds data length", "BUFFER_OVERRUN", {
|
|
65
|
+
buffer: new Uint8Array(bytes),
|
|
66
|
+
length,
|
|
67
|
+
offset: length + 1
|
|
68
|
+
});
|
|
69
|
+
const result = new Uint8Array(length);
|
|
70
|
+
result.fill(0);
|
|
71
|
+
if (left) {
|
|
72
|
+
result.set(bytes, length - bytes.length);
|
|
73
|
+
} else {
|
|
74
|
+
result.set(bytes, 0);
|
|
75
|
+
}
|
|
76
|
+
return hexlify(result);
|
|
77
|
+
}
|
|
78
|
+
function zeroPadValue(data, length) {
|
|
79
|
+
return zeroPad(data, length, true);
|
|
80
|
+
}
|
|
81
|
+
function zeroPadBytes(data, length) {
|
|
82
|
+
return zeroPad(data, length, false);
|
|
43
83
|
}
|
|
44
84
|
export {
|
|
45
|
-
|
|
85
|
+
concat,
|
|
86
|
+
dataSlice,
|
|
87
|
+
getBytes,
|
|
88
|
+
getBytesCopy,
|
|
89
|
+
hexlify,
|
|
90
|
+
isHexString,
|
|
91
|
+
zeroPadBytes,
|
|
92
|
+
zeroPadValue
|
|
46
93
|
};
|
|
47
94
|
//# sourceMappingURL=standards-sdk.es101.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es101.js","sources":["../../node_modules/ethers/lib.esm/
|
|
1
|
+
{"version":3,"file":"standards-sdk.es101.js","sources":["../../node_modules/ethers/lib.esm/utils/data.js"],"sourcesContent":["/**\n * Some data helpers.\n *\n *\n * @_subsection api/utils:Data Helpers [about-data]\n */\nimport { assert, assertArgument } from \"./errors.js\";\nfunction _getBytes(value, name, copy) {\n if (value instanceof Uint8Array) {\n if (copy) {\n return new Uint8Array(value);\n }\n return value;\n }\n if (typeof (value) === \"string\" && value.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)) {\n const result = new Uint8Array((value.length - 2) / 2);\n let offset = 2;\n for (let i = 0; i < result.length; i++) {\n result[i] = parseInt(value.substring(offset, offset + 2), 16);\n offset += 2;\n }\n return result;\n }\n assertArgument(false, \"invalid BytesLike value\", name || \"value\", value);\n}\n/**\n * Get a typed Uint8Array for %%value%%. If already a Uint8Array\n * the original %%value%% is returned; if a copy is required use\n * [[getBytesCopy]].\n *\n * @see: getBytesCopy\n */\nexport function getBytes(value, name) {\n return _getBytes(value, name, false);\n}\n/**\n * Get a typed Uint8Array for %%value%%, creating a copy if necessary\n * to prevent any modifications of the returned value from being\n * reflected elsewhere.\n *\n * @see: getBytes\n */\nexport function getBytesCopy(value, name) {\n return _getBytes(value, name, true);\n}\n/**\n * Returns true if %%value%% is a valid [[HexString]].\n *\n * If %%length%% is ``true`` or a //number//, it also checks that\n * %%value%% is a valid [[DataHexString]] of %%length%% (if a //number//)\n * bytes of data (e.g. ``0x1234`` is 2 bytes).\n */\nexport function isHexString(value, length) {\n if (typeof (value) !== \"string\" || !value.match(/^0x[0-9A-Fa-f]*$/)) {\n return false;\n }\n if (typeof (length) === \"number\" && value.length !== 2 + 2 * length) {\n return false;\n }\n if (length === true && (value.length % 2) !== 0) {\n return false;\n }\n return true;\n}\n/**\n * Returns true if %%value%% is a valid representation of arbitrary\n * data (i.e. a valid [[DataHexString]] or a Uint8Array).\n */\nexport function isBytesLike(value) {\n return (isHexString(value, true) || (value instanceof Uint8Array));\n}\nconst HexCharacters = \"0123456789abcdef\";\n/**\n * Returns a [[DataHexString]] representation of %%data%%.\n */\nexport function hexlify(data) {\n const bytes = getBytes(data);\n let result = \"0x\";\n for (let i = 0; i < bytes.length; i++) {\n const v = bytes[i];\n result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f];\n }\n return result;\n}\n/**\n * Returns a [[DataHexString]] by concatenating all values\n * within %%data%%.\n */\nexport function concat(datas) {\n return \"0x\" + datas.map((d) => hexlify(d).substring(2)).join(\"\");\n}\n/**\n * Returns the length of %%data%%, in bytes.\n */\nexport function dataLength(data) {\n if (isHexString(data, true)) {\n return (data.length - 2) / 2;\n }\n return getBytes(data).length;\n}\n/**\n * Returns a [[DataHexString]] by slicing %%data%% from the %%start%%\n * offset to the %%end%% offset.\n *\n * By default %%start%% is 0 and %%end%% is the length of %%data%%.\n */\nexport function dataSlice(data, start, end) {\n const bytes = getBytes(data);\n if (end != null && end > bytes.length) {\n assert(false, \"cannot slice beyond data bounds\", \"BUFFER_OVERRUN\", {\n buffer: bytes, length: bytes.length, offset: end\n });\n }\n return hexlify(bytes.slice((start == null) ? 0 : start, (end == null) ? bytes.length : end));\n}\n/**\n * Return the [[DataHexString]] result by stripping all **leading**\n ** zero bytes from %%data%%.\n */\nexport function stripZerosLeft(data) {\n let bytes = hexlify(data).substring(2);\n while (bytes.startsWith(\"00\")) {\n bytes = bytes.substring(2);\n }\n return \"0x\" + bytes;\n}\nfunction zeroPad(data, length, left) {\n const bytes = getBytes(data);\n assert(length >= bytes.length, \"padding exceeds data length\", \"BUFFER_OVERRUN\", {\n buffer: new Uint8Array(bytes),\n length: length,\n offset: length + 1\n });\n const result = new Uint8Array(length);\n result.fill(0);\n if (left) {\n result.set(bytes, length - bytes.length);\n }\n else {\n result.set(bytes, 0);\n }\n return hexlify(result);\n}\n/**\n * Return the [[DataHexString]] of %%data%% padded on the **left**\n * to %%length%% bytes.\n *\n * If %%data%% already exceeds %%length%%, a [[BufferOverrunError]] is\n * thrown.\n *\n * This pads data the same as **values** are in Solidity\n * (e.g. ``uint128``).\n */\nexport function zeroPadValue(data, length) {\n return zeroPad(data, length, true);\n}\n/**\n * Return the [[DataHexString]] of %%data%% padded on the **right**\n * to %%length%% bytes.\n *\n * If %%data%% already exceeds %%length%%, a [[BufferOverrunError]] is\n * thrown.\n *\n * This pads data the same as **bytes** are in Solidity\n * (e.g. ``bytes16``).\n */\nexport function zeroPadBytes(data, length) {\n return zeroPad(data, length, false);\n}\n//# sourceMappingURL=data.js.map"],"names":[],"mappings":";AAOA,SAAS,UAAU,OAAO,MAAM,MAAM;AAClC,MAAI,iBAAiB,YAAY;AAC7B,QAAI,MAAM;AACN,aAAO,IAAI,WAAW,KAAK;AAAA,IACvC;AACQ,WAAO;AAAA,EACf;AACI,MAAI,OAAQ,UAAW,YAAY,MAAM,MAAM,4BAA4B,GAAG;AAC1E,UAAM,SAAS,IAAI,YAAY,MAAM,SAAS,KAAK,CAAC;AACpD,QAAI,SAAS;AACb,aAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACpC,aAAO,CAAC,IAAI,SAAS,MAAM,UAAU,QAAQ,SAAS,CAAC,GAAG,EAAE;AAC5D,gBAAU;AAAA,IACtB;AACQ,WAAO;AAAA,EACf;AACI,iBAAe,OAAO,2BAA2B,QAAQ,SAAS,KAAK;AAC3E;AAQO,SAAS,SAAS,OAAO,MAAM;AAClC,SAAO,UAAU,OAAO,MAAM,KAAK;AACvC;AAQO,SAAS,aAAa,OAAO,MAAM;AACtC,SAAO,UAAU,OAAO,MAAM,IAAI;AACtC;AAQO,SAAS,YAAY,OAAO,QAAQ;AACvC,MAAI,OAAQ,UAAW,YAAY,CAAC,MAAM,MAAM,kBAAkB,GAAG;AACjE,WAAO;AAAA,EACf;AACI,MAAI,OAAQ,WAAY,YAAY,MAAM,WAAW,IAAI,IAAI,QAAQ;AACjE,WAAO;AAAA,EACf;AACI,MAAI,WAAW,QAAS,MAAM,SAAS,MAAO,GAAG;AAC7C,WAAO;AAAA,EACf;AACI,SAAO;AACX;AAQA,MAAM,gBAAgB;AAIf,SAAS,QAAQ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SAAO,QAAQ,MAAM,QAAQ,KAAK;AACtC;","x_google_ignoreList":[0]}
|
|
@@ -1,21 +1,87 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { keccak256 } from "./standards-sdk.es106.js";
|
|
2
|
+
import { assertArgument } from "./standards-sdk.es100.js";
|
|
3
|
+
import { getBytes } from "./standards-sdk.es101.js";
|
|
4
|
+
const BN_0 = BigInt(0);
|
|
5
|
+
const BN_36 = BigInt(36);
|
|
6
|
+
function getChecksumAddress(address) {
|
|
7
|
+
address = address.toLowerCase();
|
|
8
|
+
const chars = address.substring(2).split("");
|
|
9
|
+
const expanded = new Uint8Array(40);
|
|
10
|
+
for (let i = 0; i < 40; i++) {
|
|
11
|
+
expanded[i] = chars[i].charCodeAt(0);
|
|
7
12
|
}
|
|
8
|
-
|
|
9
|
-
|
|
13
|
+
const hashed = getBytes(keccak256(expanded));
|
|
14
|
+
for (let i = 0; i < 40; i += 2) {
|
|
15
|
+
if (hashed[i >> 1] >> 4 >= 8) {
|
|
16
|
+
chars[i] = chars[i].toUpperCase();
|
|
17
|
+
}
|
|
18
|
+
if ((hashed[i >> 1] & 15) >= 8) {
|
|
19
|
+
chars[i + 1] = chars[i + 1].toUpperCase();
|
|
20
|
+
}
|
|
10
21
|
}
|
|
11
|
-
|
|
12
|
-
|
|
22
|
+
return "0x" + chars.join("");
|
|
23
|
+
}
|
|
24
|
+
const ibanLookup = {};
|
|
25
|
+
for (let i = 0; i < 10; i++) {
|
|
26
|
+
ibanLookup[String(i)] = String(i);
|
|
27
|
+
}
|
|
28
|
+
for (let i = 0; i < 26; i++) {
|
|
29
|
+
ibanLookup[String.fromCharCode(65 + i)] = String(10 + i);
|
|
30
|
+
}
|
|
31
|
+
const safeDigits = 15;
|
|
32
|
+
function ibanChecksum(address) {
|
|
33
|
+
address = address.toUpperCase();
|
|
34
|
+
address = address.substring(4) + address.substring(0, 2) + "00";
|
|
35
|
+
let expanded = address.split("").map((c) => {
|
|
36
|
+
return ibanLookup[c];
|
|
37
|
+
}).join("");
|
|
38
|
+
while (expanded.length >= safeDigits) {
|
|
39
|
+
let block = expanded.substring(0, safeDigits);
|
|
40
|
+
expanded = parseInt(block, 10) % 97 + expanded.substring(block.length);
|
|
41
|
+
}
|
|
42
|
+
let checksum = String(98 - parseInt(expanded, 10) % 97);
|
|
43
|
+
while (checksum.length < 2) {
|
|
44
|
+
checksum = "0" + checksum;
|
|
45
|
+
}
|
|
46
|
+
return checksum;
|
|
47
|
+
}
|
|
48
|
+
const Base36 = function() {
|
|
49
|
+
const result = {};
|
|
50
|
+
for (let i = 0; i < 36; i++) {
|
|
51
|
+
const key = "0123456789abcdefghijklmnopqrstuvwxyz"[i];
|
|
52
|
+
result[key] = BigInt(i);
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}();
|
|
56
|
+
function fromBase36(value) {
|
|
57
|
+
value = value.toLowerCase();
|
|
58
|
+
let result = BN_0;
|
|
59
|
+
for (let i = 0; i < value.length; i++) {
|
|
60
|
+
result = result * BN_36 + Base36[value[i]];
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
function getAddress(address) {
|
|
65
|
+
assertArgument(typeof address === "string", "invalid address", "address", address);
|
|
66
|
+
if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
|
|
67
|
+
if (!address.startsWith("0x")) {
|
|
68
|
+
address = "0x" + address;
|
|
69
|
+
}
|
|
70
|
+
const result = getChecksumAddress(address);
|
|
71
|
+
assertArgument(!address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || result === address, "bad address checksum", "address", address);
|
|
72
|
+
return result;
|
|
13
73
|
}
|
|
14
|
-
|
|
15
|
-
|
|
74
|
+
if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
|
|
75
|
+
assertArgument(address.substring(2, 4) === ibanChecksum(address), "bad icap checksum", "address", address);
|
|
76
|
+
let result = fromBase36(address.substring(4)).toString(16);
|
|
77
|
+
while (result.length < 40) {
|
|
78
|
+
result = "0" + result;
|
|
79
|
+
}
|
|
80
|
+
return getChecksumAddress("0x" + result);
|
|
16
81
|
}
|
|
82
|
+
assertArgument(false, "invalid address", "address", address);
|
|
17
83
|
}
|
|
18
84
|
export {
|
|
19
|
-
|
|
85
|
+
getAddress
|
|
20
86
|
};
|
|
21
87
|
//# sourceMappingURL=standards-sdk.es102.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es102.js","sources":["../../node_modules/ethers/lib.esm/
|
|
1
|
+
{"version":3,"file":"standards-sdk.es102.js","sources":["../../node_modules/ethers/lib.esm/address/address.js"],"sourcesContent":["import { keccak256 } from \"../crypto/index.js\";\nimport { getBytes, assertArgument } from \"../utils/index.js\";\nconst BN_0 = BigInt(0);\nconst BN_36 = BigInt(36);\nfunction getChecksumAddress(address) {\n // if (!isHexString(address, 20)) {\n // logger.throwArgumentError(\"invalid address\", \"address\", address);\n // }\n address = address.toLowerCase();\n const chars = address.substring(2).split(\"\");\n const expanded = new Uint8Array(40);\n for (let i = 0; i < 40; i++) {\n expanded[i] = chars[i].charCodeAt(0);\n }\n const hashed = getBytes(keccak256(expanded));\n for (let i = 0; i < 40; i += 2) {\n if ((hashed[i >> 1] >> 4) >= 8) {\n chars[i] = chars[i].toUpperCase();\n }\n if ((hashed[i >> 1] & 0x0f) >= 8) {\n chars[i + 1] = chars[i + 1].toUpperCase();\n }\n }\n return \"0x\" + chars.join(\"\");\n}\n// See: https://en.wikipedia.org/wiki/International_Bank_Account_Number\n// Create lookup table\nconst ibanLookup = {};\nfor (let i = 0; i < 10; i++) {\n ibanLookup[String(i)] = String(i);\n}\nfor (let i = 0; i < 26; i++) {\n ibanLookup[String.fromCharCode(65 + i)] = String(10 + i);\n}\n// How many decimal digits can we process? (for 64-bit float, this is 15)\n// i.e. Math.floor(Math.log10(Number.MAX_SAFE_INTEGER));\nconst safeDigits = 15;\nfunction ibanChecksum(address) {\n address = address.toUpperCase();\n address = address.substring(4) + address.substring(0, 2) + \"00\";\n let expanded = address.split(\"\").map((c) => { return ibanLookup[c]; }).join(\"\");\n // Javascript can handle integers safely up to 15 (decimal) digits\n while (expanded.length >= safeDigits) {\n let block = expanded.substring(0, safeDigits);\n expanded = parseInt(block, 10) % 97 + expanded.substring(block.length);\n }\n let checksum = String(98 - (parseInt(expanded, 10) % 97));\n while (checksum.length < 2) {\n checksum = \"0\" + checksum;\n }\n return checksum;\n}\n;\nconst Base36 = (function () {\n ;\n const result = {};\n for (let i = 0; i < 36; i++) {\n const key = \"0123456789abcdefghijklmnopqrstuvwxyz\"[i];\n result[key] = BigInt(i);\n }\n return result;\n})();\nfunction fromBase36(value) {\n value = value.toLowerCase();\n let result = BN_0;\n for (let i = 0; i < value.length; i++) {\n result = result * BN_36 + Base36[value[i]];\n }\n return result;\n}\n/**\n * Returns a normalized and checksumed address for %%address%%.\n * This accepts non-checksum addresses, checksum addresses and\n * [[getIcapAddress]] formats.\n *\n * The checksum in Ethereum uses the capitalization (upper-case\n * vs lower-case) of the characters within an address to encode\n * its checksum, which offers, on average, a checksum of 15-bits.\n *\n * If %%address%% contains both upper-case and lower-case, it is\n * assumed to already be a checksum address and its checksum is\n * validated, and if the address fails its expected checksum an\n * error is thrown.\n *\n * If you wish the checksum of %%address%% to be ignore, it should\n * be converted to lower-case (i.e. ``.toLowercase()``) before\n * being passed in. This should be a very rare situation though,\n * that you wish to bypass the safegaurds in place to protect\n * against an address that has been incorrectly copied from another\n * source.\n *\n * @example:\n * // Adds the checksum (via upper-casing specific letters)\n * getAddress(\"0x8ba1f109551bd432803012645ac136ddd64dba72\")\n * //_result:\n *\n * // Converts ICAP address and adds checksum\n * getAddress(\"XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36\");\n * //_result:\n *\n * // Throws an error if an address contains mixed case,\n * // but the checksum fails\n * getAddress(\"0x8Ba1f109551bD432803012645Ac136ddd64DBA72\")\n * //_error:\n */\nexport function getAddress(address) {\n assertArgument(typeof (address) === \"string\", \"invalid address\", \"address\", address);\n if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {\n // Missing the 0x prefix\n if (!address.startsWith(\"0x\")) {\n address = \"0x\" + address;\n }\n const result = getChecksumAddress(address);\n // It is a checksummed address with a bad checksum\n assertArgument(!address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || result === address, \"bad address checksum\", \"address\", address);\n return result;\n }\n // Maybe ICAP? (we only support direct mode)\n if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {\n // It is an ICAP address with a bad checksum\n assertArgument(address.substring(2, 4) === ibanChecksum(address), \"bad icap checksum\", \"address\", address);\n let result = fromBase36(address.substring(4)).toString(16);\n while (result.length < 40) {\n result = \"0\" + result;\n }\n return getChecksumAddress(\"0x\" + result);\n }\n assertArgument(false, \"invalid address\", \"address\", address);\n}\n/**\n * The [ICAP Address format](link-icap) format is an early checksum\n * format which attempts to be compatible with the banking\n * industry [IBAN format](link-wiki-iban) for bank accounts.\n *\n * It is no longer common or a recommended format.\n *\n * @example:\n * getIcapAddress(\"0x8ba1f109551bd432803012645ac136ddd64dba72\");\n * //_result:\n *\n * getIcapAddress(\"XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36\");\n * //_result:\n *\n * // Throws an error if the ICAP checksum is wrong\n * getIcapAddress(\"XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK37\");\n * //_error:\n */\nexport function getIcapAddress(address) {\n //let base36 = _base16To36(getAddress(address).substring(2)).toUpperCase();\n let base36 = BigInt(getAddress(address)).toString(36).toUpperCase();\n while (base36.length < 30) {\n base36 = \"0\" + base36;\n }\n return \"XE\" + ibanChecksum(\"XE00\" + base36) + base36;\n}\n//# sourceMappingURL=address.js.map"],"names":[],"mappings":";;;AAEA,MAAM,OAAO,OAAO,CAAC;AACrB,MAAM,QAAQ,OAAO,EAAE;AACvB,SAAS,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;AAC/D;","x_google_ignoreList":[0]}
|
|
@@ -1,64 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { Coder } from "./standards-sdk.es94.js";
|
|
7
|
-
import { pack, unpack } from "./standards-sdk.es96.js";
|
|
8
|
-
class TupleCoder extends Coder {
|
|
9
|
-
constructor(coders, localName) {
|
|
10
|
-
let dynamic = false;
|
|
11
|
-
const types = [];
|
|
12
|
-
coders.forEach((coder) => {
|
|
13
|
-
if (coder.dynamic) {
|
|
14
|
-
dynamic = true;
|
|
15
|
-
}
|
|
16
|
-
types.push(coder.type);
|
|
17
|
-
});
|
|
18
|
-
const type = "tuple(" + types.join(",") + ")";
|
|
19
|
-
super("tuple", type, localName, dynamic);
|
|
20
|
-
__publicField(this, "coders");
|
|
21
|
-
defineProperties(this, { coders: Object.freeze(coders.slice()) });
|
|
22
|
-
}
|
|
23
|
-
defaultValue() {
|
|
24
|
-
const values = [];
|
|
25
|
-
this.coders.forEach((coder) => {
|
|
26
|
-
values.push(coder.defaultValue());
|
|
27
|
-
});
|
|
28
|
-
const uniqueNames = this.coders.reduce((accum, coder) => {
|
|
29
|
-
const name = coder.localName;
|
|
30
|
-
if (name) {
|
|
31
|
-
if (!accum[name]) {
|
|
32
|
-
accum[name] = 0;
|
|
33
|
-
}
|
|
34
|
-
accum[name]++;
|
|
35
|
-
}
|
|
36
|
-
return accum;
|
|
37
|
-
}, {});
|
|
38
|
-
this.coders.forEach((coder, index) => {
|
|
39
|
-
let name = coder.localName;
|
|
40
|
-
if (!name || uniqueNames[name] !== 1) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
if (name === "length") {
|
|
44
|
-
name = "_length";
|
|
45
|
-
}
|
|
46
|
-
if (values[name] != null) {
|
|
1
|
+
function checkType(value, type, name) {
|
|
2
|
+
const types = type.split("|").map((t) => t.trim());
|
|
3
|
+
for (let i = 0; i < types.length; i++) {
|
|
4
|
+
switch (type) {
|
|
5
|
+
case "any":
|
|
47
6
|
return;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
7
|
+
case "bigint":
|
|
8
|
+
case "boolean":
|
|
9
|
+
case "number":
|
|
10
|
+
case "string":
|
|
11
|
+
if (typeof value === type) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
56
15
|
}
|
|
57
|
-
|
|
58
|
-
|
|
16
|
+
const error = new Error(`invalid value for type ${type}`);
|
|
17
|
+
error.code = "INVALID_ARGUMENT";
|
|
18
|
+
error.argument = `value.${name}`;
|
|
19
|
+
error.value = value;
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
function defineProperties(target, values, types) {
|
|
23
|
+
for (let key in values) {
|
|
24
|
+
let value = values[key];
|
|
25
|
+
const type = types ? types[key] : null;
|
|
26
|
+
if (type) {
|
|
27
|
+
checkType(value, type, key);
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(target, key, { enumerable: true, value, writable: false });
|
|
59
30
|
}
|
|
60
31
|
}
|
|
61
32
|
export {
|
|
62
|
-
|
|
33
|
+
defineProperties
|
|
63
34
|
};
|
|
64
35
|
//# sourceMappingURL=standards-sdk.es103.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es103.js","sources":["../../node_modules/ethers/lib.esm/
|
|
1
|
+
{"version":3,"file":"standards-sdk.es103.js","sources":["../../node_modules/ethers/lib.esm/utils/properties.js"],"sourcesContent":["/**\n * Property helper functions.\n *\n * @_subsection api/utils:Properties [about-properties]\n */\nfunction checkType(value, type, name) {\n const types = type.split(\"|\").map(t => t.trim());\n for (let i = 0; i < types.length; i++) {\n switch (type) {\n case \"any\":\n return;\n case \"bigint\":\n case \"boolean\":\n case \"number\":\n case \"string\":\n if (typeof (value) === type) {\n return;\n }\n }\n }\n const error = new Error(`invalid value for type ${type}`);\n error.code = \"INVALID_ARGUMENT\";\n error.argument = `value.${name}`;\n error.value = value;\n throw error;\n}\n/**\n * Resolves to a new object that is a copy of %%value%%, but with all\n * values resolved.\n */\nexport async function resolveProperties(value) {\n const keys = Object.keys(value);\n const results = await Promise.all(keys.map((k) => Promise.resolve(value[k])));\n return results.reduce((accum, v, index) => {\n accum[keys[index]] = v;\n return accum;\n }, {});\n}\n/**\n * Assigns the %%values%% to %%target%% as read-only values.\n *\n * It %%types%% is specified, the values are checked.\n */\nexport function defineProperties(target, values, types) {\n for (let key in values) {\n let value = values[key];\n const type = (types ? types[key] : null);\n if (type) {\n checkType(value, type, key);\n }\n Object.defineProperty(target, key, { enumerable: true, value, writable: false });\n }\n}\n//# sourceMappingURL=properties.js.map"],"names":[],"mappings":"AAKA,SAAS,UAAU,OAAO,MAAM,MAAM;AAClC,QAAM,QAAQ,KAAK,MAAM,GAAG,EAAE,IAAI,OAAK,EAAE,MAAM;AAC/C,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACnC,YAAQ,MAAI;AAAA,MACR,KAAK;AACD;AAAA,MACJ,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AACD,YAAI,OAAQ,UAAW,MAAM;AACzB;AAAA,QACpB;AAAA,IACA;AAAA,EACA;AACI,QAAM,QAAQ,IAAI,MAAM,0BAA0B,IAAI,EAAE;AACxD,QAAM,OAAO;AACb,QAAM,WAAW,SAAS,IAAI;AAC9B,QAAM,QAAQ;AACd,QAAM;AACV;AAkBO,SAAS,iBAAiB,QAAQ,QAAQ,OAAO;AACpD,WAAS,OAAO,QAAQ;AACpB,QAAI,QAAQ,OAAO,GAAG;AACtB,UAAM,OAAQ,QAAQ,MAAM,GAAG,IAAI;AACnC,QAAI,MAAM;AACN,gBAAU,OAAO,MAAM,GAAG;AAAA,IACtC;AACQ,WAAO,eAAe,QAAQ,KAAK,EAAE,YAAY,MAAM,OAAO,UAAU,OAAO;AAAA,EACvF;AACA;","x_google_ignoreList":[0]}
|