@skip-go/client 1.1.5 → 1.1.7

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 (78) hide show
  1. package/dist/api/getAssets.d.ts +1 -1
  2. package/dist/api/getAssets.js +3 -2
  3. package/dist/api/getAssetsBetweenChains.d.ts +1 -1
  4. package/dist/api/getAssetsBetweenChains.js +3 -2
  5. package/dist/api/getBridges.d.ts +1 -1
  6. package/dist/api/getBridges.js +3 -2
  7. package/dist/api/getChains.d.ts +1 -1
  8. package/dist/api/getChains.js +3 -2
  9. package/dist/api/getVenues.js +3 -2
  10. package/dist/api/postAssetsFromSource.d.ts +1 -1
  11. package/dist/api/postAssetsFromSource.js +4 -3
  12. package/dist/api/postBalances.d.ts +2 -2
  13. package/dist/api/postBalances.js +3 -2
  14. package/dist/api/postIbcOriginAssets.js +3 -2
  15. package/dist/api/postMessages.d.ts +6 -473
  16. package/dist/api/postMessages.js +3 -2
  17. package/dist/api/postMessagesDirect.d.ts +5 -1
  18. package/dist/api/postMessagesDirect.js +3 -2
  19. package/dist/api/postRecommendAssets.d.ts +1 -1
  20. package/dist/api/postRecommendAssets.js +3 -2
  21. package/dist/api/postRoute.d.ts +6 -2
  22. package/dist/api/postRoute.js +3 -2
  23. package/dist/api/postSubmit.d.ts +17 -0
  24. package/dist/api/postSubmit.js +3 -0
  25. package/dist/api/postSubmitTransaction.js +3 -2
  26. package/dist/api/postTrackTransaction.js +3 -2
  27. package/dist/api/postTransactionStatus.d.ts +2 -2
  28. package/dist/api/postTransactionStatus.js +3 -2
  29. package/dist/{callbacks-BinMFSvp.d.ts → callbacks-BGRu2Ule.d.ts} +1 -1
  30. package/dist/chunk-25FJ6EBA.js +36 -0
  31. package/dist/{chunk-5KEBJTG2.js → chunk-2LKKFCUM.js} +2 -2
  32. package/dist/{chunk-P7QXKAUS.js → chunk-5WMPFEIQ.js} +1 -1
  33. package/dist/{chunk-FB32UNL7.js → chunk-7QEN4XCJ.js} +18 -321
  34. package/dist/{chunk-3G66QUIR.js → chunk-C4URP37X.js} +1 -1
  35. package/dist/{chunk-VYZE3SLF.js → chunk-CRTTBUO4.js} +1 -1
  36. package/dist/{chunk-WYKGBXPO.js → chunk-DU3RX43W.js} +3 -3
  37. package/dist/chunk-DV3I2S3T.js +181 -0
  38. package/dist/{chunk-KTCDTZCU.js → chunk-GOYJWJEC.js} +1 -1
  39. package/dist/chunk-GV2QOWB4.js +26 -0
  40. package/dist/{chunk-REIPMX4F.js → chunk-IWW34V4S.js} +1 -1
  41. package/dist/{chunk-DQJUP5YB.js → chunk-JZBFAMHE.js} +1 -1
  42. package/dist/{chunk-5G6WVH73.js → chunk-PPUUN7FI.js} +1 -1
  43. package/dist/{chunk-G3DPNB66.js → chunk-RFZBKQ35.js} +1 -1
  44. package/dist/{chunk-LJ5Y4YS2.js → chunk-RYOVQFZO.js} +1 -1
  45. package/dist/{chunk-I5V6BIOW.js → chunk-SYQHTXE7.js} +2 -2
  46. package/dist/{chunk-BYK77RST.js → chunk-T7GKUROO.js} +1 -1
  47. package/dist/chunk-TV2XPAIF.js +295 -0
  48. package/dist/{chunk-KEXKVEVT.js → chunk-U6XZFJW2.js} +1 -1
  49. package/dist/{chunk-SN5GGN5K.js → chunk-UXUJNZOA.js} +1 -181
  50. package/dist/{chunk-GHK24RZZ.js → chunk-VDEYJJZI.js} +2 -2
  51. package/dist/{chunk-ECFSAIIO.js → chunk-VTK34ED6.js} +1 -1
  52. package/dist/chunk-X67P5URV.js +10 -0
  53. package/dist/{chunk-C6EHVJEC.js → chunk-XXJUDZKJ.js} +1 -1
  54. package/dist/{chunk-YKWVCWO4.js → chunk-YMUVYT3O.js} +1 -1
  55. package/dist/{client-types-B_ihV5t6.d.ts → client-types-BkeR6R_z.d.ts} +1 -1
  56. package/dist/{generateApi-CpUxWvEf.d.ts → generateApi-8YPJU-Al.d.ts} +1 -1
  57. package/dist/index.d.ts +11 -5
  58. package/dist/index.js +26 -22
  59. package/dist/public-functions/executeRoute.d.ts +4 -4
  60. package/dist/public-functions/executeRoute.js +15 -11
  61. package/dist/public-functions/getCosmosGasAmountForMessage.d.ts +8 -0
  62. package/dist/public-functions/getCosmosGasAmountForMessage.js +2 -0
  63. package/dist/public-functions/getEvmGasAmountForMessage.d.ts +11 -0
  64. package/dist/public-functions/getEvmGasAmountForMessage.js +2 -0
  65. package/dist/public-functions/getFeeInfoForChain.d.ts +1 -1
  66. package/dist/public-functions/getFeeInfoForChain.js +4 -3
  67. package/dist/public-functions/getRecommendedGasPrice.js +5 -4
  68. package/dist/public-functions/getSigningStargateClient.js +4 -3
  69. package/dist/public-functions/setApiOptions.d.ts +1 -1
  70. package/dist/public-functions/setApiOptions.js +3 -2
  71. package/dist/public-functions/setClientOptions.d.ts +3 -3
  72. package/dist/public-functions/setClientOptions.js +4 -3
  73. package/dist/public-functions/waitForTransaction.d.ts +2 -2
  74. package/dist/public-functions/waitForTransaction.js +5 -4
  75. package/dist/{setClientOptions-C4rwBrB4.d.ts → setClientOptions-CI_7IPLT.d.ts} +1 -1
  76. package/dist/{swaggerTypes-sZ9ALP9m.d.ts → swaggerTypes-CAERZYPb.d.ts} +4 -1
  77. package/package.json +1 -1
  78. package/dist/chunk-27P5BVWA.js +0 -10
