@aeternity/aepp-sdk 9.0.1 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -14
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.LICENSE.txt +7 -36
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +1 -1
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +1 -1
- package/dist/aepp-sdk.js.map +1 -1
- package/es/account/base.mjs +179 -0
- package/es/account/base.mjs.map +1 -0
- package/es/account/memory.mjs +99 -0
- package/es/account/memory.mjs.map +1 -0
- package/es/account/multiple.mjs +179 -0
- package/es/account/multiple.mjs.map +1 -0
- package/es/ae/aens.mjs +404 -0
- package/es/ae/aens.mjs.map +1 -0
- package/es/ae/{aepp.js → aepp.mjs} +9 -9
- package/es/ae/aepp.mjs.map +1 -0
- package/es/ae/contract.mjs +159 -0
- package/es/ae/contract.mjs.map +1 -0
- package/es/ae/index.mjs +207 -0
- package/es/ae/index.mjs.map +1 -0
- package/es/ae/oracle.mjs +339 -0
- package/es/ae/oracle.mjs.map +1 -0
- package/es/ae/{universal.js → universal.mjs} +10 -10
- package/es/ae/universal.mjs.map +1 -0
- package/es/ae/{wallet.js → wallet.mjs} +10 -10
- package/es/ae/wallet.mjs.map +1 -0
- package/es/aepp-wallet-communication/schema.d.ts +74 -0
- package/es/bignumber.d.ts +1 -7
- package/es/chain/{index.js → index.mjs} +29 -9
- package/es/chain/index.mjs.map +1 -0
- package/es/chain/node.mjs +442 -0
- package/es/chain/node.mjs.map +1 -0
- package/es/channel/handlers.mjs +1110 -0
- package/es/channel/handlers.mjs.map +1 -0
- package/es/channel/{index.js → index.mjs} +245 -472
- package/es/channel/index.mjs.map +1 -0
- package/es/channel/internal.mjs +283 -0
- package/es/channel/internal.mjs.map +1 -0
- package/es/contract/aci.mjs +477 -0
- package/es/contract/aci.mjs.map +1 -0
- package/es/contract/compiler.mjs +115 -0
- package/es/contract/compiler.mjs.map +1 -0
- package/es/contract/ga/helpers.mjs +30 -0
- package/es/contract/ga/helpers.mjs.map +1 -0
- package/es/contract/ga/index.mjs +178 -0
- package/es/contract/ga/index.mjs.map +1 -0
- package/es/errors.d.ts +284 -0
- package/es/index.mjs +57 -0
- package/es/index.mjs.map +1 -0
- package/es/node-pool/index.mjs +188 -0
- package/es/node-pool/index.mjs.map +1 -0
- package/es/node.mjs +133 -0
- package/es/node.mjs.map +1 -0
- package/es/other.d.ts +1 -1
- package/es/tx/builder/field-types.mjs +74 -0
- package/es/tx/builder/field-types.mjs.map +1 -0
- package/es/tx/builder/helpers.mjs +363 -0
- package/es/tx/builder/helpers.mjs.map +1 -0
- package/es/tx/builder/index.mjs +606 -0
- package/es/tx/builder/index.mjs.map +1 -0
- package/es/tx/builder/schema.mjs +760 -0
- package/es/tx/builder/schema.mjs.map +1 -0
- package/es/tx/{index.js → index.mjs} +107 -15
- package/es/tx/index.mjs.map +1 -0
- package/es/tx/tx-object.mjs +283 -0
- package/es/tx/tx-object.mjs.map +1 -0
- package/es/tx/tx.mjs +938 -0
- package/es/tx/tx.mjs.map +1 -0
- package/es/tx/validator.mjs +247 -0
- package/es/tx/validator.mjs.map +1 -0
- package/es/typings/blakejs/index.d.mjs +2 -0
- package/es/typings/blakejs/{index.d.js.map → index.d.mjs.map} +1 -1
- package/es/utils/aepp-wallet-communication/connection/{browser-runtime.js → browser-runtime.mjs} +27 -29
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs +183 -0
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/connection/{index.js → index.mjs} +7 -3
- package/es/utils/aepp-wallet-communication/connection/index.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/{content-script-bridge.js → content-script-bridge.mjs} +29 -23
- package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/helpers.mjs +92 -0
- package/es/utils/aepp-wallet-communication/helpers.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs +375 -0
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs +275 -0
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs +541 -0
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/schema.mjs +102 -0
- package/es/utils/aepp-wallet-communication/schema.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/wallet-detector.mjs +110 -0
- package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
- package/es/utils/amount-formatter.mjs +139 -0
- package/es/utils/amount-formatter.mjs.map +1 -0
- package/es/utils/async-init.mjs +64 -0
- package/es/utils/async-init.mjs.map +1 -0
- package/es/utils/bignumber.mjs +21 -0
- package/es/utils/bignumber.mjs.map +1 -0
- package/es/utils/{bytes.js → bytes.mjs} +16 -12
- package/es/utils/bytes.mjs.map +1 -0
- package/es/utils/{crypto-ts.js → crypto-ts.mjs} +11 -3
- package/es/utils/crypto-ts.mjs.map +1 -0
- package/es/utils/crypto.mjs +239 -0
- package/es/utils/crypto.mjs.map +1 -0
- package/es/utils/errors.mjs +689 -0
- package/es/utils/errors.mjs.map +1 -0
- package/es/utils/hd-wallet.mjs +111 -0
- package/es/utils/hd-wallet.mjs.map +1 -0
- package/es/utils/json-big.mjs +45 -0
- package/es/utils/json-big.mjs.map +1 -0
- package/es/utils/keystore.mjs +240 -0
- package/es/utils/keystore.mjs.map +1 -0
- package/es/utils/mptree.mjs +161 -0
- package/es/utils/mptree.mjs.map +1 -0
- package/es/utils/other.mjs +43 -0
- package/es/utils/other.mjs.map +1 -0
- package/es/utils/semver-satisfies.mjs +16 -0
- package/es/utils/semver-satisfies.mjs.map +1 -0
- package/es/utils/{string.js → string.mjs} +5 -14
- package/es/utils/string.mjs.map +1 -0
- package/es/utils/swagger.mjs +164 -0
- package/es/utils/swagger.mjs.map +1 -0
- package/package.json +55 -62
- package/src/account/base.js +3 -1
- package/src/account/memory.js +13 -8
- package/src/account/multiple.js +31 -22
- package/src/ae/aens.js +75 -77
- package/src/ae/aepp.js +2 -2
- package/src/ae/contract.js +27 -291
- package/src/ae/index.js +9 -7
- package/src/ae/oracle.js +51 -28
- package/src/ae/universal.js +4 -2
- package/src/ae/wallet.js +2 -2
- package/src/chain/index.js +29 -6
- package/src/chain/node.js +95 -67
- package/src/channel/handlers.js +30 -21
- package/src/channel/index.js +44 -20
- package/src/channel/internal.js +30 -24
- package/src/contract/aci.js +376 -0
- package/src/contract/compiler.js +41 -91
- package/src/contract/ga/helpers.js +10 -13
- package/src/contract/ga/index.js +42 -33
- package/src/index.js +9 -10
- package/src/node-pool/index.js +29 -17
- package/src/node.js +33 -36
- package/src/tx/builder/field-types.js +61 -0
- package/src/tx/builder/helpers.js +126 -84
- package/src/tx/builder/index.js +83 -41
- package/src/tx/builder/schema.js +50 -40
- package/src/tx/index.js +101 -12
- package/src/tx/tx-object.js +35 -15
- package/src/tx/tx.js +232 -153
- package/src/tx/validator.js +34 -12
- package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +11 -5
- package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +35 -13
- package/src/utils/aepp-wallet-communication/connection/index.js +2 -1
- package/src/utils/aepp-wallet-communication/content-script-bridge.js +14 -7
- package/src/utils/aepp-wallet-communication/helpers.js +6 -14
- package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +107 -60
- package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +24 -11
- package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +98 -56
- package/src/utils/aepp-wallet-communication/schema.ts +80 -0
- package/src/utils/aepp-wallet-communication/wallet-detector.js +6 -2
- package/src/utils/amount-formatter.ts +4 -3
- package/src/utils/async-init.js +10 -6
- package/src/utils/bignumber.ts +3 -10
- package/src/utils/bytes.ts +3 -2
- package/src/utils/crypto-ts.ts +2 -2
- package/src/utils/crypto.js +10 -144
- package/src/utils/errors.ts +683 -0
- package/src/utils/hd-wallet.js +11 -26
- package/src/utils/keystore.js +57 -53
- package/src/utils/mptree.ts +12 -6
- package/src/utils/other.ts +1 -1
- package/src/utils/semver-satisfies.ts +1 -1
- package/src/utils/swagger.js +75 -45
- package/es/account/base.js +0 -259
- package/es/account/base.js.map +0 -1
- package/es/account/memory.js +0 -86
- package/es/account/memory.js.map +0 -1
- package/es/account/multiple.js +0 -267
- package/es/account/multiple.js.map +0 -1
- package/es/ae/aens.js +0 -829
- package/es/ae/aens.js.map +0 -1
- package/es/ae/aepp.js.map +0 -1
- package/es/ae/contract.js +0 -985
- package/es/ae/contract.js.map +0 -1
- package/es/ae/index.js +0 -442
- package/es/ae/index.js.map +0 -1
- package/es/ae/oracle.js +0 -690
- package/es/ae/oracle.js.map +0 -1
- package/es/ae/universal.js.map +0 -1
- package/es/ae/wallet.js.map +0 -1
- package/es/chain/index.js.map +0 -1
- package/es/chain/node.js +0 -1119
- package/es/chain/node.js.map +0 -1
- package/es/channel/handlers.js +0 -1601
- package/es/channel/handlers.js.map +0 -1
- package/es/channel/index.js.map +0 -1
- package/es/channel/internal.js +0 -438
- package/es/channel/internal.js.map +0 -1
- package/es/contract/aci/helpers.js +0 -298
- package/es/contract/aci/helpers.js.map +0 -1
- package/es/contract/aci/index.js +0 -517
- package/es/contract/aci/index.js.map +0 -1
- package/es/contract/aci/transformation.js +0 -742
- package/es/contract/aci/transformation.js.map +0 -1
- package/es/contract/compiler.js +0 -316
- package/es/contract/compiler.js.map +0 -1
- package/es/contract/ga/helpers.js +0 -120
- package/es/contract/ga/helpers.js.map +0 -1
- package/es/contract/ga/index.js +0 -307
- package/es/contract/ga/index.js.map +0 -1
- package/es/contract/index.js +0 -158
- package/es/contract/index.js.map +0 -1
- package/es/index.js +0 -57
- package/es/index.js.map +0 -1
- package/es/node-pool/index.js +0 -204
- package/es/node-pool/index.js.map +0 -1
- package/es/node.js +0 -228
- package/es/node.js.map +0 -1
- package/es/tx/builder/helpers.js +0 -355
- package/es/tx/builder/helpers.js.map +0 -1
- package/es/tx/builder/index.js +0 -686
- package/es/tx/builder/index.js.map +0 -1
- package/es/tx/builder/schema.js +0 -695
- package/es/tx/builder/schema.js.map +0 -1
- package/es/tx/index.js.map +0 -1
- package/es/tx/tx-object.js +0 -297
- package/es/tx/tx-object.js.map +0 -1
- package/es/tx/tx.js +0 -1757
- package/es/tx/tx.js.map +0 -1
- package/es/tx/validator.js +0 -344
- package/es/tx/validator.js.map +0 -1
- package/es/typings/blakejs/index.d.js +0 -2
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +0 -211
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/index.js.map +0 -1
- package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +0 -1
- package/es/utils/aepp-wallet-communication/helpers.js +0 -148
- package/es/utils/aepp-wallet-communication/helpers.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -652
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -285
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -763
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +0 -1
- package/es/utils/aepp-wallet-communication/schema.js +0 -103
- package/es/utils/aepp-wallet-communication/schema.js.map +0 -1
- package/es/utils/aepp-wallet-communication/wallet-detector.js +0 -135
- package/es/utils/aepp-wallet-communication/wallet-detector.js.map +0 -1
- package/es/utils/amount-formatter.js +0 -152
- package/es/utils/amount-formatter.js.map +0 -1
- package/es/utils/async-init.js +0 -103
- package/es/utils/async-init.js.map +0 -1
- package/es/utils/bignumber.js +0 -36
- package/es/utils/bignumber.js.map +0 -1
- package/es/utils/bytes.js.map +0 -1
- package/es/utils/crypto-ts.js.map +0 -1
- package/es/utils/crypto.js +0 -358
- package/es/utils/crypto.js.map +0 -1
- package/es/utils/hd-wallet.js +0 -148
- package/es/utils/hd-wallet.js.map +0 -1
- package/es/utils/json-big.js +0 -78
- package/es/utils/json-big.js.map +0 -1
- package/es/utils/keystore.js +0 -393
- package/es/utils/keystore.js.map +0 -1
- package/es/utils/mptree.js +0 -198
- package/es/utils/mptree.js.map +0 -1
- package/es/utils/other.js +0 -93
- package/es/utils/other.js.map +0 -1
- package/es/utils/semver-satisfies.js +0 -35
- package/es/utils/semver-satisfies.js.map +0 -1
- package/es/utils/string.js.map +0 -1
- package/es/utils/swagger.js +0 -269
- package/es/utils/swagger.js.map +0 -1
- package/src/contract/aci/helpers.js +0 -140
- package/src/contract/aci/index.js +0 -191
- package/src/contract/aci/transformation.js +0 -464
- package/src/contract/index.js +0 -159
- package/src/utils/aepp-wallet-communication/schema.js +0 -110
package/es/utils/mptree.js
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
2
|
-
import _classCallCheck from "@babel/runtime-corejs3/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime-corejs3/helpers/createClass";
|
|
4
|
-
import _Object$fromEntries from "@babel/runtime-corejs3/core-js-stable/object/from-entries";
|
|
5
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
6
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
7
|
-
import _Object$entries from "@babel/runtime-corejs3/core-js-stable/object/entries";
|
|
8
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
9
|
-
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
10
|
-
import _parseInt from "@babel/runtime-corejs3/core-js-stable/parse-int";
|
|
11
|
-
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
12
|
-
|
|
13
|
-
/*
|
|
14
|
-
* ISC License (ISC)
|
|
15
|
-
* Copyright (c) 2021 aeternity developers
|
|
16
|
-
*
|
|
17
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
|
18
|
-
* purpose with or without fee is hereby granted, provided that the above
|
|
19
|
-
* copyright notice and this permission notice appear in all copies.
|
|
20
|
-
*
|
|
21
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
22
|
-
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
23
|
-
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
24
|
-
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
25
|
-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
26
|
-
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
27
|
-
* PERFORMANCE OF THIS SOFTWARE.
|
|
28
|
-
*/
|
|
29
|
-
import { encode as rlpEncode } from 'rlp';
|
|
30
|
-
import { hash } from './crypto-ts';
|
|
31
|
-
var NodeType;
|
|
32
|
-
|
|
33
|
-
(function (NodeType) {
|
|
34
|
-
NodeType[NodeType["Branch"] = 0] = "Branch";
|
|
35
|
-
NodeType[NodeType["Extension"] = 1] = "Extension";
|
|
36
|
-
NodeType[NodeType["Leaf"] = 2] = "Leaf";
|
|
37
|
-
})(NodeType || (NodeType = {}));
|
|
38
|
-
|
|
39
|
-
var MPTree = /*#__PURE__*/function () {
|
|
40
|
-
/**
|
|
41
|
-
* Deserialize Merkle Patricia Tree
|
|
42
|
-
* @rtype (binary: Array) => MPTree
|
|
43
|
-
* @param {Array} binary - Binary
|
|
44
|
-
* @return {MPTree} Merkle Patricia Tree
|
|
45
|
-
*/
|
|
46
|
-
function MPTree(binary) {
|
|
47
|
-
var _context,
|
|
48
|
-
_context2,
|
|
49
|
-
_this = this;
|
|
50
|
-
|
|
51
|
-
_classCallCheck(this, MPTree);
|
|
52
|
-
|
|
53
|
-
this.rootHash = binary[0].toString('hex');
|
|
54
|
-
this.nodes = _Object$fromEntries(_mapInstanceProperty(_context = binary[1]).call(_context, function (node) {
|
|
55
|
-
return [node[0].toString('hex'), node[1]];
|
|
56
|
-
}));
|
|
57
|
-
if (this.nodes[this.rootHash] === undefined) throw new Error('Can\'t find a node by root hash');
|
|
58
|
-
|
|
59
|
-
_forEachInstanceProperty(_context2 = _Object$entries(this.nodes)).call(_context2, function (_ref) {
|
|
60
|
-
var _context3, _context4;
|
|
61
|
-
|
|
62
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
63
|
-
key = _ref2[0],
|
|
64
|
-
node = _ref2[1];
|
|
65
|
-
|
|
66
|
-
if (MPTree.nodeHash(node) !== key) throw new Error('Node hash is not equal to provided one');
|
|
67
|
-
|
|
68
|
-
var _MPTree$parseNode = MPTree.parseNode(node),
|
|
69
|
-
type = _MPTree$parseNode.type,
|
|
70
|
-
payload = _MPTree$parseNode.payload;
|
|
71
|
-
|
|
72
|
-
switch (type) {
|
|
73
|
-
case NodeType.Branch:
|
|
74
|
-
_forEachInstanceProperty(_context3 = _filterInstanceProperty(_context4 = _sliceInstanceProperty(payload).call(payload, 0, 16)).call(_context4, function (n) {
|
|
75
|
-
return n.length;
|
|
76
|
-
})).call(_context3, function (n) {
|
|
77
|
-
if (_this.nodes[n.toString('hex')] === undefined) {
|
|
78
|
-
throw new Error('Can\'t find a node by hash in branch node');
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
break;
|
|
83
|
-
|
|
84
|
-
case NodeType.Extension:
|
|
85
|
-
if (_this.nodes[payload[0].toString('hex')] === undefined) {
|
|
86
|
-
throw new Error('Can\'t find a node by hash in extension node');
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
_createClass(MPTree, [{
|
|
94
|
-
key: "isEqual",
|
|
95
|
-
value: function isEqual(tree) {
|
|
96
|
-
return this.rootHash === tree.rootHash;
|
|
97
|
-
}
|
|
98
|
-
}, {
|
|
99
|
-
key: "serialize",
|
|
100
|
-
value:
|
|
101
|
-
/**
|
|
102
|
-
* Serialize Merkle Patricia Tree
|
|
103
|
-
* @rtype () => Array
|
|
104
|
-
* @return {Array} Binary
|
|
105
|
-
*/
|
|
106
|
-
function serialize() {
|
|
107
|
-
var _context5;
|
|
108
|
-
|
|
109
|
-
return [Buffer.from(this.rootHash, 'hex'), _mapInstanceProperty(_context5 = _Object$entries(this.nodes)).call(_context5, function (_ref3) {
|
|
110
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
111
|
-
mptHash = _ref4[0],
|
|
112
|
-
value = _ref4[1];
|
|
113
|
-
|
|
114
|
-
return [Buffer.from(mptHash, 'hex'), value];
|
|
115
|
-
})];
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Retrieve value from Merkle Patricia Tree
|
|
119
|
-
* @rtype (key: String) => Buffer
|
|
120
|
-
* @param {String} key - The key of the element to retrieve
|
|
121
|
-
* @return {Buffer} Value associated to the specified key
|
|
122
|
-
*/
|
|
123
|
-
|
|
124
|
-
}, {
|
|
125
|
-
key: "get",
|
|
126
|
-
value: function get(key) {
|
|
127
|
-
var searchFrom = this.rootHash;
|
|
128
|
-
|
|
129
|
-
while (true) {
|
|
130
|
-
var _MPTree$parseNode2 = MPTree.parseNode(this.nodes[searchFrom]),
|
|
131
|
-
type = _MPTree$parseNode2.type,
|
|
132
|
-
payload = _MPTree$parseNode2.payload,
|
|
133
|
-
path = _MPTree$parseNode2.path;
|
|
134
|
-
|
|
135
|
-
switch (type) {
|
|
136
|
-
case NodeType.Branch:
|
|
137
|
-
if (key.length === 0) return payload[16];
|
|
138
|
-
searchFrom = payload[_parseInt(key[0], 16)].toString('hex');
|
|
139
|
-
key = key.substr(1);
|
|
140
|
-
break;
|
|
141
|
-
|
|
142
|
-
case NodeType.Extension:
|
|
143
|
-
if (key.substr(0, path === null || path === void 0 ? void 0 : path.length) !== path) return undefined;
|
|
144
|
-
searchFrom = payload[0].toString('hex');
|
|
145
|
-
key = key.substr(path.length);
|
|
146
|
-
break;
|
|
147
|
-
|
|
148
|
-
case NodeType.Leaf:
|
|
149
|
-
if (path !== key) return undefined;
|
|
150
|
-
return payload[0];
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}], [{
|
|
155
|
-
key: "nodeHash",
|
|
156
|
-
value: function nodeHash(node) {
|
|
157
|
-
return Buffer.from(hash(rlpEncode(node))).toString('hex');
|
|
158
|
-
}
|
|
159
|
-
}, {
|
|
160
|
-
key: "parseNode",
|
|
161
|
-
value: function parseNode(node) {
|
|
162
|
-
switch (node.length) {
|
|
163
|
-
case 17:
|
|
164
|
-
return {
|
|
165
|
-
type: NodeType.Branch,
|
|
166
|
-
payload: node,
|
|
167
|
-
path: null
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
case 2:
|
|
171
|
-
{
|
|
172
|
-
var _context6;
|
|
173
|
-
|
|
174
|
-
var path = node[0].toString('hex');
|
|
175
|
-
|
|
176
|
-
var nibble = _parseInt(path[0], 16);
|
|
177
|
-
|
|
178
|
-
if (nibble > 3) throw new Error("Unknown path nibble: ".concat(nibble));
|
|
179
|
-
var type = nibble <= 1 ? NodeType.Extension : NodeType.Leaf;
|
|
180
|
-
var slice = _includesInstanceProperty(_context6 = [0, 2]).call(_context6, nibble) ? 2 : 1;
|
|
181
|
-
return {
|
|
182
|
-
type: type,
|
|
183
|
-
payload: [node[1]],
|
|
184
|
-
path: _sliceInstanceProperty(path).call(path, slice)
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
default:
|
|
189
|
-
throw new Error("Unknown node length: ".concat(node.length));
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}]);
|
|
193
|
-
|
|
194
|
-
return MPTree;
|
|
195
|
-
}();
|
|
196
|
-
|
|
197
|
-
export { MPTree as default };
|
|
198
|
-
//# sourceMappingURL=mptree.js.map
|
package/es/utils/mptree.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/mptree.ts"],"names":["encode","rlpEncode","hash","NodeType","MPTree","binary","rootHash","toString","nodes","node","undefined","Error","key","nodeHash","parseNode","type","payload","Branch","n","length","Extension","tree","Buffer","from","mptHash","value","searchFrom","path","substr","Leaf","nibble","slice"],"mappings":"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","sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2021 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\nimport { encode as rlpEncode } from 'rlp'\nimport type { Input } from 'rlp'\nimport { hash } from './crypto-ts'\n\nenum NodeType {\n Branch,\n Extension,\n Leaf\n}\n\nexport type MPTreeBinary = [Buffer, Array<[Buffer, Buffer[]]>]\n\nexport default class MPTree {\n private readonly rootHash: string\n private readonly nodes: { [key: string]: Buffer[] }\n\n private static nodeHash (node: Input): string {\n return Buffer.from(hash(rlpEncode(node))).toString('hex')\n }\n\n /**\n * Deserialize Merkle Patricia Tree\n * @rtype (binary: Array) => MPTree\n * @param {Array} binary - Binary\n * @return {MPTree} Merkle Patricia Tree\n */\n constructor (binary: MPTreeBinary) {\n this.rootHash = binary[0].toString('hex')\n this.nodes = Object.fromEntries(\n binary[1].map((node) => [node[0].toString('hex'), node[1]])\n )\n\n if (this.nodes[this.rootHash] === undefined) throw new Error('Can\\'t find a node by root hash')\n Object.entries(this.nodes).forEach(([key, node]) => {\n if (MPTree.nodeHash(node) !== key) throw new Error('Node hash is not equal to provided one')\n const { type, payload } = MPTree.parseNode(node)\n switch (type) {\n case NodeType.Branch:\n payload\n .slice(0, 16)\n .filter(n => n.length)\n .forEach((n) => {\n if (this.nodes[n.toString('hex')] === undefined) {\n throw new Error('Can\\'t find a node by hash in branch node')\n }\n })\n break\n case NodeType.Extension:\n if (this.nodes[payload[0].toString('hex')] === undefined) {\n throw new Error('Can\\'t find a node by hash in extension node')\n }\n }\n })\n }\n\n isEqual (tree: MPTree): boolean {\n return this.rootHash === tree.rootHash\n }\n\n private static parseNode (node: Buffer[]): { type: NodeType, payload: Buffer[], path: string | null } {\n switch (node.length) {\n case 17:\n return { type: NodeType.Branch, payload: node, path: null }\n case 2: {\n const path = node[0].toString('hex')\n const nibble = parseInt(path[0], 16)\n if (nibble > 3) throw new Error(`Unknown path nibble: ${nibble}`)\n const type = nibble <= 1 ? NodeType.Extension : NodeType.Leaf\n const slice = [0, 2].includes(nibble) ? 2 : 1\n return { type, payload: [node[1]], path: path.slice(slice) }\n }\n default:\n throw new Error(`Unknown node length: ${node.length}`)\n }\n }\n\n /**\n * Serialize Merkle Patricia Tree\n * @rtype () => Array\n * @return {Array} Binary\n */\n serialize (): MPTreeBinary {\n return [\n Buffer.from(this.rootHash, 'hex'),\n Object.entries(this.nodes).map(([mptHash, value]) => ([\n Buffer.from(mptHash, 'hex'),\n value\n ]))\n ]\n }\n\n /**\n * Retrieve value from Merkle Patricia Tree\n * @rtype (key: String) => Buffer\n * @param {String} key - The key of the element to retrieve\n * @return {Buffer} Value associated to the specified key\n */\n get (key: string): Buffer | undefined {\n let searchFrom = this.rootHash\n while (true) {\n const { type, payload, path } = MPTree.parseNode(this.nodes[searchFrom])\n switch (type) {\n case NodeType.Branch:\n if (key.length === 0) return payload[16]\n searchFrom = payload[parseInt(key[0], 16)].toString('hex')\n key = key.substr(1)\n break\n case NodeType.Extension:\n if (key.substr(0, path?.length) !== path) return undefined\n searchFrom = payload[0].toString('hex')\n key = key.substr(path.length)\n break\n case NodeType.Leaf:\n if (path !== key) return undefined\n return payload[0]\n }\n }\n }\n}\n"],"file":"mptree.js"}
|
package/es/utils/other.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
2
|
-
import _typeof from "@babel/runtime-corejs3/helpers/typeof";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
4
|
-
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
5
|
-
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
6
|
-
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
|
7
|
-
import _Object$fromEntries from "@babel/runtime-corejs3/core-js-stable/object/from-entries";
|
|
8
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
9
|
-
import _Object$entries from "@babel/runtime-corejs3/core-js-stable/object/entries";
|
|
10
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
11
|
-
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
|
|
12
|
-
import _bindInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/bind";
|
|
13
|
-
import { snakeToPascal, pascalToSnake } from './string';
|
|
14
|
-
export var pause = /*#__PURE__*/function () {
|
|
15
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(duration) {
|
|
16
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
17
|
-
while (1) {
|
|
18
|
-
switch (_context.prev = _context.next) {
|
|
19
|
-
case 0:
|
|
20
|
-
_context.next = 2;
|
|
21
|
-
return new _Promise(function (resolve) {
|
|
22
|
-
return _setTimeout(resolve, duration);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
case 2:
|
|
26
|
-
return _context.abrupt("return", _context.sent);
|
|
27
|
-
|
|
28
|
-
case 3:
|
|
29
|
-
case "end":
|
|
30
|
-
return _context.stop();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}, _callee);
|
|
34
|
-
}));
|
|
35
|
-
|
|
36
|
-
return function pause(_x) {
|
|
37
|
-
return _ref.apply(this, arguments);
|
|
38
|
-
};
|
|
39
|
-
}();
|
|
40
|
-
export var mapObject = function mapObject(object, fn) {
|
|
41
|
-
var _context2;
|
|
42
|
-
|
|
43
|
-
return _Object$fromEntries(_mapInstanceProperty(_context2 = _Object$entries(object)).call(_context2, fn));
|
|
44
|
-
};
|
|
45
|
-
export var filterObject = function filterObject(object, fn) {
|
|
46
|
-
var _context3;
|
|
47
|
-
|
|
48
|
-
return _Object$fromEntries(_filterInstanceProperty(_context3 = _Object$entries(object)).call(_context3, fn));
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Key traversal metafunction
|
|
52
|
-
* @static
|
|
53
|
-
* @function
|
|
54
|
-
* @rtype (fn: (s: String) => String) => (o: Object) => Object
|
|
55
|
-
* @param {Function} fn - Key transformation function
|
|
56
|
-
* @param {Object} object - Object to traverse
|
|
57
|
-
* @return {Object} Transformed object
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
export var traverseKeys = function traverseKeys(fn, object) {
|
|
61
|
-
if (_typeof(object) !== 'object' || object === null) return object;
|
|
62
|
-
if (_Array$isArray(object)) return _mapInstanceProperty(object).call(object, function (i) {
|
|
63
|
-
return traverseKeys(fn, i);
|
|
64
|
-
});
|
|
65
|
-
return mapObject(object, function (_ref2) {
|
|
66
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
67
|
-
key = _ref3[0],
|
|
68
|
-
value = _ref3[1];
|
|
69
|
-
|
|
70
|
-
return [fn(key), traverseKeys(fn, value)];
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* snake_case key traversal
|
|
75
|
-
* @static
|
|
76
|
-
* @rtype (o: Object) => Object
|
|
77
|
-
* @param {Object} object - Object to traverse
|
|
78
|
-
* @return {Object} Transformed object
|
|
79
|
-
* @see pascalToSnake
|
|
80
|
-
*/
|
|
81
|
-
|
|
82
|
-
export var snakizeKeys = _bindInstanceProperty(traverseKeys).call(traverseKeys, null, pascalToSnake);
|
|
83
|
-
/**
|
|
84
|
-
* PascalCase key traversal
|
|
85
|
-
* @static
|
|
86
|
-
* @rtype (o: Object) => Object
|
|
87
|
-
* @param {Object} object - Object to traverse
|
|
88
|
-
* @return {Object} Transformed object
|
|
89
|
-
* @see snakeToPascal
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
export var pascalizeKeys = _bindInstanceProperty(traverseKeys).call(traverseKeys, null, snakeToPascal);
|
|
93
|
-
//# sourceMappingURL=other.js.map
|
package/es/utils/other.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/other.ts"],"names":["snakeToPascal","pascalToSnake","pause","duration","resolve","mapObject","object","fn","filterObject","traverseKeys","i","key","value","snakizeKeys","pascalizeKeys"],"mappings":";;;;;;;;;;;;AAAA,SAASA,aAAT,EAAwBC,aAAxB,QAA6C,UAA7C;AAEA,OAAO,IAAMC,KAAK;AAAA,sEAAG,iBAAOC,QAAP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBACb,aAAY,UAAAC,OAAO;AAAA,qBAAI,YAAWA,OAAX,EAAoBD,QAApB,CAAJ;AAAA,aAAnB,CADa;;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAAH;;AAAA,kBAALD,KAAK;AAAA;AAAA;AAAA,GAAX;AAGP,OAAO,IAAMG,SAAS,GAAG,SAAZA,SAAY,CACvBC,MADuB,EAEvBC,EAFuB;AAAA;;AAAA,SAGZ,oBAAmB,iDAAeD,MAAf,mBAA2BC,EAA3B,CAAnB,CAHY;AAAA,CAAlB;AAKP,OAAO,IAAMC,YAAY,GAAG,SAAfA,YAAe,CAC1BF,MAD0B,EAE1BC,EAF0B;AAAA;;AAAA,SAGf,oBAAmB,oDAAeD,MAAf,mBAA8BC,EAA9B,CAAnB,CAHe;AAAA,CAArB;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAME,YAAY,GAAG,SAAfA,YAAe,CAACF,EAAD,EAAeD,MAAf,EAAoC;AAC9D,MAAI,QAAOA,MAAP,MAAkB,QAAlB,IAA8BA,MAAM,KAAK,IAA7C,EAAmD,OAAOA,MAAP;AACnD,MAAI,eAAcA,MAAd,CAAJ,EAA2B,OAAO,qBAAAA,MAAM,MAAN,CAAAA,MAAM,EAAK,UAAAI,CAAC;AAAA,WAAID,YAAY,CAACF,EAAD,EAAKG,CAAL,CAAhB;AAAA,GAAN,CAAb;AAC3B,SAAOL,SAAS,CAACC,MAAD,EAAS;AAAA;AAAA,QAAEK,GAAF;AAAA,QAAOC,KAAP;;AAAA,WAAiC,CACxDL,EAAE,CAACI,GAAD,CADsD,EAC/CF,YAAY,CAACF,EAAD,EAAKK,KAAL,CADmC,CAAjC;AAAA,GAAT,CAAhB;AAGD,CANM;AAQP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,WAAW,GAAG,sBAAAJ,YAAY,MAAZ,CAAAA,YAAY,EAAM,IAAN,EAAYR,aAAZ,CAAhC;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMa,aAAa,GAAG,sBAAAL,YAAY,MAAZ,CAAAA,YAAY,EAAM,IAAN,EAAYT,aAAZ,CAAlC","sourcesContent":["import { snakeToPascal, pascalToSnake } from './string'\n\nexport const pause = async (duration: number): Promise<undefined> =>\n await new Promise(resolve => setTimeout(resolve, duration))\n\nexport const mapObject = (\n object: object,\n fn: (value: [string, any], index: number, array: Array<[string, any]>) => Array<[string, any]>\n): object => Object.fromEntries(Object.entries(object).map(fn))\n\nexport const filterObject = (\n object: object,\n fn: (value: [string, any], index: number, array: Array<[string, any]>) => boolean\n): object => Object.fromEntries(Object.entries(object).filter(fn))\n\n/**\n * Key traversal metafunction\n * @static\n * @function\n * @rtype (fn: (s: String) => String) => (o: Object) => Object\n * @param {Function} fn - Key transformation function\n * @param {Object} object - Object to traverse\n * @return {Object} Transformed object\n */\nexport const traverseKeys = (fn: Function, object: any): any => {\n if (typeof object !== 'object' || object === null) return object\n if (Array.isArray(object)) return object.map(i => traverseKeys(fn, i))\n return mapObject(object, ([key, value]: [string, any]) => [\n fn(key), traverseKeys(fn, value)\n ])\n}\n\n/**\n * snake_case key traversal\n * @static\n * @rtype (o: Object) => Object\n * @param {Object} object - Object to traverse\n * @return {Object} Transformed object\n * @see pascalToSnake\n */\nexport const snakizeKeys = traverseKeys.bind(null, pascalToSnake)\n\n/**\n * PascalCase key traversal\n * @static\n * @rtype (o: Object) => Object\n * @param {Object} object - Object to traverse\n * @return {Object} Transformed object\n * @see snakeToPascal\n */\nexport const pascalizeKeys = traverseKeys.bind(null, snakeToPascal)\n"],"file":"other.js"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
|
|
2
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
3
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
4
|
-
import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
|
|
5
|
-
import _reverseInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reverse";
|
|
6
|
-
export default function (version, geVersion, ltVersion) {
|
|
7
|
-
var _context2;
|
|
8
|
-
|
|
9
|
-
var getComponents = function getComponents(v) {
|
|
10
|
-
var _context;
|
|
11
|
-
|
|
12
|
-
return _mapInstanceProperty(_context = v.split('-')[0].split('.')).call(_context, function (i) {
|
|
13
|
-
return +i;
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
var versionComponents = getComponents(version);
|
|
18
|
-
var geComponents = getComponents(geVersion);
|
|
19
|
-
var ltComponents = getComponents(ltVersion);
|
|
20
|
-
var base = Math.max.apply(Math, _concatInstanceProperty(_context2 = _toConsumableArray(versionComponents)).call(_context2, _toConsumableArray(geComponents), _toConsumableArray(ltComponents))) + 1;
|
|
21
|
-
|
|
22
|
-
var componentsToNumber = function componentsToNumber(components) {
|
|
23
|
-
var _context3;
|
|
24
|
-
|
|
25
|
-
return _reduceInstanceProperty(_context3 = _reverseInstanceProperty(components).call(components)).call(_context3, function (acc, n, idx) {
|
|
26
|
-
return acc + n * Math.pow(base, idx);
|
|
27
|
-
}, 0);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
var vNumber = componentsToNumber(versionComponents);
|
|
31
|
-
var geNumber = componentsToNumber(geComponents);
|
|
32
|
-
var ltNumber = componentsToNumber(ltComponents);
|
|
33
|
-
return vNumber >= geNumber && vNumber < ltNumber;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=semver-satisfies.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/semver-satisfies.ts"],"names":["version","geVersion","ltVersion","getComponents","v","split","i","versionComponents","geComponents","ltComponents","base","Math","max","componentsToNumber","components","acc","n","idx","pow","vNumber","geNumber","ltNumber"],"mappings":";;;;;AAAA,eAAe,UAAUA,OAAV,EAA2BC,SAA3B,EAA8CC,SAA9C,EAA0E;AAAA;;AACvF,MAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACC,CAAD;AAAA;;AAAA,WAAyB,gCAAAA,CAAC,CAC7CC,KAD4C,CACtC,GADsC,EACjC,CADiC,EAC9BA,KAD8B,CACxB,GADwB,kBACf,UAAAC,CAAC;AAAA,aAAI,CAACA,CAAL;AAAA,KADc,CAAzB;AAAA,GAAtB;;AAGA,MAAMC,iBAAiB,GAAGJ,aAAa,CAACH,OAAD,CAAvC;AACA,MAAMQ,YAAY,GAAGL,aAAa,CAACF,SAAD,CAAlC;AACA,MAAMQ,YAAY,GAAGN,aAAa,CAACD,SAAD,CAAlC;AAEA,MAAMQ,IAAI,GAAGC,IAAI,CAACC,GAAL,OAAAD,IAAI,yDAAQJ,iBAAR,sCAA8BC,YAA9B,sBAA+CC,YAA/C,GAAJ,GAAmE,CAAhF;;AACA,MAAMI,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,UAAD;AAAA;;AAAA,WAAkC,6DAAAA,UAAU,MAAV,CAAAA,UAAU,OAAV,YACnD,UAACC,GAAD,EAAMC,CAAN,EAASC,GAAT;AAAA,aAAiBF,GAAG,GAAGC,CAAC,GAAGL,IAAI,CAACO,GAAL,CAASR,IAAT,EAAeO,GAAf,CAA3B;AAAA,KADmD,EACH,CADG,CAAlC;AAAA,GAA3B;;AAGA,MAAME,OAAO,GAAGN,kBAAkB,CAACN,iBAAD,CAAlC;AACA,MAAMa,QAAQ,GAAGP,kBAAkB,CAACL,YAAD,CAAnC;AACA,MAAMa,QAAQ,GAAGR,kBAAkB,CAACJ,YAAD,CAAnC;AACA,SAAOU,OAAO,IAAIC,QAAX,IAAuBD,OAAO,GAAGE,QAAxC;AACD","sourcesContent":["export default function (version: string, geVersion: string, ltVersion: string): boolean {\n const getComponents = (v: string): number[] => v\n .split('-')[0].split('.').map(i => +i)\n\n const versionComponents = getComponents(version)\n const geComponents = getComponents(geVersion)\n const ltComponents = getComponents(ltVersion)\n\n const base = Math.max(...versionComponents, ...geComponents, ...ltComponents) + 1\n const componentsToNumber = (components: number[]): number => components.reverse()\n .reduce((acc, n, idx) => acc + n * Math.pow(base, idx), 0)\n\n const vNumber = componentsToNumber(versionComponents)\n const geNumber = componentsToNumber(geComponents)\n const ltNumber = componentsToNumber(ltComponents)\n return vNumber >= geNumber && vNumber < ltNumber\n}\n"],"file":"semver-satisfies.js"}
|
package/es/utils/string.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/string.ts"],"names":["snakeToPascal","s","replace","match","toUpperCase","pascalToSnake","toLowerCase","isHex","str","length","test","isBase64","index"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,aAAT,CAAwBC,CAAxB,EAA2C;AAChD,SAAOA,CAAC,CAACC,OAAF,CAAU,KAAV,EAAiB,UAAAC,KAAK;AAAA,WAAIA,KAAK,CAAC,CAAD,CAAL,CAASC,WAAT,EAAJ;AAAA,GAAtB,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,aAAT,CAAwBJ,CAAxB,EAA2C;AAChD,SAAOA,CAAC,CAACC,OAAF,CAAU,QAAV,EAAoB,UAAAC,KAAK;AAAA,sBAAQA,KAAK,CAACG,WAAN,EAAR;AAAA,GAAzB,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,KAAT,CAAgBC,GAAhB,EAAsC;AAC3C,SAAOA,GAAG,CAACC,MAAJ,GAAa,CAAb,KAAmB,CAAnB,IAAwB,eAAeC,IAAf,CAAoBF,GAApB,CAA/B;AACD;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,QAAT,CAAmBH,GAAnB,EAAyC;AAC9C,MAAIA,GAAG,CAACC,MAAJ,GAAa,CAAb,GAAiB,CAAjB,IAAsB,gBAAgBC,IAAhB,CAAqBF,GAArB,CAA1B,EAAqD,OAAO,KAAP;;AACrD,MAAMI,KAAK,GAAG,yBAAAJ,GAAG,MAAH,CAAAA,GAAG,EAAS,GAAT,CAAjB;;AACA,SAAOI,KAAK,KAAK,CAAC,CAAX,IAAgB,SAASF,IAAT,CAAc,uBAAAF,GAAG,MAAH,CAAAA,GAAG,EAAOI,KAAP,CAAjB,CAAvB;AACD","sourcesContent":["/*\n * ISC License (ISC)\n * Copyright 2018 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * Convert string from snake_case to PascalCase\n * @rtype (s: String) => String\n * @param {String} s - String to convert\n * @return {String} Converted string\n */\nexport function snakeToPascal (s: string): string {\n return s.replace(/_./g, match => match[1].toUpperCase())\n}\n\n/**\n * Convert string from PascalCase to snake_case\n * @rtype (s: String) => String\n * @param {String} s - String to convert\n * @return {String} Converted string\n */\nexport function pascalToSnake (s: string): string {\n return s.replace(/[A-Z]/g, match => `_${match.toLowerCase()}`)\n}\n\n/**\n * Check whether a string is valid hex.\n * @param {string} str String to validate.\n * @return {boolean} True if the string is valid hex, false otherwise.\n */\nexport function isHex (str: string): boolean {\n return str.length % 2 === 0 && /^[0-9a-f]+$/i.test(str)\n}\n\n/**\n * Check whether a string is valid base-64.\n * @param {string} str String to validate.\n * @return {boolean} True if the string is valid base-64, false otherwise.\n */\nexport function isBase64 (str: string): boolean {\n if (str.length % 4 > 0 || /[^0-9a-z+/=]/i.test(str)) return false\n const index = str.indexOf('=')\n return index === -1 || /={1,2}/.test(str.slice(index))\n}\n"],"file":"string.js"}
|
package/es/utils/swagger.js
DELETED
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
2
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
3
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
4
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
5
|
-
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
|
6
|
-
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
|
7
|
-
import _typeof from "@babel/runtime-corejs3/helpers/typeof";
|
|
8
|
-
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/objectWithoutProperties";
|
|
9
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
10
|
-
import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
|
|
11
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
12
|
-
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
13
|
-
var _excluded = ["__requestBody"];
|
|
14
|
-
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
15
|
-
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) { symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context13; _forEachInstanceProperty(_context13 = ownKeys(Object(source), true)).call(_context13, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context14; _forEachInstanceProperty(_context14 = ownKeys(Object(source))).call(_context14, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
19
|
-
|
|
20
|
-
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
21
|
-
import _URL from "@babel/runtime-corejs3/core-js-stable/url";
|
|
22
|
-
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
23
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
24
|
-
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
25
|
-
import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
|
|
26
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
27
|
-
import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
|
|
28
|
-
import _flatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/flat";
|
|
29
|
-
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
30
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
31
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
32
|
-
import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
|
|
33
|
-
|
|
34
|
-
/*
|
|
35
|
-
* ISC License (ISC)
|
|
36
|
-
* Copyright (c) 2021 aeternity developers
|
|
37
|
-
*
|
|
38
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
|
39
|
-
* purpose with or without fee is hereby granted, provided that the above
|
|
40
|
-
* copyright notice and this permission notice appear in all copies.
|
|
41
|
-
*
|
|
42
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
43
|
-
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
44
|
-
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
45
|
-
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
46
|
-
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
47
|
-
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
48
|
-
* PERFORMANCE OF THIS SOFTWARE.
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Generator of Swagger client module
|
|
53
|
-
* @module @aeternity/aepp-sdk/es/utils/swagger
|
|
54
|
-
* @export genSwaggerClient
|
|
55
|
-
*/
|
|
56
|
-
import SwaggerClient from 'swagger-client';
|
|
57
|
-
import fetch from 'cross-fetch';
|
|
58
|
-
import JsonBig from './json-big';
|
|
59
|
-
import { snakizeKeys, pascalizeKeys, mapObject, filterObject } from './other';
|
|
60
|
-
var warnedAboutInternalApiUsage = false;
|
|
61
|
-
/**
|
|
62
|
-
* Generator of Swagger client
|
|
63
|
-
* @function
|
|
64
|
-
* @alias module:@aeternity/aepp-sdk/es/utils/swagger
|
|
65
|
-
* @rtype Object
|
|
66
|
-
* @param {String} specUrl - Swagger specification URL on external node host
|
|
67
|
-
* @param {Object} options
|
|
68
|
-
* @param {String} [options.spec] - Override OpenAPI definition
|
|
69
|
-
* @param {String} [options.internalUrl] - Node internal URL
|
|
70
|
-
* @param {Boolean} [options.disableBigNumbers]
|
|
71
|
-
* @param {Boolean} [options.disableCaseConversion]
|
|
72
|
-
* @return {Object} Swagger client
|
|
73
|
-
* @example (await genSwaggerClient('https://mainnet.aeternity.io/api')).getAccountByPubkey('ak_jupBUgZNbcC4krDLR3tAkw1iBZoBbkNeShAq4atBtpFWmz36r')
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
export default /*#__PURE__*/(function () {
|
|
77
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(specUrl) {
|
|
78
|
-
var _context, _context2, _context3, _context4, _context5, _context6, _context7, _context8;
|
|
79
|
-
|
|
80
|
-
var _ref2,
|
|
81
|
-
spec,
|
|
82
|
-
internalUrl,
|
|
83
|
-
disableBigNumbers,
|
|
84
|
-
disableCaseConversion,
|
|
85
|
-
jsonImp,
|
|
86
|
-
_yield$Promise$all,
|
|
87
|
-
_yield$Promise$all2,
|
|
88
|
-
external,
|
|
89
|
-
internal,
|
|
90
|
-
combinedApi,
|
|
91
|
-
opSpecs,
|
|
92
|
-
api,
|
|
93
|
-
_args2 = arguments;
|
|
94
|
-
|
|
95
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context12) {
|
|
96
|
-
while (1) {
|
|
97
|
-
switch (_context12.prev = _context12.next) {
|
|
98
|
-
case 0:
|
|
99
|
-
_ref2 = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {}, spec = _ref2.spec, internalUrl = _ref2.internalUrl, disableBigNumbers = _ref2.disableBigNumbers, disableCaseConversion = _ref2.disableCaseConversion;
|
|
100
|
-
_context12.t0 = spec;
|
|
101
|
-
|
|
102
|
-
if (_context12.t0) {
|
|
103
|
-
_context12.next = 8;
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
_context12.next = 5;
|
|
108
|
-
return fetch(specUrl);
|
|
109
|
-
|
|
110
|
-
case 5:
|
|
111
|
-
_context12.next = 7;
|
|
112
|
-
return _context12.sent.json();
|
|
113
|
-
|
|
114
|
-
case 7:
|
|
115
|
-
_context12.t0 = _context12.sent;
|
|
116
|
-
|
|
117
|
-
case 8:
|
|
118
|
-
spec = _context12.t0;
|
|
119
|
-
jsonImp = disableBigNumbers ? JSON : JsonBig;
|
|
120
|
-
|
|
121
|
-
if (_includesInstanceProperty(_context = ['https://compiler.aepps.com', 'https://latest.compiler.aepps.com']).call(_context, new _URL(specUrl).origin) || _includesInstanceProperty(_context2 = new _URL(specUrl).origin).call(_context2, 'https://')) {
|
|
122
|
-
spec.schemes = ['https'];
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
_context12.next = 13;
|
|
126
|
-
return _Promise.all(_mapInstanceProperty(_context3 = [specUrl, internalUrl]).call(_context3, function (url) {
|
|
127
|
-
if (!url) return null;
|
|
128
|
-
return SwaggerClient({
|
|
129
|
-
url: url,
|
|
130
|
-
spec: spec,
|
|
131
|
-
responseInterceptor: function responseInterceptor(response) {
|
|
132
|
-
if (!response.text) return response;
|
|
133
|
-
var body = jsonImp.parse(response.text);
|
|
134
|
-
return _Object$assign(response, {
|
|
135
|
-
body: disableCaseConversion ? body : pascalizeKeys(body)
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
}));
|
|
140
|
-
|
|
141
|
-
case 13:
|
|
142
|
-
_yield$Promise$all = _context12.sent;
|
|
143
|
-
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
144
|
-
external = _yield$Promise$all2[0];
|
|
145
|
-
internal = _yield$Promise$all2[1];
|
|
146
|
-
combinedApi = _reduceInstanceProperty(_context4 = _concatInstanceProperty(_context5 = []).call(_context5, _toConsumableArray(_Object$values(external.apis)), [mapObject((internal === null || internal === void 0 ? void 0 : internal.apis.internal) || {}, function (_ref3) {
|
|
147
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
148
|
-
key = _ref4[0],
|
|
149
|
-
handler = _ref4[1];
|
|
150
|
-
|
|
151
|
-
return [key, function () {
|
|
152
|
-
if (!warnedAboutInternalApiUsage) {
|
|
153
|
-
console.warn('SDK\'s wrapper of aeternity node internal API is deprecated, please use external ' + 'equivalent (for example, "sdk.api.protectedDryRunTxs" instead of "sdk.api.dryRunTxs") ' + 'or create a wrapper of internal API by yourself (using "genSwaggerClient")');
|
|
154
|
-
warnedAboutInternalApiUsage = true;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return handler.apply(void 0, arguments);
|
|
158
|
-
}];
|
|
159
|
-
})])).call(_context4, function (acc, n) {
|
|
160
|
-
return _objectSpread(_objectSpread({}, acc), n);
|
|
161
|
-
});
|
|
162
|
-
opSpecs = _reduceInstanceProperty(_context6 = _flatInstanceProperty(_context7 = _mapInstanceProperty(_context8 = _Object$values(spec.paths)).call(_context8, function (paths) {
|
|
163
|
-
return _Object$values(paths);
|
|
164
|
-
})).call(_context7)).call(_context6, function (acc, n) {
|
|
165
|
-
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, n.operationId, n));
|
|
166
|
-
}, {});
|
|
167
|
-
api = mapObject(combinedApi, function (_ref5) {
|
|
168
|
-
var _ref6 = _slicedToArray(_ref5, 2),
|
|
169
|
-
opId = _ref6[0],
|
|
170
|
-
handler = _ref6[1];
|
|
171
|
-
|
|
172
|
-
return [_sliceInstanceProperty(opId).call(opId, 0, 1).toLowerCase() + _sliceInstanceProperty(opId).call(opId, 1), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
173
|
-
var _context9, _context10;
|
|
174
|
-
|
|
175
|
-
var _len,
|
|
176
|
-
args,
|
|
177
|
-
_key,
|
|
178
|
-
opSpec,
|
|
179
|
-
parameters,
|
|
180
|
-
required,
|
|
181
|
-
values,
|
|
182
|
-
_mapObject,
|
|
183
|
-
__requestBody,
|
|
184
|
-
stringified,
|
|
185
|
-
_args = arguments;
|
|
186
|
-
|
|
187
|
-
return _regeneratorRuntime.wrap(function _callee$(_context11) {
|
|
188
|
-
while (1) {
|
|
189
|
-
switch (_context11.prev = _context11.next) {
|
|
190
|
-
case 0:
|
|
191
|
-
for (_len = _args.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
192
|
-
args[_key] = _args[_key];
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
opSpec = opSpecs[opId];
|
|
196
|
-
parameters = _concatInstanceProperty(_context9 = []).call(_context9, _toConsumableArray(opSpec.parameters), _toConsumableArray(opSpec.requestBody ? [{
|
|
197
|
-
required: opSpec.requestBody.required,
|
|
198
|
-
schema: _Object$values(opSpec.requestBody.content)[0].schema,
|
|
199
|
-
name: '__requestBody'
|
|
200
|
-
}] : []));
|
|
201
|
-
required = _mapInstanceProperty(_context10 = _filterInstanceProperty(parameters).call(parameters, function (param) {
|
|
202
|
-
return param.required;
|
|
203
|
-
})).call(_context10, function (p) {
|
|
204
|
-
return p.name;
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
if (!(args.length < required.length)) {
|
|
208
|
-
_context11.next = 6;
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
throw new Error('swagger: Not enough arguments');
|
|
213
|
-
|
|
214
|
-
case 6:
|
|
215
|
-
values = _reduceInstanceProperty(required).call(required, function (acc, req, idx) {
|
|
216
|
-
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, req, args[idx]));
|
|
217
|
-
}, args[required.length] || {});
|
|
218
|
-
_mapObject = mapObject(values, function (_ref8) {
|
|
219
|
-
var _ref9 = _slicedToArray(_ref8, 2),
|
|
220
|
-
param = _ref9[0],
|
|
221
|
-
value = _ref9[1];
|
|
222
|
-
|
|
223
|
-
if (_typeof(value) !== 'object') return [param, value];
|
|
224
|
-
|
|
225
|
-
var rootKeys = _Object$keys(_findInstanceProperty(parameters).call(parameters, function (p) {
|
|
226
|
-
return p.name === param;
|
|
227
|
-
}).schema.properties);
|
|
228
|
-
|
|
229
|
-
var filteredValue = filterObject(disableCaseConversion ? value : snakizeKeys(value), function (_ref10) {
|
|
230
|
-
var _ref11 = _slicedToArray(_ref10, 1),
|
|
231
|
-
key = _ref11[0];
|
|
232
|
-
|
|
233
|
-
return _includesInstanceProperty(rootKeys).call(rootKeys, key);
|
|
234
|
-
});
|
|
235
|
-
return [param, jsonImp.stringify(filteredValue)];
|
|
236
|
-
}), __requestBody = _mapObject.__requestBody, stringified = _objectWithoutProperties(_mapObject, _excluded);
|
|
237
|
-
_context11.next = 10;
|
|
238
|
-
return handler(stringified, {
|
|
239
|
-
requestBody: __requestBody
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
case 10:
|
|
243
|
-
return _context11.abrupt("return", _context11.sent.body);
|
|
244
|
-
|
|
245
|
-
case 11:
|
|
246
|
-
case "end":
|
|
247
|
-
return _context11.stop();
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}, _callee);
|
|
251
|
-
}))];
|
|
252
|
-
});
|
|
253
|
-
return _context12.abrupt("return", _Object$assign(external, {
|
|
254
|
-
api: api
|
|
255
|
-
}));
|
|
256
|
-
|
|
257
|
-
case 21:
|
|
258
|
-
case "end":
|
|
259
|
-
return _context12.stop();
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}, _callee2);
|
|
263
|
-
}));
|
|
264
|
-
|
|
265
|
-
return function (_x) {
|
|
266
|
-
return _ref.apply(this, arguments);
|
|
267
|
-
};
|
|
268
|
-
})();
|
|
269
|
-
//# sourceMappingURL=swagger.js.map
|