@gardenfi/swap 0.0.2-beta.1 → 0.0.2-beta.2

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 (179) hide show
  1. package/dist/index104.cjs +1 -1
  2. package/dist/index104.js +4 -4
  3. package/dist/index106.cjs +1 -1
  4. package/dist/index106.js +3 -3
  5. package/dist/index107.cjs +1 -1
  6. package/dist/index107.js +3 -3
  7. package/dist/index116.cjs +1 -1
  8. package/dist/index116.js +1 -1
  9. package/dist/index117.cjs +1 -1
  10. package/dist/index117.js +1 -1
  11. package/dist/index120.cjs +1 -1
  12. package/dist/index120.js +2 -2
  13. package/dist/index121.cjs +1 -1
  14. package/dist/index121.js +7 -7
  15. package/dist/index132.cjs +1 -1
  16. package/dist/index132.js +1 -1
  17. package/dist/index133.cjs +1 -1
  18. package/dist/index133.js +1 -1
  19. package/dist/index134.cjs +1 -1
  20. package/dist/index134.js +1 -1
  21. package/dist/index135.cjs +1 -1
  22. package/dist/index135.js +1 -1
  23. package/dist/index138.cjs +1 -1
  24. package/dist/index138.js +2 -2
  25. package/dist/index161.cjs +1 -1
  26. package/dist/index161.js +2 -2
  27. package/dist/index167.cjs +1 -1
  28. package/dist/index167.js +2 -2
  29. package/dist/index168.cjs +1 -1
  30. package/dist/index168.js +2 -2
  31. package/dist/index169.cjs +1 -1
  32. package/dist/index169.js +2 -2
  33. package/dist/index170.cjs +1 -1
  34. package/dist/index170.js +2 -2
  35. package/dist/index171.cjs +1 -1
  36. package/dist/index171.js +2 -2
  37. package/dist/index172.cjs +1 -1
  38. package/dist/index172.js +2 -2
  39. package/dist/index181.cjs +1 -1
  40. package/dist/index181.js +1 -1
  41. package/dist/index272.cjs +1 -1
  42. package/dist/index272.js +174 -9
  43. package/dist/index273.cjs +2 -1
  44. package/dist/index273.js +91 -30
  45. package/dist/index274.cjs +1 -1
  46. package/dist/index274.js +41 -2
  47. package/dist/index275.cjs +1 -1
  48. package/dist/index275.js +4 -47
  49. package/dist/index276.cjs +1 -1
  50. package/dist/index276.js +9 -11
  51. package/dist/index277.cjs +1 -1
  52. package/dist/index277.js +30 -174
  53. package/dist/index278.cjs +1 -2
  54. package/dist/index278.js +2 -92
  55. package/dist/index279.cjs +1 -1
  56. package/dist/index279.js +45 -38
  57. package/dist/index280.cjs +1 -1
  58. package/dist/index280.js +11 -4
  59. package/dist/index281.cjs +1 -1
  60. package/dist/index281.js +3 -3
  61. package/dist/index299.cjs +1 -1
  62. package/dist/index299.js +7 -37
  63. package/dist/index300.cjs +1 -1
  64. package/dist/index300.js +36 -14
  65. package/dist/index301.cjs +1 -1
  66. package/dist/index301.js +15 -8
  67. package/dist/index302.cjs +1 -1
  68. package/dist/index302.js +43 -8
  69. package/dist/index303.cjs +1 -1
  70. package/dist/index303.js +317 -39
  71. package/dist/index304.cjs +1 -1
  72. package/dist/index304.js +586 -301
  73. package/dist/index305.cjs +1 -1
  74. package/dist/index305.js +107 -603
  75. package/dist/index306.cjs +1 -1
  76. package/dist/index306.js +168 -110
  77. package/dist/index307.cjs +1 -1
  78. package/dist/index307.js +299 -165
  79. package/dist/index308.cjs +1 -1
  80. package/dist/index308.js +92 -300
  81. package/dist/index309.cjs +1 -1
  82. package/dist/index309.js +56 -93
  83. package/dist/index310.cjs +1 -1
  84. package/dist/index310.js +52 -55
  85. package/dist/index311.cjs +1 -1
  86. package/dist/index311.js +42 -51
  87. package/dist/index312.cjs +1 -1
  88. package/dist/index312.js +14 -43
  89. package/dist/index313.cjs +1 -1
  90. package/dist/index313.js +317 -15
  91. package/dist/index314.cjs +1 -1
  92. package/dist/index314.js +53 -311
  93. package/dist/index315.cjs +1 -1
  94. package/dist/index315.js +19 -59
  95. package/dist/index316.cjs +1 -1
  96. package/dist/index316.js +29 -19
  97. package/dist/index317.cjs +1 -1
  98. package/dist/index317.js +3 -29
  99. package/dist/index318.cjs +7 -1
  100. package/dist/index318.js +237 -3
  101. package/dist/index319.cjs +1 -7
  102. package/dist/index319.js +48 -238
  103. package/dist/index320.cjs +1 -1
  104. package/dist/index320.js +213 -48
  105. package/dist/index321.cjs +1 -1
  106. package/dist/index321.js +75 -206
  107. package/dist/index322.cjs +1 -1
  108. package/dist/index322.js +26 -78
  109. package/dist/index323.cjs +1 -1
  110. package/dist/index323.js +73 -26
  111. package/dist/index324.cjs +1 -1
  112. package/dist/index324.js +7 -75
  113. package/dist/index326.cjs +1 -1
  114. package/dist/index326.js +1 -1
  115. package/dist/index327.cjs +1 -1
  116. package/dist/index327.js +1 -1
  117. package/dist/index333.cjs +1 -1
  118. package/dist/index333.js +2 -2
  119. package/dist/index334.cjs +1 -1
  120. package/dist/index334.js +2 -2
  121. package/dist/index346.cjs +1 -1
  122. package/dist/index346.js +1 -1
  123. package/dist/index347.cjs +1 -1
  124. package/dist/index347.js +1 -1
  125. package/dist/index348.cjs +1 -1
  126. package/dist/index348.js +3 -3
  127. package/dist/index349.cjs +2 -1
  128. package/dist/index349.js +193 -4
  129. package/dist/index350.cjs +1 -2
  130. package/dist/index350.js +52 -168
  131. package/dist/index351.cjs +1 -1
  132. package/dist/index351.js +331 -65
  133. package/dist/index352.cjs +1 -1
  134. package/dist/index352.js +149 -332
  135. package/dist/index353.cjs +1 -1
  136. package/dist/index353.js +5 -161
  137. package/dist/index354.cjs +1 -1
  138. package/dist/index354.js +5 -5
  139. package/dist/index357.cjs +1 -1
  140. package/dist/index357.js +205 -8
  141. package/dist/index359.cjs +1 -1
  142. package/dist/index359.js +8 -205
  143. package/dist/index363.cjs +1 -1
  144. package/dist/index363.js +1 -1
  145. package/dist/index364.cjs +1 -1
  146. package/dist/index364.js +1 -1
  147. package/dist/index365.cjs +1 -1
  148. package/dist/index365.js +73 -3
  149. package/dist/index366.cjs +1 -1
  150. package/dist/index366.js +29 -138
  151. package/dist/index367.cjs +1 -1
  152. package/dist/index367.js +5 -73
  153. package/dist/index368.cjs +1 -1
  154. package/dist/index368.js +2 -30
  155. package/dist/index369.cjs +1 -1
  156. package/dist/index369.js +140 -5
  157. package/dist/index370.cjs +1 -1
  158. package/dist/index370.js +1 -1
  159. package/dist/index373.cjs +1 -1
  160. package/dist/index373.js +1 -1
  161. package/dist/index374.cjs +1 -1
  162. package/dist/index374.js +1 -1
  163. package/dist/index375.cjs +1 -1
  164. package/dist/index375.js +2 -2
  165. package/dist/index379.cjs +1 -1
  166. package/dist/index379.js +1 -1
  167. package/dist/index380.cjs +1 -1
  168. package/dist/index380.js +1 -1
  169. package/dist/index381.cjs +1 -1
  170. package/dist/index381.js +22 -2
  171. package/dist/index382.cjs +1 -1
  172. package/dist/index382.js +2 -22
  173. package/dist/index385.cjs +1 -1
  174. package/dist/index385.js +2 -2
  175. package/dist/index77.cjs +1 -1
  176. package/dist/index77.js +13 -13
  177. package/dist/index99.cjs +1 -1
  178. package/dist/index99.js +1 -1
  179. package/package.json +5 -5
