@skip-go/client 1.0.1-alpha-1 → 1.0.1

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 (87) hide show
  1. package/dist/api/getAssets.d.ts +19 -0
  2. package/dist/api/getAssets.js +15 -2
  3. package/dist/api/getAssetsBetweenChains.d.ts +56 -0
  4. package/dist/api/getAssetsBetweenChains.js +11 -2
  5. package/dist/api/getBridges.d.ts +54 -0
  6. package/dist/api/getBridges.js +11 -2
  7. package/dist/api/getChains.d.ts +41 -0
  8. package/dist/api/getChains.js +11 -2
  9. package/dist/api/getVenues.d.ts +13 -0
  10. package/dist/api/getVenues.js +11 -2
  11. package/dist/api/postAssetsFromSource.d.ts +13 -0
  12. package/dist/api/postAssetsFromSource.js +12 -3
  13. package/dist/api/postBalances.d.ts +35 -0
  14. package/dist/api/postBalances.js +11 -2
  15. package/dist/api/postIbcOriginAssets.d.ts +32 -0
  16. package/dist/api/postIbcOriginAssets.js +11 -2
  17. package/dist/api/postMessages.d.ts +528 -0
  18. package/dist/api/postMessages.js +11 -2
  19. package/dist/api/postMessagesDirect.d.ts +568 -0
  20. package/dist/api/postMessagesDirect.js +11 -2
  21. package/dist/api/postRecommendAssets.d.ts +40 -0
  22. package/dist/api/postRecommendAssets.js +11 -2
  23. package/dist/api/postRoute.d.ts +460 -0
  24. package/dist/api/postRoute.js +11 -2
  25. package/dist/api/postSubmitTransaction.d.ts +13 -0
  26. package/dist/api/postSubmitTransaction.js +11 -2
  27. package/dist/api/postTrackTransaction.d.ts +13 -0
  28. package/dist/api/postTrackTransaction.js +11 -2
  29. package/dist/api/postTransactionStatus.d.ts +559 -0
  30. package/dist/api/postTransactionStatus.js +11 -2
  31. package/dist/apiState-CdzxTxYd.d.ts +6 -0
  32. package/dist/chunk-2WHYWV4Y.js +12 -0
  33. package/dist/{chunk-VMPFHQ7U.js → chunk-4XWIXR2P.js} +27 -19
  34. package/dist/chunk-5KVRQLI5.js +17 -0
  35. package/dist/{chunk-KNV72XRZ.js → chunk-5ZJBR5AQ.js} +5 -3
  36. package/dist/chunk-6BTWKTNM.js +16 -0
  37. package/dist/chunk-6GJEXV5J.js +130 -0
  38. package/dist/chunk-ASPVKNJ7.js +242 -0
  39. package/dist/{chunk-JTIHU43D.js → chunk-CG5CQQBW.js} +42 -33
  40. package/dist/chunk-EQLA2SEZ.js +2361 -0
  41. package/dist/chunk-FVSSCQ6C.js +12 -0
  42. package/dist/{chunk-SQGWZAUC.js → chunk-GFRPLEJR.js} +311 -279
  43. package/dist/chunk-KYFTM3PI.js +12 -0
  44. package/dist/chunk-L2Q5RP6O.js +25 -0
  45. package/dist/chunk-LRIPQQ4M.js +11 -0
  46. package/dist/{chunk-TW77BXMT.js → chunk-PKPZTO4H.js} +13 -10
  47. package/dist/{chunk-PRQ2NHRZ.js → chunk-RE2QZJWE.js} +5 -3
  48. package/dist/{chunk-3OZQ35X3.js → chunk-RT5TZAMU.js} +312 -212
  49. package/dist/chunk-SWYON2RG.js +4 -1
  50. package/dist/chunk-VQ5SIQWU.js +3 -1
  51. package/dist/chunk-X2E2TKVR.js +12 -0
  52. package/dist/{chunk-3N7XVGLX.js → chunk-X2YPYBVN.js} +68 -59
  53. package/dist/chunk-YYNIFO2A.js +13 -0
  54. package/dist/{chunk-4JJWOILI.js → chunk-Z4ZKOUGH.js} +5 -3
  55. package/dist/{chunk-C2EDPY6J.js → chunk-ZG23Z3WY.js} +5 -3
  56. package/dist/client-types-CxjtffyG.d.ts +60 -0
  57. package/dist/executeRoute-BKvMVd1I.d.ts +69 -0
  58. package/dist/generateApi-DqCp36fX.d.ts +22 -0
  59. package/dist/index.d.ts +37 -0
  60. package/dist/index.js +209 -24
  61. package/dist/public-functions/executeRoute.d.ts +9 -0
  62. package/dist/public-functions/executeRoute.js +21 -12
  63. package/dist/public-functions/getFeeInfoForChain.d.ts +9 -0
  64. package/dist/public-functions/getFeeInfoForChain.js +14 -5
  65. package/dist/public-functions/getRecommendedGasPrice.d.ts +9 -0
  66. package/dist/public-functions/getRecommendedGasPrice.js +16 -7
  67. package/dist/public-functions/getSigningStargateClient.d.ts +13 -0
  68. package/dist/public-functions/getSigningStargateClient.js +13 -4
  69. package/dist/public-functions/setApiOptions.d.ts +9 -0
  70. package/dist/public-functions/setApiOptions.js +11 -2
  71. package/dist/public-functions/setClientOptions.d.ts +9 -0
  72. package/dist/public-functions/setClientOptions.js +13 -4
  73. package/dist/setClientOptions-DbanEIwL.d.ts +19 -0
  74. package/dist/swaggerTypes-O9-gvCT1.d.ts +1890 -0
  75. package/package.json +1 -10
  76. package/dist/chunk-33K6EESX.js +0 -10
  77. package/dist/chunk-BQTQJQ5E.js +0 -10
  78. package/dist/chunk-BRJDNGYH.js +0 -22
  79. package/dist/chunk-BRMONS6A.js +0 -130
  80. package/dist/chunk-DW4U6YI6.js +0 -10
  81. package/dist/chunk-GARVPN2H.js +0 -16
  82. package/dist/chunk-MGVXJ2U4.js +0 -11
  83. package/dist/chunk-MTMPHY3Y.js +0 -9
  84. package/dist/chunk-RDRDFJQE.js +0 -10
  85. package/dist/chunk-RMP3HM5N.js +0 -14
  86. package/dist/chunk-W6TBGBV3.js +0 -675
  87. package/dist/chunk-Y5EY3Q6D.js +0 -1790
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var chunkASPVKNJ7_js = require('./chunk-ASPVKNJ7.js');
4
+
5
+ // src/api/postRoute.ts
6
+ var route = (request) => chunkASPVKNJ7_js.__async(void 0, null, function* () {
7
+ const requestWithAffiliateFeeBps = chunkASPVKNJ7_js.__spreadProps(chunkASPVKNJ7_js.__spreadValues({}, request), {
8
+ cumulativeAffiliateFeeBps: chunkASPVKNJ7_js.ApiState.cumulativeAffiliateFeeBPS
9
+ });
10
+ return chunkASPVKNJ7_js.api({
11
+ methodName: "getRouteV2",
12
+ method: "post",
13
+ path: "/v2/fungible/route"
14
+ })(requestWithAffiliateFeeBps);
15
+ });
16
+
17
+ exports.route = route;
@@ -1,10 +1,12 @@
1
- import { api } from './chunk-W6TBGBV3.js';
1
+ 'use strict';
2
+
3
+ var chunkASPVKNJ7_js = require('./chunk-ASPVKNJ7.js');
2
4
 
