@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/index363.js CHANGED
@@ -1,151 +1,136 @@
1
- import { ulebEncode as n } from "./index362.js";
2
- import { encodeStr as o } from "./index317.js";
3
- class u {
4
- constructor({
5
- initialSize: t = 1024,
6
- maxSize: i = 1 / 0,
7
- allocateSize: e = 1024
8
- } = {}) {
9
- this.bytePosition = 0, this.size = t, this.maxSize = i, this.allocateSize = e, this.dataView = new DataView(new ArrayBuffer(t));
10
- }
11
- ensureSizeOrGrow(t) {
12
- const i = this.bytePosition + t;
13
- if (i > this.size) {
14
- const e = Math.min(
15
- this.maxSize,
16
- Math.max(this.size + i, this.size + this.allocateSize)
17
- );
18
- if (i > e)
19
- throw new Error(
20
- `Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${i}`
21
- );
22
- this.size = e;
23
- const s = new ArrayBuffer(this.size);
24
- new Uint8Array(s).set(new Uint8Array(this.dataView.buffer)), this.dataView = new DataView(s);
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 "./index383.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;
25
53
  }
26
54
  }
27
- /**
28
- * Shift current cursor position by `bytes`.
29
- *
30
- * @param {Number} bytes Number of bytes to
31
- * @returns {this} Self for possible chaining.
32
- */
33
- shift(t) {
34
- return this.bytePosition += t, this;
35
- }
36
- /**
37
- * Write a U8 value into a buffer and shift cursor position by 1.
38
- * @param {Number} value Value to write.
39
- * @returns {this}
40
- */
41
- write8(t) {
42
- return this.ensureSizeOrGrow(1), this.dataView.setUint8(this.bytePosition, Number(t)), this.shift(1);
43
- }
44
- /**
45
- * Write a U8 value into a buffer and shift cursor position by 1.
46
- * @param {Number} value Value to write.
47
- * @returns {this}
48
- */
49
- writeBytes(t) {
50
- this.ensureSizeOrGrow(t.length);
51
- for (let i = 0; i < t.length; i++)
52
- this.dataView.setUint8(this.bytePosition + i, t[i]);
53
- return this.shift(t.length);
54
- }
55
- /**
56
- * Write a U16 value into a buffer and shift cursor position by 2.
57
- * @param {Number} value Value to write.
58
- * @returns {this}
59
- */
60
- write16(t) {
61
- return this.ensureSizeOrGrow(2), this.dataView.setUint16(this.bytePosition, Number(t), !0), this.shift(2);
62
- }
63
- /**
64
- * Write a U32 value into a buffer and shift cursor position by 4.
65
- * @param {Number} value Value to write.
66
- * @returns {this}
67
- */
68
- write32(t) {
69
- return this.ensureSizeOrGrow(4), this.dataView.setUint32(this.bytePosition, Number(t), !0), this.shift(4);
70
- }
71
- /**
72
- * Write a U64 value into a buffer and shift cursor position by 8.
73
- * @param {bigint} value Value to write.
74
- * @returns {this}
75
- */
76
- write64(t) {
77
- return h(BigInt(t), 8).forEach((i) => this.write8(i)), this;
78
- }
79
- /**
80
- * Write a U128 value into a buffer and shift cursor position by 16.
81
- *
82
- * @param {bigint} value Value to write.
83
- * @returns {this}
84
- */
85
- write128(t) {
86
- return h(BigInt(t), 16).forEach((i) => this.write8(i)), this;
87
- }
88
- /**
89
- * Write a U256 value into a buffer and shift cursor position by 16.
90
- *
91
- * @param {bigint} value Value to write.
92
- * @returns {this}
93
- */
94
- write256(t) {
95
- return h(BigInt(t), 32).forEach((i) => this.write8(i)), this;
96
- }
97
- /**
98
- * Write a ULEB value into a buffer and shift cursor position by number of bytes
99
- * written.
100
- * @param {Number} value Value to write.
101
- * @returns {this}
102
- */
103
- writeULEB(t) {
104
- return n(t).forEach((i) => this.write8(i)), this;
105
- }
106
- /**
107
- * Write a vector into a buffer by first writing the vector length and then calling
108
- * a callback on each passed value.
109
- *
110
- * @param {Array<Any>} vector Array of elements to write.
111
- * @param {WriteVecCb} cb Callback to call on each element of the vector.
112
- * @returns {this}
113
- */
114
- writeVec(t, i) {
115
- return this.writeULEB(t.length), Array.from(t).forEach((e, s) => i(this, e, s, t.length)), this;
116
- }
117
- /**
118
- * Adds support for iterations over the object.
119
- * @returns {Uint8Array}
120
- */
121
- // oxlint-disable-next-line require-yields
122
- *[Symbol.iterator]() {
123
- for (let t = 0; t < this.bytePosition; t++)
124
- yield this.dataView.getUint8(t);
125
- return this.toBytes();
126
- }
127
- /**
128
- * Get underlying buffer taking only value bytes (in case initial buffer size was bigger).
129
- * @returns {Uint8Array} Resulting bcs.
130
- */
131
- toBytes() {
132
- return new Uint8Array(this.dataView.buffer.slice(0, this.bytePosition));
133
- }
134
- /**
135
- * Represent data as 'hex' or 'base64'
136
- * @param encoding Encoding to use: 'base64' or 'hex'
137
- */
138
- toString(t) {
139
- return o(this.toBytes(), t);
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
+ });
140
115
  }