@@ -0,0 +1,181 @@
1
+ // src/utils/timer.ts
2
+ var wait = (ms) => {
3
+ return new Promise((resolve) => setTimeout(resolve, ms));
4
+ };
5
+
6
+ // src/utils/convert.ts
7
+ function toSnake(obj) {
8
+ return convertKeys(obj, (key) => key.replace(/([A-Z])/g, "_$1").toLowerCase());
9
+ }
10
+ function toCamel(obj) {
11
+ return convertKeys(obj, (key) => key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()));
12
+ }
13
+ function convertKeys(obj, convertKey) {
14
+ if (Array.isArray(obj)) {
15
+ return obj.map((item) => convertKeys(item, convertKey));
16
+ } else if (obj !== null && typeof obj === "object") {
17
+ return Object.keys(obj).reduce((acc, key) => {
18
+ acc[convertKey(key)] = convertKeys(obj[key], convertKey);
19
+ return acc;
20
+ }, {});
21
+ } else {
22
+ return obj;
23
+ }
24
+ }
25
+
26
+ // src/utils/generateApi.ts
27
+ var createRequestClient = ({ baseUrl, apiKey }) => {
28
+ const defaultHeaders = {
29
+ "content-type": "application/json",
30
+ ...apiKey ? { authorization: apiKey } : {}
31
+ };
32
+ const handleResponse = async (response) => {
33
+ const contentType = response.headers.get("content-type");
34
+ const isJson = contentType?.includes("application/json");
35
+ const body = isJson ? await response.json() : await response.text();
36
+ if (!response.ok) {
37
+ const message = typeof body === "object" && body?.message ? body.message : response.statusText;
38
+ throw new Error(message);
39
+ }
40
+ return body;
41
+ };
42
+ const get = async (path, params, signal) => {
43
+ const url = new URL(baseUrl + (path ?? ""));
44
+ if (params && typeof params === "object") {
45
+ Object.entries(params).forEach(([key, value]) => {
46
+ if (value !== void 0 && value !== null) {
47
+ url.searchParams.append(key, String(value));
48
+ }
49
+ });
50
+ }
51
+ const response = await fetch(url.toString(), {
52
+ method: "GET",
53
+ headers: defaultHeaders,
54
+ signal
55
+ });
56
+ return handleResponse(response);
57
+ };
58
+ const post = async (path, data = {}, signal) => {
59
+ const response = await fetch(new URL(baseUrl + path).toString(), {
60
+ method: "POST",
61
+ headers: defaultHeaders,
62
+ body: JSON.stringify(data),
63
+ signal
64
+ });
65
+ return handleResponse(response);
66
+ };
67
+ return { get, post };
68
+ };
69
+ function createRequest({
70
+ path,
71
+ method = "get",
72
+ onSuccess,
73
+ transformResponse
74
+ }) {
75
+ let controller = null;
76
+ const request = async (options) => {
77
+ const { apiKey, apiUrl, abortDuplicateRequests, ...requestParams } = options ?? {};
78
+ let fetchClient = ApiState.client;
79
+ if (apiUrl || apiKey) {
80
+ fetchClient = createRequestClient({
81
+ baseUrl: apiUrl || "https://api.skip.build",
82
+ apiKey
83
+ });
84
+ } else {
85
+ await ApiState.clientInitialized;
86
+ }
87
+ if (abortDuplicateRequests && controller && !controller?.signal?.aborted) {
88
+ controller?.abort();
89
+ }
90
+ controller = new AbortController();
91
+ try {
92
+ const response = await fetchClient[method](
93
+ path,
94
+ requestParams ? toSnake(requestParams) : void 0,
95
+ controller.signal
96
+ );
97
+ const camelCased = toCamel(response ?? {});
98
+ const finalResponse = transformResponse ? transformResponse(camelCased) : camelCased;
99
+ onSuccess?.(finalResponse, requestParams);
100
+ return finalResponse;
101
+ } catch (error) {
102
+ if (error.name === "AbortError") {
103
+ console.log("Request was cancelled");
104
+ } else {
105
+ console.error("Error:", error);
106
+ throw error;
107
+ }
108
+ }
109
+ };
110
+ return request;
111
+ }
112
+ function api({
113
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
114
+ methodName,
115
+ path,
116
+ onSuccess,
117
+ method = "get",
118
+ transformResponse
119
+ }) {
120
+ return createRequest({
121
+ path,
122
+ method,
123
+ onSuccess,
124
+ transformResponse
125
+ });
126
+ }
127
+ function pollingApi({
128
+ methodName,
129
+ path,
130
+ method = "get",
131
+ onSuccess,
132
+ onError,
133
+ isSuccess = () => true,
134
+ maxRetries = 5,
135
+ retryInterval = 1e3,
136
+ backoffMultiplier = 2
137
+ }) {
138
+ const request = async (requestParams) => {
139
+ let attempt = 0;
140
+ let lastError;
141
+ while (attempt < maxRetries) {
142
+ try {
143
+ const result = await api({ methodName, path, method })(requestParams);
144
+ if (result && isSuccess(result)) {
145
+ onSuccess?.(result, attempt);
146
+ return result;
147
+ }
148
+ } catch (err) {
149
+ lastError = err;
150
+ onError?.(err, attempt);
151
+ }
152
+ const delay = retryInterval * Math.pow(backoffMultiplier, attempt);
153
+ await wait(delay);
154
+ attempt++;
155
+ }
156
+ throw lastError ?? new Error("pollingApi: max retries exceeded");
157
+ };
158
+ return (params) => request(params);
159
+ }
160
+
161
+ // src/state/apiState.ts
162
+ var ApiState = class _ApiState {
163
+ static client;
164
+ static chainIdsToAffiliates;
165
+ static cumulativeAffiliateFeeBPS = "0";
166
+ static isInitialized = false;
167
+ static resolveInitialization;
168
+ static clientInitialized = new Promise((resolve) => {
169
+ _ApiState.resolveInitialization = () => {
170
+ if (!_ApiState.isInitialized) {
171
+ _ApiState.isInitialized = true;
172
+ resolve();
173
+ }
174
+ };
175
+ });
176
+ static setClientInitialized() {
177
+ _ApiState.resolveInitialization();
178
+ }
179
+ };
180
+
181
+ export { ApiState, api, createRequestClient, pollingApi, toCamel, wait };
@@ -1,5 +1,5 @@
1
1
  import { chains, findFirstWorkingEndpoint } from './chunk-36MCR5DZ.js';
