@skip-go/client 1.6.0-alpha.2 → 1.6.0-alpha.3

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 (158) hide show
  1. package/package.json +1 -1
  2. package/dist/cjs/api/getAssets.cjs +0 -16
  3. package/dist/cjs/api/getAssetsBetweenChains.cjs +0 -12
  4. package/dist/cjs/api/getBridges.cjs +0 -12
  5. package/dist/cjs/api/getChains.cjs +0 -12
  6. package/dist/cjs/api/getVenues.cjs +0 -12
  7. package/dist/cjs/api/postAssetsFromSource.cjs +0 -13
  8. package/dist/cjs/api/postBalances.cjs +0 -12
  9. package/dist/cjs/api/postIbcOriginAssets.cjs +0 -12
  10. package/dist/cjs/api/postMessages.cjs +0 -12
  11. package/dist/cjs/api/postMessagesDirect.cjs +0 -12
  12. package/dist/cjs/api/postRecommendAssets.cjs +0 -12
  13. package/dist/cjs/api/postRoute.cjs +0 -12
  14. package/dist/cjs/api/postSubmitTransaction.cjs +0 -12
  15. package/dist/cjs/api/postTrackTransaction.cjs +0 -12
  16. package/dist/cjs/api/postTransactionStatus.cjs +0 -12
  17. package/dist/cjs/chunk-25TA7Z7R.cjs +0 -460
  18. package/dist/cjs/chunk-2QPPD3BB.cjs +0 -210
  19. package/dist/cjs/chunk-2SA3OAIJ.cjs +0 -18
  20. package/dist/cjs/chunk-4BWE7SOV.cjs +0 -68
  21. package/dist/cjs/chunk-4GHUZDDP.cjs +0 -16
  22. package/dist/cjs/chunk-4ZIVDKQN.cjs +0 -387
  23. package/dist/cjs/chunk-A3UNNRKD.cjs +0 -574
  24. package/dist/cjs/chunk-A5S6SIYN.cjs +0 -12
  25. package/dist/cjs/chunk-AQTXZWLA.cjs +0 -55
  26. package/dist/cjs/chunk-ASDMDYTC.cjs +0 -11
  27. package/dist/cjs/chunk-ATW6UNT5.cjs +0 -136
  28. package/dist/cjs/chunk-AUTOIM57.cjs +0 -22
  29. package/dist/cjs/chunk-AVWWCQ5P.cjs +0 -2264
  30. package/dist/cjs/chunk-CIZTNJ3K.cjs +0 -24
  31. package/dist/cjs/chunk-CK6CQWQU.cjs +0 -49
  32. package/dist/cjs/chunk-EAZQ2ECA.cjs +0 -185
  33. package/dist/cjs/chunk-F3EB2AQG.cjs +0 -28
  34. package/dist/cjs/chunk-FCTBCHOT.cjs +0 -12
  35. package/dist/cjs/chunk-IJIBMN2F.cjs +0 -12
  36. package/dist/cjs/chunk-JRXPJ45U.cjs +0 -12
  37. package/dist/cjs/chunk-LJF74VNZ.cjs +0 -214
  38. package/dist/cjs/chunk-LJV45UGL.cjs +0 -582
  39. package/dist/cjs/chunk-MUJBB64F.cjs +0 -291
  40. package/dist/cjs/chunk-NCFH5MGF.cjs +0 -39
  41. package/dist/cjs/chunk-NM4PISTQ.cjs +0 -3359
  42. package/dist/cjs/chunk-OJISEAMX.cjs +0 -13
  43. package/dist/cjs/chunk-OVKHTOBP.cjs +0 -99
  44. package/dist/cjs/chunk-PDNKS5R2.cjs +0 -13
  45. package/dist/cjs/chunk-TEH6UMUR.cjs +0 -280
  46. package/dist/cjs/chunk-UXW4XVHF.cjs +0 -15
  47. package/dist/cjs/chunk-WVMDZODS.cjs +0 -1495
  48. package/dist/cjs/chunk-YX56UXDX.cjs +0 -189
  49. package/dist/cjs/index.cjs +0 -349
  50. package/dist/cjs/public-functions/executeMultipleRoutes.cjs +0 -27
  51. package/dist/cjs/public-functions/executeRoute.cjs +0 -27
  52. package/dist/cjs/public-functions/getCosmosGasAmountForMessage.cjs +0 -16
  53. package/dist/cjs/public-functions/getEvmGasAmountForMessage.cjs +0 -11
  54. package/dist/cjs/public-functions/getFeeInfoForChain.cjs +0 -14
  55. package/dist/cjs/public-functions/getRecommendedGasPrice.cjs +0 -15
  56. package/dist/cjs/public-functions/getRouteWithGasOnReceive.cjs +0 -41
  57. package/dist/cjs/public-functions/getSigningStargateClient.cjs +0 -15
  58. package/dist/cjs/public-functions/setApiOptions.cjs +0 -12
  59. package/dist/cjs/public-functions/setClientOptions.cjs +0 -16
  60. package/dist/cjs/public-functions/subscribeToRouteStatus.cjs +0 -26
  61. package/dist/cjs/public-functions/validateCosmosGasBalance.cjs +0 -18
  62. package/dist/cjs/public-functions/waitForTransaction.cjs +0 -18
  63. package/dist/esm/api/getAssets.d.ts +0 -19
  64. package/dist/esm/api/getAssets.js +0 -3
  65. package/dist/esm/api/getAssetsBetweenChains.d.ts +0 -56
  66. package/dist/esm/api/getAssetsBetweenChains.js +0 -3
  67. package/dist/esm/api/getBridges.d.ts +0 -55
  68. package/dist/esm/api/getBridges.js +0 -3
  69. package/dist/esm/api/getChains.d.ts +0 -41
  70. package/dist/esm/api/getChains.js +0 -3
  71. package/dist/esm/api/getVenues.d.ts +0 -13
  72. package/dist/esm/api/getVenues.js +0 -3
  73. package/dist/esm/api/postAssetsFromSource.d.ts +0 -22
  74. package/dist/esm/api/postAssetsFromSource.js +0 -4
  75. package/dist/esm/api/postBalances.d.ts +0 -35
  76. package/dist/esm/api/postBalances.js +0 -3
  77. package/dist/esm/api/postIbcOriginAssets.d.ts +0 -32
  78. package/dist/esm/api/postIbcOriginAssets.js +0 -3
  79. package/dist/esm/api/postMessages.d.ts +0 -101
  80. package/dist/esm/api/postMessages.js +0 -3
  81. package/dist/esm/api/postMessagesDirect.d.ts +0 -640
  82. package/dist/esm/api/postMessagesDirect.js +0 -3
  83. package/dist/esm/api/postRecommendAssets.d.ts +0 -40
  84. package/dist/esm/api/postRecommendAssets.js +0 -3
  85. package/dist/esm/api/postRoute.d.ts +0 -530
  86. package/dist/esm/api/postRoute.js +0 -3
  87. package/dist/esm/api/postSubmitTransaction.d.ts +0 -17
  88. package/dist/esm/api/postSubmitTransaction.js +0 -3
  89. package/dist/esm/api/postTrackTransaction.d.ts +0 -12
  90. package/dist/esm/api/postTrackTransaction.js +0 -3
  91. package/dist/esm/api/postTransactionStatus.d.ts +0 -639
  92. package/dist/esm/api/postTransactionStatus.js +0 -3
  93. package/dist/esm/apiState-1VvikVK-.d.ts +0 -8
  94. package/dist/esm/callbacks-DdC6QMlE.d.ts +0 -158
  95. package/dist/esm/chunk-3DIX6KRJ.js +0 -566
  96. package/dist/esm/chunk-3JHLVPRG.js +0 -10
  97. package/dist/esm/chunk-5WYMRZIO.js +0 -97
  98. package/dist/esm/chunk-6QW6MRVQ.js +0 -53
  99. package/dist/esm/chunk-A5NZMSTI.js +0 -10
  100. package/dist/esm/chunk-CGJRRAFS.js +0 -22
  101. package/dist/esm/chunk-DMJMN4J3.js +0 -379
  102. package/dist/esm/chunk-E4NRDAVO.js +0 -65
  103. package/dist/esm/chunk-ETBJVFQP.js +0 -10
  104. package/dist/esm/chunk-F2LQB2DP.js +0 -3323
  105. package/dist/esm/chunk-F66EKL3W.js +0 -203
  106. package/dist/esm/chunk-GV2QOWB4.js +0 -26
  107. package/dist/esm/chunk-GZJLX2CP.js +0 -2258
  108. package/dist/esm/chunk-HNU2Y3JI.js +0 -13
  109. package/dist/esm/chunk-J24LYWJE.js +0 -130
  110. package/dist/esm/chunk-KZKAL5ZN.js +0 -16
  111. package/dist/esm/chunk-N4PTRCNT.js +0 -11
  112. package/dist/esm/chunk-NUHMTWHP.js +0 -180
  113. package/dist/esm/chunk-OMOVHXSC.js +0 -212
  114. package/dist/esm/chunk-P36PE4CR.js +0 -37
  115. package/dist/esm/chunk-PZ2624FK.js +0 -187
  116. package/dist/esm/chunk-QYXGDTUU.js +0 -47
  117. package/dist/esm/chunk-R2GHDOWX.js +0 -272
  118. package/dist/esm/chunk-RH7PDDI5.js +0 -433
  119. package/dist/esm/chunk-RTDD7HZ3.js +0 -275
  120. package/dist/esm/chunk-SXBG57J3.js +0 -20
  121. package/dist/esm/chunk-TGTOO2ZQ.js +0 -14
  122. package/dist/esm/chunk-UHCKOKBM.js +0 -9
  123. package/dist/esm/chunk-ULUX2CVU.js +0 -557
  124. package/dist/esm/chunk-UN46DUOV.js +0 -11
  125. package/dist/esm/chunk-XNU3TKKM.js +0 -10
  126. package/dist/esm/chunk-ZVFYCNA5.js +0 -1492
  127. package/dist/esm/client-types-D03Tellv.d.ts +0 -114
  128. package/dist/esm/generateApi-Bv02Xt5y.d.ts +0 -56
  129. package/dist/esm/index.d.ts +0 -1859
  130. package/dist/esm/index.js +0 -32
  131. package/dist/esm/public-functions/executeMultipleRoutes.d.ts +0 -80
  132. package/dist/esm/public-functions/executeMultipleRoutes.js +0 -18
  133. package/dist/esm/public-functions/executeRoute.d.ts +0 -12
  134. package/dist/esm/public-functions/executeRoute.js +0 -18
  135. package/dist/esm/public-functions/getCosmosGasAmountForMessage.d.ts +0 -8
  136. package/dist/esm/public-functions/getCosmosGasAmountForMessage.js +0 -3
  137. package/dist/esm/public-functions/getEvmGasAmountForMessage.d.ts +0 -14
  138. package/dist/esm/public-functions/getEvmGasAmountForMessage.js +0 -2
  139. package/dist/esm/public-functions/getFeeInfoForChain.d.ts +0 -9
  140. package/dist/esm/public-functions/getFeeInfoForChain.js +0 -5
  141. package/dist/esm/public-functions/getRecommendedGasPrice.d.ts +0 -9
  142. package/dist/esm/public-functions/getRecommendedGasPrice.js +0 -6
  143. package/dist/esm/public-functions/getRouteWithGasOnReceive.d.ts +0 -20
  144. package/dist/esm/public-functions/getRouteWithGasOnReceive.js +0 -32
  145. package/dist/esm/public-functions/getSigningStargateClient.d.ts +0 -13
  146. package/dist/esm/public-functions/getSigningStargateClient.js +0 -6
  147. package/dist/esm/public-functions/setApiOptions.d.ts +0 -9
  148. package/dist/esm/public-functions/setApiOptions.js +0 -3
  149. package/dist/esm/public-functions/setClientOptions.d.ts +0 -11
  150. package/dist/esm/public-functions/setClientOptions.js +0 -7
  151. package/dist/esm/public-functions/subscribeToRouteStatus.d.ts +0 -12
  152. package/dist/esm/public-functions/subscribeToRouteStatus.js +0 -5
  153. package/dist/esm/public-functions/validateCosmosGasBalance.d.ts +0 -44
  154. package/dist/esm/public-functions/validateCosmosGasBalance.js +0 -9
  155. package/dist/esm/public-functions/waitForTransaction.d.ts +0 -1279
  156. package/dist/esm/public-functions/waitForTransaction.js +0 -5
  157. package/dist/esm/setClientOptions-CTwe8YVX.d.ts +0 -76
  158. package/dist/esm/swaggerTypes-CzGbnX_b.d.ts +0 -2067