141
116
  }
142
- function h(r, t) {
143
- const i = new Uint8Array(t);
144
- let e = 0;
145
- for (; r > 0; )
146
- i[e] = Number(r % BigInt(256)), r = r / BigInt(256), e += 1;
147
- return i;
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
+ });
126
+ }
148
127
  }
149
128
  export {
150
- u as BcsWriter
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
151
136
  };
package/dist/index364.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./index304.cjs"),m=require("./index362.cjs");function y(e,r,a){return new d.BcsType({read:t=>{const n=new Array(e);for(let u=0;u<e;u++)n[u]=r.read(t);return n},write:(t,n)=>{for(const u of t)r.write(u,n)},...a,name:(a==null?void 0:a.name)??`${r.name}[${e}]`,validate:t=>{var n;if((n=a==null?void 0:a.validate)==null||n.call(a,t),!t||typeof t!="object"||!("length"in t))throw new TypeError(`Expected array, found ${typeof t}`);if(t.length!==e)throw new TypeError(`Expected array of length ${e}, found ${t.length}`)}})}function w(e){return c.enum(`Option<${e.name}>`,{None:null,Some:e}).transform({input:r=>r==null?{None:!0}:{Some:r},output:r=>r.$kind==="Some"?r.Some:null})}function f(e,r){return new d.BcsType({read:a=>{const t=a.readULEB(),n=new Array(t);for(let u=0;u<t;u++)n[u]=e.read(a);return n},write:(a,t)=>{t.writeULEB(a.length);for(const n of a)e.write(n,t)},...r,name:(r==null?void 0:r.name)??`vector<${e.name}>`,validate:a=>{var t;if((t=r==null?void 0:r.validate)==null||t.call(r,a),!a||typeof a!="object"||!("length"in a))throw new TypeError(`Expected array, found ${typeof a}`)}})}function l(e,r){return c.vector(c.tuple([e,r])).transform({name:`Map<${e.name}, ${r.name}>`,input:a=>[...a.entries()],output:a=>{const t=new Map;for(const[n,u]of a)t.set(n,u);return t}})}const c={u8(e){return d.uIntBcsType({readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...e,name:(e==null?void 0:e.name)??"u8"})},u16(e){return d.uIntBcsType({readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...e,name:(e==null?void 0:e.name)??"u16"})},u32(e){return d.uIntBcsType({readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...e,name:(e==null?void 0:e.name)??"u32"})},u64(e){return d.bigUIntBcsType({readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...e,name:(e==null?void 0:e.name)??"u64"})},u128(e){return d.bigUIntBcsType({readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...e,name:(e==null?void 0:e.name)??"u128"})},u256(e){return d.bigUIntBcsType({readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...e,name:(e==null?void 0:e.name)??"u256"})},bool(e){return d.fixedSizeBcsType({size:1,read:r=>r.read8()===1,write:(r,a)=>a.write8(r?1:0),...e,name:(e==null?void 0:e.name)??"bool",validate:r=>{var a;if((a=e==null?void 0:e.validate)==null||a.call(e,r),typeof r!="boolean")throw new TypeError(`Expected boolean, found ${typeof r}`)}})},uleb128(e){return d.dynamicSizeBcsType({read:r=>r.readULEB(),serialize:r=>Uint8Array.from(m.ulebEncode(r)),...e,name:(e==null?void 0:e.name)??"uleb128"})},bytes(e,r){return d.fixedSizeBcsType({size:e,read:a=>a.readBytes(e),write:(a,t)=>{t.writeBytes(new Uint8Array(a))},...r,name:(r==null?void 0:r.name)??`bytes[${e}]`,validate:a=>{var t;if((t=r==null?void 0:r.validate)==null||t.call(r,a),!a||typeof a!="object"||!("length"in a))throw new TypeError(`Expected array, found ${typeof a}`);if(a.length!==e)throw new TypeError(`Expected array of length ${e}, found ${a.length}`)}})},byteVector(e){return new d.BcsType({read:r=>{const a=r.readULEB();return r.readBytes(a)},write:(r,a)=>{const t=new Uint8Array(r);a.writeULEB(t.length),a.writeBytes(t)},...e,name:(e==null?void 0:e.name)??"vector<u8>",serializedSize:r=>{const a="length"in r?r.length:null;return a==null?null:m.ulebEncode(a).length+a},validate:r=>{var a;if((a=e==null?void 0:e.validate)==null||a.call(e,r),!r||typeof r!="object"||!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`)}})},string(e){return d.stringLikeBcsType({toBytes:r=>new TextEncoder().encode(r),fromBytes:r=>new TextDecoder().decode(r),...e,name:(e==null?void 0:e.name)??"string"})},fixedArray:y,option:w,vector:f,tuple(e,r){return new d.BcsTuple({fields:e,...r})},struct(e,r,a){return new d.BcsStruct({name:e,fields:r,...a})},enum(e,r,a){return new d.BcsEnum({name:e,fields:r,...a})},map:l,lazy(e){return d.lazyBcsType(e)}};exports.bcs=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index365.cjs");class n{constructor(t){this.bytePosition=0,this.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength)}shift(t){return this.bytePosition+=t,this}read8(){const t=this.dataView.getUint8(this.bytePosition);return this.shift(1),t}read16(){const t=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),t}read32(){const t=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),t}read64(){const t=this.read32(),e=this.read32().toString(16)+t.toString(16).padStart(8,"0");return BigInt("0x"+e).toString(10)}read128(){const t=BigInt(this.read64()),e=BigInt(this.read64()).toString(16)+t.toString(16).padStart(16,"0");return BigInt("0x"+e).toString(10)}read256(){const t=BigInt(this.read128()),e=BigInt(this.read128()).toString(16)+t.toString(16).padStart(32,"0");return BigInt("0x"+e).toString(10)}readBytes(t){const i=this.bytePosition+this.dataView.byteOffset,e=new Uint8Array(this.dataView.buffer,i,t);return this.shift(t),e}readULEB(){const t=this.bytePosition+this.dataView.byteOffset,i=new Uint8Array(this.dataView.buffer,t),{value:e,length:s}=r.ulebDecode(i);return this.shift(s),e}readVec(t){const i=this.readULEB(),e=[];for(let s=0;s<i;s++)e.push(t(this,s,i));return e}}exports.BcsReader=n;