@dydxprotocol/v4-client-js 1.1.12 → 1.1.14

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 (150) hide show
  1. package/.eslintrc.js +3 -5
  2. package/.prettierignore +3 -0
  3. package/.prettierrc.json +6 -0
  4. package/.telescope.json +2 -4
  5. package/.vscode/launch.json +10 -10
  6. package/README.md +3 -1
  7. package/__native__/__ios__/v4-native-client.js +2648 -806
  8. package/__tests__/helpers/constants.ts +10 -8
  9. package/__tests__/lib/helpers.test.ts +22 -23
  10. package/__tests__/lib/util.test.ts +2 -8
  11. package/__tests__/lib/validation.test.ts +23 -26
  12. package/__tests__/modules/client/Transfers.test.ts +4 -19
  13. package/__tests__/modules/client/ValidatorPostEndpoints.test.ts +2 -5
  14. package/__tests__/modules/client/constants.ts +4 -2
  15. package/__tests__/modules/onboarding.test.ts +9 -7
  16. package/build/__tests__/helpers/constants.js +7 -7
  17. package/build/__tests__/lib/helpers.test.js +2 -6
  18. package/build/__tests__/lib/util.test.js +1 -1
  19. package/build/__tests__/lib/validation.test.js +3 -11
  20. package/build/__tests__/modules/client/Transfers.test.js +1 -1
  21. package/build/__tests__/modules/client/ValidatorPostEndpoints.test.js +2 -2
  22. package/build/__tests__/modules/client/constants.js +1 -1
  23. package/build/__tests__/modules/onboarding.test.js +2 -3
  24. package/build/examples/account_endpoints.js +4 -3
  25. package/build/examples/composite_example.js +5 -4
  26. package/build/examples/constants.js +1 -1
  27. package/build/examples/faucet_endpoint.js +4 -3
  28. package/build/examples/long_term_order_cancel_example.js +4 -3
  29. package/build/examples/markets_endpoints.js +4 -3
  30. package/build/examples/native_examples.js +4 -3
  31. package/build/examples/noble_example.js +1 -1
  32. package/build/examples/optimal_node.js +4 -12
  33. package/build/examples/short_term_order_cancel_example.js +4 -3
  34. package/build/examples/short_term_order_composite_example.js +4 -3
  35. package/build/examples/test.js +5 -4
  36. package/build/examples/transfer_example_deposit.js +4 -3
  37. package/build/examples/transfer_example_send.js +1 -1
  38. package/build/examples/transfer_example_subaccount_transfer.js +4 -3
  39. package/build/examples/transfer_example_withdraw.js +4 -3
  40. package/build/examples/transfer_example_withdraw_other.js +1 -1
  41. package/build/examples/utility_endpoints.js +4 -3
  42. package/build/examples/validator_get_example.js +15 -9
  43. package/build/examples/validator_post_example.js +4 -3
  44. package/build/examples/wallet_address.js +5 -4
  45. package/build/examples/websocket_example.js +1 -1
  46. package/build/src/clients/composite-client.d.ts +225 -224
  47. package/build/src/clients/composite-client.js +242 -237
  48. package/build/src/clients/constants.d.ts +3 -0
  49. package/build/src/clients/constants.js +6 -2
  50. package/build/src/clients/faucet-client.d.ts +4 -4
  51. package/build/src/clients/faucet-client.js +5 -5
  52. package/build/src/clients/helpers/chain-helpers.js +1 -1
  53. package/build/src/clients/helpers/request-helpers.js +5 -4
  54. package/build/src/clients/indexer-client.js +1 -1
  55. package/build/src/clients/lib/axios/axiosRequest.js +1 -1
  56. package/build/src/clients/lib/axios/errors.js +1 -1
  57. package/build/src/clients/lib/cctpProto.d.ts +2 -2
  58. package/build/src/clients/lib/cctpProto.js +287 -237
  59. package/build/src/clients/lib/errors.js +1 -1
  60. package/build/src/clients/modules/account.js +1 -1
  61. package/build/src/clients/modules/composer.d.ts +4 -0
  62. package/build/src/clients/modules/composer.js +39 -3
  63. package/build/src/clients/modules/get.d.ts +10 -3
  64. package/build/src/clients/modules/get.js +41 -54
  65. package/build/src/clients/modules/local-wallet.js +1 -1
  66. package/build/src/clients/modules/post.d.ts +3 -0
  67. package/build/src/clients/modules/post.js +34 -18
  68. package/build/src/clients/modules/proto-includes.d.ts +1 -0
  69. package/build/src/clients/modules/proto-includes.js +3 -2
  70. package/build/src/clients/modules/rest.js +1 -1
  71. package/build/src/clients/modules/signer.js +1 -1
  72. package/build/src/clients/modules/tendermintClient.d.ts +5 -5
  73. package/build/src/clients/modules/tendermintClient.js +6 -6
  74. package/build/src/clients/native.js +4 -7
  75. package/build/src/clients/noble-client.js +1 -1
  76. package/build/src/clients/socket-client.js +1 -1
  77. package/build/src/clients/subaccount.js +1 -1
  78. package/build/src/clients/types.d.ts +1 -1
  79. package/build/src/clients/types.js +1 -1
  80. package/build/src/clients/validator-client.d.ts +12 -12
  81. package/build/src/clients/validator-client.js +13 -13
  82. package/build/src/lib/errors.js +1 -1
  83. package/build/src/lib/onboarding.js +1 -1
  84. package/build/src/lib/utils.js +3 -3
  85. package/build/src/lib/validation.js +5 -4
  86. package/build/src/network_optimizer.js +10 -11
  87. package/build/src/types.d.ts +1 -1
  88. package/build/src/types.js +1 -1
  89. package/examples/account_endpoints.ts +5 -4
  90. package/examples/composite_example.ts +12 -7
  91. package/examples/constants.ts +10 -4
  92. package/examples/faucet_endpoint.ts +5 -4
  93. package/examples/human_readable_orders.json +85 -85
  94. package/examples/human_readable_short_term_orders.json +41 -41
  95. package/examples/long_term_order_cancel_example.ts +11 -6
  96. package/examples/markets_endpoints.ts +5 -4
  97. package/examples/native_examples.ts +8 -7
  98. package/examples/noble_example.ts +11 -23
  99. package/examples/optimal_node.ts +4 -14
  100. package/examples/raw_orders.json +128 -128
  101. package/examples/short_term_order_cancel_example.ts +7 -8
  102. package/examples/short_term_order_composite_example.ts +7 -8
  103. package/examples/test.ts +12 -7
  104. package/examples/transfer_example_deposit.ts +6 -9
  105. package/examples/transfer_example_send.ts +2 -10
  106. package/examples/transfer_example_subaccount_transfer.ts +6 -11
  107. package/examples/transfer_example_withdraw.ts +6 -9
  108. package/examples/transfer_example_withdraw_other.ts +1 -5
  109. package/examples/utility_endpoints.ts +5 -4
  110. package/examples/validator_get_example.ts +19 -10
  111. package/examples/validator_post_example.ts +7 -9
  112. package/examples/wallet_address.ts +6 -5
  113. package/examples/websocket_example.ts +5 -1
  114. package/package.json +4 -1
  115. package/src/clients/composite-client.ts +279 -330
  116. package/src/clients/constants.ts +38 -26
  117. package/src/clients/faucet-client.ts +5 -8
  118. package/src/clients/helpers/chain-helpers.ts +10 -6
  119. package/src/clients/helpers/request-helpers.ts +6 -5
  120. package/src/clients/indexer-client.ts +34 -34
  121. package/src/clients/lib/axios/axiosRequest.ts +4 -7
  122. package/src/clients/lib/axios/errors.ts +16 -21
  123. package/src/clients/lib/cctpProto.ts +655 -387
  124. package/src/clients/lib/errors.ts +8 -17
  125. package/src/clients/modules/account.ts +4 -12
  126. package/src/clients/modules/composer.ts +61 -20
  127. package/src/clients/modules/get.ts +71 -89
  128. package/src/clients/modules/local-wallet.ts +41 -56
  129. package/src/clients/modules/post.ts +664 -634
  130. package/src/clients/modules/proto-includes.ts +1 -0
  131. package/src/clients/modules/rest.ts +23 -26
  132. package/src/clients/modules/signer.ts +8 -22
  133. package/src/clients/modules/tendermintClient.ts +13 -36
  134. package/src/clients/native.ts +73 -139
  135. package/src/clients/noble-client.ts +1 -5
  136. package/src/clients/socket-client.ts +216 -216
  137. package/src/clients/subaccount.ts +16 -16
  138. package/src/clients/types.ts +14 -10
  139. package/src/clients/validator-client.ts +14 -16
  140. package/src/codegen/helpers.ts +149 -150
  141. package/src/codegen/index.ts +4 -5
  142. package/src/lib/errors.ts +3 -9
  143. package/src/lib/onboarding.ts +7 -2
  144. package/src/lib/utils.ts +5 -12
  145. package/src/lib/validation.ts +21 -19
  146. package/src/network_optimizer.ts +78 -65
  147. package/src/types.ts +5 -6
  148. package/tasks.json +15 -15
  149. package/tsconfig.eslint.json +1 -4
  150. package/tsconfig.json +2 -6