2
- import { ClientState } from './chunk-I5V6BIOW.js';
2
+ import { ClientState } from './chunk-SYQHTXE7.js';
3
3
  import { accountFromAny, SigningStargateClient } from '@cosmjs/stargate';
4
4
  import { assertDefinedAndNotNull } from '@cosmjs/utils';
5
5
  import { BinaryWriter, BinaryReader } from 'cosmjs-types/binary.js';
@@ -0,0 +1,26 @@
1
+ import { publicActions } from 'viem';
2
+
3
+ // src/public-functions/getEvmGasAmountForMessage.ts
4
+ async function getEVMGasAmountForMessage(signer, tx, getFallbackGasAmount) {
5
+ const { to, data, value } = tx;
6
+ if (!signer.account) throw new Error("estimateGasForEvmTx: No account found");
7
+ const extendedSigner = signer.extend(publicActions);
8
+ const fee = await extendedSigner.estimateFeesPerGas();
9
+ try {
10
+ const gasAmount = await extendedSigner.estimateGas({
11
+ account: signer.account,
12
+ to,
13
+ data: `0x${data}`,
14
+ value: value === "" ? void 0 : BigInt(value ?? "")
15
+ });
16
+ return gasAmount * fee.maxFeePerGas;
17
+ } catch (error) {
18
+ const fallbackGasAmount = await getFallbackGasAmount?.(tx.chainId ?? "", "evm" /* Evm */);
19
+ if (fallbackGasAmount) {
20
+ return BigInt(fallbackGasAmount) * fee.maxFeePerGas;
21
+ }
22
+ throw error;
23
+ }
24
+ }
25
+
26
+ export { getEVMGasAmountForMessage };
@@ -1,4 +1,4 @@
1
- import { api } from './chunk-SN5GGN5K.js';
1
+ import { api } from './chunk-DV3I2S3T.js';
2
2
 
