@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.
Files changed (148) hide show
  1. package/dist/index113.cjs +1 -1
  2. package/dist/index113.js +1 -1
  3. package/dist/index116.cjs +1 -1
  4. package/dist/index116.js +1 -1
  5. package/dist/index117.cjs +1 -1
  6. package/dist/index117.js +1 -1
  7. package/dist/index12.cjs +1 -1
  8. package/dist/index12.js +1 -1
  9. package/dist/index120.cjs +1 -1
  10. package/dist/index120.js +2 -2
  11. package/dist/index121.cjs +1 -1
  12. package/dist/index121.js +7 -7
  13. package/dist/index126.cjs +1 -1
  14. package/dist/index126.js +2 -2
  15. package/dist/index127.cjs +1 -1
  16. package/dist/index127.js +1 -1
  17. package/dist/index128.cjs +1 -1
  18. package/dist/index128.js +1 -1
  19. package/dist/index129.cjs +1 -1
  20. package/dist/index129.js +1 -1
  21. package/dist/index130.cjs +1 -1
  22. package/dist/index130.js +2 -2
  23. package/dist/index138.cjs +1 -1
  24. package/dist/index138.js +1 -1
  25. package/dist/index140.cjs +1 -1
  26. package/dist/index140.js +1 -1
  27. package/dist/index148.cjs +1 -1
  28. package/dist/index148.js +1 -1
  29. package/dist/index149.cjs +1 -1
  30. package/dist/index149.js +1 -1
  31. package/dist/index154.cjs +1 -1
  32. package/dist/index154.js +1 -1
  33. package/dist/index162.cjs +1 -1
  34. package/dist/index162.js +2 -2
  35. package/dist/index173.cjs +1 -1
  36. package/dist/index173.js +2 -2
  37. package/dist/index303.cjs +1 -1
  38. package/dist/index303.js +10 -43
  39. package/dist/index304.cjs +1 -1
  40. package/dist/index304.js +16 -320
  41. package/dist/index305.cjs +1 -1
  42. package/dist/index305.js +21 -604
  43. package/dist/index306.cjs +1 -1
  44. package/dist/index306.js +14 -110
  45. package/dist/index307.cjs +1 -1
  46. package/dist/index307.js +13 -167
  47. package/dist/index308.cjs +1 -1
  48. package/dist/index308.js +13 -300
  49. package/dist/index309.cjs +1 -1
  50. package/dist/index309.js +9 -93
  51. package/dist/index310.cjs +1 -1
  52. package/dist/index310.js +13 -54
  53. package/dist/index311.cjs +1 -1
  54. package/dist/index311.js +23 -51
  55. package/dist/index312.cjs +1 -1
  56. package/dist/index312.js +30 -43
  57. package/dist/index313.cjs +2 -1
  58. package/dist/index313.js +18 -15
  59. package/dist/index314.cjs +1 -1
  60. package/dist/index314.js +14 -317
  61. package/dist/index315.cjs +1 -1
  62. package/dist/index315.js +41 -58
  63. package/dist/index316.cjs +1 -1
  64. package/dist/index316.js +319 -18
  65. package/dist/index317.cjs +1 -1
  66. package/dist/index317.js +602 -26
  67. package/dist/index318.cjs +1 -1
  68. package/dist/index318.js +110 -4
  69. package/dist/index319.cjs +1 -7
  70. package/dist/index319.js +166 -236
  71. package/dist/index320.cjs +1 -1
  72. package/dist/index320.js +302 -48
  73. package/dist/index321.cjs +1 -1
  74. package/dist/index321.js +92 -211
  75. package/dist/index322.cjs +1 -1
  76. package/dist/index322.js +49 -74
  77. package/dist/index323.cjs +1 -1
  78. package/dist/index323.js +51 -27
  79. package/dist/index324.cjs +1 -1
  80. package/dist/index324.js +42 -74
  81. package/dist/index325.cjs +1 -1
  82. package/dist/index325.js +15 -9
  83. package/dist/index326.cjs +1 -1
  84. package/dist/index326.js +317 -16
  85. package/dist/index327.cjs +1 -1
  86. package/dist/index327.js +57 -20
  87. package/dist/index328.cjs +1 -1
  88. package/dist/index328.js +18 -12
  89. package/dist/index329.cjs +1 -1
  90. package/dist/index329.js +29 -13
  91. package/dist/index330.cjs +1 -1
  92. package/dist/index330.js +3 -14
  93. package/dist/index331.cjs +7 -1
  94. package/dist/index331.js +237 -9
  95. package/dist/index332.cjs +1 -1
  96. package/dist/index332.js +48 -16
  97. package/dist/index333.cjs +1 -1
  98. package/dist/index333.js +209 -22
  99. package/dist/index334.cjs +1 -1
  100. package/dist/index334.js +80 -30
  101. package/dist/index335.cjs +1 -2
  102. package/dist/index335.js +29 -18
  103. package/dist/index336.cjs +1 -1
  104. package/dist/index336.js +75 -13
  105. package/dist/index361.cjs +1 -1
  106. package/dist/index361.js +3 -94
  107. package/dist/index362.cjs +1 -1
  108. package/dist/index362.js +137 -25
  109. package/dist/index363.cjs +1 -1
  110. package/dist/index363.js +129 -144
  111. package/dist/index364.cjs +1 -1
  112. package/dist/index364.js +71 -331
  113. package/dist/index365.cjs +1 -1
  114. package/dist/index365.js +27 -72
  115. package/dist/index366.cjs +1 -1
  116. package/dist/index366.js +148 -31
  117. package/dist/index367.cjs +1 -1
  118. package/dist/index367.js +354 -5
  119. package/dist/index368.cjs +1 -1
  120. package/dist/index368.js +275 -3
  121. package/dist/index369.cjs +1 -1
  122. package/dist/index369.js +170 -140
  123. package/dist/index370.cjs +1 -1
  124. package/dist/index370.js +10 -276
  125. package/dist/index371.cjs +1 -1
  126. package/dist/index371.js +107 -170
  127. package/dist/index372.cjs +1 -1
  128. package/dist/index372.js +6 -10
  129. package/dist/index373.cjs +1 -1
  130. package/dist/index373.js +70 -104
  131. package/dist/index374.cjs +1 -1
  132. package/dist/index374.js +2 -2
  133. package/dist/index375.cjs +1 -1
  134. package/dist/index375.js +29 -131
  135. package/dist/index383.cjs +1 -1
  136. package/dist/index383.js +59 -106
  137. package/dist/index384.cjs +1 -1
  138. package/dist/index384.js +110 -3
  139. package/dist/index385.cjs +1 -1
  140. package/dist/index385.js +3 -63
  141. package/dist/index6.cjs +1 -1
  142. package/dist/index6.js +42 -42
  143. package/dist/index77.cjs +1 -1
  144. package/dist/index77.js +13 -13
  145. package/dist/index9.cjs +1 -1
  146. package/dist/index9.js +16 -14
  147. package/dist/src/lib/store/swapStore.d.ts +1 -1
  148. package/package.json +5 -5