3
5
  // src/api/getBridges.ts
4
- var bridges = api({
6
+ var bridges = chunkASPVKNJ7_js.api({
5
7
  methodName: "getBridges",
6
8
  path: "/v2/info/bridges",
7
9
  transformResponse: (response) => response.bridges
8
10
  });
9
11
 
10
- export { bridges };
12
+ exports.bridges = bridges;
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var chunk6GJEXV5J_js = require('./chunk-6GJEXV5J.js');
4
+ var chunkASPVKNJ7_js = require('./chunk-ASPVKNJ7.js');
5
+
6
+ // src/api/postAssetsFromSource.ts
7
+ var assetsFromSource = chunkASPVKNJ7_js.api({
8
+ methodName: "getAssetsFromSource",
9
+ method: "post",
10
+ path: "/v2/fungible/assets_from_source",
11
+ transformResponse(response) {
12
+ return chunk6GJEXV5J_js.transformAssetsMap(response.destAssets);
13
+ }
14
+ });
15
+
16
+ exports.assetsFromSource = assetsFromSource;
@@ -0,0 +1,130 @@
1
+ 'use strict';
2
+
3
+ var chunkASPVKNJ7_js = require('./chunk-ASPVKNJ7.js');
4
+
5
+ // src/private-functions/getMainnetAndTestnetChains.ts
6
+ var getMainnetAndTestnetChains = (apiOptions) => chunkASPVKNJ7_js.__async(void 0, null, function* () {
7
+ const [mainnetRes, testnetRes] = yield Promise.all([
8
+ chains(chunkASPVKNJ7_js.__spreadValues({
9
+ includeEvm: true,
10
+ includeSvm: true
11
+ }, apiOptions)),
12
+ chains(chunkASPVKNJ7_js.__spreadValues({
13
+ includeEvm: true,
14
+ includeSvm: true,
15
+ onlyTestnets: true
16
+ }, apiOptions))
17
+ ]);
18
+ const combinedChains = [...mainnetRes != null ? mainnetRes : [], ...testnetRes != null ? testnetRes : []];
19
+ ClientState.skipChains = combinedChains;
20
+ return combinedChains;
21
+ });
22
+
23
+ // src/api/getAssets.ts
24
+ var assets = chunkASPVKNJ7_js.api({
25
+ methodName: "getAssets",
26
+ path: "/v2/fungible/assets",
27
+ transformResponse: (response) => {
28
+ return transformAssetsMap(response.chainToAssetsMap);
29
+ },
30
+ onSuccess: (response, options) => {
31
+ if ((options == null ? void 0 : options.includeEvmAssets) && (options == null ? void 0 : options.includeSvmAssets) && (options == null ? void 0 : options.includeCw20Assets)) {
32
+ ClientState.skipAssets = response;
33
+ }
34
+ }
35
+ });
36
+ var transformAssetsMap = (input) => Object.entries(input != null ? input : {}).reduce(
37
+ (acc, [chainId, { assets: assets2 }]) => {
38
+ acc[chainId] = (assets2 != null ? assets2 : []).map((asset) => asset);
39
+ return acc;
40
+ },
41
+ {}
42
+ );
43
+
44
+ // src/private-functions/getMainnetAndTestnetAssets.ts
45
+ var getMainnetAndTestnetAssets = (_a) => chunkASPVKNJ7_js.__async(void 0, null, function* () {
46
+ var _b = _a, {
47
+ chainId
48
+ } = _b, apiOptions = chunkASPVKNJ7_js.__objRest(_b, [
49
+ "chainId"
50
+ ]);
51
+ const [assetsMainnet, assetsTestnet] = yield Promise.all([
52
+ assets(chunkASPVKNJ7_js.__spreadValues({
53
+ chainIds: chainId ? [chainId] : void 0
54
+ }, apiOptions)),
55
+ assets(chunkASPVKNJ7_js.__spreadValues({
56
+ chainIds: chainId ? [chainId] : void 0,
57
+ onlyTestnets: true
58
+ }, apiOptions))
59
+ ]);
60
+ const mainnet = assetsMainnet;
61
+ const testnet = assetsTestnet;
62
+ const merged = chunkASPVKNJ7_js.__spreadValues(chunkASPVKNJ7_js.__spreadValues({}, mainnet), testnet);
63
+ ClientState.skipAssets = merged;
64
+ return merged;
65
+ });
66
+
67
+ // src/api/postBalances.ts
68
+ var balances = chunkASPVKNJ7_js.api({
69
+ methodName: "getBalances",
70
+ method: "post",
71
+ path: "/v2/info/balances",
72
+ onSuccess: (response, options) => {
73
+ if (!options) {
74
+ ClientState.skipBalances = response;
75
+ }
76
+ }
77
+ });
78
+
79
+ // src/state/clientState.ts
80
+ var ClientState = class {
81
+ static getSkipChains(apiOptions) {
82
+ return chunkASPVKNJ7_js.__async(this, null, function* () {
83
+ if (this.skipChains) {
84
+ return this.skipChains;
85
+ }
86
+ const response = yield getMainnetAndTestnetChains(apiOptions);
87
+ this.skipChains = response;
88
+ return response;
89
+ });
90
+ }
91
+ static getSkipAssets(props) {
92
+ return chunkASPVKNJ7_js.__async(this, null, function* () {
93
+ if (this.skipAssets) {
94
+ return this.skipAssets;
95
+ }
96
+ const response = yield getMainnetAndTestnetAssets(props);
97
+ this.skipAssets = response;
98
+ return response;
99
+ });
100
+ }
101
+ static getSkipBalances() {
102
+ return chunkASPVKNJ7_js.__async(this, null, function* () {
103
+ if (this.skipBalances) {
104
+ return this.skipBalances;
105
+ }
106
+ const response = yield balances();
107
+ this.skipBalances = response;
108
+ return response;
109
+ });
110
+ }
111
+ };
112
+ ClientState.signingStargateClientByChainId = {};
113
+
114
+ // src/api/getChains.ts
115
+ var chains = chunkASPVKNJ7_js.api({
116
+ methodName: "getChains",
117
+ path: "/v2/info/chains",
118
+ transformResponse: (response) => response.chains,
119
+ onSuccess: (response, options) => {
120
+ if ((options == null ? void 0 : options.includeEvm) && (options == null ? void 0 : options.includeSvm)) {
121
+ ClientState.skipChains = response;
122
+ }
123
+ }
124
+ });
125
+
126
+ exports.ClientState = ClientState;
127
+ exports.assets = assets;
128
+ exports.balances = balances;
129
+ exports.chains = chains;
130
+ exports.transformAssetsMap = transformAssetsMap;
@@ -0,0 +1,242 @@
1
+ 'use strict';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
+ var __objRest = (source, exclude) => {
23
+ var target = {};
24
+ for (var prop in source)
25
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
26
+ target[prop] = source[prop];
27
+ if (source != null && __getOwnPropSymbols)
28
+ for (var prop of __getOwnPropSymbols(source)) {
29
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
30
+ target[prop] = source[prop];
31
+ }
32
+ return target;
33
+ };
34
+ var __async = (__this, __arguments, generator) => {
35
+ return new Promise((resolve, reject) => {
36
+ var fulfilled = (value) => {
37
+ try {
38
+ step(generator.next(value));
39
+ } catch (e) {
40
+ reject(e);
41
+ }
42
+ };
43
+ var rejected = (value) => {
44
+ try {
45
+ step(generator.throw(value));
46
+ } catch (e) {
47
+ reject(e);
48
+ }
49
+ };
50
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
51
+ step((generator = generator.apply(__this, __arguments)).next());
52
+ });
53
+ };
54
+
55
+ // src/state/apiState.ts
56
+ var _ApiState = class _ApiState {
57
+ static setClientInitialized() {
58
+ _ApiState.resolveInitialization();
59
+ }
60
+ };
61
+ _ApiState.cumulativeAffiliateFeeBPS = "0";
62
+ _ApiState.isInitialized = false;
63
+ _ApiState.clientInitialized = new Promise((resolve) => {
64
+ _ApiState.resolveInitialization = () => {
65
+ if (!_ApiState.isInitialized) {
66
+ _ApiState.isInitialized = true;
67
+ resolve();
68
+ }
69
+ };
70
+ });
71
+ var ApiState = _ApiState;
72
+
73
+ // src/utils/convert.ts
74
+ function toSnake(obj) {
75
+ return convertKeys(obj, (key) => key.replace(/([A-Z])/g, "_$1").toLowerCase());
76
+ }
77
+ function toCamel(obj) {
78
+ return convertKeys(obj, (key) => key.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase()));
79
+ }
80
+ function convertKeys(obj, convertKey) {
81
+ if (Array.isArray(obj)) {
82
+ return obj.map((item) => convertKeys(item, convertKey));
83
+ } else if (obj !== null && typeof obj === "object") {
84
+ return Object.keys(obj).reduce((acc, key) => {
85
+ acc[convertKey(key)] = convertKeys(obj[key], convertKey);
86
+ return acc;
87
+ }, {});
88
+ } else {
89
+ return obj;
90
+ }
91
+ }
92
+
93
+ // src/utils/timer.ts
94
+ var wait = (ms) => {
95
+ return new Promise((resolve) => setTimeout(resolve, ms));
96
+ };
97
+
98
+ // src/utils/generateApi.ts
99
+ var createRequestClient = ({ baseUrl, apiKey }) => {
100
+ const defaultHeaders = __spreadValues({
101
+ "content-type": "application/json"
102
+ }, apiKey ? { authorization: apiKey } : {});
103
+ const handleResponse = (response) => __async(void 0, null, function* () {
104
+ const contentType = response.headers.get("content-type");
105
+ const isJson = contentType == null ? void 0 : contentType.includes("application/json");
106
+ const body = isJson ? yield response.json() : yield response.text();
107
+ if (!response.ok) {
108
+ const message = typeof body === "object" && (body == null ? void 0 : body.message) ? body.message : response.statusText;
109
+ throw new Error(message);
110
+ }
111
+ return body;
112
+ });
113
+ const get = (path, params, signal) => __async(void 0, null, function* () {
114
+ const url = new URL(baseUrl + (path != null ? path : ""));
115
+ if (params && typeof params === "object") {
116
+ Object.entries(params).forEach(([key, value]) => {
117
+ if (value !== void 0 && value !== null) {
118
+ url.searchParams.append(key, String(value));
119
+ }
120
+ });
121
+ }
122
+ const response = yield fetch(url.toString(), {
123
+ method: "GET",
124
+ headers: defaultHeaders,
125
+ signal
126
+ });
127
+ return handleResponse(response);
128
+ });
129
+ const post = (_0, ..._1) => __async(void 0, [_0, ..._1], function* (path, data = {}, signal) {
130
+ const response = yield fetch(new URL(baseUrl + path).toString(), {
131
+ method: "POST",
132
+ headers: defaultHeaders,
133
+ body: JSON.stringify(data),
134
+ signal
135
+ });
136
+ return handleResponse(response);
137
+ });
138
+ return { get, post };
139
+ };
140
+ function createRequest({
141
+ path,
142
+ method = "get",
143
+ onSuccess,
144
+ transformResponse
145
+ }) {
146
+ let controller = null;
147
+ const request = (options) => __async(this, null, function* () {
148
+ var _b;
149
+ const _a = options != null ? options : {}, { apiKey, apiUrl, abortDuplicateRequests } = _a, requestParams = __objRest(_a, ["apiKey", "apiUrl", "abortDuplicateRequests"]);
150
+ let fetchClient = ApiState.client;
151
+ if (apiUrl || apiKey) {
152
+ fetchClient = createRequestClient({
153
+ baseUrl: apiUrl || "https://api.skip.build",
154
+ apiKey
155
+ });
156
+ } else {
157
+ yield ApiState.clientInitialized;
158
+ }
159
+ if (abortDuplicateRequests && controller && !((_b = controller == null ? void 0 : controller.signal) == null ? void 0 : _b.aborted)) {
160
+ controller == null ? void 0 : controller.abort();
161
+ }
162
+ controller = new AbortController();
163
+ try {
164
+ const response = yield fetchClient[method](
165
+ path,
166
+ requestParams ? toSnake(requestParams) : void 0,
167
+ controller.signal
168
+ );
169
+ const camelCased = toCamel(response != null ? response : {});
170
+ const finalResponse = transformResponse ? transformResponse(camelCased) : camelCased;
171
+ onSuccess == null ? void 0 : onSuccess(finalResponse, requestParams);
172
+ return finalResponse;
173
+ } catch (error) {
174
+ if (error.name === "AbortError") {
175
+ console.log("Request was cancelled");
176
+ } else {
177
+ console.error("Error:", error);
178
+ throw error;
179
+ }
180
+ }
181
+ });
182
+ return request;
183
+ }
184
+ function api({
185
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
186
+ methodName,
187
+ path,
188
+ onSuccess,
189
+ method = "get",
190
+ transformResponse
191
+ }) {
192
+ return createRequest({
193
+ path,
194
+ method,
195
+ onSuccess,
196
+ transformResponse
197
+ });
198
+ }
199
+ function pollingApi({
200
+ methodName,
201
+ path,
202
+ method = "get",
203
+ onSuccess,
204
+ onError,
205
+ isSuccess = () => true,
206
+ maxRetries = 5,
207
+ retryInterval = 1e3,
208
+ backoffMultiplier = 2
209
+ }) {
210
+ const request = (requestParams) => __async(this, null, function* () {
211
+ let attempt = 0;
212
+ let lastError;
213
+ while (attempt < maxRetries) {
214
+ try {
215
+ const result = yield api({ methodName, path, method })(requestParams);
216
+ if (result && isSuccess(result)) {
217
+ onSuccess == null ? void 0 : onSuccess(result, attempt);
218
+ return result;
219
+ }
220
+ } catch (err) {
221
+ lastError = err;
222
+ onError == null ? void 0 : onError(err, attempt);
223
+ }
224
+ const delay = retryInterval * Math.pow(backoffMultiplier, attempt);
225
+ yield wait(delay);
226
+ attempt++;
227
+ }
228
+ throw lastError != null ? lastError : new Error("pollingApi: max retries exceeded");
229
+ });
230
+ return (params) => request(params);
231
+ }
232
+
233
+ exports.ApiState = ApiState;
234
+ exports.__async = __async;
235
+ exports.__objRest = __objRest;
236
+ exports.__spreadProps = __spreadProps;
237
+ exports.__spreadValues = __spreadValues;
238
+ exports.api = api;
239
+ exports.createRequestClient = createRequestClient;
240
+ exports.pollingApi = pollingApi;
241
+ exports.toCamel = toCamel;
242
+ exports.wait = wait;