3
3
  // src/api/getAssetsBetweenChains.ts
4
4
  var assetsBetweenChains = api({
@@ -1,4 +1,4 @@
1
- import { api } from './chunk-SN5GGN5K.js';
1
+ import { api } from './chunk-DV3I2S3T.js';
2
2
 
3
3
  // src/api/postRecommendAssets.ts
4
4
  var recommendAssets = api({
@@ -1,4 +1,4 @@
1
- import { pollingApi } from './chunk-SN5GGN5K.js';
1
+ import { pollingApi } from './chunk-DV3I2S3T.js';
2
2
 
3
3
  // src/api/postTransactionStatus.ts
4
4
  var transactionStatus = pollingApi({
@@ -1,4 +1,4 @@
1
- import { ApiState, createRequestClient } from './chunk-SN5GGN5K.js';
1
+ import { ApiState, createRequestClient } from './chunk-DV3I2S3T.js';
2
2
 
3
3
  // src/public-functions/setApiOptions.ts
4
4
  var setApiOptions = (options = {}) => {
@@ -1,4 +1,4 @@
1
- import { api } from './chunk-SN5GGN5K.js';
1
+ import { api } from './chunk-DV3I2S3T.js';
2
2
 
3
3
  // src/api/postIbcOriginAssets.ts
4
4
  var ibcOriginAssets = api({
@@ -1,4 +1,4 @@
1
- import { api } from './chunk-SN5GGN5K.js';
1
+ import { api } from './chunk-DV3I2S3T.js';
2
2
 
3
3
  // src/private-functions/getMainnetAndTestnetChains.ts
4
4
  var getMainnetAndTestnetChains = async (apiOptions) => {
@@ -96,7 +96,7 @@ var ClientState = class {
96
96
  return response;
97
97
  }
98
98
  static async getSkipAssets(props) {
99
- if (this.skipAssets) {
99
+ if (props.chainId && this.skipAssets?.[props.chainId] || !props.chainId && this.skipAssets) {
100
100
  return this.skipAssets;
101
101
  }
102
102
  const response = await getMainnetAndTestnetAssets(props);
@@ -1,4 +1,4 @@
1
- import { pollingApi } from './chunk-SN5GGN5K.js';
1
+ import { pollingApi } from './chunk-DV3I2S3T.js';
2
2
 
3
3
  // src/api/postTrackTransaction.ts
4
4
  var trackTransaction = pollingApi({
@@ -0,0 +1,295 @@
1
+ import { MsgDepositForBurn, MsgDepositForBurnWithCaller, MsgExecute, MsgInitiateTokenDeposit, BaseVestingAccount, Timestamp, toTimestamp, Period, fromTimestamp, isSet, fromJsonTimestamp } from './chunk-TD63P2AG.js';
2
+ import '@cosmjs/stargate';
3
+ import { toUtf8 } from '@cosmjs/encoding';
4
+ import { MsgTransfer as MsgTransfer$1, MsgExecuteContractCompat } from '@injectivelabs/sdk-ts';
5
+ import { MsgSend } from 'cosmjs-types/cosmos/bank/v1beta1/tx.js';
6
+ import { MsgExecuteContract } from 'cosmjs-types/cosmwasm/wasm/v1/tx.js';
7
+ import { MsgTransfer } from 'cosmjs-types/ibc/applications/transfer/v1/tx.js';
8
+ import _m0 from 'protobufjs/minimal.js';
9
+
10
+ function createBaseClawbackVestingAccount() {
11
+ return {
12
+ baseVestingAccount: void 0,
13
+ funderAddress: "",
14
+ startTime: /* @__PURE__ */ new Date(),
15
+ lockupPeriods: [],
16
+ vestingPeriods: []
17
+ };
18
+ }
19
+ var ClawbackVestingAccount = {
20
+ typeUrl: "/evmos.vesting.v2.ClawbackVestingAccount",
21
+ encode(message, writer = _m0.Writer.create()) {
22
+ if (message.baseVestingAccount !== void 0) {
23
+ BaseVestingAccount.encode(message.baseVestingAccount, writer.uint32(10).fork()).ldelim();
24
+ }
25
+ if (message.funderAddress !== "") {
26
+ writer.uint32(18).string(message.funderAddress);
27
+ }
28
+ if (message.startTime !== void 0) {
29
+ Timestamp.encode(toTimestamp(message.startTime), writer.uint32(26).fork()).ldelim();
30
+ }
31
+ for (const v of message.lockupPeriods) {
32
+ Period.encode(v, writer.uint32(34).fork()).ldelim();
33
+ }
34
+ for (const v of message.vestingPeriods) {
35
+ Period.encode(v, writer.uint32(42).fork()).ldelim();
36
+ }
37
+ return writer;
38
+ },
39
+ decode(input, length) {
40
+ const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
41
+ let end = length === void 0 ? reader.len : reader.pos + length;
42
+ const message = createBaseClawbackVestingAccount();
43
+ while (reader.pos < end) {
44
+ const tag = reader.uint32();
45
+ switch (tag >>> 3) {
46
+ case 1:
47
+ message.baseVestingAccount = BaseVestingAccount.decode(reader, reader.uint32());
48
+ break;
49
+ case 2:
50
+ message.funderAddress = reader.string();
51
+ break;
52
+ case 3:
53
+ message.startTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
54
+ break;
55
+ case 4:
56
+ message.lockupPeriods.push(Period.decode(reader, reader.uint32()));
57
+ break;
58
+ case 5:
59
+ message.vestingPeriods.push(Period.decode(reader, reader.uint32()));
60
+ break;
61
+ default:
62
+ reader.skipType(tag & 7);
63
+ break;
64
+ }
65
+ }
66
+ return message;
67
+ },
68
+ fromJSON(object) {
69
+ return {
70
+ baseVestingAccount: isSet(object.baseVestingAccount) ? BaseVestingAccount.fromJSON(object.baseVestingAccount) : void 0,
71
+ funderAddress: isSet(object.funderAddress) ? String(object.funderAddress) : "",
72
+ startTime: isSet(object.startTime) ? fromJsonTimestamp(object.startTime) : void 0,
73
+ lockupPeriods: Array.isArray(object?.lockupPeriods) ? object.lockupPeriods.map((e) => Period.fromJSON(e)) : [],
74
+ vestingPeriods: Array.isArray(object?.vestingPeriods) ? object.vestingPeriods.map((e) => Period.fromJSON(e)) : []
75
+ };
76
+ },
77
+ toJSON(message) {
78
+ const obj = {};
79
+ message.baseVestingAccount !== void 0 && (obj.baseVestingAccount = message.baseVestingAccount ? BaseVestingAccount.toJSON(message.baseVestingAccount) : void 0);
80
+ message.funderAddress !== void 0 && (obj.funderAddress = message.funderAddress);
81
+ message.startTime !== void 0 && (obj.startTime = message.startTime.toISOString());
82
+ if (message.lockupPeriods) {
83
+ obj.lockupPeriods = message.lockupPeriods.map((e) => e ? Period.toJSON(e) : void 0);
84
+ } else {
85
+ obj.lockupPeriods = [];
86
+ }
87
+ if (message.vestingPeriods) {
88
+ obj.vestingPeriods = message.vestingPeriods.map((e) => e ? Period.toJSON(e) : void 0);
89
+ } else {
90
+ obj.vestingPeriods = [];
91
+ }
92
+ return obj;
93
+ },
94
+ fromPartial(object) {
95
+ const message = createBaseClawbackVestingAccount();
96
+ message.baseVestingAccount = object.baseVestingAccount !== void 0 && object.baseVestingAccount !== null ? BaseVestingAccount.fromPartial(object.baseVestingAccount) : void 0;
97
+ message.funderAddress = object.funderAddress ?? "";
98
+ message.startTime = object.startTime ?? void 0;
99
+ message.lockupPeriods = object.lockupPeriods?.map((e) => Period.fromPartial(e)) || [];
100
+ message.vestingPeriods = object.vestingPeriods?.map((e) => Period.fromPartial(e)) || [];
101
+ return message;
102
+ },
103
+ fromAmino(object) {
104
+ const message = createBaseClawbackVestingAccount();
105
+ if (object.base_vesting_account !== void 0 && object.base_vesting_account !== null) {
106
+ message.baseVestingAccount = BaseVestingAccount.fromAmino(object.base_vesting_account);
107
+ }
108
+ if (object.funder_address !== void 0 && object.funder_address !== null) {
109
+ message.funderAddress = object.funder_address;
110
+ }
111
+ if (object.start_time !== void 0 && object.start_time !== null) {
112
+ message.startTime = fromTimestamp(Timestamp.fromAmino(object.start_time));
113
+ }
114
+ message.lockupPeriods = object.lockup_periods?.map((e) => Period.fromAmino(e)) || [];
115
+ message.vestingPeriods = object.vesting_periods?.map((e) => Period.fromAmino(e)) || [];
116
+ return message;
117
+ },
118
+ toAmino(message) {
119
+ const obj = {};
120
+ obj.base_vesting_account = message.baseVestingAccount ? BaseVestingAccount.toAmino(message.baseVestingAccount) : void 0;
121
+ obj.funder_address = message.funderAddress === "" ? void 0 : message.funderAddress;
122
+ obj.start_time = message.startTime ? Timestamp.toAmino(toTimestamp(message.startTime)) : void 0;
123
+ if (message.lockupPeriods) {
124
+ obj.lockup_periods = message.lockupPeriods.map((e) => e ? Period.toAmino(e) : void 0);
125
+ } else {
126
+ obj.lockup_periods = message.lockupPeriods;
127
+ }
128
+ if (message.vestingPeriods) {
129
+ obj.vesting_periods = message.vestingPeriods.map((e) => e ? Period.toAmino(e) : void 0);
130
+ } else {
131
+ obj.vesting_periods = message.vestingPeriods;
132
+ }
133
+ return obj;
134
+ },
135
+ fromAminoMsg(object) {
136
+ return ClawbackVestingAccount.fromAmino(object.value);
137
+ },
138
+ toAminoMsg(message) {
139
+ return {
140
+ type: "vesting/ClawbackVestingAccount",
141
+ value: ClawbackVestingAccount.toAmino(message)
142
+ };
143
+ },
144
+ fromProtoMsg(message) {
145
+ return ClawbackVestingAccount.decode(message.value);
146
+ },
147
+ toProto(message) {
148
+ return ClawbackVestingAccount.encode(message).finish();
149
+ },
150
+ toProtoMsg(message) {
151
+ return {
152
+ typeUrl: "/evmos.vesting.v2.ClawbackVestingAccount",
153
+ value: ClawbackVestingAccount.encode(message).finish()
154
+ };
155
+ }
156
+ };
157
+
158
+ // src/private-functions/cosmos/getEncodeObjectFromCosmosMessage.ts
159
+ function getEncodeObjectFromCosmosMessage(message) {
160
+ const msgJson = JSON.parse(message.msg ?? "");
161
+ if (message.msgTypeUrl === "/ibc.applications.transfer.v1.MsgTransfer") {
162
+ return {
163
+ typeUrl: "/ibc.applications.transfer.v1.MsgTransfer",
164
+ value: MsgTransfer.fromJSON({
165
+ sourcePort: msgJson.source_port,
166
+ sourceChannel: msgJson.source_channel,
167
+ token: msgJson.token,
168
+ sender: msgJson.sender,
169
+ receiver: msgJson.receiver,
170
+ timeoutHeight: msgJson.timeout_height,
171
+ timeoutTimestamp: msgJson.timeout_timestamp,
172
+ memo: msgJson.memo
173
+ })
174
+ };
175
+ }
176
+ if (message.msgTypeUrl === "/cosmwasm.wasm.v1.MsgExecuteContract") {
177
+ return {
178
+ typeUrl: message.msgTypeUrl,
179
+ value: MsgExecuteContract.fromPartial({
180
+ sender: msgJson.sender,
181
+ contract: msgJson.contract,
182
+ msg: toUtf8(JSON.stringify(msgJson.msg)),
183
+ funds: msgJson.funds
184
+ })
185
+ };
186
+ }
187
+ if (message.msgTypeUrl === "/cosmos.bank.v1beta1.MsgSend") {
188
+ return {
189
+ typeUrl: message.msgTypeUrl,
190
+ value: MsgSend.fromPartial({
191
+ fromAddress: msgJson.from_address,
192
+ toAddress: msgJson.to_address,
193
+ amount: msgJson.amount
194
+ })
195
+ };
196
+ }
197
+ if (message.msgTypeUrl === "/circle.cctp.v1.MsgDepositForBurn") {
198
+ return {
199
+ typeUrl: message.msgTypeUrl,
200
+ value: MsgDepositForBurn.fromAmino(msgJson)
201
+ };
202
+ }
203
+ if (message.msgTypeUrl === "/circle.cctp.v1.MsgDepositForBurnWithCaller") {
204
+ return {
205
+ typeUrl: message.msgTypeUrl,
206
+ value: MsgDepositForBurnWithCaller.fromAmino(msgJson)
207
+ };
208
+ }
209
+ if (message.msgTypeUrl === "/initia.move.v1.MsgExecute") {
210
+ return {
211
+ typeUrl: message.msgTypeUrl,
212
+ value: MsgExecute.fromPartial({
213
+ sender: msgJson.sender,
214
+ moduleAddress: msgJson.module_address,
215
+ moduleName: msgJson.module_name,
216
+ functionName: msgJson.function_name,
217
+ args: msgJson.args
218
+ })
219
+ };
220
+ }
221
+ if (message.msgTypeUrl === "/opinit.ophost.v1.MsgInitiateTokenDeposit") {
222
+ return {
223
+ typeUrl: message.msgTypeUrl,
224
+ value: MsgInitiateTokenDeposit.fromPartial({
225
+ sender: msgJson.sender,
226
+ to: msgJson.to,
227
+ amount: msgJson.amount,
228
+ bridgeId: msgJson.bridge_id
229
+ })
230
+ };
231
+ }
232
+ if (message.msgTypeUrl === "/evmos.vesting.v2.ClawbackVestingAccount") {
233
+ return {
234
+ typeUrl: message.msgTypeUrl,
235
+ value: ClawbackVestingAccount.fromPartial({
236
+ baseVestingAccount: msgJson.base_vesting_account,
237
+ funderAddress: msgJson.funder_address,
238
+ lockupPeriods: msgJson.lockup_periods,
239
+ startTime: msgJson.start_time,
240
+ vestingPeriods: msgJson.vesting_periods
241
+ })
242
+ };
243
+ }
244
+ return {
245
+ typeUrl: message.msgTypeUrl ?? "",
246
+ value: msgJson
247
+ };
248
+ }
249
+ function getEncodeObjectFromCosmosMessageInjective(message) {
250
+ const msgJson = JSON.parse(message.msg ?? "");
251
+ if (message.msgTypeUrl === "/ibc.applications.transfer.v1.MsgTransfer") {
252
+ return MsgTransfer$1.fromJSON({
253
+ port: msgJson.source_port,
254
+ channelId: msgJson.source_channel,
255
+ amount: msgJson.token,
256
+ sender: msgJson.sender,
257
+ receiver: msgJson.receiver,
258
+ timeout: msgJson.timeout_timestamp,
259
+ memo: msgJson.memo
260
+ });
261
+ }
262
+ if (message.msgTypeUrl === "/cosmwasm.wasm.v1.MsgExecuteContract") {
263
+ return MsgExecuteContractCompat.fromJSON({
264
+ sender: msgJson.sender,
265
+ contractAddress: msgJson.contract,
266
+ msg: msgJson.msg,
267
+ funds: msgJson.funds
268
+ });
269
+ }
270
+ throw new Error("Unsupported message type");
271
+ }
272
+
273
+ // src/public-functions/getCosmosGasAmountForMessage.ts
274
+ var DEFAULT_GAS_MULTIPLIER = 1.5;
275
+ async function getCosmosGasAmountForMessage(client, signerAddress, chainId, messages, encodedMsgs, multiplier = DEFAULT_GAS_MULTIPLIER) {
276
+ if (!messages && !encodedMsgs) {
277
+ throw new Error("Either message or encodedMsg must be provided");
278
+ }
279
+ const _encodedMsgs = messages?.map((message) => getEncodeObjectFromCosmosMessage(message));
280
+ encodedMsgs = encodedMsgs || _encodedMsgs;
281
+ if (!encodedMsgs) {
282
+ throw new Error("Either message or encodedMsg must be provided");
283
+ }
284
+ if (chainId.includes("evmos") || chainId.includes("injective") || chainId.includes("dymension") || process?.env.NODE_ENV === "test") {
285
+ if (messages?.find((i) => i.msgTypeUrl === "/cosmwasm.wasm.v1.MsgExecuteContract")) {
286
+ return "2400000";
287
+ }
288
+ return "280000";
289
+ }
290
+ const estimatedGas = await client.simulate(signerAddress, encodedMsgs, "");
291
+ const estimatedGasWithBuffer = estimatedGas * multiplier;
292
+ return Math.ceil(estimatedGasWithBuffer).toFixed(0);
293
+ }
294
+
295
+ export { DEFAULT_GAS_MULTIPLIER, getCosmosGasAmountForMessage, getEncodeObjectFromCosmosMessage, getEncodeObjectFromCosmosMessageInjective };
@@ -1,4 +1,4 @@
1
- import { api } from './chunk-SN5GGN5K.js';
1
+ import { api } from './chunk-DV3I2S3T.js';
2
2
 
3
3
  // src/api/getBridges.ts
4
4
  var bridges = api({