@keplr-wallet/hooks-starknet 0.12.133-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/.eslintignore +2 -0
  2. package/.prettierignore +2 -0
  3. package/LICENSE +209 -0
  4. package/build/index.d.ts +1 -0
  5. package/build/index.js +18 -0
  6. package/build/index.js.map +1 -0
  7. package/build/tx/amount.d.ts +27 -0
  8. package/build/tx/amount.js +230 -0
  9. package/build/tx/amount.js.map +1 -0
  10. package/build/tx/chain.d.ts +11 -0
  11. package/build/tx/chain.js +37 -0
  12. package/build/tx/chain.js.map +1 -0
  13. package/build/tx/errors.d.ts +48 -0
  14. package/build/tx/errors.js +132 -0
  15. package/build/tx/errors.js.map +1 -0
  16. package/build/tx/fee.d.ts +30 -0
  17. package/build/tx/fee.js +167 -0
  18. package/build/tx/fee.js.map +1 -0
  19. package/build/tx/gas-simulator.d.ts +72 -0
  20. package/build/tx/gas-simulator.js +491 -0
  21. package/build/tx/gas-simulator.js.map +1 -0
  22. package/build/tx/gas.d.ts +14 -0
  23. package/build/tx/gas.js +116 -0
  24. package/build/tx/gas.js.map +1 -0
  25. package/build/tx/index.d.ts +12 -0
  26. package/build/tx/index.js +29 -0
  27. package/build/tx/index.js.map +1 -0
  28. package/build/tx/noop-amount.d.ts +20 -0
  29. package/build/tx/noop-amount.js +90 -0
  30. package/build/tx/noop-amount.js.map +1 -0
  31. package/build/tx/recipient.d.ts +12 -0
  32. package/build/tx/recipient.js +80 -0
  33. package/build/tx/recipient.js.map +1 -0
  34. package/build/tx/send-tx.d.ts +9 -0
  35. package/build/tx/send-tx.js +22 -0
  36. package/build/tx/send-tx.js.map +1 -0
  37. package/build/tx/sender.d.ts +14 -0
  38. package/build/tx/sender.js +88 -0
  39. package/build/tx/sender.js.map +1 -0
  40. package/build/tx/types.d.ts +63 -0
  41. package/build/tx/types.js +3 -0
  42. package/build/tx/types.js.map +1 -0
  43. package/build/tx/validate.d.ts +11 -0
  44. package/build/tx/validate.js +52 -0
  45. package/build/tx/validate.js.map +1 -0
  46. package/jest.config.js +5 -0
  47. package/package.json +43 -0
  48. package/src/index.ts +1 -0
  49. package/src/tx/amount.ts +275 -0
  50. package/src/tx/chain.ts +32 -0
  51. package/src/tx/errors.ts +127 -0
  52. package/src/tx/fee.ts +209 -0
  53. package/src/tx/gas-simulator.ts +571 -0
  54. package/src/tx/gas.ts +131 -0
  55. package/src/tx/index.ts +12 -0
  56. package/src/tx/noop-amount.ts +92 -0
  57. package/src/tx/recipient.ts +82 -0
  58. package/src/tx/send-tx.ts +53 -0
  59. package/src/tx/sender.ts +104 -0
  60. package/src/tx/types.ts +97 -0
  61. package/src/tx/validate.ts +70 -0
  62. package/tsconfig.json +13 -0