package/dist/index373.js CHANGED
@@ -1,110 +1,76 @@
1
- import { bcs as r } from "./index320.js";
2
- import { normalizeSuiAddress as n } from "./index117.js";
3
- import { MOVE_STDLIB_ADDRESS as s, SUI_FRAMEWORK_ADDRESS as a } from "./index372.js";
4
- const d = "object", i = "ID", f = "ascii", T = "String", _ = "string", l = "String", U = "option", m = "Option";
5
- function M(e) {
6
- const t = typeof e.body == "object" && "datatype" in e.body ? e.body.datatype : null;
7
- return !!t && n(t.package) === n("0x2") && t.module === "tx_context" && t.type === "TxContext";
8
- }
9
- function u(e) {
10
- if (typeof e == "string")
11
- switch (e) {
12
- case "address":
13
- return r.Address;
14
- case "bool":
15
- return r.Bool;
16
- case "u8":
17
- return r.U8;
18
- case "u16":
19
- return r.U16;
20
- case "u32":
21
- return r.U32;
22
- case "u64":
23
- return r.U64;
24
- case "u128":
25
- return r.U128;
26
- case "u256":
27
- return r.U256;
28
- default:
29
- throw new Error(`Unknown type signature ${e}`);
30
- }
31
- if ("vector" in e) {
32
- if (e.vector === "u8")
33
- return r.byteVector().transform({
34
- input: (o) => typeof o == "string" ? new TextEncoder().encode(o) : o,
35
- output: (o) => o
36
- });
37
- const t = u(e.vector);
38
- return t ? r.vector(t) : null;
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
- if ("datatype" in e) {
41
- const t = n(e.datatype.package);
42
- if (t === n(s)) {
43
- if (e.datatype.module === f && e.datatype.type === T)
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
- return null;
56
- }
57
- function D(e) {
58
- return typeof e == "object" && "Reference" in e ? {
59
- ref: "&",
60
- body: c(e.Reference)
61
- } : typeof e == "object" && "MutableReference" in e ? {
62
- ref: "&mut",
63
- body: c(e.MutableReference)
64
- } : {
65
- ref: null,
66
- body: c(e)
67
- };
68
- }
69
- function c(e) {
70
- if (typeof e == "string")
71
- switch (e) {
72
- case "Address":
73
- return "address";
74
- case "Bool":
75
- return "bool";
76
- case "U8":
77
- return "u8";
78
- case "U16":
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
- if ("Vector" in e)
92
- return { vector: c(e.Vector) };
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
- u as getPureBcsSchema,
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("./index384.cjs"),t=require("./index320.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;
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 "./index384.js";
3
- import { bcs as t } from "./index320.js";
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 d=require("./index278.cjs"),E=require("./index347.cjs"),m=require("./index277.cjs"),f=require("./index385.cjs"),A=require("./index292.cjs"),l=require("./index285.cjs");function q(r,e={}){const{prepare:i=!0}=e,n=Array.isArray(r)||typeof r=="string"?A.parseAbiItem(r):r;return{...n,...i?{hash:s(n)}:{}}}function g(r,e,i){const{args:n=[],prepare:o=!0}=i??{},w=m.validate(e,{strict:!1}),a=r.filter(t=>w?t.type==="function"||t.type==="error"?I(t)===m.slice(e,0,4):t.type==="event"?s(t)===e:!1:"name"in t&&t.name===e);if(a.length===0)throw new b({name:e});if(a.length===1)return{...a[0],...o?{hash:s(a[0])}:{}};let u;for(const t of a){if(!("inputs"in t))continue;if(!n||n.length===0){if(!t.inputs||t.inputs.length===0)return{...t,...o?{hash:s(t)}:{}};continue}if(!t.inputs||t.inputs.length===0||t.inputs.length!==n.length)continue;if(n.every((c,v)=>{const y="inputs"in t&&t.inputs[v];return y?f.isArgOfType(c,y):!1})){if(u&&"inputs"in u&&u.inputs){const c=f.getAmbiguousTypes(t.inputs,u.inputs,n);if(c)throw new $({abiItem:t,type:c[0]},{abiItem:u,type:c[1]})}u=t}}const h=(()=>{if(u)return u;const[t,...p]=a;return{...t,overloads:p}})();if(!h)throw new b({name:e});return{...h,...o?{hash:s(h)}:{}}}function I(...r){const e=(()=>{if(Array.isArray(r[0])){const[i,n]=r;return g(i,n)}return r[0]})();return m.slice(s(e),0,4)}function S(...r){const e=(()=>{if(Array.isArray(r[0])){const[n,o]=r;return g(n,o)}return r[0]})(),i=typeof e=="string"?e:l.formatAbiItem(e);return f.normalizeSignature(i)}function s(...r){const e=(()=>{if(Array.isArray(r[0])){const[i,n]=r;return g(i,n)}return r[0]})();return typeof e!="string"&&"hash"in e&&e.hash?e.hash:E.keccak256(m.fromString(S(e)))}class $ extends d.BaseError{constructor(e,i){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${e.type}\` in \`${f.normalizeSignature(l.formatAbiItem(e.abiItem))}\`, and`,`\`${i.type}\` in \`${f.normalizeSignature(l.formatAbiItem(i.abiItem))}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.AmbiguityError"})}}class b extends d.BaseError{constructor({name:e,data:i,type:n="item"}){const o=e?` with name "${e}"`:i?` with data "${i}"`:"";super(`ABI ${n}${o} not found.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.NotFoundError"})}}exports.AmbiguityError=$;exports.NotFoundError=b;exports.from=q;exports.fromAbi=g;exports.getSelector=I;exports.getSignature=S;exports.getSignatureHash=s;
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 { BaseError as d } from "./index278.js";
2
- import { keccak256 as v } from "./index347.js";
3
- import { validate as $, slice as A, fromString as S } from "./index277.js";
4
- import { isArgOfType as E, normalizeSignature as m, getAmbiguousTypes as B } from "./index385.js";
5
- import { parseAbiItem as y } from "./index292.js";
6
- import { formatAbiItem as p } from "./index285.js";
7
- function H(r, t = {}) {
8
- const { prepare: i = !0 } = t, n = Array.isArray(r) ? y(r) : typeof r == "string" ? y(r) : r;
9
- return {
10
- ...n,
11
- ...i ? { hash: f(n) } : {}
12
- };
13
- }
14
- function h(r, t, i) {
15
- const { args: n = [], prepare: u = !0 } = i ?? {}, w = $(t, { strict: !1 }), s = r.filter((e) => w ? e.type === "function" || e.type === "error" ? T(e) === A(t, 0, 4) : e.type === "event" ? f(e) === t : !1 : "name" in e && e.name === t);
16
- if (s.length === 0)
17
- throw new b({ name: t });
18
- if (s.length === 1)
19
- return {
20
- ...s[0],
21
- ...u ? { hash: f(s[0]) } : {}
22
- };
23
- let o;
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 c = (() => {
56
- if (o)
57
- return o;
58
- const [e, ...g] = s;
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
- O as AmbiguityError,
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"});/*! 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;
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
- /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2
- function x(e) {
3
- return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
4
- }
5
- function g(e, r) {
6
- return Array.isArray(r) ? r.length === 0 ? !0 : e ? r.every((t) => typeof t == "string") : r.every((t) => Number.isSafeInteger(t)) : !1;
7
- }
8
- function w(e, r) {
9
- if (typeof r != "string")
10
- throw new Error(`${e}: string expected`);
11
- return !0;
12
- }
13
- function b(e) {
14
- if (!Number.isSafeInteger(e))
15
- throw new Error(`invalid integer: ${e}`);
16
- }
17
- function h(e) {
18
- if (!Array.isArray(e))
19
- throw new Error("array expected");
20
- }
21
- function A(e, r) {
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
- for (let o = 0; o < e.length - 1 && e[o] === 0; o++)
93
- i.push(0);
94
- return i.reverse();
24
+ if (!o)
25
+ throw new f("Unable to normalize signature.");
26
+ return n;
95
27
  }
96
- // @__NO_SIDE_EFFECTS__
97
- function j(e) {
98
- b(e);
99
- const r = 2 ** 8;
100
- return {
101
- encode: (t) => {
102
- if (!x(t))
103
- throw new Error("radix.encode input should be Uint8Array");
104
- return p(Array.from(t), r, e);
105
- },
106
- decode: (t) => (E("radix.decode", t), Uint8Array.from(p(t, e, r)))
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
- S as base58
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=require("./index386.cjs"),b=e.blake2b;exports.blake2b=b;
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;