package/dist/index318.js CHANGED
@@ -1,6 +1,240 @@
1
- function c(t, n) {
2
- return Array.from({ length: Math.ceil(t.length / n) }, (e, r) => t.slice(r * n, (r + 1) * n));
1
+ class k {
2
+ constructor(e, c) {
3
+ if (typeof e != "function")
4
+ throw new TypeError(
5
+ `DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but got: ${e}.`
6
+ );
7
+ this._batchLoadFn = e, this._maxBatchSize = p(c), this._batchScheduleFn = w(c), this._cacheKeyFn = g(c), this._cacheMap = b(c), this._batch = null, this.name = P(c);
8
+ }
9
+ /**
10
+ * Loads a key, returning a `Promise` for the value represented by that key.
11
+ */
12
+ load(e) {
13
+ if (e == null)
14
+ throw new TypeError(
15
+ `The loader.load() function must be called with a value, but got: ${String(e)}.`
16
+ );
17
+ const c = d(this), r = this._cacheMap;
18
+ let n;
19
+ if (r) {
20
+ n = this._cacheKeyFn(e);
21
+ const i = r.get(n);
22
+ if (i) {
23
+ const s = c.cacheHits || (c.cacheHits = []);
24
+ return new Promise((f) => {
25
+ s.push(() => {
26
+ f(i);
27
+ });
28
+ });
29
+ }
30
+ }
31
+ c.keys.push(e);
32
+ const a = new Promise((i, s) => {
33
+ c.callbacks.push({ resolve: i, reject: s });
34
+ });
35
+ return r && r.set(n, a), a;
36
+ }
37
+ /**
38
+ * Loads multiple keys, promising an array of values:
39
+ *
40
+ * var [ a, b ] = await myLoader.loadMany([ 'a', 'b' ]);
41
+ *
42
+ * This is similar to the more verbose:
43
+ *
44
+ * var [ a, b ] = await Promise.all([
45
+ * myLoader.load('a'),
46
+ * myLoader.load('b')
47
+ * ]);
48
+ *
49
+ * However it is different in the case where any load fails. Where
50
+ * Promise.all() would reject, loadMany() always resolves, however each result
51
+ * is either a value or an Error instance.
52
+ *
53
+ * var [ a, b, c ] = await myLoader.loadMany([ 'a', 'b', 'badkey' ]);
54
+ * // c instanceof Error
55
+ *
56
+ */
57
+ loadMany(e) {
58
+ if (!l(e))
59
+ throw new TypeError(
60
+ `The loader.loadMany() function must be called with Array<key>, but got: ${e}.`
61
+ );
62
+ const c = [];
63
+ for (let r = 0; r < e.length; r++)
64
+ c.push(this.load(e[r]).catch((n) => n));
65
+ return Promise.all(c);
66
+ }
67
+ /**
68
+ * Clears the value at `key` from the cache, if it exists. Returns itself for
69
+ * method chaining.
70
+ */
71
+ clear(e) {
72
+ const c = this._cacheMap;
73
+ if (c) {
74
+ const r = this._cacheKeyFn(e);
75
+ c.delete(r);
76
+ }
77
+ return this;
78
+ }
79
+ /**
80
+ * Clears the entire cache. To be used when some event results in unknown
81
+ * invalidations across this particular `DataLoader`. Returns itself for
82
+ * method chaining.
83
+ */
84
+ clearAll() {
85
+ const e = this._cacheMap;
86
+ return e && e.clear(), this;
87
+ }
88
+ /**
89
+ * Adds the provided key and value to the cache. If the key already
90
+ * exists, no change is made. Returns itself for method chaining.
91
+ *
92
+ * To prime the cache with an error at a key, provide an Error instance.
93
+ */
94
+ prime(e, c) {
95
+ const r = this._cacheMap;
96
+ if (r) {
97
+ const n = this._cacheKeyFn(e);
98
+ if (r.get(n) === void 0) {
99
+ let a;
100
+ c instanceof Error ? (a = Promise.reject(c), a.catch(() => {
101
+ })) : a = Promise.resolve(c), r.set(n, a);
102
+ }
103
+ }
104
+ return this;
105
+ }
106
+ }
107
+ const y = (
108
+ /** @ts-ignore */
109
+ typeof process == "object" && typeof process.nextTick == "function" ? function(t) {
110
+ o || (o = Promise.resolve()), o.then(() => {
111
+ process.nextTick(t);
112
+ });
113
+ } : (
114
+ // @ts-ignore
115
+ typeof setImmediate == "function" ? function(t) {
116
+ setImmediate(t);
117
+ } : function(t) {
118
+ setTimeout(t);
119
+ }
120
+ )
121
+ );
122
+ let o;
123
+ function d(t) {
124
+ const e = t._batch;
125
+ if (e !== null && !e.hasDispatched && e.keys.length < t._maxBatchSize)
126
+ return e;
127
+ const c = { hasDispatched: !1, keys: [], callbacks: [] };
128
+ return t._batch = c, t._batchScheduleFn(() => {
129
+ m(t, c);
130
+ }), c;
131
+ }
132
+ function m(t, e) {
133
+ if (e.hasDispatched = !0, e.keys.length === 0) {
134
+ u(e);
135
+ return;
136
+ }
137
+ let c;
138
+ try {
139
+ c = t._batchLoadFn(e.keys);
140
+ } catch (r) {
141
+ return h(
142
+ t,
143
+ e,
144
+ new TypeError(
145
+ `DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function errored synchronously: ${String(r)}.`
146
+ )
147
+ );
148
+ }
149
+ if (!c || typeof c.then != "function")
150
+ return h(
151
+ t,
152
+ e,
153
+ new TypeError(
154
+ `DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise: ${String(c)}.`
155
+ )
156
+ );
157
+ Promise.resolve(c).then((r) => {
158
+ if (!l(r))
159
+ throw new TypeError(
160
+ `DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array: ${String(r)}.`
161
+ );
162
+ if (r.length !== e.keys.length)
163
+ throw new TypeError(
164
+ `DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys.
165
+
166
+ Keys:
167
+ ${String(e.keys)}
168
+
169
+ Values:
170
+ ${String(r)}`
171
+ );
172
+ u(e);
173
+ for (let n = 0; n < e.callbacks.length; n++) {
174
+ const a = r[n];
175
+ a instanceof Error ? e.callbacks[n].reject(a) : e.callbacks[n].resolve(a);
176
+ }
177
+ }).catch((r) => {
178
+ h(t, e, r);
179
+ });
180
+ }
181
+ function h(t, e, c) {
182
+ u(e);
183
+ for (let r = 0; r < e.keys.length; r++)
184
+ t.clear(e.keys[r]), e.callbacks[r].reject(c);
185
+ }
186
+ function u(t) {
187
+ if (t.cacheHits)
188
+ for (let e = 0; e < t.cacheHits.length; e++)
189
+ t.cacheHits[e]();
190
+ }
191
+ function p(t) {
192
+ if (!(!t || t.batch !== !1))
193
+ return 1;
194
+ const c = t && t.maxBatchSize;
195
+ if (c === void 0)
196
+ return 1 / 0;
197
+ if (typeof c != "number" || c < 1)
198
+ throw new TypeError(`maxBatchSize must be a positive number: ${c}`);
199
+ return c;
200
+ }
201
+ function w(t) {
202
+ const e = t && t.batchScheduleFn;
203
+ if (e === void 0)
204
+ return y;
205
+ if (typeof e != "function")
206
+ throw new TypeError(`batchScheduleFn must be a function: ${e}`);
207
+ return e;
208
+ }
209
+ function g(t) {
210
+ const e = t && t.cacheKeyFn;
211
+ if (e === void 0)
212
+ return (c) => c;
213
+ if (typeof e != "function")
214
+ throw new TypeError(`cacheKeyFn must be a function: ${e}`);
215
+ return e;
216
+ }
217
+ function b(t) {
218
+ if (!(!t || t.cache !== !1))
219
+ return null;
220
+ const c = t && t.cacheMap;
221
+ if (c === void 0)
222
+ return /* @__PURE__ */ new Map();
223
+ if (c !== null) {
224
+ const n = ["get", "set", "delete", "clear"].filter(
225
+ (a) => c && typeof c[a] != "function"
226
+ );
227
+ if (n.length !== 0)
228
+ throw new TypeError("Custom cacheMap missing methods: " + n.join(", "));
229
+ }
230
+ return c;
231
+ }
232
+ function P(t) {
233
+ return t && t.name ? t.name : null;
234
+ }
235
+ function l(t) {
236
+ return typeof t == "object" && t !== null && "length" in t && typeof t.length == "number" && (t.length === 0 || t.length > 0 && Object.prototype.hasOwnProperty.call(t, t.length - 1));
3
237
  }
4
238
  export {
5
- c as chunk
239
+ k as DataLoader
6
240
  };
package/dist/index319.cjs CHANGED
@@ -1,7 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class y{constructor(e,r){if(typeof e!="function")throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but got: ${e}.`);this._batchLoadFn=e,this._maxBatchSize=g(r),this._batchScheduleFn=w(r),this._cacheKeyFn=b(r),this._cacheMap=P(r),this._batch=null,this.name=S(r)}load(e){if(e==null)throw new TypeError(`The loader.load() function must be called with a value, but got: ${String(e)}.`);const r=m(this),c=this._cacheMap;let n;if(c){n=this._cacheKeyFn(e);const i=c.get(n);if(i){const s=r.cacheHits||(r.cacheHits=[]);return new Promise(f=>{s.push(()=>{f(i)})})}}r.keys.push(e);const a=new Promise((i,s)=>{r.callbacks.push({resolve:i,reject:s})});return c&&c.set(n,a),a}loadMany(e){if(!l(e))throw new TypeError(`The loader.loadMany() function must be called with Array<key>, but got: ${e}.`);const r=[];for(let c=0;c<e.length;c++)r.push(this.load(e[c]).catch(n=>n));return Promise.all(r)}clear(e){const r=this._cacheMap;if(r){const c=this._cacheKeyFn(e);r.delete(c)}return this}clearAll(){const e=this._cacheMap;return e&&e.clear(),this}prime(e,r){const c=this._cacheMap;if(c){const n=this._cacheKeyFn(e);if(c.get(n)===void 0){let a;r instanceof Error?(a=Promise.reject(r),a.catch(()=>{})):a=Promise.resolve(r),c.set(n,a)}}return this}}const d=typeof process=="object"&&typeof process.nextTick=="function"?function(t){o||(o=Promise.resolve()),o.then(()=>{process.nextTick(t)})}:typeof setImmediate=="function"?function(t){setImmediate(t)}:function(t){setTimeout(t)};let o;function m(t){const e=t._batch;if(e!==null&&!e.hasDispatched&&e.keys.length<t._maxBatchSize)return e;const r={hasDispatched:!1,keys:[],callbacks:[]};return t._batch=r,t._batchScheduleFn(()=>{p(t,r)}),r}function p(t,e){if(e.hasDispatched=!0,e.keys.length===0){u(e);return}let r;try{r=t._batchLoadFn(e.keys)}catch(c){return h(t,e,new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function errored synchronously: ${String(c)}.`))}if(!r||typeof r.then!="function")return h(t,e,new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise: ${String(r)}.`));Promise.resolve(r).then(c=>{if(!l(c))throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array: ${String(c)}.`);if(c.length!==e.keys.length)throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys.
2
-
3
- Keys:
4
- ${String(e.keys)}
5
-
6
- Values:
7
- ${String(c)}`);u(e);for(let n=0;n<e.callbacks.length;n++){const a=c[n];a instanceof Error?e.callbacks[n].reject(a):e.callbacks[n].resolve(a)}}).catch(c=>{h(t,e,c)})}function h(t,e,r){u(e);for(let c=0;c<e.keys.length;c++)t.clear(e.keys[c]),e.callbacks[c].reject(r)}function u(t){if(t.cacheHits)for(let e=0;e<t.cacheHits.length;e++)t.cacheHits[e]()}function g(t){if(!(!t||t.batch!==!1))return 1;const r=t&&t.maxBatchSize;if(r===void 0)return 1/0;if(typeof r!="number"||r<1)throw new TypeError(`maxBatchSize must be a positive number: ${r}`);return r}function w(t){const e=t&&t.batchScheduleFn;if(e===void 0)return d;if(typeof e!="function")throw new TypeError(`batchScheduleFn must be a function: ${e}`);return e}function b(t){const e=t&&t.cacheKeyFn;if(e===void 0)return r=>r;if(typeof e!="function")throw new TypeError(`cacheKeyFn must be a function: ${e}`);return e}function P(t){if(!(!t||t.cache!==!1))return null;const r=t&&t.cacheMap;if(r===void 0)return new Map;if(r!==null){const n=["get","set","delete","clear"].filter(a=>r&&typeof r[a]!="function");if(n.length!==0)throw new TypeError("Custom cacheMap missing methods: "+n.join(", "))}return r}function S(t){return t&&t.name?t.name:null}function l(t){return typeof t=="object"&&t!==null&&"length"in t&&typeof t.length=="number"&&(t.length===0||t.length>0&&Object.prototype.hasOwnProperty.call(t,t.length-1))}exports.DataLoader=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index364.cjs"),e=require("./index370.cjs"),a=require("./index371.cjs"),n={...t.bcs,U8:t.bcs.u8(),U16:t.bcs.u16(),U32:t.bcs.u32(),U64:t.bcs.u64(),U128:t.bcs.u128(),U256:t.bcs.u256(),ULEB128:t.bcs.uleb128(),Bool:t.bcs.bool(),String:t.bcs.string(),Address:e.Address,AppId:e.AppId,Argument:e.Argument,CallArg:e.CallArg,Command:e.Command,CompressedSignature:e.CompressedSignature,GasData:e.GasData,Intent:e.Intent,IntentMessage:e.IntentMessage,IntentScope:e.IntentScope,IntentVersion:e.IntentVersion,MultiSig:e.MultiSig,MultiSigPkMap:e.MultiSigPkMap,MultiSigPublicKey:e.MultiSigPublicKey,ObjectArg:e.ObjectArg,ObjectDigest:e.ObjectDigest,Owner:e.Owner,PasskeyAuthenticator:e.PasskeyAuthenticator,ProgrammableMoveCall:e.ProgrammableMoveCall,ProgrammableTransaction:e.ProgrammableTransaction,PublicKey:e.PublicKey,SenderSignedData:e.SenderSignedData,SenderSignedTransaction:e.SenderSignedTransaction,SharedObjectRef:e.SharedObjectRef,StructTag:e.StructTag,SuiObjectRef:e.SuiObjectRef,TransactionData:e.TransactionData,TransactionDataV1:e.TransactionDataV1,TransactionEffects:a.TransactionEffects,TransactionExpiration:e.TransactionExpiration,TransactionKind:e.TransactionKind,TypeTag:e.TypeTag};exports.bcs=n;
package/dist/index319.js CHANGED
@@ -1,240 +1,50 @@
1
- class k {
2
- constructor(e, c) {
3
- if (typeof e != "function")
4
- throw new TypeError(
5
- `DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but got: ${e}.`
6
- );
7
- this._batchLoadFn = e, this._maxBatchSize = p(c), this._batchScheduleFn = w(c), this._cacheKeyFn = g(c), this._cacheMap = b(c), this._batch = null, this.name = P(c);
8
- }
9
- /**
10
- * Loads a key, returning a `Promise` for the value represented by that key.
11
- */
12
- load(e) {
13
- if (e == null)
14
- throw new TypeError(
15
- `The loader.load() function must be called with a value, but got: ${String(e)}.`
16
- );
17
- const c = d(this), r = this._cacheMap;
18
- let n;
19
- if (r) {
20
- n = this._cacheKeyFn(e);
21
- const i = r.get(n);
22
- if (i) {
23
- const s = c.cacheHits || (c.cacheHits = []);
24
- return new Promise((f) => {
25
- s.push(() => {
26
- f(i);
27
- });
28
- });
29
- }
30
- }
31
- c.keys.push(e);
32
- const a = new Promise((i, s) => {
33
- c.callbacks.push({ resolve: i, reject: s });
34
- });
35
- return r && r.set(n, a), a;
36
- }
37
- /**
38
- * Loads multiple keys, promising an array of values:
39
- *
40
- * var [ a, b ] = await myLoader.loadMany([ 'a', 'b' ]);
41
- *
42
- * This is similar to the more verbose:
43
- *
44
- * var [ a, b ] = await Promise.all([
45
- * myLoader.load('a'),
46
- * myLoader.load('b')
47
- * ]);
48
- *
49
- * However it is different in the case where any load fails. Where
50
- * Promise.all() would reject, loadMany() always resolves, however each result
51
- * is either a value or an Error instance.
52
- *
53
- * var [ a, b, c ] = await myLoader.loadMany([ 'a', 'b', 'badkey' ]);
54
- * // c instanceof Error
55
- *
56
- */
57
- loadMany(e) {
58
- if (!l(e))
59
- throw new TypeError(
60
- `The loader.loadMany() function must be called with Array<key>, but got: ${e}.`
61
- );
62
- const c = [];
63
- for (let r = 0; r < e.length; r++)
64
- c.push(this.load(e[r]).catch((n) => n));
65
- return Promise.all(c);
66
- }
67
- /**
68
- * Clears the value at `key` from the cache, if it exists. Returns itself for
69
- * method chaining.
70
- */
71
- clear(e) {
72
- const c = this._cacheMap;
73
- if (c) {
74
- const r = this._cacheKeyFn(e);
75
- c.delete(r);
76
- }
77
- return this;
78
- }
79
- /**
80
- * Clears the entire cache. To be used when some event results in unknown
81
- * invalidations across this particular `DataLoader`. Returns itself for
82
- * method chaining.
83
- */
84
- clearAll() {
85
- const e = this._cacheMap;
86
- return e && e.clear(), this;
87
- }
88
- /**
89
- * Adds the provided key and value to the cache. If the key already
90
- * exists, no change is made. Returns itself for method chaining.
91
- *
92
- * To prime the cache with an error at a key, provide an Error instance.
93
- */
94
- prime(e, c) {
95
- const r = this._cacheMap;
96
- if (r) {
97
- const n = this._cacheKeyFn(e);
98
- if (r.get(n) === void 0) {
99
- let a;
100
- c instanceof Error ? (a = Promise.reject(c), a.catch(() => {
101
- })) : a = Promise.resolve(c), r.set(n, a);
102
- }
103
- }
104
- return this;
105
- }
106
- }
107
- const y = (
108
- /** @ts-ignore */
109
- typeof process == "object" && typeof process.nextTick == "function" ? function(t) {
110
- o || (o = Promise.resolve()), o.then(() => {
111
- process.nextTick(t);
112
- });
113
- } : (
114
- // @ts-ignore
115
- typeof setImmediate == "function" ? function(t) {
116
- setImmediate(t);
117
- } : function(t) {
118
- setTimeout(t);
119
- }
120
- )
121
- );
122
- let o;
123
- function d(t) {
124
- const e = t._batch;
125
- if (e !== null && !e.hasDispatched && e.keys.length < t._maxBatchSize)
126
- return e;
127
- const c = { hasDispatched: !1, keys: [], callbacks: [] };
128
- return t._batch = c, t._batchScheduleFn(() => {
129
- m(t, c);
130
- }), c;
131
- }
132
- function m(t, e) {
133
- if (e.hasDispatched = !0, e.keys.length === 0) {
134
- u(e);
135
- return;
136
- }
137
- let c;
138
- try {
139
- c = t._batchLoadFn(e.keys);
140
- } catch (r) {
141
- return h(
142
- t,
143
- e,
144
- new TypeError(
145
- `DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function errored synchronously: ${String(r)}.`
146
- )
147
- );
148
- }
149
- if (!c || typeof c.then != "function")
150
- return h(
151
- t,
152
- e,
153
- new TypeError(
154
- `DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise: ${String(c)}.`
155
- )
156
- );
157
- Promise.resolve(c).then((r) => {
158
- if (!l(r))
159
- throw new TypeError(
160
- `DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array: ${String(r)}.`
161
- );
162
- if (r.length !== e.keys.length)
163
- throw new TypeError(
164
- `DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys.
165
-
166
- Keys:
167
- ${String(e.keys)}
168
-
169
- Values:
170
- ${String(r)}`
171
- );
172
- u(e);
173
- for (let n = 0; n < e.callbacks.length; n++) {
174
- const a = r[n];
175
- a instanceof Error ? e.callbacks[n].reject(a) : e.callbacks[n].resolve(a);
176
- }
177
- }).catch((r) => {
178
- h(t, e, r);
179
- });
180
- }
181
- function h(t, e, c) {
182
- u(e);
183
- for (let r = 0; r < e.keys.length; r++)
184
- t.clear(e.keys[r]), e.callbacks[r].reject(c);
185
- }
186
- function u(t) {
187
- if (t.cacheHits)
188
- for (let e = 0; e < t.cacheHits.length; e++)
189
- t.cacheHits[e]();
190
- }
191
- function p(t) {
192
- if (!(!t || t.batch !== !1))
193
- return 1;
194
- const c = t && t.maxBatchSize;
195
- if (c === void 0)
196
- return 1 / 0;
197
- if (typeof c != "number" || c < 1)
198
- throw new TypeError(`maxBatchSize must be a positive number: ${c}`);
199
- return c;
200
- }
201
- function w(t) {
202
- const e = t && t.batchScheduleFn;
203
- if (e === void 0)
204
- return y;
205
- if (typeof e != "function")
206
- throw new TypeError(`batchScheduleFn must be a function: ${e}`);
207
- return e;
208
- }
209
- function g(t) {
210
- const e = t && t.cacheKeyFn;
211
- if (e === void 0)
212
- return (c) => c;
213
- if (typeof e != "function")
214
- throw new TypeError(`cacheKeyFn must be a function: ${e}`);
215
- return e;
216
- }
217
- function b(t) {
218
- if (!(!t || t.cache !== !1))
219
- return null;
220
- const c = t && t.cacheMap;
221
- if (c === void 0)
222
- return /* @__PURE__ */ new Map();
223
- if (c !== null) {
224
- const n = ["get", "set", "delete", "clear"].filter(
225
- (a) => c && typeof c[a] != "function"
226
- );
227
- if (n.length !== 0)
228
- throw new TypeError("Custom cacheMap missing methods: " + n.join(", "));
229
- }
230
- return c;
231
- }
232
- function P(t) {
233
- return t && t.name ? t.name : null;
234
- }
235
- function l(t) {
236
- return typeof t == "object" && t !== null && "length" in t && typeof t.length == "number" && (t.length === 0 || t.length > 0 && Object.prototype.hasOwnProperty.call(t, t.length - 1));
237
- }
1
+ import { bcs as t } from "./index364.js";
2
+ import { TransactionKind as a, TransactionData as e, TypeTag as n, TransactionExpiration as r, TransactionDataV1 as i, SuiObjectRef as o, StructTag as s, SharedObjectRef as c, SenderSignedTransaction as u, SenderSignedData as g, PublicKey as l, ProgrammableTransaction as m, ProgrammableMoveCall as S, PasskeyAuthenticator as b, Owner as d, ObjectDigest as p, ObjectArg as T, MultiSigPublicKey as f, MultiSigPkMap as U, MultiSig as A, IntentVersion as M, IntentScope as P, IntentMessage as D, Intent as I, GasData as O, CompressedSignature as j, Command as y, CallArg as C, Argument as B, AppId as E, Address as K } from "./index370.js";
3
+ import { TransactionEffects as h } from "./index371.js";
4
+ const V = {
5
+ ...t,
6
+ U8: t.u8(),
7
+ U16: t.u16(),
8
+ U32: t.u32(),
9
+ U64: t.u64(),
10
+ U128: t.u128(),
11
+ U256: t.u256(),
12
+ ULEB128: t.uleb128(),
13
+ Bool: t.bool(),
14
+ String: t.string(),
15
+ Address: K,
16
+ AppId: E,
17
+ Argument: B,
18
+ CallArg: C,
19
+ Command: y,
20
+ CompressedSignature: j,
21
+ GasData: O,
22
+ Intent: I,
23
+ IntentMessage: D,
24
+ IntentScope: P,
25
+ IntentVersion: M,
26
+ MultiSig: A,
27
+ MultiSigPkMap: U,
28
+ MultiSigPublicKey: f,
29
+ ObjectArg: T,
30
+ ObjectDigest: p,
31
+ Owner: d,
32
+ PasskeyAuthenticator: b,
33
+ ProgrammableMoveCall: S,
34
+ ProgrammableTransaction: m,
35
+ PublicKey: l,
36
+ SenderSignedData: g,
37
+ SenderSignedTransaction: u,
38
+ SharedObjectRef: c,
39
+ StructTag: s,
40
+ SuiObjectRef: o,
41
+ TransactionData: e,
42
+ TransactionDataV1: i,
43
+ TransactionEffects: h,
44
+ TransactionExpiration: r,
45
+ TransactionKind: a,
46
+ TypeTag: n
47
+ };
238
48
  export {
239
- k as DataLoader
49
+ V as bcs
240
50
  };
package/dist/index320.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index364.cjs"),e=require("./index370.cjs"),a=require("./index371.cjs"),n={...t.bcs,U8:t.bcs.u8(),U16:t.bcs.u16(),U32:t.bcs.u32(),U64:t.bcs.u64(),U128:t.bcs.u128(),U256:t.bcs.u256(),ULEB128:t.bcs.uleb128(),Bool:t.bcs.bool(),String:t.bcs.string(),Address:e.Address,AppId:e.AppId,Argument:e.Argument,CallArg:e.CallArg,Command:e.Command,CompressedSignature:e.CompressedSignature,GasData:e.GasData,Intent:e.Intent,IntentMessage:e.IntentMessage,IntentScope:e.IntentScope,IntentVersion:e.IntentVersion,MultiSig:e.MultiSig,MultiSigPkMap:e.MultiSigPkMap,MultiSigPublicKey:e.MultiSigPublicKey,ObjectArg:e.ObjectArg,ObjectDigest:e.ObjectDigest,Owner:e.Owner,PasskeyAuthenticator:e.PasskeyAuthenticator,ProgrammableMoveCall:e.ProgrammableMoveCall,ProgrammableTransaction:e.ProgrammableTransaction,PublicKey:e.PublicKey,SenderSignedData:e.SenderSignedData,SenderSignedTransaction:e.SenderSignedTransaction,SharedObjectRef:e.SharedObjectRef,StructTag:e.StructTag,SuiObjectRef:e.SuiObjectRef,TransactionData:e.TransactionData,TransactionDataV1:e.TransactionDataV1,TransactionEffects:a.TransactionEffects,TransactionExpiration:e.TransactionExpiration,TransactionKind:e.TransactionKind,TypeTag:e.TypeTag};exports.bcs=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("./index304.cjs"),I=require("./index117.cjs"),w=require("./index372.cjs"),M=require("./index306.cjs"),b=require("./index309.cjs"),m=require("./index373.cjs"),U=require("./index317.cjs"),S=50,T=1000n,R=5e10;function $(n){return async function(r,a,s){return await A(r,n),await E(r,n),a.onlyTransactionKind||(await _(r,n),await k(r,n),await P(r,n)),await s()}}async function _(n,c){n.gasConfig.price||(n.gasConfig.price=String(await c.getReferenceGasPrice()))}async function k(n,c){if(n.gasConfig.budget)return;const r=await c.dryRunTransactionBlock({transactionBlock:n.build({overrides:{gasData:{budget:String(R),payment:[]}}})});if(r.effects.status.status!=="success")throw new Error(`Dry run failed, could not automatically determine a budget: ${r.effects.status.error}`,{cause:r});const a=T*BigInt(n.gasConfig.price||1n),s=BigInt(r.effects.gasUsed.computationCost)+a,d=s+BigInt(r.effects.gasUsed.storageCost)-BigInt(r.effects.gasUsed.storageRebate);n.gasConfig.budget=String(d>s?d:s)}async function P(n,c){if(!n.gasConfig.payment){const a=(await c.getCoins({owner:n.gasConfig.owner||n.sender,coinType:w.SUI_TYPE_ARG})).data.filter(s=>!n.inputs.find(g=>{var i;return(i=g.Object)!=null&&i.ImmOrOwnedObject?s.coinObjectId===g.Object.ImmOrOwnedObject.objectId:!1})).map(s=>({objectId:s.coinObjectId,digest:s.digest,version:s.version}));if(!a.length)throw new Error("No valid gas coins found for the transaction.");n.gasConfig.payment=a.map(s=>j.parse(M.ObjectRefSchema,s))}}async function E(n,c){const r=n.inputs.filter(e=>{var t;return e.UnresolvedObject&&!(e.UnresolvedObject.version||(t=e.UnresolvedObject)!=null&&t.initialSharedVersion)}),a=[...new Set(r.map(e=>I.normalizeSuiObjectId(e.UnresolvedObject.objectId)))],s=a.length?U.chunk(a,S):[],d=(await Promise.all(s.map(e=>c.multiGetObjects({ids:e,options:{showOwner:!0}})))).flat(),g=new Map(a.map((e,t)=>[e,d[t]])),i=Array.from(g).filter(([e,t])=>t.error).map(([e,t])=>JSON.stringify(t.error));if(i.length)throw new Error(`The following input objects are invalid: ${i.join(", ")}`);const l=d.map(e=>{if(e.error||!e.data)throw new Error(`Failed to fetch object: ${e.error}`);const t=e.data.owner,f=t&&typeof t=="object"?"Shared"in t?t.Shared.initial_shared_version:"ConsensusAddressOwner"in t?t.ConsensusAddressOwner.start_version:null:null;return{objectId:e.data.objectId,digest:e.data.digest,version:e.data.version,initialSharedVersion:f}}),v=new Map(a.map((e,t)=>[e,l[t]]));for(const[e,t]of n.inputs.entries()){if(!t.UnresolvedObject)continue;let f;const u=I.normalizeSuiAddress(t.UnresolvedObject.objectId),o=v.get(u);t.UnresolvedObject.initialSharedVersion??(o==null?void 0:o.initialSharedVersion)?f=b.Inputs.SharedObjectRef({objectId:u,initialSharedVersion:t.UnresolvedObject.initialSharedVersion||(o==null?void 0:o.initialSharedVersion),mutable:t.UnresolvedObject.mutable||B(n,e)}):V(n,e)&&(f=b.Inputs.ReceivingRef({objectId:u,digest:t.UnresolvedObject.digest??(o==null?void 0:o.digest),version:t.UnresolvedObject.version??(o==null?void 0:o.version)})),n.inputs[n.inputs.indexOf(t)]=f??b.Inputs.ObjectRef({objectId:u,digest:t.UnresolvedObject.digest??(o==null?void 0:o.digest),version:t.UnresolvedObject.version??(o==null?void 0:o.version)})}}async function A(n,c){const{inputs:r,commands:a}=n,s=[],d=new Set;a.forEach(i=>{if(i.MoveCall){if(i.MoveCall._argumentTypes)return;if(i.MoveCall.arguments.map(e=>e.$kind==="Input"?n.inputs[e.Input]:null).some(e=>(e==null?void 0:e.UnresolvedPure)||(e==null?void 0:e.UnresolvedObject)&&typeof(e==null?void 0:e.UnresolvedObject.mutable)!="boolean")){const e=`${i.MoveCall.package}::${i.MoveCall.module}::${i.MoveCall.function}`;d.add(e),s.push(i.MoveCall)}}});const g=new Map;d.size>0&&await Promise.all([...d].map(async i=>{const[l,v,e]=i.split("::"),t=await c.getNormalizedMoveFunction({package:l,module:v,function:e});g.set(i,t.parameters.map(f=>m.normalizedTypeToMoveTypeSignature(f)))})),s.length&&await Promise.all(s.map(async i=>{const l=g.get(`${i.package}::${i.module}::${i.function}`);if(!l)return;const e=l.length>0&&m.isTxContext(l.at(-1))?l.slice(0,l.length-1):l;i._argumentTypes=e})),a.forEach(i=>{if(!i.MoveCall)return;const l=i.MoveCall,v=`${l.package}::${l.module}::${l.function}`,e=l._argumentTypes;if(e){if(e.length!==i.MoveCall.arguments.length)throw new Error(`Incorrect number of arguments for ${v}`);e.forEach((t,f)=>{var y,h;const u=l.arguments[f];if(u.$kind!=="Input")return;const o=r[u.Input];if(!o.UnresolvedPure&&!o.UnresolvedObject)return;const p=((y=o.UnresolvedPure)==null?void 0:y.value)??((h=o.UnresolvedObject)==null?void 0:h.objectId),O=m.getPureBcsSchema(t.body);if(O){u.type="pure",r[r.indexOf(o)]=b.Inputs.Pure(O.serialize(p));return}if(typeof p!="string")throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(p,null,2)}`);u.type="object";const C=o.UnresolvedPure?{$kind:"UnresolvedObject",UnresolvedObject:{objectId:p}}:o;r[u.Input]=C})}})}function B(n,c){let r=!1;return n.getInputUses(c,(a,s)=>{if(s.MoveCall&&s.MoveCall._argumentTypes){const d=s.MoveCall.arguments.indexOf(a);r=s.MoveCall._argumentTypes[d].ref!=="&"||r}(s.$kind==="MakeMoveVec"||s.$kind==="MergeCoins"||s.$kind==="SplitCoins"||s.$kind==="TransferObjects")&&(r=!0)}),r}function V(n,c){let r=!1;return n.getInputUses(c,(a,s)=>{if(s.MoveCall&&s.MoveCall._argumentTypes){const d=s.MoveCall.arguments.indexOf(a);r=z(s.MoveCall._argumentTypes[d])||r}}),r}function z(n){return typeof n.body!="object"||!("datatype"in n.body)?!1:n.body.datatype.package==="0x2"&&n.body.datatype.module==="transfer"&&n.body.datatype.type==="Receiving"}exports.jsonRpcClientResolveTransactionPlugin=$;