@@ -4,7 +4,10 @@
4
4
 
5
5
  import { EncodeObject, coin as createCoin } from '@cosmjs/proto-signing';
6
6
  import { MsgTransferEncodeObject, accountFromAny } from '@cosmjs/stargate';
7
- import { Order_Side, Order_TimeInForce } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/order';
7
+ import {
8
+ Order_Side,
9
+ Order_TimeInForce,
10
+ } from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/clob/order';
8
11
  import * as AuthModule from 'cosmjs-types/cosmos/auth/v1beta1/query';
9
12
  import Long from 'long';
10
13
 
@@ -15,7 +18,13 @@ import { deriveHDKeyFromEthereumSignature } from '../lib/onboarding';
15
18
  import { NetworkOptimizer } from '../network_optimizer';
16
19
  import { CompositeClient, MarketInfo } from './composite-client';
17
20
  import {
18
- Network, OrderType, OrderSide, OrderTimeInForce, OrderExecution, IndexerConfig, ValidatorConfig,
21
+ Network,
22
+ OrderType,
23
+ OrderSide,
24
+ OrderTimeInForce,
25
+ OrderExecution,
26
+ IndexerConfig,
27
+ ValidatorConfig,
19
28
  } from './constants';
20
29
  import { FaucetClient } from './faucet-client';
