@skip-go/client 1.0.0-alpha-0 → 1.0.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 (51) hide show
  1. package/dist/api/getAssets.mjs +2 -25
  2. package/dist/api/getAssetsBetweenChains.mjs +2 -9
  3. package/dist/api/getBridges.mjs +2 -10
  4. package/dist/api/getChains.mjs +2 -16
  5. package/dist/api/getVenues.mjs +2 -10
  6. package/dist/api/postAssetsFromSource.mjs +3 -14
  7. package/dist/api/postBalances.mjs +2 -16
  8. package/dist/api/postIbcOriginAssets.mjs +2 -11
  9. package/dist/api/postMessages.d.mts +183 -183
  10. package/dist/api/postMessages.mjs +2 -10
  11. package/dist/api/postMessagesDirect.d.mts +183 -183
  12. package/dist/api/postMessagesDirect.mjs +2 -10
  13. package/dist/api/postRecommendAssets.mjs +2 -13
  14. package/dist/api/postRoute.d.mts +160 -160
  15. package/dist/api/postRoute.mjs +2 -16
  16. package/dist/api/postSubmitTransaction.mjs +2 -10
  17. package/dist/api/postTrackTransaction.mjs +2 -11
  18. package/dist/api/postTransactionStatus.mjs +2 -10
  19. package/dist/chunk-2ETF4N4H.mjs +45 -0
  20. package/dist/chunk-2F4MBSMT.mjs +99 -0
  21. package/dist/chunk-2FYLP573.mjs +15 -0
  22. package/dist/chunk-7TBBV2YY.mjs +13 -0
  23. package/dist/chunk-B72MYSG5.mjs +273 -0
  24. package/dist/chunk-C5CGY2X7.mjs +10 -0
  25. package/dist/chunk-CAAR7GDJ.mjs +11 -0
  26. package/dist/chunk-CZ27FEZ7.mjs +11 -0
  27. package/dist/chunk-DKIWPD5I.mjs +124 -0
  28. package/dist/chunk-IGD32L7C.mjs +9 -0
  29. package/dist/chunk-J7GGREYX.mjs +10 -0
  30. package/dist/chunk-KPK3Z6QZ.mjs +10 -0
  31. package/dist/chunk-KSMJWLEH.mjs +2315 -0
  32. package/dist/chunk-LJVI5DLG.mjs +10 -0
  33. package/dist/chunk-NNZFCKHP.mjs +10 -0
  34. package/dist/chunk-NU7MCJOK.mjs +187 -0
  35. package/dist/chunk-OTLFF5OB.mjs +3634 -0
  36. package/dist/chunk-PEZHVPSR.mjs +2237 -0
  37. package/dist/chunk-QZ3X6MP3.mjs +10 -0
  38. package/dist/chunk-RXWDHQLG.mjs +231 -0
  39. package/dist/chunk-TUBI6VE6.mjs +1344 -0
  40. package/dist/chunk-WDMGUHWR.mjs +23 -0
  41. package/dist/chunk-YWYU6P7W.mjs +14 -0
  42. package/dist/chunk-ZAF3Z56R.mjs +7 -0
  43. package/dist/index.mjs +24 -24
  44. package/dist/public-functions/executeRoute.mjs +12 -100
  45. package/dist/public-functions/getFeeInfoForChain.mjs +5 -47
  46. package/dist/public-functions/getRecommendedGasPrice.mjs +7 -1366
  47. package/dist/public-functions/getSigningStargateClient.mjs +4 -32
  48. package/dist/public-functions/setApiOptions.mjs +2 -46
  49. package/dist/public-functions/setClientOptions.mjs +4 -34
  50. package/package.json +1 -8
  51. package/dist/chunk-AXBFBHS2.mjs +0 -41
