@skip-go/client 1.3.3 → 1.3.5

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 (32) hide show
  1. package/dist/cjs/api/postMessages.cjs +2 -2
  2. package/dist/cjs/{chunk-KJ5NZG2D.cjs → chunk-3FYU3BJ7.cjs} +3 -3
  3. package/dist/cjs/{chunk-A7GR26AQ.cjs → chunk-5BVYKNVO.cjs} +50 -21
  4. package/dist/cjs/{chunk-LP3L6XJB.cjs → chunk-FY56EEFB.cjs} +1 -0
  5. package/dist/cjs/{chunk-XNBHMZQZ.cjs → chunk-IE22IVFA.cjs} +3 -3
  6. package/dist/cjs/{chunk-B4OGYBRC.cjs → chunk-JTB3SPCH.cjs} +4 -4
  7. package/dist/cjs/chunk-MN763TPC.cjs +187 -0
  8. package/dist/cjs/{chunk-L4MLX6KI.cjs → chunk-SZ64FWGB.cjs} +2 -2
  9. package/dist/cjs/index.cjs +13 -13
  10. package/dist/cjs/public-functions/executeRoute.cjs +6 -6
  11. package/dist/cjs/public-functions/getFeeInfoForChain.cjs +3 -3
  12. package/dist/cjs/public-functions/getRecommendedGasPrice.cjs +4 -4
  13. package/dist/cjs/public-functions/getSigningStargateClient.cjs +3 -3
  14. package/dist/cjs/public-functions/validateCosmosGasBalance.cjs +4 -4
  15. package/dist/esm/api/postMessages.js +1 -1
  16. package/dist/esm/{chunk-CFDTJGQK.js → chunk-5KIWNRW4.js} +1 -1
  17. package/dist/esm/{chunk-GSCIF7YA.js → chunk-7LSTJXAF.js} +1 -0
  18. package/dist/esm/{chunk-2R3M45RX.js → chunk-ADUNNC4O.js} +2 -2
  19. package/dist/esm/chunk-VBWLUZXT.js +182 -0
  20. package/dist/esm/{chunk-35H4PDPF.js → chunk-YL6PL36T.js} +41 -12
  21. package/dist/esm/{chunk-6F2T2KB3.js → chunk-YLVFZDR5.js} +2 -2
  22. package/dist/esm/{chunk-Y5H25R7Z.js → chunk-ZL6XF5A3.js} +1 -1
  23. package/dist/esm/index.js +7 -7
  24. package/dist/esm/public-functions/executeRoute.d.ts +12 -0
  25. package/dist/esm/public-functions/executeRoute.js +5 -5
  26. package/dist/esm/public-functions/getFeeInfoForChain.js +2 -2
  27. package/dist/esm/public-functions/getRecommendedGasPrice.js +3 -3
  28. package/dist/esm/public-functions/getSigningStargateClient.js +2 -2
  29. package/dist/esm/public-functions/validateCosmosGasBalance.js +3 -3
  30. package/package.json +1 -1
  31. package/dist/cjs/chunk-T5LPU5A2.cjs +0 -188
  32. package/dist/esm/chunk-43P4WRGN.js +0 -183
@@ -1,16 +1,16 @@
1
- import { validateCosmosGasBalance } from './chunk-2R3M45RX.js';
1
+ import { validateCosmosGasBalance } from './chunk-ADUNNC4O.js';
2
2
  import { waitForTransaction } from './chunk-CU6W3622.js';
3
3
  import { getEncodeObjectFromCosmosMessage, getEncodeObjectFromCosmosMessageInjective } from './chunk-TV2XPAIF.js';
4
4
  import { getEVMGasAmountForMessage } from './chunk-GV2QOWB4.js';
5
5
  import { BigNumber } from './chunk-VQ5SIQWU.js';
6
6
  import { GAS_STATION_CHAIN_IDS } from './chunk-SWYON2RG.js';
7
- import { getSigningStargateClient, getRpcEndpointForChain, accountParser } from './chunk-6F2T2KB3.js';
8
- import { chains, findFirstWorkingEndpoint, getIsEthermint, getIsInitia } from './chunk-43P4WRGN.js';
9
- import { messages } from './chunk-GSCIF7YA.js';
7
+ import { getSigningStargateClient, getRpcEndpointForChain, accountParser } from './chunk-YLVFZDR5.js';
8
+ import { chains, findFirstWorkingEndpoint, getIsEthermint, getIsInitia } from './chunk-VBWLUZXT.js';
9
+ import { messages } from './chunk-7LSTJXAF.js';
10
10
  import { submitTransaction } from './chunk-OHV2LZEG.js';