@@ -1,210 +0,0 @@
1
- 'use strict';
2
-
3
- // src/utils/timer.ts
4
- var wait = (ms) => {
5
- return new Promise((resolve) => setTimeout(resolve, ms));
6
- };
7
-
8
- // src/utils/convert.ts
9
- function toSnake(obj) {
10
- return convertKeys(obj, (key) => key.replace(/([A-Z])/g, "_$1").toLowerCase());
11
- }
12
- function toCamel(obj) {
13
- return convertKeys(obj, (key) => key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()));
14
- }
15
- function convertKeys(obj, convertKey) {
16
- if (Array.isArray(obj)) {
17
- return obj.map((item) => convertKeys(item, convertKey));
18
- } else if (obj !== null && typeof obj === "object") {
19
- return Object.keys(obj).reduce((acc, key) => {
20
- acc[convertKey(key)] = convertKeys(obj[key], convertKey);
21
- return acc;
22
- }, {});
23
- } else {
24
- return obj;
25
- }
26
- }
27
-
28
- // src/utils/generateApi.ts
29
- var createRequestClient = ({ apiUrl, apiKey, apiHeaders }) => {
30
- if (!apiUrl?.endsWith("/")) {
31
- apiUrl += "/";
32
- }
33
- const headers = new Headers({
34
- "content-type": "application/json"
35
- });
36
- if (apiKey) {
37
- headers.set("authorization", apiKey);
38
- }
39
- if (apiHeaders) {
40
- new Headers(apiHeaders).forEach((value, key) => {
41
- headers.set(key, value);
42
- });
43
- }
44
- const handleResponse = async (response) => {
45
- const contentType = response.headers.get("content-type");
46
- const isJson = contentType?.includes("application/json");
47
- const body = isJson ? await response.json() : await response.text();
48
- if (!response.ok) {
49
- const message = typeof body === "object" && body?.message ? body.message : response.statusText;
50
- const error = new Error(message);
51
- if (body?.code) {
52
- error.code = body.code;
53
- }
54
- if (body?.details) {
55
- error.details = body.details;
56
- }
57
- throw error;
58
- }
59
- return body;
60
- };
61
- const get = async (path, params, signal) => {
62
- if (path?.startsWith("/")) {
63
- console.warn("paths that start with / are treated as absolute paths, please remove the leading / if this path is intended to be a relative path");
64
- }
65
- const url = new URL(path ?? "", apiUrl);
66
- if (params && typeof params === "object") {
67
- Object.entries(params).forEach(([key, value]) => {
68
- if (value !== void 0 && value !== null) {
69
- if (Array.isArray(value)) {
70
- value.forEach((item) => {
71
- url.searchParams.append(key, String(item));
72
- });
73
- } else {
74
- url.searchParams.append(key, String(value));
75
- }
76
- }
77
- });
78
- }
79
- const response = await fetch(url.toString(), {
80
- method: "GET",
81
- headers,
82
- signal
83
- });
84
- return handleResponse(response);
85
- };
86
- const post = async (path, data = {}, signal) => {
87
- if (path?.startsWith("/")) {
88
- console.warn("paths that start with / are treated as absolute paths, please remove the leading / if this path is intended to be a relative path");
89
- }
90
- const response = await fetch(new URL(path, apiUrl).toString(), {
91
- method: "POST",
92
- headers,
93
- body: JSON.stringify(data),
94
- signal
95
- });
96
- return handleResponse(response);
97
- };
98
- return { get, post };
99
- };
100
- function createRequest({
101
- path,
102
- method = "get",
103
- onSuccess,
104
- transformResponse
105
- }) {
106
- let controller = null;
107
- const request = async (options) => {
108
- const { apiKey, apiUrl, apiHeaders, abortDuplicateRequests, ...requestParams } = options ?? {};
109
- let fetchClient = ApiState.client;
110
- if (apiKey || apiUrl || apiHeaders || fetchClient === void 0) {
111
- fetchClient = createRequestClient({
112
- apiUrl: apiUrl || "https://api.skip.build",
113
- apiKey,
114
- apiHeaders
115
- });
116
- }
117
- ApiState.apiCalled = true;
118
- if (abortDuplicateRequests && controller && !controller?.signal?.aborted) {
119
- controller?.abort();
120
- }
121
- controller = new AbortController();
122
- try {
123
- const response = await fetchClient[method](
124
- path,
125
- requestParams ? toSnake(requestParams) : void 0,
126
- controller.signal
127
- );
128
- const camelCased = toCamel(response ?? {});
129
- const finalResponse = transformResponse ? transformResponse(camelCased) : camelCased;
130
- onSuccess?.(finalResponse, requestParams);
131
- return finalResponse;
132
- } catch (error) {
133
- if (error.name === "AbortError") {
134
- console.log("Request was cancelled");
135
- } else {
136
- console.error("Error:", error);
137
- throw error;
138
- }
139
- }
140
- };
141
- return request;
142
- }
143
- function api({
144
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
145
- methodName,
146
- path,
147
- onSuccess,
148
- method = "get",
149
- transformResponse
150
- }) {
151
- return createRequest({
152
- path,
153
- method,
154
- onSuccess,
155
- transformResponse
156
- });
157
- }
158
- function pollingApi({
159
- methodName,
160
- path,
161
- method = "get",
162
- onSuccess,
163
- onError,
164
- isSuccess = () => true,
165
- maxRetries = 10,
166
- retryInterval = 1e3,
167
- backoffMultiplier = 2,
168
- throwOnError = false
169
- }) {
170
- const request = async (requestParams) => {
171
- let attempt = 0;
172
- let lastError;
173
- while (attempt < maxRetries) {
174
- try {
175
- const result = await api({ methodName, path, method })(requestParams);
176
- if (result && isSuccess(result)) {
177
- onSuccess?.(result, attempt);
178
- return result;
179
- }
180
- } catch (err) {
181
- lastError = err;
182
- onError?.(err, attempt);
183
- if (throwOnError) {
184
- throw err;
185
- }
186
- }
187
- const delay = retryInterval * Math.pow(backoffMultiplier, attempt);
188
- await wait(delay);
189
- attempt++;
190
- }
191
- throw lastError ?? new Error("pollingApi: max retries exceeded");
192
- };
193
- return (params) => request(params);
194
- }
195
-
196
- // src/state/apiState.ts
197
- var ApiState = class {
198
- static client;
199
- static chainIdsToAffiliates;
200
- static cumulativeAffiliateFeeBPS = "0";
201
- static initialized = false;
202
- static apiCalled = false;
203
- };
204
-
205
- exports.ApiState = ApiState;
206
- exports.api = api;
207
- exports.createRequestClient = createRequestClient;
208
- exports.pollingApi = pollingApi;
209
- exports.toCamel = toCamel;
210
- exports.wait = wait;
@@ -1,18 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk2QPPD3BB_cjs = require('./chunk-2QPPD3BB.cjs');
4
-
5
- // src/api/postRoute.ts
6
- var route = async (request) => {
7
- const requestWithAffiliateFeeBps = {
8
- ...request,
9
- cumulativeAffiliateFeeBps: chunk2QPPD3BB_cjs.ApiState.cumulativeAffiliateFeeBPS
10
- };
11
- return chunk2QPPD3BB_cjs.api({
12
- methodName: "route",
13
- method: "post",
14
- path: "v2/fungible/route"
15
- })(requestWithAffiliateFeeBps);
16
- };
17
-
18
- exports.route = route;
@@ -1,68 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkAUTOIM57_cjs = require('./chunk-AUTOIM57.cjs');
4
- var chunkPDNKS5R2_cjs = require('./chunk-PDNKS5R2.cjs');
5
- var chunk2QPPD3BB_cjs = require('./chunk-2QPPD3BB.cjs');
6
-
7
- // src/public-functions/waitForTransaction.ts
8
- var waitForTransaction = async ({
9
- chainId,
10
- txHash,
11
- explorerLink,
12
- doNotTrack = false,
13
- onStatusUpdated,
14
- onError,
15
- onTransactionTracked,
16
- isCancelled,
17
- ...trackTxPollingOptions
18
- }) => {
19
- try {
20
- if (!explorerLink && !doNotTrack) {
21
- const response = await chunkAUTOIM57_cjs.trackTransaction({
22
- chainId,
23
- txHash,
24
- ...trackTxPollingOptions
25
- });
26
- explorerLink = response.explorerLink;
27
- await onTransactionTracked?.({ txHash, chainId, explorerLink });
28
- }
29
- } catch (error) {
30
- console.warn(`track failed for txHash:${txHash}, chainId: ${chainId}`);
31
- }
32
- while (true) {
33
- if (isCancelled?.()) {
34
- throw new Error("waitForTransaction was aborted");
35
- }
36
- try {
37
- const txStatusResponse = await chunkPDNKS5R2_cjs.transactionStatus({
38
- chainId,
39
- txHash
40
- });
41
- onStatusUpdated?.(txStatusResponse);
42
- if (txStatusResponse.state === "STATE_COMPLETED_SUCCESS") {
43
- return txStatusResponse;
44
- }
45
- if (txStatusResponse.state === "STATE_COMPLETED_ERROR") {
46
- throw new Error(`${txStatusResponse.error?.type}: ${txStatusResponse.error?.message}`);
47
- }
48
- if (txStatusResponse.state === "STATE_ABANDONED") {
49
- throw new Error("Tracking for the transaction has been abandoned");
50
- }
51
- await chunk2QPPD3BB_cjs.wait(1e3);
52
- } catch (error) {
53
- onError?.(error);
54
- throw error;
55
- }
56
- }
57
- };
58
- var waitForTransactionWithCancel = (props) => {
59
- let isCancelled = false;
60
- const cancel = () => {
61
- isCancelled = true;
62
- };
63
- const wrappedPromise = waitForTransaction({ ...props, isCancelled: () => isCancelled });
64
- return { promise: wrappedPromise, cancel };
65
- };
66
-
67
- exports.waitForTransaction = waitForTransaction;
68
- exports.waitForTransactionWithCancel = waitForTransactionWithCancel;
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkATW6UNT5_cjs = require('./chunk-ATW6UNT5.cjs');
4
- var chunk2QPPD3BB_cjs = require('./chunk-2QPPD3BB.cjs');
5
-
6
- // src/api/postAssetsFromSource.ts
7
- var assetsFromSource = chunk2QPPD3BB_cjs.api({
8
- methodName: "assetsFromSource",
9
- method: "post",
10
- path: "v2/fungible/assets_from_source",
11
- transformResponse(response) {
12
- return chunkATW6UNT5_cjs.transformAssetsMap(response.destAssets);
13
- }
14
- });
15
-
16
- exports.assetsFromSource = assetsFromSource;
@@ -1,387 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkMUJBB64F_cjs = require('./chunk-MUJBB64F.cjs');
4
- var chunkEAZQ2ECA_cjs = require('./chunk-EAZQ2ECA.cjs');
5
- var chunkATW6UNT5_cjs = require('./chunk-ATW6UNT5.cjs');
6
- var stargate = require('@cosmjs/stargate');
7
- var utils = require('@cosmjs/utils');
8
- var binary_js = require('cosmjs-types/binary.js');
9
- var auth_js = require('cosmjs-types/cosmos/auth/v1beta1/auth.js');
10
- var coin_js = require('cosmjs-types/cosmos/base/v1beta1/coin.js');
11
- var protoSigning = require('@cosmjs/proto-signing');
12
- var keys_js = require('cosmjs-types/cosmos/crypto/secp256k1/keys.js');
13
- var amino = require('@cosmjs/amino');
14
- var _m0 = require('protobufjs/minimal.js');
15
-
16
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
17
-
18
- var _m0__default = /*#__PURE__*/_interopDefault(_m0);
19
-
20
- var createBaseVestingAccount = () => {
21
- return {
22
- // @ts-expect-error
23
- baseAccount: void 0,
24
- originalVesting: [],
25
- delegatedFree: [],
26
- delegatedVesting: [],
27
- endTime: BigInt(0)
28
- };
29
- };
30
- var BaseVestingAccount = {
31
- encode(message, writer = binary_js.BinaryWriter.create()) {
32
- if (message.baseAccount !== void 0) {
33
- auth_js.BaseAccount.encode(
34
- message.baseAccount,
35
- writer.uint32(10).fork()
36
- ).ldelim();
37
- }
38
- for (const v of message.originalVesting) {
39
- coin_js.Coin.encode(v, writer.uint32(18).fork()).ldelim();
40
- }
41
- for (const v of message.delegatedFree) {
42
- coin_js.Coin.encode(v, writer.uint32(26).fork()).ldelim();
43
- }
44
- for (const v of message.delegatedVesting) {
45
- coin_js.Coin.encode(v, writer.uint32(34).fork()).ldelim();
46
- }
47
- if (message.endTime !== BigInt(0)) {
48
- writer.uint32(40).int64(message.endTime);
49
- }
50
- return writer;
51
- },
52
- decode(input, length) {
53
- const reader = input instanceof binary_js.BinaryReader ? input : new binary_js.BinaryReader(input);
54
- const end = length === void 0 ? reader.len : reader.pos + length;
55
- const message = createBaseVestingAccount();
56
- while (reader.pos < end) {
57
- const tag = reader.uint32();
58
- switch (tag >>> 3) {
59
- case 1:
60
- message.baseAccount = auth_js.BaseAccount.decode(reader, reader.uint32());
61
- break;
62
- case 2:
63
- message.originalVesting.push(coin_js.Coin.decode(reader, reader.uint32()));
64
- break;
65
- case 3:
66
- message.delegatedFree.push(coin_js.Coin.decode(reader, reader.uint32()));
67
- break;
68
- case 4:
69
- message.delegatedVesting.push(coin_js.Coin.decode(reader, reader.uint32()));
70
- break;
71
- case 5:
72
- message.endTime = reader.int64();
73
- break;
74
- default:
75
- reader.skipType(tag & 7);
76
- break;
77
- }
78
- }
79
- return message;
80
- }
81
- };
82
- function createBasePeriod() {
83
- return {
84
- startTime: BigInt(0),
85
- length: BigInt(0),
86
- amount: [],
87
- actionType: 0
88
- };
89
- }
90
- var Period = {
91
- encode(message, writer = binary_js.BinaryWriter.create()) {
92
- if (message.startTime !== BigInt(0)) {
93
- writer.uint32(8).int64(message.startTime);
94
- }
95
- if (message.length !== BigInt(0)) {
96
- writer.uint32(16).int64(message.length);
97
- }
98
- for (const v of message.amount) {
99
- coin_js.Coin.encode(v, writer.uint32(26).fork()).ldelim();
100
- }
101
- if (message.actionType !== 0) {
102
- writer.uint32(32).int32(message.actionType);
103
- }
104
- return writer;
105
- },
106
- decode(input, length) {
107
- const reader = input instanceof binary_js.BinaryReader ? input : new binary_js.BinaryReader(input);
108
- const end = length === void 0 ? reader.len : reader.pos + length;
109
- const message = createBasePeriod();
110
- while (reader.pos < end) {
111
- const tag = reader.uint32();
112
- switch (tag >>> 3) {
113
- case 1:
114
- message.startTime = reader.int64();
115
- break;
116
- case 2:
117
- message.length = reader.int64();
118
- break;
119
- case 3:
120
- message.amount.push(coin_js.Coin.decode(reader, reader.uint32()));
121
- break;
122
- case 4:
123
- message.actionType = reader.int32();
124
- break;
125
- default:
126
- reader.skipType(tag & 7);
127
- break;
128
- }
129
- }
130
- return message;
131
- }
132
- };
133
- function createBaseStridePeriodicVestingAccount() {
134
- return {
135
- //eslint-disable-next-line @typescript-eslint/ban-ts-comment
136
- //@ts-ignore
137
- baseVestingAccount: void 0,
138
- vestingPeriods: []
139
- };
140
- }
141
- var StridePeriodicVestingAccount = {
142
- encode(message, writer = binary_js.BinaryWriter.create()) {
143
- if (message.baseVestingAccount !== void 0) {
144
- BaseVestingAccount.encode(
145
- message.baseVestingAccount,
146
- writer.uint32(10).fork()
147
- ).ldelim();
148
- }
149
- for (const v of message.vestingPeriods) {
150
- Period.encode(v, writer.uint32(26).fork()).ldelim();
151
- }
152
- return writer;
153
- },
154
- decode(input, length) {
155
- const reader = input instanceof binary_js.BinaryReader ? input : new binary_js.BinaryReader(input);
156
- const end = length === void 0 ? reader.len : reader.pos + length;
157
- const message = createBaseStridePeriodicVestingAccount();
158
- while (reader.pos < end) {
159
- const tag = reader.uint32();
160
- switch (tag >>> 3) {
161
- case 1:
162
- message.baseVestingAccount = BaseVestingAccount.decode(
163
- reader,
164
- reader.uint32()
165
- );
166
- break;
167
- case 3:
168
- message.vestingPeriods.push(Period.decode(reader, reader.uint32()));
169
- break;
170
- default:
171
- reader.skipType(tag & 7);
172
- break;
173
- }
174
- }
175
- return message;
176
- }
177
- };
178
- function createBaseEthAccount() {
179
- return {
180
- baseAccount: void 0,
181
- codeHash: new Uint8Array()
182
- };
183
- }
184
- var EthAccount = {
185
- typeUrl: "/injective.types.v1beta1.EthAccount",
186
- encode(message, writer = _m0__default.default.Writer.create()) {
187
- if (message.baseAccount !== void 0) {
188
- chunkMUJBB64F_cjs.BaseAccount.encode(message.baseAccount, writer.uint32(10).fork()).ldelim();
189
- }
190
- if (message.codeHash.length !== 0) {
191
- writer.uint32(18).bytes(message.codeHash);
192
- }
193
- return writer;
194
- },
195
- decode(input, length) {
196
- const reader = input instanceof _m0__default.default.Reader ? input : new _m0__default.default.Reader(input);
197
- let end = length === void 0 ? reader.len : reader.pos + length;
198
- const message = createBaseEthAccount();
199
- while (reader.pos < end) {
200
- const tag = reader.uint32();
201
- switch (tag >>> 3) {
202
- case 1:
203
- message.baseAccount = chunkMUJBB64F_cjs.BaseAccount.decode(reader, reader.uint32());
204
- break;
205
- case 2:
206
- message.codeHash = reader.bytes();
207
- break;
208
- default:
209
- reader.skipType(tag & 7);
210
- break;
211
- }
212
- }
213
- return message;
214
- },
215
- fromJSON(object) {
216
- return {
217
- baseAccount: chunkMUJBB64F_cjs.isSet(object.baseAccount) ? chunkMUJBB64F_cjs.BaseAccount.fromJSON(object.baseAccount) : void 0,
218
- codeHash: chunkMUJBB64F_cjs.isSet(object.codeHash) ? chunkMUJBB64F_cjs.bytesFromBase64(object.codeHash) : new Uint8Array()
219
- };
220
- },
221
- toJSON(message) {
222
- const obj = {};
223
- message.baseAccount !== void 0 && (obj.baseAccount = message.baseAccount ? chunkMUJBB64F_cjs.BaseAccount.toJSON(message.baseAccount) : void 0);
224
- message.codeHash !== void 0 && (obj.codeHash = chunkMUJBB64F_cjs.base64FromBytes(message.codeHash !== void 0 ? message.codeHash : new Uint8Array()));
225
- return obj;
226
- },
227
- fromPartial(object) {
228
- const message = createBaseEthAccount();
229
- message.baseAccount = object.baseAccount !== void 0 && object.baseAccount !== null ? chunkMUJBB64F_cjs.BaseAccount.fromPartial(object.baseAccount) : void 0;
230
- message.codeHash = object.codeHash ?? new Uint8Array();
231
- return message;
232
- },
233
- fromAmino(object) {
234
- const message = createBaseEthAccount();
235
- if (object.base_account !== void 0 && object.base_account !== null) {
236
- message.baseAccount = chunkMUJBB64F_cjs.BaseAccount.fromAmino(object.base_account);
237
- }
238
- if (object.code_hash !== void 0 && object.code_hash !== null) {
239
- message.codeHash = chunkMUJBB64F_cjs.bytesFromBase64(object.code_hash);
240
- }
241
- return message;
242
- },
243
- toAmino(message) {
244
- const obj = {};
245
- obj.base_account = message.baseAccount ? chunkMUJBB64F_cjs.BaseAccount.toAmino(message.baseAccount) : void 0;
246
- obj.code_hash = message.codeHash ? chunkMUJBB64F_cjs.base64FromBytes(message.codeHash) : void 0;
247
- return obj;
248
- },
249
- fromAminoMsg(object) {
250
- return EthAccount.fromAmino(object.value);
251
- },
252
- fromProtoMsg(message) {
253
- return EthAccount.decode(message.value);
254
- },
255
- toProto(message) {
256
- return EthAccount.encode(message).finish();
257
- },
258
- toProtoMsg(message) {
259
- return {
260
- typeUrl: "/injective.types.v1beta1.EthAccount",
261
- value: EthAccount.encode(message).finish()
262
- };
263
- }
264
- };
265
-
266
- // src/registry.ts
267
- var accountParser = (acc) => {
268
- switch (acc.typeUrl) {
269
- case "/stride.vesting.StridePeriodicVestingAccount": {
270
- const baseAccount = StridePeriodicVestingAccount.decode(acc.value).baseVestingAccount?.baseAccount;
271
- utils.assertDefinedAndNotNull(baseAccount);
272
- return {
273
- address: baseAccount.address,
274
- pubkey: baseAccount.pubKey ? protoSigning.decodePubkey(baseAccount.pubKey) : null,
275
- accountNumber: Number(baseAccount.accountNumber),
276
- sequence: Number(baseAccount.sequence)
277
- };
278
- }
279
- case "/injective.types.v1beta1.EthAccount":
280
- return accountEthParser(
281
- acc,
282
- "/injective.crypto.v1beta1.ethsecp256k1.PubKey"
283
- );
284
- case "/ethermint.types.v1.EthAccount":
285
- return accountEthParser(acc, "/ethermint.crypto.v1.ethsecp256k1.PubKey");
286
- default: {
287
- if (acc.typeUrl === "/cosmos.auth.v1beta1.BaseAccount") {
288
- const { address, pubKey, accountNumber, sequence } = auth_js.BaseAccount.decode(
289
- acc.value
290
- );
291
- switch (pubKey?.typeUrl) {
292
- case "/initia.crypto.v1beta1.ethsecp256k1.PubKey":
293
- case "/ethermint.crypto.v1.ethsecp256k1.PubKey":
294
- case "/cosmos.evm.crypto.v1.ethsecp256k1.PubKey": {
295
- const { key } = keys_js.PubKey.decode(pubKey.value);
296
- const pk = amino.encodeSecp256k1Pubkey(key);
297
- return {
298
- address,
299
- pubkey: pk,
300
- accountNumber: Number(accountNumber),
301
- sequence: Number(sequence)
302
- };
303
- }
304
- }
305
- }
306
- return stargate.accountFromAny(acc);
307
- }
308
- }
309
- };
310
- var accountEthParser = (ethAccount, pubKeyTypeUrl = "/injective.crypto.v1beta1.ethsecp256k1.PubKey") => {
311
- const account = EthAccount.decode(
312
- ethAccount.value
313
- );
314
- const baseAccount = account.baseAccount;
315
- const pubKey = baseAccount.pubKey;
316
- return {
317
- address: baseAccount.address,
318
- pubkey: pubKey ? {
319
- type: pubKeyTypeUrl,
320
- value: Buffer.from(pubKey.value).toString("base64")
321
- } : null,
322
- accountNumber: parseInt(baseAccount.accountNumber.toString(), 10),
323
- sequence: parseInt(baseAccount.sequence.toString(), 10)
324
- };
325
- };
326
-
327
- // src/private-functions/getRpcEndpointForChain.ts
328
- var getRpcEndpointForChain = async (chainId) => {
329
- if (chunkATW6UNT5_cjs.ClientState.endpointOptions.getRpcEndpointForChain) {
330
- return chunkATW6UNT5_cjs.ClientState.endpointOptions.getRpcEndpointForChain(chainId);
331
- }
332
- if (chunkATW6UNT5_cjs.ClientState.endpointOptions.endpoints && chunkATW6UNT5_cjs.ClientState.endpointOptions.endpoints[chainId]) {
333
- const endpointOptions = chunkATW6UNT5_cjs.ClientState.endpointOptions.endpoints[chainId];
334
- if (endpointOptions?.rpc) {
335
- return endpointOptions.rpc;
336
- }
337
- }
338
- console.warn(
339
- "Warning: You are using unreliable public endpoints. We strongly recommend overriding them via endpointOptions for use beyond development settings."
340
- );
341
- const chain = chunkEAZQ2ECA_cjs.chains().find((chain2) => chain2.chainId === chainId);
342
- if (!chain) {
343
- throw new Error(`getRpcEndpointForChain: failed to find chain id '${chainId}' in registry`);
344
- }
345
- if (chain.apis?.rpc?.length === 0 || !chain.apis?.rpc) {
346
- throw new Error(
347
- `getRpcEndpointForChain error: failed to find RPC endpoint for chain id '${chainId}'`
348
- );
349
- }
350
- const endpoints = chain.apis?.rpc?.map((api) => api.address);
351
- const endpoint = await chunkEAZQ2ECA_cjs.findFirstWorkingEndpoint(endpoints, "rpc");
352
- if (!endpoint) {
353
- throw new Error(
354
- `getRpcEndpointForChain error: failed to find RPC endpoint for chain id '${chainId}'`
355
- );
356
- }
357
- return endpoint;
358
- };
359
-
360
- // src/public-functions/getSigningStargateClient.ts
361
- var getSigningStargateClient = async ({
362
- chainId,
363
- getOfflineSigner
364
- }) => {
365
- if (!getOfflineSigner) {
366
- throw new Error("'getCosmosSigner' is not provided or configured in skip router");
367
- }
368
- if (!chunkATW6UNT5_cjs.ClientState.signingStargateClientByChainId?.[chainId]) {
369
- const [signer, endpoint] = await Promise.all([
370
- getOfflineSigner(chainId),
371
- getRpcEndpointForChain(chainId)
372
- ]);
373
- chunkATW6UNT5_cjs.ClientState.signingStargateClientByChainId[chainId] = await stargate.SigningStargateClient.connectWithSigner(endpoint, signer, {
374
- aminoTypes: chunkATW6UNT5_cjs.ClientState.aminoTypes,
375
- registry: chunkATW6UNT5_cjs.ClientState.registry,
376
- accountParser
377
- });
378
- }
379
- return {
380
- stargateClient: chunkATW6UNT5_cjs.ClientState.signingStargateClientByChainId[chainId],
381
- signer: await getOfflineSigner(chainId)
382
- };
383
- };
384
-
385
- exports.accountParser = accountParser;
386
- exports.getRpcEndpointForChain = getRpcEndpointForChain;
387
- exports.getSigningStargateClient = getSigningStargateClient;