@@ -0,0 +1,273 @@
1
+ import { chains, findFirstWorkingEndpoint } from './chunk-NU7MCJOK.mjs';
2
+ import { ClientState } from './chunk-DKIWPD5I.mjs';
3
+ import { __async } from './chunk-RXWDHQLG.mjs';
4
+ import { accountFromAny, SigningStargateClient } from '@cosmjs/stargate';
5
+ import { assertDefinedAndNotNull } from '@cosmjs/utils';
6
+ import { BinaryWriter, BinaryReader } from 'cosmjs-types/binary';
7
+ import { BaseAccount } from 'cosmjs-types/cosmos/auth/v1beta1/auth';
8
+ import { Coin } from 'cosmjs-types/cosmos/base/v1beta1/coin';
9
+ import { decodePubkey } from '@cosmjs/proto-signing';
10
+ import { accountEthParser } from '@injectivelabs/sdk-ts';
11
+ import { PubKey } from 'cosmjs-types/cosmos/crypto/secp256k1/keys';
12
+ import { encodeSecp256k1Pubkey } from '@cosmjs/amino';
13
+
14
+ var createBaseVestingAccount = () => {
15
+ return {
16
+ // @ts-expect-error
17
+ baseAccount: void 0,
18
+ originalVesting: [],
19
+ delegatedFree: [],
20
+ delegatedVesting: [],
21
+ endTime: BigInt(0)
22
+ };
23
+ };
24
+ var BaseVestingAccount = {
25
+ encode(message, writer = BinaryWriter.create()) {
26
+ if (message.baseAccount !== void 0) {
27
+ BaseAccount.encode(
28
+ message.baseAccount,
29
+ writer.uint32(10).fork()
30
+ ).ldelim();
31
+ }
32
+ for (const v of message.originalVesting) {
33
+ Coin.encode(v, writer.uint32(18).fork()).ldelim();
34
+ }
35
+ for (const v of message.delegatedFree) {
36
+ Coin.encode(v, writer.uint32(26).fork()).ldelim();
37
+ }
38
+ for (const v of message.delegatedVesting) {
39
+ Coin.encode(v, writer.uint32(34).fork()).ldelim();
40
+ }
41
+ if (message.endTime !== BigInt(0)) {
42
+ writer.uint32(40).int64(message.endTime);
43
+ }
44
+ return writer;
45
+ },
46
+ decode(input, length) {
47
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
48
+ const end = length === void 0 ? reader.len : reader.pos + length;
49
+ const message = createBaseVestingAccount();
50
+ while (reader.pos < end) {
51
+ const tag = reader.uint32();
52
+ switch (tag >>> 3) {
53
+ case 1:
54
+ message.baseAccount = BaseAccount.decode(reader, reader.uint32());
55
+ break;
56
+ case 2:
57
+ message.originalVesting.push(Coin.decode(reader, reader.uint32()));
58
+ break;
59
+ case 3:
60
+ message.delegatedFree.push(Coin.decode(reader, reader.uint32()));
61
+ break;
62
+ case 4:
63
+ message.delegatedVesting.push(Coin.decode(reader, reader.uint32()));
64
+ break;
65
+ case 5:
66
+ message.endTime = reader.int64();
67
+ break;
68
+ default:
69
+ reader.skipType(tag & 7);
70
+ break;
71
+ }
72
+ }
73
+ return message;
74
+ }
75
+ };
76
+ function createBasePeriod() {
77
+ return {
78
+ startTime: BigInt(0),
79
+ length: BigInt(0),
80
+ amount: [],
81
+ actionType: 0
82
+ };
83
+ }
84
+ var Period = {
85
+ encode(message, writer = BinaryWriter.create()) {
86
+ if (message.startTime !== BigInt(0)) {
87
+ writer.uint32(8).int64(message.startTime);
88
+ }
89
+ if (message.length !== BigInt(0)) {
90
+ writer.uint32(16).int64(message.length);
91
+ }
92
+ for (const v of message.amount) {
93
+ Coin.encode(v, writer.uint32(26).fork()).ldelim();
94
+ }
95
+ if (message.actionType !== 0) {
96
+ writer.uint32(32).int32(message.actionType);
97
+ }
98
+ return writer;
99
+ },
100
+ decode(input, length) {
101
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
102
+ const end = length === void 0 ? reader.len : reader.pos + length;
103
+ const message = createBasePeriod();
104
+ while (reader.pos < end) {
105
+ const tag = reader.uint32();
106
+ switch (tag >>> 3) {
107
+ case 1:
108
+ message.startTime = reader.int64();
109
+ break;
110
+ case 2:
111
+ message.length = reader.int64();
112
+ break;
113
+ case 3:
114
+ message.amount.push(Coin.decode(reader, reader.uint32()));
115
+ break;
116
+ case 4:
117
+ message.actionType = reader.int32();
118
+ break;
119
+ default:
120
+ reader.skipType(tag & 7);
121
+ break;
122
+ }
123
+ }
124
+ return message;
125
+ }
126
+ };
127
+ function createBaseStridePeriodicVestingAccount() {
128
+ return {
129
+ //eslint-disable-next-line @typescript-eslint/ban-ts-comment
130
+ //@ts-ignore
131
+ baseVestingAccount: void 0,
132
+ vestingPeriods: []
133
+ };
134
+ }
135
+ var StridePeriodicVestingAccount = {
136
+ encode(message, writer = BinaryWriter.create()) {
137
+ if (message.baseVestingAccount !== void 0) {
138
+ BaseVestingAccount.encode(
139
+ message.baseVestingAccount,
140
+ writer.uint32(10).fork()
141
+ ).ldelim();
142
+ }
143
+ for (const v of message.vestingPeriods) {
144
+ Period.encode(v, writer.uint32(26).fork()).ldelim();
145
+ }
146
+ return writer;
147
+ },
148
+ decode(input, length) {
149
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
150
+ const end = length === void 0 ? reader.len : reader.pos + length;
151
+ const message = createBaseStridePeriodicVestingAccount();
152
+ while (reader.pos < end) {
153
+ const tag = reader.uint32();
154
+ switch (tag >>> 3) {
155
+ case 1:
156
+ message.baseVestingAccount = BaseVestingAccount.decode(
157
+ reader,
158
+ reader.uint32()
159
+ );
160
+ break;
161
+ case 3:
162
+ message.vestingPeriods.push(Period.decode(reader, reader.uint32()));
163
+ break;
164
+ default:
165
+ reader.skipType(tag & 7);
166
+ break;
167
+ }
168
+ }
169
+ return message;
170
+ }
171
+ };
172
+ var accountParser = (acc) => {
173
+ var _a;
174
+ switch (acc.typeUrl) {
175
+ case "/stride.vesting.StridePeriodicVestingAccount": {
176
+ const baseAccount = (_a = StridePeriodicVestingAccount.decode(acc.value).baseVestingAccount) == null ? void 0 : _a.baseAccount;
177
+ assertDefinedAndNotNull(baseAccount);
178
+ return {
179
+ address: baseAccount.address,
180
+ pubkey: baseAccount.pubKey ? decodePubkey(baseAccount.pubKey) : null,
181
+ accountNumber: Number(baseAccount.accountNumber),
182
+ sequence: Number(baseAccount.sequence)
183
+ };
184
+ }
185
+ case "/injective.types.v1beta1.EthAccount":
186
+ return accountEthParser(
187
+ acc,
188
+ "/injective.crypto.v1beta1.ethsecp256k1.PubKey"
189
+ );
190
+ case "/ethermint.types.v1.EthAccount":
191
+ return accountEthParser(acc, "/ethermint.crypto.v1.ethsecp256k1.PubKey");
192
+ default: {
193
+ if (acc.typeUrl === "/cosmos.auth.v1beta1.BaseAccount") {
194
+ const { address, pubKey, accountNumber, sequence } = BaseAccount.decode(
195
+ acc.value
196
+ );
197
+ if ((pubKey == null ? void 0 : pubKey.typeUrl) === "/initia.crypto.v1beta1.ethsecp256k1.PubKey") {
198
+ const { key } = PubKey.decode(pubKey.value);
199
+ const pk = encodeSecp256k1Pubkey(key);
200
+ return {
201
+ address,
202
+ pubkey: pk,
203
+ accountNumber: Number(accountNumber),
204
+ sequence: Number(sequence)
205
+ };
206
+ }
207
+ }
208
+ return accountFromAny(acc);
209
+ }
210
+ }
211
+ };
212
+
213
+ // src/private-functions/getRpcEndpointForChain.ts
214
+ var getRpcEndpointForChain = (chainId) => __async(void 0, null, function* () {
215
+ var _a, _b, _c, _d, _e;
216
+ if (ClientState.endpointOptions.getRpcEndpointForChain) {
217
+ return ClientState.endpointOptions.getRpcEndpointForChain(chainId);
218
+ }
219
+ if (ClientState.endpointOptions.endpoints && ClientState.endpointOptions.endpoints[chainId]) {
220
+ const endpointOptions = ClientState.endpointOptions.endpoints[chainId];
221
+ if (endpointOptions == null ? void 0 : endpointOptions.rpc) {
222
+ return endpointOptions.rpc;
223
+ }
224
+ }
225
+ console.warn(
226
+ "Warning: You are using unreliable public endpoints. We strongly recommend overriding them via endpointOptions for use beyond development settings."
227
+ );
228
+ const chain = chains().find((chain2) => chain2.chain_id === chainId);
229
+ if (!chain) {
230
+ throw new Error(`getRpcEndpointForChain: failed to find chain id '${chainId}' in registry`);
231
+ }
232
+ if (((_b = (_a = chain.apis) == null ? void 0 : _a.rpc) == null ? void 0 : _b.length) === 0 || !((_c = chain.apis) == null ? void 0 : _c.rpc)) {
233
+ throw new Error(
234
+ `getRpcEndpointForChain error: failed to find RPC endpoint for chain '${chainId}'`
235
+ );
236
+ }
237
+ const endpoints = (_e = (_d = chain.apis) == null ? void 0 : _d.rpc) == null ? void 0 : _e.map((api) => api.address);
238
+ const endpoint = yield findFirstWorkingEndpoint(endpoints, "rpc");
239
+ if (!endpoint) {
240
+ throw new Error(
241
+ `getRpcEndpointForChain error: failed to find RPC endpoint for chain '${chainId}'`
242
+ );
243
+ }
244
+ return endpoint;
245
+ });
246
+
247
+ // src/public-functions/getSigningStargateClient.ts
248
+ var getSigningStargateClient = (_0) => __async(void 0, [_0], function* ({
249
+ chainId,
250
+ getOfflineSigner
251
+ }) {
252
+ var _a;
253
+ if (!getOfflineSigner) {
254
+ throw new Error("'getCosmosSigner' is not provided or configured in skip router");
255
+ }
256
+ if (!((_a = ClientState.signingStargateClientByChainId) == null ? void 0 : _a[chainId])) {
257
+ const [signer, endpoint] = yield Promise.all([
258
+ getOfflineSigner(chainId),
259
+ getRpcEndpointForChain(chainId)
260
+ ]);
261
+ ClientState.signingStargateClientByChainId[chainId] = yield SigningStargateClient.connectWithSigner(endpoint, signer, {
262
+ aminoTypes: ClientState.aminoTypes,
263
+ registry: ClientState.registry,
264
+ accountParser
265
+ });
266
+ }
267
+ return {
268
+ stargateClient: ClientState.signingStargateClientByChainId[chainId],
269
+ signer: yield getOfflineSigner(chainId)
270
+ };
271
+ });
272
+
273
+ export { accountParser, getRpcEndpointForChain, getSigningStargateClient };
@@ -0,0 +1,10 @@
1
+ import { pollingApi } from './chunk-RXWDHQLG.mjs';
2
+
3
+ // src/api/postTransactionStatus.ts
4
+ var transactionStatus = pollingApi({
5
+ methodName: "getTransactionStatusV2",
6
+ path: "/v2/tx/status",
7
+ method: "get"
8
+ });
9
+
10
+ export { transactionStatus };
@@ -0,0 +1,11 @@
1
+ import { pollingApi } from './chunk-RXWDHQLG.mjs';
2
+
3
+ // src/api/postTrackTransaction.ts
4
+ var trackTransaction = pollingApi({
5
+ methodName: "trackTransactionV2",
6
+ path: "/v2/tx/track",
7
+ method: "post",
8
+ backoffMultiplier: 2.5
9
+ });
10
+
11
+ export { trackTransaction };
@@ -0,0 +1,11 @@
1
+ import { api } from './chunk-RXWDHQLG.mjs';
2
+
3
+ // src/api/postIbcOriginAssets.ts
4
+ var ibcOriginAssets = api({
5
+ methodName: "getOriginAssets",
6
+ method: "post",
7
+ path: "/v2/fungible/ibc_origin_assets",
8
+ transformResponse: (response) => response.originAssets
9
+ });
10
+
11
+ export { ibcOriginAssets };
@@ -0,0 +1,124 @@
1
+ import { api, __async, __spreadValues, __objRest } from './chunk-RXWDHQLG.mjs';
2
+
3
+ // src/private-functions/getMainnetAndTestnetChains.ts
4
+ var getMainnetAndTestnetChains = (apiOptions) => __async(void 0, null, function* () {
5
+ const [mainnetRes, testnetRes] = yield Promise.all([
6
+ chains(__spreadValues({
7
+ includeEvm: true,
8
+ includeSvm: true
9
+ }, apiOptions)),
10
+ chains(__spreadValues({
11
+ includeEvm: true,
12
+ includeSvm: true,
13
+ onlyTestnets: true
14
+ }, apiOptions))
15
+ ]);
16
+ const combinedChains = [...mainnetRes != null ? mainnetRes : [], ...testnetRes != null ? testnetRes : []];
17
+ ClientState.skipChains = combinedChains;
18
+ return combinedChains;
19
+ });
20
+
21
+ // src/api/getAssets.ts
22
+ var assets = api({
23
+ methodName: "getAssets",
24
+ path: "/v2/fungible/assets",
25
+ transformResponse: (response) => {
26
+ return transformAssetsMap(response.chainToAssetsMap);
27
+ },
28
+ onSuccess: (response, options) => {
29
+ if ((options == null ? void 0 : options.includeEvmAssets) && (options == null ? void 0 : options.includeSvmAssets) && (options == null ? void 0 : options.includeCw20Assets)) {
30
+ ClientState.skipAssets = response;
31
+ }
32
+ }
33
+ });
34
+ var transformAssetsMap = (input) => Object.entries(input != null ? input : {}).reduce(
35
+ (acc, [chainId, { assets: assets2 }]) => {
36
+ acc[chainId] = (assets2 != null ? assets2 : []).map((asset) => asset);
37
+ return acc;
38
+ },
39
+ {}
40
+ );
41
+
42
+ // src/private-functions/getMainnetAndTestnetAssets.ts
43
+ var getMainnetAndTestnetAssets = (_a) => __async(void 0, null, function* () {
44
+ var _b = _a, {
45
+ chainId
46
+ } = _b, apiOptions = __objRest(_b, [
47
+ "chainId"
48
+ ]);
49
+ const [assetsMainnet, assetsTestnet] = yield Promise.all([
50
+ assets(__spreadValues({
51
+ chainIds: chainId ? [chainId] : void 0
52
+ }, apiOptions)),
53
+ assets(__spreadValues({
54
+ chainIds: chainId ? [chainId] : void 0,
55
+ onlyTestnets: true
56
+ }, apiOptions))
57
+ ]);
58
+ const mainnet = assetsMainnet;
59
+ const testnet = assetsTestnet;
60
+ const merged = __spreadValues(__spreadValues({}, mainnet), testnet);
61
+ ClientState.skipAssets = merged;
62
+ return merged;
63
+ });
64
+
65
+ // src/api/postBalances.ts
66
+ var balances = api({
67
+ methodName: "getBalances",
68
+ method: "post",
69
+ path: "/v2/info/balances",
70
+ onSuccess: (response, options) => {
71
+ if (!options) {
72
+ ClientState.skipBalances = response;
73
+ }
74
+ }
75
+ });
76
+
77
+ // src/state/clientState.ts
78
+ var ClientState = class {
79
+ static getSkipChains(apiOptions) {
80
+ return __async(this, null, function* () {
81
+ if (this.skipChains) {
82
+ return this.skipChains;
83
+ }
84
+ const response = yield getMainnetAndTestnetChains(apiOptions);
85
+ this.skipChains = response;
86
+ return response;
87
+ });
88
+ }
89
+ static getSkipAssets(props) {
90
+ return __async(this, null, function* () {
91
+ if (this.skipAssets) {
92
+ return this.skipAssets;
93
+ }
94
+ const response = yield getMainnetAndTestnetAssets(props);
95
+ this.skipAssets = response;
96
+ return response;
97
+ });
98
+ }
99
+ static getSkipBalances() {
100
+ return __async(this, null, function* () {
101
+ if (this.skipBalances) {
102
+ return this.skipBalances;
103
+ }
104
+ const response = yield balances();
105
+ this.skipBalances = response;
106
+ return response;
107
+ });
108
+ }
109
+ };
110
+ ClientState.signingStargateClientByChainId = {};
111
+
112
+ // src/api/getChains.ts
113
+ var chains = api({
114
+ methodName: "getChains",
115
+ path: "/v2/info/chains",
116
+ transformResponse: (response) => response.chains,
117
+ onSuccess: (response, options) => {
118
+ if ((options == null ? void 0 : options.includeEvm) && (options == null ? void 0 : options.includeSvm)) {
119
+ ClientState.skipChains = response;
120
+ }
121
+ }
122
+ });
123
+
124
+ export { ClientState, assets, balances, chains, transformAssetsMap };
@@ -0,0 +1,9 @@
1
+ import { api } from './chunk-RXWDHQLG.mjs';
2
+
3
+ // src/api/getAssetsBetweenChains.ts
4
+ var assetsBetweenChains = api({
5
+ methodName: "fungibleAssetsBetweenChainsCreate",
6
+ path: "/v2/fungible/assets_between_chains"
7
+ });
8
+
9
+ export { assetsBetweenChains };
@@ -0,0 +1,10 @@
1
+ import { api } from './chunk-RXWDHQLG.mjs';
2
+
3
+ // src/api/getBridges.ts
4
+ var bridges = api({
5
+ methodName: "getBridges",
6
+ path: "/v2/info/bridges",
7
+ transformResponse: (response) => response.bridges
8
+ });
9
+
10
+ export { bridges };
@@ -0,0 +1,10 @@
1
+ import { api } from './chunk-RXWDHQLG.mjs';
2
+
3
+ // src/api/postMessages.ts
4
+ var messages = api({
5
+ methodName: "getMsgsV2",
6
+ method: "post",
7
+ path: "/v2/fungible/msgs"
8
+ });
9
+
10
+ export { messages };