21
30
  import { Response } from './lib/axios';
@@ -38,9 +47,7 @@ declare global {
38
47
  var nobleWallet: LocalWallet | undefined;
39
48
  }
40
49
 
41
- export async function connectClient(
42
- network: Network,
43
- ): Promise<string> {
50
+ export async function connectClient(network: Network): Promise<string> {
44
51
  try {
45
52
  globalThis.client = await CompositeClient.connect(network);
46
53
  return encodeJson(network);
@@ -49,9 +56,7 @@ export async function connectClient(
49
56
  }
50
57
  }
51
58
 
52
- export async function connectNetwork(
53
- paramsJSON: string,
54
- ): Promise<string> {
59
+ export async function connectNetwork(paramsJSON: string): Promise<string> {
55
60
  try {
56
61
  const params = JSON.parse(paramsJSON);
57
62
  const {
@@ -70,16 +75,20 @@ export async function connectNetwork(
70
75
  txnMemo,
71
76
  } = params;
72
77
 
73
- if (indexerUrl === undefined ||
78
+ if (
79
+ indexerUrl === undefined ||
74
80
  websocketUrl === undefined ||
75
81
  validatorUrl === undefined ||
76
- chainId === undefined) {
82
+ chainId === undefined
83
+ ) {
77
84
  throw new UserError('Missing required network params');
78
85
  }
79
- if (USDC_DENOM === undefined ||
86
+ if (
87
+ USDC_DENOM === undefined ||
80
88
  USDC_DECIMALS === undefined ||
81
89
  CHAINTOKEN_DENOM === undefined ||
82
- CHAINTOKEN_DECIMALS === undefined) {
90
+ CHAINTOKEN_DECIMALS === undefined
91
+ ) {
83
92
  throw new UserError('Missing required token params');
84
93
  }
85
94
  if (txnMemo === undefined) {
@@ -125,15 +134,10 @@ export async function connectNetwork(
125
134
  }
126
135
  }
127
136
 
128
- export async function connectWallet(
129
- mnemonic: string,
130
- ): Promise<string> {
137
+ export async function connectWallet(mnemonic: string): Promise<string> {
131
138
  try {
132
139
  globalThis.wallet = await LocalWallet.fromMnemonic(mnemonic, BECH32_PREFIX);
133
- globalThis.nobleWallet = await LocalWallet.fromMnemonic(
134
- mnemonic,
135
- NOBLE_BECH32_PREFIX,
136
- );
140
+ globalThis.nobleWallet = await LocalWallet.fromMnemonic(mnemonic, NOBLE_BECH32_PREFIX);
137
141
 
138
142
  try {
139
143
  await globalThis.nobleClient?.connect(globalThis.nobleWallet);
@@ -148,10 +152,7 @@ export async function connectWallet(
148
152
  }
149
153
  }
150
154
 
151
- export async function connect(
152
- network: Network,
153
- mnemonic: string,
154
- ): Promise<string> {
155
+ export async function connect(network: Network, mnemonic: string): Promise<string> {
155
156
  try {
156
157
  await connectClient(network);
157
158
  return connectWallet(mnemonic);
@@ -218,8 +219,8 @@ export async function getEquityTiers(): Promise<string> {
218
219
  if (client === undefined) {
219
220
  throw new UserError('client is not connected. Call connectClient() first');
220
221
  }
221
- const equityTiers = await globalThis.client?.validatorClient.get
222
- .getEquityTierLimitConfiguration();
222
+ const equityTiers =
223
+ await globalThis.client?.validatorClient.get.getEquityTierLimitConfiguration();
223
224
  return encodeJson(equityTiers, ByteArrayEncoding.BIGINT);
224
225
  } catch (e) {
225
226
  return wrappedError(e);
@@ -239,9 +240,7 @@ export async function getPerpetualMarkets(): Promise<string> {
239
240
  }
240
241
  }
241
242
 
242
- export async function placeOrder(
243
- payload: string,
244
- ): Promise<string> {
243
+ export async function placeOrder(payload: string): Promise<string> {
245
244
  try {
246
245
  const client = globalThis.client;
247
246
  if (client === undefined) {
@@ -323,9 +322,7 @@ export function wrappedError(error: Error): string {
323
322
  return `{"error": ${text}}`;
324
323
  }
325
324
 
326
- export async function cancelOrder(
327
- payload: string,
328
- ): Promise<string> {
325
+ export async function cancelOrder(payload: string): Promise<string> {
329
326
  try {
330
327
  const client = globalThis.client;
331
328
  if (client === undefined) {
@@ -371,9 +368,7 @@ export async function cancelOrder(
371
368
  }
372
369
  }
373
370
 
374
- export async function deposit(
375
- payload: string,
376
- ): Promise<string> {
371
+ export async function deposit(payload: string): Promise<string> {
377
372
  try {
378
373
  const client = globalThis.client;
379
374
  if (client === undefined) {
@@ -395,19 +390,14 @@ export async function deposit(
395
390
  }
396
391
 
397
392
  const subaccount = new SubaccountInfo(wallet, subaccountNumber);
398
- const tx = await client.depositToSubaccount(
399
- subaccount,
400
- amount,
401
- );
393
+ const tx = await client.depositToSubaccount(subaccount, amount);
402
394
  return encodeJson(tx);
403
395
  } catch (error) {
404
396
  return wrappedError(error);
405
397
  }
406
398
  }
407
399
 
408
- export async function withdraw(
409
- payload: string,
410
- ): Promise<string> {
400
+ export async function withdraw(payload: string): Promise<string> {
411
401
  try {
412
402
  const client = globalThis.client;
413
403
  if (client === undefined) {
@@ -429,20 +419,14 @@ export async function withdraw(
429
419
  }
430
420
 
431
421
  const subaccount = new SubaccountInfo(wallet, subaccountNumber);
432
- const tx = await client.withdrawFromSubaccount(
433
- subaccount,
434
- amount,
435
- json.recipient,
436
- );
422
+ const tx = await client.withdrawFromSubaccount(subaccount, amount, json.recipient);
437
423
  return encodeJson(tx);
438
424
  } catch (error) {
439
425
  return wrappedError(error);
440
426
  }
441
427
  }
442
428
 
443
- export async function faucet(
444
- payload: string,
445
- ): Promise<string> {
429
+ export async function faucet(payload: string): Promise<string> {
446
430
  try {
447
431
  const faucetClient = globalThis.faucetClient;
448
432
  if (!faucetClient) {
@@ -491,7 +475,7 @@ export async function withdrawToIBC(
491
475
  throw new UserError('wallet is not set. Call connectWallet() first');
492
476
  }
493
477
 
494
- const decode = (str: string):string => Buffer.from(str, 'base64').toString('binary');
478
+ const decode = (str: string): string => Buffer.from(str, 'base64').toString('binary');
495
479
  const decoded = decode(payload);
496
480
 
497
481
  const json: SquidIBCPayload = JSON.parse(decoded);
@@ -528,9 +512,7 @@ export async function withdrawToIBC(
528
512
  }
529
513
  }
530
514
 
531
- export async function transferNativeToken(
532
- payload: string,
533
- ): Promise<string> {
515
+ export async function transferNativeToken(payload: string): Promise<string> {
534
516
  try {
535
517
  const client = globalThis.client;
536
518
  if (client === undefined) {
@@ -547,11 +529,7 @@ export async function transferNativeToken(
547
529
  throw new UserError('amount is not set');
548
530
  }
549
531
 
550
- const msg: EncodeObject = client.sendTokenMessage(
551
- wallet,
552
- amount,
553
- json.recipient,
554
- );
532
+ const msg: EncodeObject = client.sendTokenMessage(wallet, amount, json.recipient);
555
533
  const msgs = [msg];
556
534
  const encodeObjects: Promise<EncodeObject[]> = new Promise((resolve) => resolve(msgs));
557
535
 
@@ -582,8 +560,10 @@ export async function getAccountBalance(): Promise<String> {
582
560
  }
583
561
  const address = globalThis.wallet.address!;
584
562
 
585
- const tx = await client.validatorClient.get
586
- .getAccountBalance(address, client.validatorClient.config.denoms.USDC_DENOM);
563
+ const tx = await client.validatorClient.get.getAccountBalance(
564
+ address,
565
+ client.validatorClient.config.denoms.USDC_DENOM,
566
+ );
587
567
  return encodeJson(tx);
588
568
  } catch (error) {
589
569
  return wrappedError(error);
@@ -609,9 +589,7 @@ export async function getAccountBalances(): Promise<String> {
609
589
  }
610
590
  }
611
591
 
612
- export async function getUserStats(
613
- payload: string,
614
- ): Promise<String> {
592
+ export async function getUserStats(payload: string): Promise<String> {
615
593
  try {
616
594
  const client = globalThis.client;
617
595
  if (client === undefined) {
@@ -630,9 +608,7 @@ export async function getUserStats(
630
608
  }
631
609
  }
632
610
 
633
- export async function simulateDeposit(
634
- payload: string,
635
- ): Promise<string> {
611
+ export async function simulateDeposit(payload: string): Promise<string> {
636
612
  try {
637
613
  const client = globalThis.client;
638
614
  if (client === undefined) {
@@ -653,28 +629,20 @@ export async function simulateDeposit(
653
629
  }
654
630
 
655
631
  const subaccount = new SubaccountInfo(wallet, subaccountNumber);
656
- const msg: EncodeObject = client.depositToSubaccountMessage(
657
- subaccount,
658
- amount,
659
- );
632
+ const msg: EncodeObject = client.depositToSubaccountMessage(subaccount, amount);
660
633
  const msgs: EncodeObject[] = [msg];
661
634
  const encodeObjects: Promise<EncodeObject[]> = new Promise((resolve) => resolve(msgs));
662
635
 
663
- const stdFee = await client.simulate(
664
- globalThis.wallet,
665
- () => {
666
- return encodeObjects;
667
- },
668
- );
636
+ const stdFee = await client.simulate(globalThis.wallet, () => {
637
+ return encodeObjects;
638
+ });
669
639
  return JSON.stringify(stdFee);
670
640
  } catch (error) {
671
641
  return wrappedError(error);
672
642
  }
673
643
  }
674
644
 
675
- export async function simulateWithdraw(
676
- payload: string,
677
- ): Promise<string> {
645
+ export async function simulateWithdraw(payload: string): Promise<string> {
678
646
  try {
679
647
  const client = globalThis.client;
680
648
  if (client === undefined) {
@@ -703,21 +671,16 @@ export async function simulateWithdraw(
703
671
  const msgs: EncodeObject[] = [msg];
704
672
  const encodeObjects: Promise<EncodeObject[]> = new Promise((resolve) => resolve(msgs));
705
673
 
706
- const stdFee = await client.simulate(
707
- globalThis.wallet,
708
- () => {
709
- return encodeObjects;
710
- },
711
- );
674
+ const stdFee = await client.simulate(globalThis.wallet, () => {
675
+ return encodeObjects;
676
+ });
712
677
  return encodeJson(stdFee);
713
678
  } catch (error) {
714
679
  return wrappedError(error);
715
680
  }
716
681
  }
717
682
 
718
- export async function simulateTransferNativeToken(
719
- payload: string,
720
- ): Promise<string> {
683
+ export async function simulateTransferNativeToken(payload: string): Promise<string> {
721
684
  try {
722
685
  const client = globalThis.client;
723
686
  if (client === undefined) {
@@ -737,11 +700,7 @@ export async function simulateTransferNativeToken(
737
700
  throw new UserError('amount is not set');
738
701
  }
739
702
 
740
- const msg: EncodeObject = client.sendTokenMessage(
741
- wallet,
742
- amount,
743
- json.recipient,
744
- );
703
+ const msg: EncodeObject = client.sendTokenMessage(wallet, amount, json.recipient);
745
704
  const msgs: EncodeObject[] = [msg];
746
705
  const encodeObjects: Promise<EncodeObject[]> = new Promise((resolve) => resolve(msgs));
747
706
 
@@ -800,11 +759,7 @@ export async function signRawPlaceOrder(
800
759
  );
801
760
  resolve([msg]);
802
761
  });
803
- const signed = await client.sign(
804
- wallet,
805
- () => msgs,
806
- true,
807
- );
762
+ const signed = await client.sign(wallet, () => msgs, true);
808
763
  return Buffer.from(signed).toString('base64');
809
764
  } catch (error) {
810
765
  return wrappedError(error);
@@ -983,9 +938,7 @@ export async function getRewardsParams(): Promise<string> {
983
938
  }
984
939
  }
985
940
 
986
- export async function getDelegatorDelegations(
987
- payload: string,
988
- ): Promise<string> {
941
+ export async function getDelegatorDelegations(payload: string): Promise<string> {
989
942
  try {
990
943
  const client = globalThis.client;
991
944
  if (client === undefined) {
@@ -996,17 +949,15 @@ export async function getDelegatorDelegations(
996
949
  if (address === undefined) {
997
950
  throw new UserError('address is not set');
998
951
  }
999
- const delegations = await globalThis
1000
- .client?.validatorClient.get.getDelegatorDelegations(address);
952
+ const delegations =
953
+ await globalThis.client?.validatorClient.get.getDelegatorDelegations(address);
1001
954
  return encodeJson(delegations);
1002
955
  } catch (e) {
1003
956
  return wrappedError(e);
1004
957
  }
1005
958
  }
1006
959
 
1007
- export async function getDelegatorUnbondingDelegations(
1008
- payload: string,
1009
- ): Promise<string> {
960
+ export async function getDelegatorUnbondingDelegations(payload: string): Promise<string> {
1010
961
  try {
1011
962
  const client = globalThis.client;
1012
963
  if (client === undefined) {
@@ -1017,17 +968,15 @@ export async function getDelegatorUnbondingDelegations(
1017
968
  if (address === undefined) {
1018
969
  throw new UserError('address is not set');
1019
970
  }
1020
- const delegations = await globalThis
1021
- .client?.validatorClient.get.getDelegatorUnbondingDelegations(address);
971
+ const delegations =
972
+ await globalThis.client?.validatorClient.get.getDelegatorUnbondingDelegations(address);
1022
973
  return encodeJson(delegations);
1023
974
  } catch (e) {
1024
975
  return wrappedError(e);
1025
976
  }
1026
977
  }
1027
978
 
1028
- export async function getMarketPrice(
1029
- payload: string,
1030
- ): Promise<string> {
979
+ export async function getMarketPrice(payload: string): Promise<string> {
1031
980
  try {
1032
981
  const client = globalThis.client;
1033
982
  if (client === undefined) {
@@ -1049,9 +998,7 @@ export async function getNobleBalance(): Promise<String> {
1049
998
  try {
1050
999
  const client = globalThis.nobleClient;
1051
1000
  if (client === undefined || !client.isConnected) {
1052
- throw new UserError(
1053
- 'client is not connected.',
1054
- );
1001
+ throw new UserError('client is not connected.');
1055
1002
  }
1056
1003
  const coin = await client.getAccountBalance('uusdc');
1057
1004
  return encodeJson(coin);
@@ -1064,9 +1011,7 @@ export async function sendNobleIBC(squidPayload: string): Promise<String> {
1064
1011
  try {
1065
1012
  const client = globalThis.nobleClient;
1066
1013
  if (client === undefined || !client.isConnected) {
1067
- throw new UserError(
1068
- 'client is not connected.',
1069
- );
1014
+ throw new UserError('client is not connected.');
1070
1015
  }
1071
1016
 
1072
1017
  const json: SquidIBCPayload = JSON.parse(squidPayload);
@@ -1084,13 +1029,12 @@ export async function sendNobleIBC(squidPayload: string): Promise<String> {
1084
1029
  const fee = await client.simulateTransaction([ibcMsg]);
1085
1030
 
1086
1031
  if (!ibcMsg.value.token) {
1087
- throw new UserError(
1088
- 'Payload missing token field',
1089
- );
1032
+ throw new UserError('Payload missing token field');
1090
1033
  }
1091
1034
 
1092
1035
  // take out fee from amount before sweeping
1093
- const amount = parseInt(ibcMsg.value.token.amount, 10) -
1036
+ const amount =
1037
+ parseInt(ibcMsg.value.token.amount, 10) -
1094
1038
  Math.floor(parseInt(fee.amount[0].amount, 10) * GAS_MULTIPLIER);
1095
1039
 
1096
1040
  if (amount <= 0) {
@@ -1119,7 +1063,7 @@ export async function withdrawToNobleIBC(payload: string): Promise<String> {
1119
1063
 
1120
1064
  const { subaccountNumber, amount, ibcPayload } = json ?? {};
1121
1065
 
1122
- const decode = (str: string):string => Buffer.from(str, 'base64').toString('binary');
1066
+ const decode = (str: string): string => Buffer.from(str, 'base64').toString('binary');
1123
1067
  const decoded = decode(ibcPayload);
1124
1068
 
1125
1069
  const parsedIbcPayload: SquidIBCPayload = JSON.parse(decoded);
@@ -1139,11 +1083,7 @@ export async function withdrawToNobleIBC(payload: string): Promise<String> {
1139
1083
  },
1140
1084
  };
1141
1085
 
1142
- const tx = await client.send(
1143
- wallet,
1144
- () => Promise.resolve([msg, ibcMsg]),
1145
- false,
1146
- );
1086
+ const tx = await client.send(wallet, () => Promise.resolve([msg, ibcMsg]), false);
1147
1087
 
1148
1088
  return encodeJson({
1149
1089
  txHash: `0x${Buffer.from(tx?.hash).toString('hex')}`,
@@ -1157,9 +1097,7 @@ export async function cctpWithdraw(squidPayload: string): Promise<String> {
1157
1097
  try {
1158
1098
  const client = globalThis.nobleClient;
1159
1099
  if (client === undefined || !client.isConnected) {
1160
- throw new UserError(
1161
- 'client is not connected.',
1162
- );
1100
+ throw new UserError('client is not connected.');
1163
1101
  }
1164
1102
 
1165
1103
  const json = JSON.parse(squidPayload);
@@ -1171,7 +1109,8 @@ export async function cctpWithdraw(squidPayload: string): Promise<String> {
1171
1109
  const fee = await client.simulateTransaction([ibcMsg]);
1172
1110
 
1173
1111
  // take out fee from amount before sweeping
1174
- const amount = parseInt(ibcMsg.value.amount, 10) -
1112
+ const amount =
1113
+ parseInt(ibcMsg.value.amount, 10) -
1175
1114
  Math.floor(parseInt(fee.amount[0].amount, 10) * GAS_MULTIPLIER);
1176
1115
 
1177
1116
  if (amount <= 0) {
@@ -1188,9 +1127,7 @@ export async function cctpWithdraw(squidPayload: string): Promise<String> {
1188
1127
  }
1189
1128
  }
1190
1129
 
1191
- export async function getWithdrawalCapacityByDenom(
1192
- payload: string,
1193
- ): Promise<string> {
1130
+ export async function getWithdrawalCapacityByDenom(payload: string): Promise<string> {
1194
1131
  try {
1195
1132
  const client = globalThis.client;
1196
1133
  if (client === undefined) {
@@ -1209,8 +1146,7 @@ export async function getWithdrawalCapacityByDenom(
1209
1146
  }
1210
1147
  }
1211
1148
 
1212
- export async function getWithdrawalAndTransferGatingStatus(
1213
- ): Promise<string> {
1149
+ export async function getWithdrawalAndTransferGatingStatus(): Promise<string> {
1214
1150
  try {
1215
1151
  const client = globalThis.client;
1216
1152
  if (client === undefined) {
@@ -1224,9 +1160,7 @@ export async function getWithdrawalAndTransferGatingStatus(
1224
1160
  }
1225
1161
  }
1226
1162
 
1227
- export async function subaccountTransfer(
1228
- payload: string,
1229
- ): Promise<string> {
1163
+ export async function subaccountTransfer(payload: string): Promise<string> {
1230
1164
  try {
1231
1165
  const client = globalThis.client;
1232
1166
  if (client === undefined) {
@@ -99,11 +99,7 @@ export class NobleClient {
99
99
  throw new Error('NobleClient wallet not initialized');
100
100
  }
101
101
  // Get simulated response
102
- const gasEstimate = await this.stargateClient.simulate(
103
- this.wallet?.address,
104
- messages,
105
- memo,
106
- );
102
+ const gasEstimate = await this.stargateClient.simulate(this.wallet?.address, messages, memo);
107
103
 
108
104
  // Calculate and return the fee
109
105
  return calculateFee(Math.floor(gasEstimate * GAS_MULTIPLIER), gasPrice);