11
11
  import { venues } from './chunk-JSY7M43P.js';
12
12
  import { ClientState, balances } from './chunk-2L7PKZDY.js';
13
- import { ApiState, wait, createRequestClient, toCamel } from './chunk-LZI7A4JI.js';
13
+ import { ApiState, wait, toCamel } from './chunk-LZI7A4JI.js';
14
14
  import { PublicKey, Transaction, Connection, LAMPORTS_PER_SOL } from '@solana/web3.js';
15
15
  import { bech32m, bech32 } from 'bech32';
16
16
  import { StargateClient } from '@cosmjs/stargate';
@@ -37,7 +37,7 @@ var getRestEndpointForChain = async (chainId) => {
37
37
  return endpointOptions.rest;
38
38
  }
39
39
  }
40
- const chain = chains().find((chain2) => chain2.chain_id === chainId);
40
+ const chain = chains().find((chain2) => chain2.chainId === chainId);
41
41
  if (!chain) {
42
42
  throw new Error(
43
43
  `getRestEndpointForChain error: failed to find chain id '${chainId}' in registry`
@@ -79,9 +79,18 @@ var getAccountNumberAndSequence = async (address, chainId) => {
79
79
  };
80
80
  var getAccountNumberAndSequenceFromDymension = async (address, chainId) => {
81
81
  const endpoint = await getRestEndpointForChain(chainId);
82
- const jsonResponse = await createRequestClient({
83
- baseUrl: `${endpoint}/cosmos/auth/v1beta1/accounts/${address}`
84
- }).get();
82
+ const res = await fetch(
83
+ `${endpoint}/cosmos/auth/v1beta1/accounts/${address}`,
84
+ {
85
+ headers: {
86
+ "Content-Type": "application/json"
87
+ }
88
+ }
89
+ );
90
+ if (!res.ok) {
91
+ throw new Error(`Failed to fetch account data: ${res.statusText}`);
92
+ }
93
+ const jsonResponse = await res.json();
85
94
  const response = toCamel(jsonResponse);
86
95
  let sequence = 0;
87
96
  let accountNumber = 0;
@@ -770,6 +779,14 @@ var signSvmTransaction = async ({
770
779
  }
771
780
  const txBuffer = Buffer.from(svmTx.tx ?? "", "base64");
772
781
  const transaction = Transaction.from(txBuffer);
782
+ if (options.svmFeePayer) {
783
+ const message = transaction.serializeMessage();
784
+ const resSignTx = await options.svmFeePayer.signTransaction(message);
785
+ transaction.addSignature(
786
+ new PublicKey(options.svmFeePayer.address),
787
+ Buffer.from(resSignTx)
788
+ );
789
+ }
773
790
  if (!("signTransaction" in signer)) return;
774
791
  options?.onTransactionSignRequested?.({
775
792
  chainId: svmTx.chainId,
@@ -1010,9 +1027,19 @@ var validateEvmGasBalance = async ({
1010
1027
  }
1011
1028
  };
1012
1029
  var validateSvmGasBalance = async ({
1013
- tx
1030
+ tx,
1031
+ simulate
1014
1032
  }) => {
1015
1033
  if (!tx) throw new Error("Transaction is required");
1034
+ if (simulate === false) {
1035
+ return {
1036
+ success: true,
1037
+ logs: [],
1038
+ error: null,
1039
+ asset: null,
1040
+ fee: null
1041
+ };
1042
+ }
1016
1043
  const endpoint = await getRpcEndpointForChain(tx.chainId ?? "");
1017
1044
  const connection = new Connection(endpoint);
1018
1045
  if (!connection) throw new Error(`Failed to connect to ${tx.chainId}`);
@@ -1146,7 +1173,8 @@ var validateGasBalances = async ({
1146
1173
  });
1147
1174
  try {
1148
1175
  const res = await validateSvmGasBalance({
1149
- tx: tx.svmTx
1176
+ tx: tx.svmTx,
1177
+ simulate
1150
1178
  });
1151
1179
  return res;
1152
1180
  } catch (e) {
@@ -1387,7 +1415,8 @@ var executeRoute = async (options) => {
1387
1415
  addressList,
1388
1416
  slippageTolerancePercent: options.slippageTolerancePercent || "1",
1389
1417
  chainIdsToAffiliates: ApiState.chainIdsToAffiliates,
1390
- postRouteHandler: options.postRouteHandler
1418
+ postRouteHandler: options.postRouteHandler,
1419
+ feePayerAddress: options.svmFeePayer?.address
1391
1420
  });
1392
1421
  if (beforeMsg && (response?.txs?.length ?? 0) > 0) {
1393
1422
  const firstTx = response?.txs?.[0];
@@ -1,4 +1,4 @@
1
- import { chains, findFirstWorkingEndpoint } from './chunk-43P4WRGN.js';
1
+ import { chains, findFirstWorkingEndpoint } from './chunk-VBWLUZXT.js';
2
2
  import { ClientState } from './chunk-2L7PKZDY.js';
3
3
  import { accountFromAny, SigningStargateClient } from '@cosmjs/stargate';
4
4
  import { assertDefinedAndNotNull } from '@cosmjs/utils';
@@ -222,7 +222,7 @@ var getRpcEndpointForChain = async (chainId) => {
222
222
  console.warn(
223
223
  "Warning: You are using unreliable public endpoints. We strongly recommend overriding them via endpointOptions for use beyond development settings."
224
224
  );
225
- const chain = chains().find((chain2) => chain2.chain_id === chainId);
225
+ const chain = chains().find((chain2) => chain2.chainId === chainId);
226
226
  if (!chain) {
227
227
  throw new Error(`getRpcEndpointForChain: failed to find chain id '${chainId}' in registry`);
228
228
  }
@@ -1,5 +1,5 @@
1
1
  import { DEFAULT_GAS_DENOM_OVERRIDES } from './chunk-SWYON2RG.js';
2
- import { chains } from './chunk-43P4WRGN.js';
2
+ import { chains } from './chunk-VBWLUZXT.js';
3
3
  import { ClientState } from './chunk-2L7PKZDY.js';
4
4
 
5
5
  // src/private-functions/getDefaultGasTokenForChain.ts
package/dist/esm/index.js CHANGED
@@ -1,19 +1,19 @@
1
- export { executeRoute } from './chunk-35H4PDPF.js';
2
- export { validateCosmosGasBalance } from './chunk-2R3M45RX.js';
1
+ export { executeRoute } from './chunk-YL6PL36T.js';
2
+ export { validateCosmosGasBalance } from './chunk-ADUNNC4O.js';
3
3
  export { waitForTransaction } from './chunk-CU6W3622.js';
4
4
  export { getCosmosGasAmountForMessage } from './chunk-TV2XPAIF.js';
5
5
  export { getEVMGasAmountForMessage } from './chunk-GV2QOWB4.js';
6
- export { getRecommendedGasPrice } from './chunk-CFDTJGQK.js';
6
+ export { getRecommendedGasPrice } from './chunk-5KIWNRW4.js';
7
7
  import './chunk-VQ5SIQWU.js';
8
- export { getFeeInfoForChain } from './chunk-Y5H25R7Z.js';
8
+ export { getFeeInfoForChain } from './chunk-ZL6XF5A3.js';
9
9
  export { GAS_STATION_CHAIN_IDS } from './chunk-SWYON2RG.js';
10
- export { getSigningStargateClient } from './chunk-6F2T2KB3.js';
11
- import './chunk-43P4WRGN.js';
10
+ export { getSigningStargateClient } from './chunk-YLVFZDR5.js';
11
+ import './chunk-VBWLUZXT.js';
12
12
  export { setApiOptions } from './chunk-JYUNVL4F.js';
13
13
  export { setClientOptions } from './chunk-OL7CWCPB.js';
14
14
  import './chunk-TD63P2AG.js';
15
15
  export { ibcOriginAssets } from './chunk-XXTECZG3.js';
16
- export { messages } from './chunk-GSCIF7YA.js';
16
+ export { messages } from './chunk-7LSTJXAF.js';
17
17
  export { messagesDirect } from './chunk-SJP6W2SK.js';
18
18
  export { recommendAssets } from './chunk-IPHFFTGO.js';
19
19
  export { route } from './chunk-JIADJKRD.js';
@@ -63,6 +63,18 @@ type ExecuteRouteOptions = SignerGetters & GasOptions & TransactionCallbacks & P
63
63
  * It should be a function that takes a chainId and returns the denom for the priority fee.
64
64
  */
65
65
  getCosmosPriorityFeeDenom?: (chainId: string) => Promise<string | undefined>;
66
+ /**
67
+ * SVM Fee Payer
68
+ *
69
+ * This is used to pay for the transaction fees on SVM chains.
70
+ * It should be an object with the following properties:
71
+ * `address`: The address of the fee payer.
72
+ * `signTransaction`: A function that takes the data to sign and returns a Promise that resolves to the signed transaction.
73
+ */
74
+ svmFeePayer?: {
75
+ address: string;
76
+ signTransaction: (dataToSign: Buffer) => Promise<Uint8Array>;
77
+ };
66
78
  };
67
79
  declare const executeRoute: (options: ExecuteRouteOptions) => Promise<void>;
68
80
 
@@ -1,14 +1,14 @@
1
- export { executeRoute } from '../chunk-35H4PDPF.js';
2
- import '../chunk-2R3M45RX.js';
1
+ export { executeRoute } from '../chunk-YL6PL36T.js';
2
+ import '../chunk-ADUNNC4O.js';
3
3
  import '../chunk-CU6W3622.js';
4
4
  import '../chunk-TV2XPAIF.js';
5
5
  import '../chunk-GV2QOWB4.js';
6
6
  import '../chunk-VQ5SIQWU.js';
7
7
  import '../chunk-SWYON2RG.js';
8
- import '../chunk-6F2T2KB3.js';
9
- import '../chunk-43P4WRGN.js';
8
+ import '../chunk-YLVFZDR5.js';
9
+ import '../chunk-VBWLUZXT.js';
10
10
  import '../chunk-TD63P2AG.js';
11
- import '../chunk-GSCIF7YA.js';
11
+ import '../chunk-7LSTJXAF.js';
12
12
  import '../chunk-OHV2LZEG.js';
13
13
  import '../chunk-7ITTEUMR.js';
14
14
  import '../chunk-MXCJ2M3K.js';
@@ -1,6 +1,6 @@
1
- export { getFeeInfoForChain } from '../chunk-Y5H25R7Z.js';
1
+ export { getFeeInfoForChain } from '../chunk-ZL6XF5A3.js';
2
2
  import '../chunk-SWYON2RG.js';
3
- import '../chunk-43P4WRGN.js';
3
+ import '../chunk-VBWLUZXT.js';
4
4
  import '../chunk-2L7PKZDY.js';
5
5
  import '../chunk-LZI7A4JI.js';
6
6
  import '../chunk-OQDBWVET.js';
@@ -1,8 +1,8 @@
1
- export { getRecommendedGasPrice } from '../chunk-CFDTJGQK.js';
1
+ export { getRecommendedGasPrice } from '../chunk-5KIWNRW4.js';
2
2
  import '../chunk-VQ5SIQWU.js';
3
- import '../chunk-Y5H25R7Z.js';
3
+ import '../chunk-ZL6XF5A3.js';
4
4
  import '../chunk-SWYON2RG.js';
5
- import '../chunk-43P4WRGN.js';
5
+ import '../chunk-VBWLUZXT.js';
6
6
  import '../chunk-2L7PKZDY.js';
7
7
  import '../chunk-LZI7A4JI.js';
8
8
  import '../chunk-OQDBWVET.js';
@@ -1,5 +1,5 @@
1
- export { getSigningStargateClient } from '../chunk-6F2T2KB3.js';
2
- import '../chunk-43P4WRGN.js';
1
+ export { getSigningStargateClient } from '../chunk-YLVFZDR5.js';
2
+ import '../chunk-VBWLUZXT.js';
3
3
  import '../chunk-2L7PKZDY.js';
4
4
  import '../chunk-LZI7A4JI.js';
5
5
  import '../chunk-OQDBWVET.js';
@@ -1,8 +1,8 @@
1
- export { validateCosmosGasBalance } from '../chunk-2R3M45RX.js';
1
+ export { validateCosmosGasBalance } from '../chunk-ADUNNC4O.js';
2
2
  import '../chunk-TV2XPAIF.js';
3
3
  import '../chunk-VQ5SIQWU.js';
4
- import '../chunk-6F2T2KB3.js';
5
- import '../chunk-43P4WRGN.js';
4
+ import '../chunk-YLVFZDR5.js';
5
+ import '../chunk-VBWLUZXT.js';
6
6
  import '../chunk-TD63P2AG.js';
7
7
  import '../chunk-2L7PKZDY.js';
8
8
  import '../chunk-LZI7A4JI.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@skip-go/client",
3
3
  "description": "JavaScript SDK for Skip Go API",
4
- "version": "1.3.3",
4
+ "version": "1.3.5",
5
5
  "repository": "https://github.com/skip-mev/skip-go",
6
6
  "type": "module",
7
7
  "main": "./dist/cjs/index.cjs",