@gardenfi/swap 0.1.2 → 0.1.3-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index113.cjs +1 -1
- package/dist/index113.js +1 -1
- package/dist/index116.cjs +1 -1
- package/dist/index116.js +1 -1
- package/dist/index117.cjs +1 -1
- package/dist/index117.js +1 -1
- package/dist/index12.cjs +1 -1
- package/dist/index12.js +1 -1
- package/dist/index120.cjs +1 -1
- package/dist/index120.js +2 -2
- package/dist/index121.cjs +1 -1
- package/dist/index121.js +7 -7
- package/dist/index126.cjs +1 -1
- package/dist/index126.js +2 -2
- package/dist/index127.cjs +1 -1
- package/dist/index127.js +1 -1
- package/dist/index128.cjs +1 -1
- package/dist/index128.js +1 -1
- package/dist/index129.cjs +1 -1
- package/dist/index129.js +1 -1
- package/dist/index130.cjs +1 -1
- package/dist/index130.js +2 -2
- package/dist/index138.cjs +1 -1
- package/dist/index138.js +1 -1
- package/dist/index140.cjs +1 -1
- package/dist/index140.js +1 -1
- package/dist/index148.cjs +1 -1
- package/dist/index148.js +1 -1
- package/dist/index149.cjs +1 -1
- package/dist/index149.js +1 -1
- package/dist/index154.cjs +1 -1
- package/dist/index154.js +1 -1
- package/dist/index162.cjs +1 -1
- package/dist/index162.js +2 -2
- package/dist/index173.cjs +1 -1
- package/dist/index173.js +2 -2
- package/dist/index303.cjs +1 -1
- package/dist/index303.js +10 -43
- package/dist/index304.cjs +1 -1
- package/dist/index304.js +16 -320
- package/dist/index305.cjs +1 -1
- package/dist/index305.js +21 -604
- package/dist/index306.cjs +1 -1
- package/dist/index306.js +14 -110
- package/dist/index307.cjs +1 -1
- package/dist/index307.js +13 -167
- package/dist/index308.cjs +1 -1
- package/dist/index308.js +13 -300
- package/dist/index309.cjs +1 -1
- package/dist/index309.js +9 -93
- package/dist/index310.cjs +1 -1
- package/dist/index310.js +13 -54
- package/dist/index311.cjs +1 -1
- package/dist/index311.js +23 -51
- package/dist/index312.cjs +1 -1
- package/dist/index312.js +30 -43
- package/dist/index313.cjs +2 -1
- package/dist/index313.js +18 -15
- package/dist/index314.cjs +1 -1
- package/dist/index314.js +14 -317
- package/dist/index315.cjs +1 -1
- package/dist/index315.js +41 -58
- package/dist/index316.cjs +1 -1
- package/dist/index316.js +319 -18
- package/dist/index317.cjs +1 -1
- package/dist/index317.js +602 -26
- package/dist/index318.cjs +1 -1
- package/dist/index318.js +110 -4
- package/dist/index319.cjs +1 -7
- package/dist/index319.js +166 -236
- package/dist/index320.cjs +1 -1
- package/dist/index320.js +302 -48
- package/dist/index321.cjs +1 -1
- package/dist/index321.js +92 -211
- package/dist/index322.cjs +1 -1
- package/dist/index322.js +49 -74
- package/dist/index323.cjs +1 -1
- package/dist/index323.js +51 -27
- package/dist/index324.cjs +1 -1
- package/dist/index324.js +42 -74
- package/dist/index325.cjs +1 -1
- package/dist/index325.js +15 -9
- package/dist/index326.cjs +1 -1
- package/dist/index326.js +317 -16
- package/dist/index327.cjs +1 -1
- package/dist/index327.js +57 -20
- package/dist/index328.cjs +1 -1
- package/dist/index328.js +18 -12
- package/dist/index329.cjs +1 -1
- package/dist/index329.js +29 -13
- package/dist/index330.cjs +1 -1
- package/dist/index330.js +3 -14
- package/dist/index331.cjs +7 -1
- package/dist/index331.js +237 -9
- package/dist/index332.cjs +1 -1
- package/dist/index332.js +48 -16
- package/dist/index333.cjs +1 -1
- package/dist/index333.js +209 -22
- package/dist/index334.cjs +1 -1
- package/dist/index334.js +80 -30
- package/dist/index335.cjs +1 -2
- package/dist/index335.js +29 -18
- package/dist/index336.cjs +1 -1
- package/dist/index336.js +75 -13
- package/dist/index361.cjs +1 -1
- package/dist/index361.js +3 -94
- package/dist/index362.cjs +1 -1
- package/dist/index362.js +137 -25
- package/dist/index363.cjs +1 -1
- package/dist/index363.js +129 -144
- package/dist/index364.cjs +1 -1
- package/dist/index364.js +71 -331
- package/dist/index365.cjs +1 -1
- package/dist/index365.js +27 -72
- package/dist/index366.cjs +1 -1
- package/dist/index366.js +148 -31
- package/dist/index367.cjs +1 -1
- package/dist/index367.js +354 -5
- package/dist/index368.cjs +1 -1
- package/dist/index368.js +275 -3
- package/dist/index369.cjs +1 -1
- package/dist/index369.js +170 -140
- package/dist/index370.cjs +1 -1
- package/dist/index370.js +10 -276
- package/dist/index371.cjs +1 -1
- package/dist/index371.js +107 -170
- package/dist/index372.cjs +1 -1
- package/dist/index372.js +6 -10
- package/dist/index373.cjs +1 -1
- package/dist/index373.js +70 -104
- package/dist/index374.cjs +1 -1
- package/dist/index374.js +2 -2
- package/dist/index375.cjs +1 -1
- package/dist/index375.js +29 -131
- package/dist/index383.cjs +1 -1
- package/dist/index383.js +59 -106
- package/dist/index384.cjs +1 -1
- package/dist/index384.js +110 -3
- package/dist/index385.cjs +1 -1
- package/dist/index385.js +3 -63
- package/dist/index6.cjs +1 -1
- package/dist/index6.js +42 -42
- package/dist/index77.cjs +1 -1
- package/dist/index77.js +13 -13
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +16 -14
- package/dist/src/lib/store/swapStore.d.ts +1 -1
- package/package.json +5 -5
package/dist/index373.js
CHANGED
|
@@ -1,110 +1,76 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { normalizeSuiAddress as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
import { splitGenericParameters as s } from "./index329.js";
|
|
2
|
+
import { normalizeSuiAddress as i } from "./index117.js";
|
|
3
|
+
const o = /^vector<(.+)>$/, l = /^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;
|
|
4
|
+
class t {
|
|
5
|
+
static parseFromStr(r, e = !1) {
|
|
6
|
+
if (r === "address")
|
|
7
|
+
return { address: null };
|
|
8
|
+
if (r === "bool")
|
|
9
|
+
return { bool: null };
|
|
10
|
+
if (r === "u8")
|
|
11
|
+
return { u8: null };
|
|
12
|
+
if (r === "u16")
|
|
13
|
+
return { u16: null };
|
|
14
|
+
if (r === "u32")
|
|
15
|
+
return { u32: null };
|
|
16
|
+
if (r === "u64")
|
|
17
|
+
return { u64: null };
|
|
18
|
+
if (r === "u128")
|
|
19
|
+
return { u128: null };
|
|
20
|
+
if (r === "u256")
|
|
21
|
+
return { u256: null };
|
|
22
|
+
if (r === "signer")
|
|
23
|
+
return { signer: null };
|
|
24
|
+
const n = r.match(o);
|
|
25
|
+
if (n)
|
|
26
|
+
return {
|
|
27
|
+
vector: t.parseFromStr(n[1], e)
|
|
28
|
+
};
|
|
29
|
+
const u = r.match(l);
|
|
30
|
+
if (u)
|
|
31
|
+
return {
|
|
32
|
+
struct: {
|
|
33
|
+
address: e ? i(u[1]) : u[1],
|
|
34
|
+
module: u[2],
|
|
35
|
+
name: u[3],
|
|
36
|
+
typeParams: u[5] === void 0 ? [] : t.parseStructTypeArgs(u[5], e)
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
throw new Error(`Encountered unexpected token when parsing type args for ${r}`);
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return r.String;
|
|
45
|
-
if (e.datatype.module === _ && e.datatype.type === l)
|
|
46
|
-
return r.String;
|
|
47
|
-
if (e.datatype.module === U && e.datatype.type === m) {
|
|
48
|
-
const o = u(e.datatype.typeParameters[0]);
|
|
49
|
-
return o ? r.vector(o) : null;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (t === n(a) && e.datatype.module === d && e.datatype.type === i)
|
|
53
|
-
return r.Address;
|
|
41
|
+
static parseStructTypeArgs(r, e = !1) {
|
|
42
|
+
return s(r).map(
|
|
43
|
+
(n) => t.parseFromStr(n, e)
|
|
44
|
+
);
|
|
54
45
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return "u16";
|
|
80
|
-
case "U32":
|
|
81
|
-
return "u32";
|
|
82
|
-
case "U64":
|
|
83
|
-
return "u64";
|
|
84
|
-
case "U128":
|
|
85
|
-
return "u128";
|
|
86
|
-
case "U256":
|
|
87
|
-
return "u256";
|
|
88
|
-
default:
|
|
89
|
-
throw new Error(`Unexpected type ${e}`);
|
|
46
|
+
static tagToString(r) {
|
|
47
|
+
if ("bool" in r)
|
|
48
|
+
return "bool";
|
|
49
|
+
if ("u8" in r)
|
|
50
|
+
return "u8";
|
|
51
|
+
if ("u16" in r)
|
|
52
|
+
return "u16";
|
|
53
|
+
if ("u32" in r)
|
|
54
|
+
return "u32";
|
|
55
|
+
if ("u64" in r)
|
|
56
|
+
return "u64";
|
|
57
|
+
if ("u128" in r)
|
|
58
|
+
return "u128";
|
|
59
|
+
if ("u256" in r)
|
|
60
|
+
return "u256";
|
|
61
|
+
if ("address" in r)
|
|
62
|
+
return "address";
|
|
63
|
+
if ("signer" in r)
|
|
64
|
+
return "signer";
|
|
65
|
+
if ("vector" in r)
|
|
66
|
+
return `vector<${t.tagToString(r.vector)}>`;
|
|
67
|
+
if ("struct" in r) {
|
|
68
|
+
const e = r.struct, n = e.typeParams.map(t.tagToString).join(", ");
|
|
69
|
+
return `${e.address}::${e.module}::${e.name}${n ? `<${n}>` : ""}`;
|
|
90
70
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if ("Struct" in e)
|
|
94
|
-
return {
|
|
95
|
-
datatype: {
|
|
96
|
-
package: e.Struct.address,
|
|
97
|
-
module: e.Struct.module,
|
|
98
|
-
type: e.Struct.name,
|
|
99
|
-
typeParameters: e.Struct.typeArguments.map(c)
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
if ("TypeParameter" in e)
|
|
103
|
-
return { typeParameter: e.TypeParameter };
|
|
104
|
-
throw new Error(`Unexpected type ${JSON.stringify(e)}`);
|
|
71
|
+
throw new Error("Invalid TypeTag");
|
|
72
|
+
}
|
|
105
73
|
}
|
|
106
74
|
export {
|
|
107
|
-
|
|
108
|
-
M as isTxContext,
|
|
109
|
-
D as normalizedTypeToMoveTypeSignature
|
|
75
|
+
t as TypeTagSerializer
|
|
110
76
|
};
|
package/dist/index374.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index115.cjs"),o=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index115.cjs"),o=require("./index385.cjs"),t=require("./index332.cjs");function u(i,r,s){const a=t.bcs.Address.serialize(i).toBytes(),n=t.bcs.TypeTag.serialize(r).toBytes(),d=t.bcs.u64().serialize(s.length).toBytes(),e=o.blake2b.create({dkLen:32});return e.update(new Uint8Array([240])),e.update(a),e.update(d),e.update(s),e.update(n),`0x${c.toHex(e.digest().slice(0,32))}`}exports.deriveDynamicFieldID=u;
|
package/dist/index374.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toHex as n } from "./index115.js";
|
|
2
|
-
import { blake2b as c } from "./
|
|
3
|
-
import { bcs as t } from "./
|
|
2
|
+
import { blake2b as c } from "./index385.js";
|
|
3
|
+
import { bcs as t } from "./index332.js";
|
|
4
4
|
function m(r, a, s) {
|
|
5
5
|
const i = t.Address.serialize(r).toBytes(), o = t.TypeTag.serialize(a).toBytes(), d = t.u64().serialize(s.length).toBytes(), e = c.create({
|
|
6
6
|
dkLen: 32
|
package/dist/index375.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index367.cjs"),n=require("./index368.cjs");function c(r){switch(r){case"u8":return e.bcs.u8();case"u16":return e.bcs.u16();case"u32":return e.bcs.u32();case"u64":return e.bcs.u64();case"u128":return e.bcs.u128();case"u256":return e.bcs.u256();case"bool":return e.bcs.bool();case"string":return e.bcs.string();case"id":case"address":return n.Address}const s=r.match(/^(vector|option)<(.+)>$/);if(s){const[u,t]=s.slice(1);return u==="vector"?e.bcs.vector(c(t)):e.bcs.option(c(t))}throw new Error(`Invalid Pure type name: ${r}`)}exports.pureBcsSchemaFromTypeName=c;
|
package/dist/index375.js
CHANGED
|
@@ -1,136 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
for (const e of s) {
|
|
25
|
-
if (!("inputs" in e))
|
|
26
|
-
continue;
|
|
27
|
-
if (!n || n.length === 0) {
|
|
28
|
-
if (!e.inputs || e.inputs.length === 0)
|
|
29
|
-
return {
|
|
30
|
-
...e,
|
|
31
|
-
...u ? { hash: f(e) } : {}
|
|
32
|
-
};
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
if (!e.inputs || e.inputs.length === 0 || e.inputs.length !== n.length)
|
|
36
|
-
continue;
|
|
37
|
-
if (n.every((a, I) => {
|
|
38
|
-
const l = "inputs" in e && e.inputs[I];
|
|
39
|
-
return l ? E(a, l) : !1;
|
|
40
|
-
})) {
|
|
41
|
-
if (o && "inputs" in o && o.inputs) {
|
|
42
|
-
const a = B(e.inputs, o.inputs, n);
|
|
43
|
-
if (a)
|
|
44
|
-
throw new O({
|
|
45
|
-
abiItem: e,
|
|
46
|
-
type: a[0]
|
|
47
|
-
}, {
|
|
48
|
-
abiItem: o,
|
|
49
|
-
type: a[1]
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
o = e;
|
|
53
|
-
}
|
|
1
|
+
import { bcs as r } from "./index367.js";
|
|
2
|
+
import { Address as s } from "./index368.js";
|
|
3
|
+
function n(e) {
|
|
4
|
+
switch (e) {
|
|
5
|
+
case "u8":
|
|
6
|
+
return r.u8();
|
|
7
|
+
case "u16":
|
|
8
|
+
return r.u16();
|
|
9
|
+
case "u32":
|
|
10
|
+
return r.u32();
|
|
11
|
+
case "u64":
|
|
12
|
+
return r.u64();
|
|
13
|
+
case "u128":
|
|
14
|
+
return r.u128();
|
|
15
|
+
case "u256":
|
|
16
|
+
return r.u256();
|
|
17
|
+
case "bool":
|
|
18
|
+
return r.bool();
|
|
19
|
+
case "string":
|
|
20
|
+
return r.string();
|
|
21
|
+
case "id":
|
|
22
|
+
case "address":
|
|
23
|
+
return s;
|
|
54
24
|
}
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return { ...e, overloads: g };
|
|
60
|
-
})();
|
|
61
|
-
if (!c)
|
|
62
|
-
throw new b({ name: t });
|
|
63
|
-
return {
|
|
64
|
-
...c,
|
|
65
|
-
...u ? { hash: f(c) } : {}
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
function T(...r) {
|
|
69
|
-
const t = (() => {
|
|
70
|
-
if (Array.isArray(r[0])) {
|
|
71
|
-
const [i, n] = r;
|
|
72
|
-
return h(i, n);
|
|
73
|
-
}
|
|
74
|
-
return r[0];
|
|
75
|
-
})();
|
|
76
|
-
return A(f(t), 0, 4);
|
|
77
|
-
}
|
|
78
|
-
function F(...r) {
|
|
79
|
-
const t = (() => {
|
|
80
|
-
if (Array.isArray(r[0])) {
|
|
81
|
-
const [n, u] = r;
|
|
82
|
-
return h(n, u);
|
|
83
|
-
}
|
|
84
|
-
return r[0];
|
|
85
|
-
})(), i = typeof t == "string" ? t : p(t);
|
|
86
|
-
return m(i);
|
|
87
|
-
}
|
|
88
|
-
function f(...r) {
|
|
89
|
-
const t = (() => {
|
|
90
|
-
if (Array.isArray(r[0])) {
|
|
91
|
-
const [i, n] = r;
|
|
92
|
-
return h(i, n);
|
|
93
|
-
}
|
|
94
|
-
return r[0];
|
|
95
|
-
})();
|
|
96
|
-
return typeof t != "string" && "hash" in t && t.hash ? t.hash : v(S(F(t)));
|
|
97
|
-
}
|
|
98
|
-
class O extends d {
|
|
99
|
-
constructor(t, i) {
|
|
100
|
-
super("Found ambiguous types in overloaded ABI Items.", {
|
|
101
|
-
metaMessages: [
|
|
102
|
-
// TODO: abitype to add support for signature-formatted ABI items.
|
|
103
|
-
`\`${t.type}\` in \`${m(p(t.abiItem))}\`, and`,
|
|
104
|
-
`\`${i.type}\` in \`${m(p(i.abiItem))}\``,
|
|
105
|
-
"",
|
|
106
|
-
"These types encode differently and cannot be distinguished at runtime.",
|
|
107
|
-
"Remove one of the ambiguous items in the ABI."
|
|
108
|
-
]
|
|
109
|
-
}), Object.defineProperty(this, "name", {
|
|
110
|
-
enumerable: !0,
|
|
111
|
-
configurable: !0,
|
|
112
|
-
writable: !0,
|
|
113
|
-
value: "AbiItem.AmbiguityError"
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
class b extends d {
|
|
118
|
-
constructor({ name: t, data: i, type: n = "item" }) {
|
|
119
|
-
const u = t ? ` with name "${t}"` : i ? ` with data "${i}"` : "";
|
|
120
|
-
super(`ABI ${n}${u} not found.`), Object.defineProperty(this, "name", {
|
|
121
|
-
enumerable: !0,
|
|
122
|
-
configurable: !0,
|
|
123
|
-
writable: !0,
|
|
124
|
-
value: "AbiItem.NotFoundError"
|
|
125
|
-
});
|
|
25
|
+
const t = e.match(/^(vector|option)<(.+)>$/);
|
|
26
|
+
if (t) {
|
|
27
|
+
const [c, u] = t.slice(1);
|
|
28
|
+
return c === "vector" ? r.vector(n(u)) : r.option(n(u));
|
|
126
29
|
}
|
|
30
|
+
throw new Error(`Invalid Pure type name: ${e}`);
|
|
127
31
|
}
|
|
128
32
|
export {
|
|
129
|
-
|
|
130
|
-
b as NotFoundError,
|
|
131
|
-
H as from,
|
|
132
|
-
h as fromAbi,
|
|
133
|
-
T as getSelector,
|
|
134
|
-
F as getSignature,
|
|
135
|
-
f as getSignatureHash
|
|
33
|
+
n as pureBcsSchemaFromTypeName
|
|
136
34
|
};
|
package/dist/index383.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index351.cjs"),a=require("./index278.cjs");function d(r){let i=!0,t="",e=0,n="",o=!1;for(let s=0;s<r.length;s++){const u=r[s];if(["(",")",","].includes(u)&&(i=!0),u==="("&&e++,u===")"&&e--,!!i){if(e===0){if(u===" "&&["event","function","error",""].includes(n))n="";else if(n+=u,u===")"){o=!0;break}continue}if(u===" "){r[s-1]!==","&&t!==","&&t!==",("&&(t="",i=!1);continue}n+=u,t+=u}}if(!o)throw new a.BaseError("Unable to normalize signature.");return n}function l(r,i){const t=typeof r,e=i.type;switch(e){case"address":return c.validate(r,{strict:!1});case"bool":return t==="boolean";case"function":return t==="string";case"string":return t==="string";default:return e==="tuple"&&"components"in i?Object.values(i.components).every((n,o)=>l(Object.values(r)[o],n)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(e)?t==="number"||t==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(e)?t==="string"||r instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(e)?Array.isArray(r)&&r.every(n=>l(n,{...i,type:e.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function f(r,i,t){for(const e in r){const n=r[e],o=i[e];if(n.type==="tuple"&&o.type==="tuple"&&"components"in n&&"components"in o)return f(n.components,o.components,t[e]);const s=[n.type,o.type];if(s.includes("address")&&s.includes("bytes20")?!0:s.includes("address")&&s.includes("string")?c.validate(t[e],{strict:!1}):s.includes("address")&&s.includes("bytes")?c.validate(t[e],{strict:!1}):!1)return s}}exports.getAmbiguousTypes=f;exports.isArgOfType=l;exports.normalizeSignature=d;
|
package/dist/index383.js
CHANGED
|
@@ -1,112 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (!g(!0, r))
|
|
23
|
-
throw new Error(`${e}: array of strings expected`);
|
|
24
|
-
}
|
|
25
|
-
function E(e, r) {
|
|
26
|
-
if (!g(!1, r))
|
|
27
|
-
throw new Error(`${e}: array of numbers expected`);
|
|
28
|
-
}
|
|
29
|
-
// @__NO_SIDE_EFFECTS__
|
|
30
|
-
function m(...e) {
|
|
31
|
-
const r = (n) => n, t = (n, a) => (o) => n(a(o)), c = e.map((n) => n.encode).reduceRight(t, r), i = e.map((n) => n.decode).reduce(t, r);
|
|
32
|
-
return { encode: c, decode: i };
|
|
33
|
-
}
|
|
34
|
-
// @__NO_SIDE_EFFECTS__
|
|
35
|
-
function $(e) {
|
|
36
|
-
const r = typeof e == "string" ? e.split("") : e, t = r.length;
|
|
37
|
-
A("alphabet", r);
|
|
38
|
-
const c = new Map(r.map((i, n) => [i, n]));
|
|
39
|
-
return {
|
|
40
|
-
encode: (i) => (h(i), i.map((n) => {
|
|
41
|
-
if (!Number.isSafeInteger(n) || n < 0 || n >= t)
|
|
42
|
-
throw new Error(`alphabet.encode: digit index outside alphabet "${n}". Allowed: ${e}`);
|
|
43
|
-
return r[n];
|
|
44
|
-
})),
|
|
45
|
-
decode: (i) => (h(i), i.map((n) => {
|
|
46
|
-
w("alphabet.decode", n);
|
|
47
|
-
const a = c.get(n);
|
|
48
|
-
if (a === void 0)
|
|
49
|
-
throw new Error(`Unknown letter: "${n}". Allowed: ${e}`);
|
|
50
|
-
return a;
|
|
51
|
-
}))
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
// @__NO_SIDE_EFFECTS__
|
|
55
|
-
function R(e = "") {
|
|
56
|
-
return w("join", e), {
|
|
57
|
-
encode: (r) => (A("join.decode", r), r.join(e)),
|
|
58
|
-
decode: (r) => (w("join.decode", r), r.split(e))
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function p(e, r, t) {
|
|
62
|
-
if (r < 2)
|
|
63
|
-
throw new Error(`convertRadix: invalid from=${r}, base cannot be less than 2`);
|
|
64
|
-
if (t < 2)
|
|
65
|
-
throw new Error(`convertRadix: invalid to=${t}, base cannot be less than 2`);
|
|
66
|
-
if (h(e), !e.length)
|
|
67
|
-
return [];
|
|
68
|
-
let c = 0;
|
|
69
|
-
const i = [], n = Array.from(e, (o) => {
|
|
70
|
-
if (b(o), o < 0 || o >= r)
|
|
71
|
-
throw new Error(`invalid integer: ${o}`);
|
|
72
|
-
return o;
|
|
73
|
-
}), a = n.length;
|
|
74
|
-
for (; ; ) {
|
|
75
|
-
let o = 0, d = !0;
|
|
76
|
-
for (let s = c; s < a; s++) {
|
|
77
|
-
const y = n[s], l = r * o, f = l + y;
|
|
78
|
-
if (!Number.isSafeInteger(f) || l / r !== o || f - y !== l)
|
|
79
|
-
throw new Error("convertRadix: carry overflow");
|
|
80
|
-
const v = f / t;
|
|
81
|
-
o = f % t;
|
|
82
|
-
const u = Math.floor(v);
|
|
83
|
-
if (n[s] = u, !Number.isSafeInteger(u) || u * t + o !== f)
|
|
84
|
-
throw new Error("convertRadix: carry overflow");
|
|
85
|
-
if (d)
|
|
86
|
-
u ? d = !1 : c = s;
|
|
87
|
-
else continue;
|
|
1
|
+
import { validate as c } from "./index351.js";
|
|
2
|
+
import { BaseError as f } from "./index278.js";
|
|
3
|
+
function y(r) {
|
|
4
|
+
let i = !0, t = "", e = 0, n = "", o = !1;
|
|
5
|
+
for (let s = 0; s < r.length; s++) {
|
|
6
|
+
const u = r[s];
|
|
7
|
+
if (["(", ")", ","].includes(u) && (i = !0), u === "(" && e++, u === ")" && e--, !!i) {
|
|
8
|
+
if (e === 0) {
|
|
9
|
+
if (u === " " && ["event", "function", "error", ""].includes(n))
|
|
10
|
+
n = "";
|
|
11
|
+
else if (n += u, u === ")") {
|
|
12
|
+
o = !0;
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (u === " ") {
|
|
18
|
+
r[s - 1] !== "," && t !== "," && t !== ",(" && (t = "", i = !1);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
n += u, t += u;
|
|
88
22
|
}
|
|
89
|
-
if (i.push(o), d)
|
|
90
|
-
break;
|
|
91
23
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return
|
|
24
|
+
if (!o)
|
|
25
|
+
throw new f("Unable to normalize signature.");
|
|
26
|
+
return n;
|
|
95
27
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
28
|
+
function l(r, i) {
|
|
29
|
+
const t = typeof r, e = i.type;
|
|
30
|
+
switch (e) {
|
|
31
|
+
case "address":
|
|
32
|
+
return c(r, { strict: !1 });
|
|
33
|
+
case "bool":
|
|
34
|
+
return t === "boolean";
|
|
35
|
+
case "function":
|
|
36
|
+
return t === "string";
|
|
37
|
+
case "string":
|
|
38
|
+
return t === "string";
|
|
39
|
+
default:
|
|
40
|
+
return e === "tuple" && "components" in i ? Object.values(i.components).every((n, o) => l(Object.values(r)[o], n)) : /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(e) ? t === "number" || t === "bigint" : /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(e) ? t === "string" || r instanceof Uint8Array : /[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(e) ? Array.isArray(r) && r.every((n) => l(n, {
|
|
41
|
+
...i,
|
|
42
|
+
// Pop off `[]` or `[M]` from end of type
|
|
43
|
+
type: e.replace(/(\[[0-9]{0,}\])$/, "")
|
|
44
|
+
})) : !1;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function a(r, i, t) {
|
|
48
|
+
for (const e in r) {
|
|
49
|
+
const n = r[e], o = i[e];
|
|
50
|
+
if (n.type === "tuple" && o.type === "tuple" && "components" in n && "components" in o)
|
|
51
|
+
return a(n.components, o.components, t[e]);
|
|
52
|
+
const s = [n.type, o.type];
|
|
53
|
+
if (s.includes("address") && s.includes("bytes20") ? !0 : s.includes("address") && s.includes("string") ? c(t[e], {
|
|
54
|
+
strict: !1
|
|
55
|
+
}) : s.includes("address") && s.includes("bytes") ? c(t[e], {
|
|
56
|
+
strict: !1
|
|
57
|
+
}) : !1)
|
|
58
|
+
return s;
|
|
59
|
+
}
|
|
108
60
|
}
|
|
109
|
-
const N = /* @__NO_SIDE_EFFECTS__ */ (e) => /* @__PURE__ */ m(/* @__PURE__ */ j(58), /* @__PURE__ */ $(e), /* @__PURE__ */ R("")), S = /* @__PURE__ */ N("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
110
61
|
export {
|
|
111
|
-
|
|
62
|
+
a as getAmbiguousTypes,
|
|
63
|
+
l as isArgOfType,
|
|
64
|
+
y as normalizeSignature
|
|
112
65
|
};
|
package/dist/index384.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function x(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function p(e,r){return Array.isArray(r)?r.length===0?!0:e?r.every(t=>typeof t=="string"):r.every(t=>Number.isSafeInteger(t)):!1}function w(e,r){if(typeof r!="string")throw new Error(`${e}: string expected`);return!0}function b(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function h(e){if(!Array.isArray(e))throw new Error("array expected")}function A(e,r){if(!p(!0,r))throw new Error(`${e}: array of strings expected`)}function m(e,r){if(!p(!1,r))throw new Error(`${e}: array of numbers expected`)}function E(...e){const r=n=>n,t=(n,a)=>o=>n(a(o)),c=e.map(n=>n.encode).reduceRight(t,r),i=e.map(n=>n.decode).reduce(t,r);return{encode:c,decode:i}}function $(e){const r=typeof e=="string"?e.split(""):e,t=r.length;A("alphabet",r);const c=new Map(r.map((i,n)=>[i,n]));return{encode:i=>(h(i),i.map(n=>{if(!Number.isSafeInteger(n)||n<0||n>=t)throw new Error(`alphabet.encode: digit index outside alphabet "${n}". Allowed: ${e}`);return r[n]})),decode:i=>(h(i),i.map(n=>{w("alphabet.decode",n);const a=c.get(n);if(a===void 0)throw new Error(`Unknown letter: "${n}". Allowed: ${e}`);return a}))}}function S(e=""){return w("join",e),{encode:r=>(A("join.decode",r),r.join(e)),decode:r=>(w("join.decode",r),r.split(e))}}function g(e,r,t){if(r<2)throw new Error(`convertRadix: invalid from=${r}, base cannot be less than 2`);if(t<2)throw new Error(`convertRadix: invalid to=${t}, base cannot be less than 2`);if(h(e),!e.length)return[];let c=0;const i=[],n=Array.from(e,o=>{if(b(o),o<0||o>=r)throw new Error(`invalid integer: ${o}`);return o}),a=n.length;for(;;){let o=0,d=!0;for(let s=c;s<a;s++){const y=n[s],l=r*o,u=l+y;if(!Number.isSafeInteger(u)||l/r!==o||u-y!==l)throw new Error("convertRadix: carry overflow");const v=u/t;o=u%t;const f=Math.floor(v);if(n[s]=f,!Number.isSafeInteger(f)||f*t+o!==u)throw new Error("convertRadix: carry overflow");if(d)f?d=!1:c=s;else continue}if(i.push(o),d)break}for(let o=0;o<e.length-1&&e[o]===0;o++)i.push(0);return i.reverse()}function j(e){b(e);const r=2**8;return{encode:t=>{if(!x(t))throw new Error("radix.encode input should be Uint8Array");return g(Array.from(t),r,e)},decode:t=>(m("radix.decode",t),Uint8Array.from(g(t,e,r)))}}const R=e=>E(j(58),$(e),S("")),N=R("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");exports.base58=N;
|