@@ -0,0 +1,491 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.useGasSimulator = exports.GasSimulator = void 0;
10
+ const mobx_1 = require("mobx");
11
+ const react_1 = require("react");
12
+ const cosmos_1 = require("@keplr-wallet/cosmos");
13
+ const chain_1 = require("./chain");
14
+ const simple_fetch_1 = require("@keplr-wallet/simple-fetch");
15
+ class GasSimulatorState {
16
+ constructor() {
17
+ this._outdatedCosmosSdk = false;
18
+ // If the initialGasEstimated is null, it means that there is no value stored or being loaded.
19
+ this._initialGasEstimated = null;
20
+ this._isInitialized = false;
21
+ this._recentGasEstimated = undefined;
22
+ this._tx = undefined;
23
+ this._stdFee = undefined;
24
+ this._error = undefined;
25
+ (0, mobx_1.makeObservable)(this);
26
+ }
27
+ get outdatedCosmosSdk() {
28
+ return this._outdatedCosmosSdk;
29
+ }
30
+ setIsInitialized(value) {
31
+ this._isInitialized = value;
32
+ }
33
+ get isInitialized() {
34
+ return this._isInitialized;
35
+ }
36
+ setOutdatedCosmosSdk(value) {
37
+ this._outdatedCosmosSdk = value;
38
+ }
39
+ get initialGasEstimated() {
40
+ return this._initialGasEstimated;
41
+ }
42
+ setInitialGasEstimated(value) {
43
+ this._initialGasEstimated = value;
44
+ }
45
+ get recentGasEstimated() {
46
+ return this._recentGasEstimated;
47
+ }
48
+ setRecentGasEstimated(value) {
49
+ this._recentGasEstimated = value;
50
+ }
51
+ get tx() {
52
+ return this._tx;
53
+ }
54
+ refreshTx(tx) {
55
+ this._tx = tx;
56
+ }
57
+ get stdFee() {
58
+ return this._stdFee;
59
+ }
60
+ refreshStdFee(fee) {
61
+ this._stdFee = fee;
62
+ }
63
+ get error() {
64
+ return this._error;
65
+ }
66
+ setError(error) {
67
+ this._error = error;
68
+ }
69
+ static isZeroFee(amount) {
70
+ if (!amount) {
71
+ return true;
72
+ }
73
+ for (const coin of amount) {
74
+ if (coin.amount !== "0") {
75
+ return false;
76
+ }
77
+ }
78
+ return true;
79
+ }
80
+ }
81
+ __decorate([
82
+ mobx_1.observable
83
+ ], GasSimulatorState.prototype, "_outdatedCosmosSdk", void 0);
84
+ __decorate([
85
+ mobx_1.observable
86
+ ], GasSimulatorState.prototype, "_initialGasEstimated", void 0);
87
+ __decorate([
88
+ mobx_1.observable
89
+ ], GasSimulatorState.prototype, "_isInitialized", void 0);
90
+ __decorate([
91
+ mobx_1.observable
92
+ ], GasSimulatorState.prototype, "_recentGasEstimated", void 0);
93
+ __decorate([
94
+ mobx_1.observable.ref
95
+ ], GasSimulatorState.prototype, "_tx", void 0);
96
+ __decorate([
97
+ mobx_1.observable.ref
98
+ ], GasSimulatorState.prototype, "_stdFee", void 0);
99
+ __decorate([
100
+ mobx_1.observable.ref
101
+ ], GasSimulatorState.prototype, "_error", void 0);
102
+ __decorate([
103
+ mobx_1.action
104
+ ], GasSimulatorState.prototype, "setIsInitialized", null);
105
+ __decorate([
106
+ mobx_1.action
107
+ ], GasSimulatorState.prototype, "setOutdatedCosmosSdk", null);
108
+ __decorate([
109
+ mobx_1.action
110
+ ], GasSimulatorState.prototype, "setInitialGasEstimated", null);
111
+ __decorate([
112
+ mobx_1.action
113
+ ], GasSimulatorState.prototype, "setRecentGasEstimated", null);
114
+ __decorate([
115
+ mobx_1.action
116
+ ], GasSimulatorState.prototype, "refreshTx", null);
117
+ __decorate([
118
+ mobx_1.action
119
+ ], GasSimulatorState.prototype, "refreshStdFee", null);
120
+ __decorate([
121
+ mobx_1.action
122
+ ], GasSimulatorState.prototype, "setError", null);
123
+ class GasSimulator extends chain_1.TxChainSetter {
124
+ constructor(
125
+ // TODO: Add comment about the reason why kvStore field is not observable.
126
+ kvStore, chainGetter, initialChainId, gasConfig, feeConfig, initialKey,
127
+ // TODO: Add comment about the reason why simulateGasFn field is not observable.
128
+ simulateGasFn) {
129
+ super(chainGetter, initialChainId);
130
+ this.kvStore = kvStore;
131
+ this.gasConfig = gasConfig;
132
+ this.feeConfig = feeConfig;
133
+ this.initialKey = initialKey;
134
+ this.simulateGasFn = simulateGasFn;
135
+ this._gasAdjustmentValue = "1";
136
+ this._enabled = false;
137
+ this._forceDisabled = false;
138
+ this._forceDisableReason = undefined;
139
+ this._isSimulating = false;
140
+ // Key is the store key (probably, ${chainIdentifier}/${key})
141
+ this._stateMap = new Map();
142
+ this._disposers = [];
143
+ this._key = initialKey;
144
+ (0, mobx_1.makeObservable)(this);
145
+ this.init();
146
+ }
147
+ setKVStore(kvStore) {
148
+ this.kvStore = kvStore;
149
+ }
150
+ get key() {
151
+ return this._key;
152
+ }
153
+ setKey(value) {
154
+ this._key = value;
155
+ }
156
+ get isSimulating() {
157
+ return this._isSimulating;
158
+ }
159
+ setSimulateGasFn(simulateGasFn) {
160
+ this.simulateGasFn = simulateGasFn;
161
+ }
162
+ get enabled() {
163
+ if (this._forceDisabled) {
164
+ return false;
165
+ }
166
+ return this._enabled;
167
+ }
168
+ setEnabled(value) {
169
+ if (this._forceDisabled && value) {
170
+ console.log("Gas simulator is disabled by force. You can not enable the gas simulator");
171
+ return;
172
+ }
173
+ this._enabled = value;
174
+ }
175
+ get forceDisabled() {
176
+ return this._forceDisabled;
177
+ }
178
+ get forceDisableReason() {
179
+ return this._forceDisableReason;
180
+ }
181
+ forceDisable(valueOrReason) {
182
+ if (!valueOrReason) {
183
+ this._forceDisabled = false;
184
+ this._forceDisableReason = undefined;
185
+ }
186
+ else {
187
+ if (this.enabled) {
188
+ this.setEnabled(false);
189
+ }
190
+ this._forceDisabled = true;
191
+ if (typeof valueOrReason !== "boolean") {
192
+ this._forceDisableReason = valueOrReason;
193
+ }
194
+ }
195
+ }
196
+ get outdatedCosmosSdk() {
197
+ const key = this.storeKey;
198
+ const state = this.getState(key);
199
+ return state.outdatedCosmosSdk;
200
+ }
201
+ get error() {
202
+ const key = this.storeKey;
203
+ const state = this.getState(key);
204
+ return state.error;
205
+ }
206
+ get gasEstimated() {
207
+ const key = this.storeKey;
208
+ const state = this.getState(key);
209
+ if (state.recentGasEstimated != null) {
210
+ return state.recentGasEstimated;
211
+ }
212
+ if (state.initialGasEstimated != null) {
213
+ return state.initialGasEstimated;
214
+ }
215
+ return undefined;
216
+ }
217
+ get gasAdjustment() {
218
+ if (this._gasAdjustmentValue === "") {
219
+ return 0;
220
+ }
221
+ const num = parseFloat(this._gasAdjustmentValue);
222
+ if (Number.isNaN(num) || num < 0) {
223
+ return 0;
224
+ }
225
+ return num;
226
+ }
227
+ get gasAdjustmentValue() {
228
+ return this._gasAdjustmentValue;
229
+ }
230
+ setGasAdjustmentValue(gasAdjustment) {
231
+ if (typeof gasAdjustment === "number") {
232
+ if (gasAdjustment < 0 || gasAdjustment > 2) {
233
+ return;
234
+ }
235
+ this._gasAdjustmentValue = gasAdjustment.toString();
236
+ return;
237
+ }
238
+ if (gasAdjustment === "") {
239
+ this._gasAdjustmentValue = "";
240
+ return;
241
+ }
242
+ if (gasAdjustment.startsWith(".")) {
243
+ this._gasAdjustmentValue = "0" + gasAdjustment;
244
+ }
245
+ const num = parseFloat(gasAdjustment);
246
+ if (Number.isNaN(num) || num < 0 || num > 2) {
247
+ return;
248
+ }
249
+ this._gasAdjustmentValue = gasAdjustment;
250
+ }
251
+ init() {
252
+ this._disposers.push((0, mobx_1.autorun)(() => {
253
+ if (!this.enabled) {
254
+ return;
255
+ }
256
+ const key = this.storeKey;
257
+ const state = this.getState(key);
258
+ this.kvStore.get(key).then((saved) => {
259
+ if (saved) {
260
+ state.setInitialGasEstimated(saved);
261
+ }
262
+ state.setIsInitialized(true);
263
+ });
264
+ }));
265
+ // autorun is intentionally split.
266
+ // The main reason for this implementation is that the gas when paying the fee is somewhat different from when there is a zero fee.
267
+ // In order to calculate the gas more accurately, the fee should be included in the simulation,
268
+ // but in the current reactive logic, the gas change by the simulation changes the fee and causes the simulation again.
269
+ // Even though the implementation is not intuitive, the goals are
270
+ // - Every time the observable used in simulateGasFn is updated, the simulation is refreshed.
271
+ // - The simulation is refreshed only when changing from zero fee to paying fee or vice versa.
272
+ // - feemarket 등에서 문제를 일으켜서 fee의 currency 자체가 바뀔때도 refresh 하도록 수정되었다. 이 경우 원활한 처리를 위해서 (귀찮아서) storeKey setter에서 적용된다.
273
+ this._disposers.push((0, mobx_1.autorun)(() => {
274
+ if (!this.enabled) {
275
+ return;
276
+ }
277
+ try {
278
+ const key = this.storeKey;
279
+ const state = this.getState(key);
280
+ if (!state.isInitialized) {
281
+ return;
282
+ }
283
+ const tx = this.simulateGasFn();
284
+ // TODO
285
+ // const fee = this.feeConfig.toStdFee();
286
+ (0, mobx_1.runInAction)(() => {
287
+ if ((state.recentGasEstimated == null || state.error != null) &&
288
+ !state.outdatedCosmosSdk
289
+ // || GasSimulatorState.isZeroFee(state.stdFee?.amount) !==
290
+ // GasSimulatorState.isZeroFee(fee.amount)
291
+ ) {
292
+ state.refreshTx(tx);
293
+ // state.refreshStdFee(fee);
294
+ }
295
+ });
296
+ }
297
+ catch (e) {
298
+ console.log(e);
299
+ return;
300
+ }
301
+ }));
302
+ this._disposers.push((0, mobx_1.autorun)(() => {
303
+ // TODO: Add debounce logic?
304
+ const key = this.storeKey;
305
+ const state = this.getState(key);
306
+ if (!state.tx) {
307
+ return;
308
+ }
309
+ const promise = state.tx.simulate(state.stdFee);
310
+ (0, mobx_1.runInAction)(() => {
311
+ this._isSimulating = true;
312
+ });
313
+ promise
314
+ .then(({ gasUsed }) => {
315
+ // Changing the gas in the gas config definitely will make the reaction to the fee config,
316
+ // and, this reaction can potentially create a reaction in the amount config as well (Ex, when the "Max" option set).
317
+ // These potential reactions can create repeated meaningless reactions.
318
+ // To avoid this potential problem, change the value when there is a meaningful change in the gas estimated.
319
+ if (!state.recentGasEstimated ||
320
+ Math.abs(state.recentGasEstimated - gasUsed) /
321
+ state.recentGasEstimated >
322
+ 0.02) {
323
+ state.setRecentGasEstimated(gasUsed);
324
+ }
325
+ state.setOutdatedCosmosSdk(false);
326
+ state.setError(undefined);
327
+ this.kvStore.set(key, gasUsed).catch((e) => {
328
+ console.log(e);
329
+ });
330
+ })
331
+ .catch((e) => {
332
+ var _a, _b, _c;
333
+ console.log(e);
334
+ if ((0, simple_fetch_1.isSimpleFetchError)(e) && e.response) {
335
+ const response = e.response;
336
+ if (response.status === 400 &&
337
+ ((_a = response.data) === null || _a === void 0 ? void 0 : _a.message) &&
338
+ typeof response.data.message === "string" &&
339
+ response.data.message.includes("invalid empty tx")) {
340
+ state.setOutdatedCosmosSdk(true);
341
+ return;
342
+ }
343
+ let message = "";
344
+ const contentType = e.response.headers
345
+ ? e.response.headers.get("content-type") || ""
346
+ : "";
347
+ // Try to figure out the message from the response.
348
+ // If the contentType in the header is specified, try to use the message from the response.
349
+ if (contentType.startsWith("text/plain") &&
350
+ typeof e.response.data === "string") {
351
+ message = e.response.data;
352
+ }
353
+ // If the response is an object and "message" field exists, it is used as a message.
354
+ if (contentType.startsWith("application/json") &&
355
+ ((_b = e.response.data) === null || _b === void 0 ? void 0 : _b.message) &&
356
+ typeof ((_c = e.response.data) === null || _c === void 0 ? void 0 : _c.message) === "string") {
357
+ message = e.response.data.message;
358
+ }
359
+ if (message !== "") {
360
+ state.setError(new Error(message));
361
+ return;
362
+ }
363
+ }
364
+ state.setError(e);
365
+ })
366
+ .finally(() => {
367
+ (0, mobx_1.runInAction)(() => {
368
+ this._isSimulating = false;
369
+ });
370
+ });
371
+ }));
372
+ this._disposers.push((0, mobx_1.autorun)(() => {
373
+ if (this.enabled && this.gasEstimated != null) {
374
+ this.gasConfig.setValue(this.gasEstimated * this.gasAdjustment);
375
+ }
376
+ }));
377
+ }
378
+ dispose() {
379
+ for (const disposer of this._disposers) {
380
+ disposer();
381
+ }
382
+ }
383
+ get uiProperties() {
384
+ const key = this.storeKey;
385
+ const state = this.getState(key);
386
+ return {
387
+ warning: (() => {
388
+ if (this.outdatedCosmosSdk) {
389
+ return new Error("Outdated Cosmos SDK");
390
+ }
391
+ if (this.forceDisableReason) {
392
+ return this.forceDisableReason;
393
+ }
394
+ if (this.error) {
395
+ return this.error;
396
+ }
397
+ })(),
398
+ loadingState: (() => {
399
+ if (!this.enabled) {
400
+ return;
401
+ }
402
+ if (this.isSimulating) {
403
+ // If there is no saved result of the last simulation, user interaction is blocked.
404
+ return state.initialGasEstimated == null
405
+ ? "loading-block"
406
+ : "loading";
407
+ }
408
+ })(),
409
+ };
410
+ }
411
+ getState(key) {
412
+ if (!this._stateMap.has(key)) {
413
+ (0, mobx_1.runInAction)(() => {
414
+ this._stateMap.set(key, new GasSimulatorState());
415
+ });
416
+ }
417
+ return this._stateMap.get(key);
418
+ }
419
+ get storeKey() {
420
+ const chainIdentifier = cosmos_1.ChainIdHelper.parse(this.chainId);
421
+ const fees = "TODO";
422
+ // TODO
423
+ // const fees = this.feeConfig
424
+ // .toStdFee()
425
+ // .amount.map((coin) => coin.denom)
426
+ // .join("/");
427
+ return `${chainIdentifier.identifier}/${fees}/${this.key}}`;
428
+ }
429
+ }
430
+ __decorate([
431
+ mobx_1.observable
432
+ ], GasSimulator.prototype, "_key", void 0);
433
+ __decorate([
434
+ mobx_1.observable
435
+ ], GasSimulator.prototype, "_gasAdjustmentValue", void 0);
436
+ __decorate([
437
+ mobx_1.observable
438
+ ], GasSimulator.prototype, "_enabled", void 0);
439
+ __decorate([
440
+ mobx_1.observable
441
+ ], GasSimulator.prototype, "_forceDisabled", void 0);
442
+ __decorate([
443
+ mobx_1.observable
444
+ ], GasSimulator.prototype, "_forceDisableReason", void 0);
445
+ __decorate([
446
+ mobx_1.observable
447
+ ], GasSimulator.prototype, "_isSimulating", void 0);
448
+ __decorate([
449
+ mobx_1.observable.shallow
450
+ ], GasSimulator.prototype, "_stateMap", void 0);
451
+ __decorate([
452
+ mobx_1.action
453
+ ], GasSimulator.prototype, "setKey", null);
454
+ __decorate([
455
+ mobx_1.action
456
+ ], GasSimulator.prototype, "setEnabled", null);
457
+ __decorate([
458
+ mobx_1.action
459
+ ], GasSimulator.prototype, "forceDisable", null);
460
+ __decorate([
461
+ mobx_1.action
462
+ ], GasSimulator.prototype, "setGasAdjustmentValue", null);
463
+ __decorate([
464
+ mobx_1.computed
465
+ ], GasSimulator.prototype, "storeKey", null);
466
+ exports.GasSimulator = GasSimulator;
467
+ // CONTRACT: Use with `observer`
468
+ const useGasSimulator = (kvStore, chainGetter, chainId, gasConfig, feeConfig, key, simulateGasFn, initialDisabled) => {
469
+ const [gasSimulator] = (0, react_1.useState)(() => {
470
+ const gasSimulator = new GasSimulator(kvStore, chainGetter, chainId, gasConfig, feeConfig, key, simulateGasFn);
471
+ if (initialDisabled) {
472
+ gasSimulator.setEnabled(false);
473
+ }
474
+ else {
475
+ gasSimulator.setEnabled(true);
476
+ }
477
+ return gasSimulator;
478
+ });
479
+ gasSimulator.setKVStore(kvStore);
480
+ gasSimulator.setChain(chainId);
481
+ gasSimulator.setKey(key);
482
+ gasSimulator.setSimulateGasFn(simulateGasFn);
483
+ (0, react_1.useEffect)(() => {
484
+ return () => {
485
+ gasSimulator.dispose();
486
+ };
487
+ }, [gasSimulator]);
488
+ return gasSimulator;
489
+ };
490
+ exports.useGasSimulator = useGasSimulator;
491
+ //# sourceMappingURL=gas-simulator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gas-simulator.js","sourceRoot":"","sources":["../../src/tx/gas-simulator.ts"],"names":[],"mappings":";;;;;;;;;AACA,+BAQc;AACd,iCAA4C;AAE5C,iDAAqD;AACrD,mCAAwC;AAGxC,6DAAgE;AAKhE,MAAM,iBAAiB;IAqBrB;QAnBU,uBAAkB,GAAY,KAAK,CAAC;QAE9C,8FAA8F;QAEpF,yBAAoB,GAAkB,IAAI,CAAC;QAG3C,mBAAc,GAAY,KAAK,CAAC;QAGhC,wBAAmB,GAAuB,SAAS,CAAC;QAGpD,QAAG,GAA2B,SAAS,CAAC;QAExC,YAAO,GAAuB,SAAS,CAAC;QAExC,WAAM,GAAsB,SAAS,CAAC;QAG9C,IAAA,qBAAc,EAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAED,IAAI,iBAAiB;QACnB,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;IAGD,gBAAgB,CAAC,KAAc;QAC7B,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;IAC9B,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAGD,oBAAoB,CAAC,KAAc;QACjC,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;IAClC,CAAC;IAED,IAAI,mBAAmB;QACrB,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;IAGD,sBAAsB,CAAC,KAAa;QAClC,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC;IACpC,CAAC;IAED,IAAI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wC1B"}
@@ -0,0 +1,14 @@
1
+ import { IGasConfig, UIProperties } from "./types";
2
+ import { TxChainSetter } from "./chain";
3
+ import { ChainGetter } from "@keplr-wallet/stores";
4
+ export declare class GasConfig extends TxChainSetter implements IGasConfig {
5
+ protected _value: string;
6
+ protected _allowZeroGas?: boolean;
7
+ constructor(chainGetter: ChainGetter, initialChainId: string, initialGas?: number, allowZeroGas?: boolean);
8
+ get value(): string;
9
+ setValue(value: string | number): void;
10
+ get gas(): number;
11
+ get uiProperties(): UIProperties;
12
+ }
13
+ export declare const useGasConfig: (chainGetter: ChainGetter, chainId: string, initialGas?: number) => GasConfig;
14
+ export declare const useZeroAllowedGasConfig: (chainGetter: ChainGetter, chainId: string, initialGas?: number) => GasConfig;
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.useZeroAllowedGasConfig = exports.useGasConfig = exports.GasConfig = void 0;
10
+ const chain_1 = require("./chain");
11
+ const mobx_1 = require("mobx");
12
+ const react_1 = require("react");
13
+ class GasConfig extends chain_1.TxChainSetter {
14
+ constructor(chainGetter, initialChainId, initialGas, allowZeroGas) {
15
+ super(chainGetter, initialChainId);
16
+ /*
17
+ This field is used to handle the value from the input more flexibly.
18
+ We use string because there is no guarantee that only number is input in input component.
19
+ */
20
+ this._value = "";
21
+ /*
22
+ There are services that sometimes use invalid tx to sign arbitrary data on the sign page.
23
+ In this case, there is no obligation to deal with it, but 0 gas is favorably allowed. This option is used for this case.
24
+ */
25
+ this._allowZeroGas = undefined;
26
+ if (initialGas) {
27
+ this._value = initialGas.toString();
28
+ }
29
+ this._allowZeroGas = allowZeroGas;
30
+ (0, mobx_1.makeObservable)(this);
31
+ }
32
+ get value() {
33
+ return this._value;
34
+ }
35
+ setValue(value) {
36
+ if (typeof value === "number") {
37
+ this._value = Math.ceil(value).toString();
38
+ }
39
+ else {
40
+ this._value = value;
41
+ }
42
+ }
43
+ get gas() {
44
+ if (this.value.trim() === "") {
45
+ return 0;
46
+ }
47
+ const num = Number.parseInt(this.value);
48
+ if (Number.isNaN(num)) {
49
+ return 0;
50
+ }
51
+ return num;
52
+ }
53
+ get uiProperties() {
54
+ if (this.value.trim() === "") {
55
+ return {
56
+ error: new Error("Gas not set"),
57
+ };
58
+ }
59
+ const parsed = Number.parseFloat(this.value);
60
+ if (Number.isNaN(parsed)) {
61
+ return {
62
+ error: new Error("Gas is not valid number"),
63
+ };
64
+ }
65
+ if (this.value.includes(".") || !Number.isInteger(parsed)) {
66
+ return {
67
+ error: new Error("Gas is not integer"),
68
+ };
69
+ }
70
+ if (!this._allowZeroGas) {
71
+ if (this.gas <= 0) {
72
+ return {
73
+ error: new Error("Gas should be greater than 0"),
74
+ };
75
+ }
76
+ }
77
+ else {
78
+ if (this.gas < 0) {
79
+ return {
80
+ error: new Error("Gas should be greater or equal than 0"),
81
+ };
82
+ }
83
+ }
84
+ return {};
85
+ }
86
+ }
87
+ __decorate([
88
+ mobx_1.observable
89
+ ], GasConfig.prototype, "_value", void 0);
90
+ __decorate([
91
+ mobx_1.observable
92
+ ], GasConfig.prototype, "_allowZeroGas", void 0);
93
+ __decorate([
94
+ mobx_1.action
95
+ ], GasConfig.prototype, "setValue", null);
96
+ __decorate([
97
+ mobx_1.computed
98
+ ], GasConfig.prototype, "uiProperties", null);
99
+ exports.GasConfig = GasConfig;
100
+ const useGasConfig = (chainGetter, chainId, initialGas) => {
101
+ const [txConfig] = (0, react_1.useState)(() => new GasConfig(chainGetter, chainId, initialGas));
102
+ txConfig.setChain(chainId);
103
+ return txConfig;
104
+ };
105
+ exports.useGasConfig = useGasConfig;
106
+ /*
107
+ There are services that sometimes use invalid tx to sign arbitrary data on the sign page.
108
+ In this case, there is no obligation to deal with it, but 0 gas is favorably allowed. This option is used for this case.
109
+ */
110
+ const useZeroAllowedGasConfig = (chainGetter, chainId, initialGas) => {
111
+ const [txConfig] = (0, react_1.useState)(() => new GasConfig(chainGetter, chainId, initialGas, true));
112
+ txConfig.setChain(chainId);
113
+ return txConfig;
114
+ };
115
+ exports.useZeroAllowedGasConfig = useZeroAllowedGasConfig;
116
+ //# sourceMappingURL=gas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gas.js","sourceRoot":"","sources":["../../src/tx/gas.ts"],"names":[],"mappings":";;;;;;;;;AACA,mCAAwC;AAExC,+BAAoE;AACpE,iCAAiC;AAEjC,MAAa,SAAU,SAAQ,qBAAa;IAe1C,YACE,WAAwB,EACxB,cAAsB,EACtB,UAAmB,EACnB,YAAsB;QAEtB,KAAK,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;QApBrC;;;WAGG;QAEO,WAAM,GAAW,EAAE,CAAC;QAE9B;;;WAGG;QAEO,kBAAa,GAAa,SAAS,CAAC;QAU5C,IAAI,UAAU,EAAE;YACd,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;SACrC;QACD,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAElC,IAAA,qBAAc,EAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAGD,QAAQ,CAAC,KAAsB;QAC7B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC;SAC3C;aAAM;YACL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AC;aACH;SACF;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAxFW;IADT,iBAAU;yCACmB;AAOpB;IADT,iBAAU;gDACmC;AAuB9C;IADC,aAAM;yCAON;AAgBD;IADC,eAAQ;6CAoCR;AA7FH,8BA8FC;AAEM,MAAM,YAAY,GAAG,CAC1B,WAAwB,EACxB,OAAe,EACf,UAAmB,EACnB,EAAE;IACF,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EACzB,GAAG,EAAE,CAAC,IAAI,SAAS,CAAC,WAAW,EAAE,OAAO,EAAE,UAAU,CAAC,CACtD,CAAC;IACF,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAE3B,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAXW,QAAA,YAAY,gBAWvB;AAEF;;;GAGG;AACI,MAAM,uBAAuB,GAAG,CACrC,WAAwB,EACxB,OAAe,EACf,UAAmB,EACnB,EAAE;IACF,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EACzB,GAAG,EAAE,CAAC,IAAI,SAAS,CAAC,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,CAC5D,CAAC;IACF,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAE3B,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAXW,QAAA,uBAAuB,2BAWlC"}
@@ -0,0 +1,12 @@
1
+ export * from "./errors";
2
+ export * from "./types";
3
+ export * from "./fee";
4
+ export * from "./gas";
5
+ export * from "./recipient";
6
+ export * from "./amount";
7
+ export * from "./sender";
8
+ export * from "./send-tx";
9
+ export * from "./chain";
10
+ export * from "./gas-simulator";
11
+ export * from "./validate";
12
+ export * from "./noop-amount";