@skip-go/client 1.3.5 → 1.3.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.
- package/dist/cjs/{chunk-MN763TPC.cjs → chunk-7H6XRQAX.cjs} +3 -5
- package/dist/cjs/{chunk-SZ64FWGB.cjs → chunk-AF7EI5BT.cjs} +2 -2
- package/dist/cjs/{chunk-IE22IVFA.cjs → chunk-E2P5MVX3.cjs} +4 -4
- package/dist/cjs/{chunk-N3LR7KTI.cjs → chunk-MN6HFZJA.cjs} +1 -25
- package/dist/cjs/{chunk-5BVYKNVO.cjs → chunk-OEYY7NXT.cjs} +35 -122
- package/dist/cjs/{chunk-JTB3SPCH.cjs → chunk-VKVHMUDR.cjs} +4 -4
- package/dist/cjs/{chunk-3FYU3BJ7.cjs → chunk-YN66ABRQ.cjs} +3 -3
- package/dist/cjs/index.cjs +13 -13
- package/dist/cjs/public-functions/executeRoute.cjs +6 -6
- package/dist/cjs/public-functions/getCosmosGasAmountForMessage.cjs +3 -3
- package/dist/cjs/public-functions/getFeeInfoForChain.cjs +3 -3
- package/dist/cjs/public-functions/getRecommendedGasPrice.cjs +4 -4
- package/dist/cjs/public-functions/getSigningStargateClient.cjs +3 -3
- package/dist/cjs/public-functions/validateCosmosGasBalance.cjs +5 -5
- package/dist/esm/{chunk-ZL6XF5A3.js → chunk-5FKIW2ZL.js} +1 -1
- package/dist/esm/{chunk-5KIWNRW4.js → chunk-5JZOTYDC.js} +1 -1
- package/dist/esm/{chunk-YL6PL36T.js → chunk-FFFVITWF.js} +24 -111
- package/dist/esm/{chunk-ADUNNC4O.js → chunk-IQQDEBLI.js} +2 -2
- package/dist/esm/{chunk-YLVFZDR5.js → chunk-KJVD5P3Q.js} +1 -1
- package/dist/esm/{chunk-TV2XPAIF.js → chunk-P76IRSIS.js} +2 -25
- package/dist/esm/{chunk-VBWLUZXT.js → chunk-U6AH2WOP.js} +3 -5
- package/dist/esm/index.js +7 -7
- package/dist/esm/public-functions/executeRoute.js +5 -5
- package/dist/esm/public-functions/getCosmosGasAmountForMessage.js +1 -1
- package/dist/esm/public-functions/getFeeInfoForChain.js +2 -2
- package/dist/esm/public-functions/getRecommendedGasPrice.js +3 -3
- package/dist/esm/public-functions/getSigningStargateClient.js +2 -2
- package/dist/esm/public-functions/validateCosmosGasBalance.js +4 -4
- package/package.json +1 -1
|
@@ -134,6 +134,7 @@ function chains() {
|
|
|
134
134
|
}
|
|
135
135
|
var getIsEthermint = (chainId) => {
|
|
136
136
|
const chain = chains().find((c) => c.chainId === chainId);
|
|
137
|
+
if (chain?.chainId?.includes("injective")) return true;
|
|
137
138
|
if (!chain) return false;
|
|
138
139
|
const keyAlgos = chain.keyAlgos;
|
|
139
140
|
const extraCodecs = chain.extraCodecs;
|
|
@@ -151,14 +152,11 @@ async function findFirstWorkingEndpoint(endpoints, type) {
|
|
|
151
152
|
const url = (() => {
|
|
152
153
|
switch (type) {
|
|
153
154
|
case "rpc": {
|
|
154
|
-
const rpc = new URL(
|
|
155
|
+
const rpc = new URL(endpoint);
|
|
155
156
|
return rpc.toString();
|
|
156
157
|
}
|
|
157
158
|
case "rest": {
|
|
158
|
-
const url2 = new URL(
|
|
159
|
-
"cosmos/base/tendermint/v1beta1/node_info",
|
|
160
|
-
endpoint
|
|
161
|
-
);
|
|
159
|
+
const url2 = new URL(endpoint);
|
|
162
160
|
return url2.toString();
|
|
163
161
|
}
|
|
164
162
|
default:
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunk4R6OCWRR_cjs = require('./chunk-4R6OCWRR.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkVKVHMUDR_cjs = require('./chunk-VKVHMUDR.cjs');
|
|
5
5
|
var math = require('@cosmjs/math');
|
|
6
6
|
var stargate = require('@cosmjs/stargate');
|
|
7
7
|
|
|
8
8
|
var getRecommendedGasPrice = async (props) => {
|
|
9
|
-
const feeInfo = await
|
|
9
|
+
const feeInfo = await chunkVKVHMUDR_cjs.getFeeInfoForChain(props);
|
|
10
10
|
if (!feeInfo || !feeInfo.gasPrice) {
|
|
11
11
|
return void 0;
|
|
12
12
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkMN6HFZJA_cjs = require('./chunk-MN6HFZJA.cjs');
|
|
4
4
|
var chunk4R6OCWRR_cjs = require('./chunk-4R6OCWRR.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkYN66ABRQ_cjs = require('./chunk-YN66ABRQ.cjs');
|
|
6
6
|
var chunkQSISUSYP_cjs = require('./chunk-QSISUSYP.cjs');
|
|
7
7
|
var stargate = require('@cosmjs/stargate');
|
|
8
8
|
var math = require('@cosmjs/math');
|
|
@@ -34,11 +34,11 @@ var validateCosmosGasBalance = async ({
|
|
|
34
34
|
if (txIndex !== 0 && chainId === "noble-1") {
|
|
35
35
|
return "0";
|
|
36
36
|
}
|
|
37
|
-
const { stargateClient } = await
|
|
37
|
+
const { stargateClient } = await chunkYN66ABRQ_cjs.getSigningStargateClient({
|
|
38
38
|
chainId,
|
|
39
39
|
getOfflineSigner
|
|
40
40
|
});
|
|
41
|
-
const estimatedGas = await
|
|
41
|
+
const estimatedGas = await chunkMN6HFZJA_cjs.getCosmosGasAmountForMessage(
|
|
42
42
|
stargateClient,
|
|
43
43
|
signerAddress,
|
|
44
44
|
chainId,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var chunkWMXUOVHN_cjs = require('./chunk-WMXUOVHN.cjs');
|
|
4
4
|
require('@cosmjs/stargate');
|
|
5
5
|
var encoding = require('@cosmjs/encoding');
|
|
6
|
-
|
|
6
|
+
require('@injectivelabs/sdk-ts');
|
|
7
7
|
var tx_js$2 = require('cosmjs-types/cosmos/bank/v1beta1/tx.js');
|
|
8
8
|
var tx_js$1 = require('cosmjs-types/cosmwasm/wasm/v1/tx.js');
|
|
9
9
|
var tx_js = require('cosmjs-types/ibc/applications/transfer/v1/tx.js');
|
|
@@ -252,29 +252,6 @@ function getEncodeObjectFromCosmosMessage(message) {
|
|
|
252
252
|
value: msgJson
|
|
253
253
|
};
|
|
254
254
|
}
|
|
255
|
-
function getEncodeObjectFromCosmosMessageInjective(message) {
|
|
256
|
-
const msgJson = JSON.parse(message.msg ?? "");
|
|
257
|
-
if (message.msgTypeUrl === "/ibc.applications.transfer.v1.MsgTransfer") {
|
|
258
|
-
return sdkTs.MsgTransfer.fromJSON({
|
|
259
|
-
port: msgJson.source_port,
|
|
260
|
-
channelId: msgJson.source_channel,
|
|
261
|
-
amount: msgJson.token,
|
|
262
|
-
sender: msgJson.sender,
|
|
263
|
-
receiver: msgJson.receiver,
|
|
264
|
-
timeout: msgJson.timeout_timestamp,
|
|
265
|
-
memo: msgJson.memo
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
if (message.msgTypeUrl === "/cosmwasm.wasm.v1.MsgExecuteContract") {
|
|
269
|
-
return sdkTs.MsgExecuteContractCompat.fromJSON({
|
|
270
|
-
sender: msgJson.sender,
|
|
271
|
-
contractAddress: msgJson.contract,
|
|
272
|
-
msg: msgJson.msg,
|
|
273
|
-
funds: msgJson.funds
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
throw new Error("Unsupported message type");
|
|
277
|
-
}
|
|
278
255
|
|
|
279
256
|
// src/public-functions/getCosmosGasAmountForMessage.ts
|
|
280
257
|
var DEFAULT_GAS_MULTIPLIER = 1.5;
|
|
@@ -301,4 +278,3 @@ async function getCosmosGasAmountForMessage(client, signerAddress, chainId, mess
|
|
|
301
278
|
exports.DEFAULT_GAS_MULTIPLIER = DEFAULT_GAS_MULTIPLIER;
|
|
302
279
|
exports.getCosmosGasAmountForMessage = getCosmosGasAmountForMessage;
|
|
303
280
|
exports.getEncodeObjectFromCosmosMessage = getEncodeObjectFromCosmosMessage;
|
|
304
|
-
exports.getEncodeObjectFromCosmosMessageInjective = getEncodeObjectFromCosmosMessageInjective;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkE2P5MVX3_cjs = require('./chunk-E2P5MVX3.cjs');
|
|
4
4
|
var chunkJ5RC6ZU5_cjs = require('./chunk-J5RC6ZU5.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkMN6HFZJA_cjs = require('./chunk-MN6HFZJA.cjs');
|
|
6
6
|
var chunkF3EB2AQG_cjs = require('./chunk-F3EB2AQG.cjs');
|
|
7
7
|
var chunk4R6OCWRR_cjs = require('./chunk-4R6OCWRR.cjs');
|
|
8
8
|
var chunkKZOSEIWH_cjs = require('./chunk-KZOSEIWH.cjs');
|
|
9
|
-
var
|
|
10
|
-
var
|
|
9
|
+
var chunkYN66ABRQ_cjs = require('./chunk-YN66ABRQ.cjs');
|
|
10
|
+
var chunk7H6XRQAX_cjs = require('./chunk-7H6XRQAX.cjs');
|
|
11
11
|
var chunkFY56EEFB_cjs = require('./chunk-FY56EEFB.cjs');
|
|
12
12
|
var chunk2CCLIBCC_cjs = require('./chunk-2CCLIBCC.cjs');
|
|
13
13
|
var chunkMW3TE7DC_cjs = require('./chunk-MW3TE7DC.cjs');
|
|
@@ -18,10 +18,8 @@ var bech32 = require('bech32');
|
|
|
18
18
|
var stargate = require('@cosmjs/stargate');
|
|
19
19
|
var tx_js = require('cosmjs-types/cosmos/tx/v1beta1/tx.js');
|
|
20
20
|
var protoSigning = require('@cosmjs/proto-signing');
|
|
21
|
-
var encoding = require('@cosmjs/encoding');
|
|
22
|
-
var sdkTs = require('@injectivelabs/sdk-ts');
|
|
23
|
-
var utils = require('@injectivelabs/utils');
|
|
24
21
|
var amino = require('@cosmjs/amino');
|
|
22
|
+
var encoding = require('@cosmjs/encoding');
|
|
25
23
|
var keys_js = require('cosmjs-types/cosmos/crypto/secp256k1/keys.js');
|
|
26
24
|
var any_js = require('cosmjs-types/google/protobuf/any.js');
|
|
27
25
|
var math = require('@cosmjs/math');
|
|
@@ -39,7 +37,7 @@ var getRestEndpointForChain = async (chainId) => {
|
|
|
39
37
|
return endpointOptions.rest;
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
|
-
const chain =
|
|
40
|
+
const chain = chunk7H6XRQAX_cjs.chains().find((chain2) => chain2.chainId === chainId);
|
|
43
41
|
if (!chain) {
|
|
44
42
|
throw new Error(
|
|
45
43
|
`getRestEndpointForChain error: failed to find chain id '${chainId}' in registry`
|
|
@@ -51,7 +49,7 @@ var getRestEndpointForChain = async (chainId) => {
|
|
|
51
49
|
);
|
|
52
50
|
}
|
|
53
51
|
const endpoints = chain.apis?.rest?.map((api) => api.address);
|
|
54
|
-
const endpoint = await
|
|
52
|
+
const endpoint = await chunk7H6XRQAX_cjs.findFirstWorkingEndpoint(endpoints, "rest");
|
|
55
53
|
if (!endpoint) {
|
|
56
54
|
throw new Error(
|
|
57
55
|
`getRestEndpointForChain error: failed to find REST endpoint for chain id '${chainId}'`
|
|
@@ -65,9 +63,9 @@ var getAccountNumberAndSequence = async (address, chainId) => {
|
|
|
65
63
|
if (chainId.includes("dymension")) {
|
|
66
64
|
return getAccountNumberAndSequenceFromDymension(address, chainId);
|
|
67
65
|
}
|
|
68
|
-
const endpoint = await
|
|
66
|
+
const endpoint = await chunkYN66ABRQ_cjs.getRpcEndpointForChain(chainId);
|
|
69
67
|
const client = chunkQSISUSYP_cjs.ClientState.signingStargateClientByChainId[chainId] ?? await stargate.StargateClient.connect(endpoint, {
|
|
70
|
-
accountParser:
|
|
68
|
+
accountParser: chunkYN66ABRQ_cjs.accountParser
|
|
71
69
|
});
|
|
72
70
|
const account = await client.getAccount(address);
|
|
73
71
|
if (!account) {
|
|
@@ -108,95 +106,6 @@ var getAccountNumberAndSequenceFromDymension = async (address, chainId) => {
|
|
|
108
106
|
sequence
|
|
109
107
|
};
|
|
110
108
|
};
|
|
111
|
-
function createTransaction({
|
|
112
|
-
chainId,
|
|
113
|
-
message,
|
|
114
|
-
timeoutHeight,
|
|
115
|
-
memo = "",
|
|
116
|
-
fee = utils.DEFAULT_STD_FEE,
|
|
117
|
-
signMode = 1,
|
|
118
|
-
pubKey,
|
|
119
|
-
accountNumber,
|
|
120
|
-
sequence
|
|
121
|
-
}) {
|
|
122
|
-
const signers = {
|
|
123
|
-
pubKey,
|
|
124
|
-
accountNumber,
|
|
125
|
-
sequence
|
|
126
|
-
};
|
|
127
|
-
return sdkTs.createTransactionWithSigners({
|
|
128
|
-
fee,
|
|
129
|
-
memo,
|
|
130
|
-
message,
|
|
131
|
-
signers,
|
|
132
|
-
chainId,
|
|
133
|
-
signMode,
|
|
134
|
-
timeoutHeight
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// src/private-functions/cosmos/signCosmosMessageDirectEvmos.ts
|
|
139
|
-
var signCosmosMessageDirectEvmos = async (signerAddress, signer, cosmosMsgs, fee, { accountNumber, sequence, chainId }) => {
|
|
140
|
-
const accounts = await signer.getAccounts();
|
|
141
|
-
const accountFromSigner = accounts.find((account) => account.address === signerAddress);
|
|
142
|
-
if (!accountFromSigner) {
|
|
143
|
-
throw new Error("signCosmosMessageDirectEvmos: failed to retrieve account from signer");
|
|
144
|
-
}
|
|
145
|
-
const messages2 = cosmosMsgs.map(
|
|
146
|
-
(cosmosMsg) => chunkN3LR7KTI_cjs.getEncodeObjectFromCosmosMessageInjective(cosmosMsg)
|
|
147
|
-
);
|
|
148
|
-
const pk = Buffer.from(accountFromSigner.pubkey).toString("base64");
|
|
149
|
-
const { signDoc } = createTransaction({
|
|
150
|
-
pubKey: pk,
|
|
151
|
-
chainId,
|
|
152
|
-
message: messages2,
|
|
153
|
-
sequence,
|
|
154
|
-
accountNumber,
|
|
155
|
-
timeoutHeight: 0,
|
|
156
|
-
fee
|
|
157
|
-
});
|
|
158
|
-
const directSignResponse = await signer.signDirect(signerAddress, signDoc);
|
|
159
|
-
return tx_js.TxRaw.fromPartial({
|
|
160
|
-
bodyBytes: directSignResponse.signed.bodyBytes,
|
|
161
|
-
authInfoBytes: directSignResponse.signed.authInfoBytes,
|
|
162
|
-
signatures: [encoding.fromBase64(directSignResponse.signature.signature)]
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
var signCosmosMessageDirectInjective = async (signerAddress, signer, cosmosMsgs, fee, { accountNumber, sequence, chainId }) => {
|
|
166
|
-
const accounts = await signer.getAccounts();
|
|
167
|
-
const accountFromSigner = accounts.find((account) => account.address === signerAddress);
|
|
168
|
-
if (!accountFromSigner) {
|
|
169
|
-
throw new Error("signCosmosMessageDirectInjective: failed to retrieve account from signer");
|
|
170
|
-
}
|
|
171
|
-
const restEndpoint = await getRestEndpointForChain(chainId);
|
|
172
|
-
const chainRestTendermintApi = new sdkTs.ChainRestTendermintApi(restEndpoint);
|
|
173
|
-
const latestBlock = await chainRestTendermintApi.fetchLatestBlock();
|
|
174
|
-
const latestHeight = latestBlock.header.height;
|
|
175
|
-
const timeoutHeight = new utils.BigNumberInBase(latestHeight).plus(utils.DEFAULT_BLOCK_TIMEOUT_HEIGHT);
|
|
176
|
-
const pk = Buffer.from(accountFromSigner.pubkey).toString("base64");
|
|
177
|
-
const messages2 = cosmosMsgs.map(
|
|
178
|
-
(cosmosMsg) => chunkN3LR7KTI_cjs.getEncodeObjectFromCosmosMessageInjective(cosmosMsg)
|
|
179
|
-
);
|
|
180
|
-
const { signDoc } = createTransaction({
|
|
181
|
-
pubKey: pk,
|
|
182
|
-
chainId,
|
|
183
|
-
message: messages2,
|
|
184
|
-
sequence,
|
|
185
|
-
accountNumber,
|
|
186
|
-
timeoutHeight: timeoutHeight.toNumber(),
|
|
187
|
-
fee
|
|
188
|
-
});
|
|
189
|
-
const directSignResponse = await signer.signDirect(
|
|
190
|
-
signerAddress,
|
|
191
|
-
// @ts-expect-error TODO: Fix this
|
|
192
|
-
signDoc
|
|
193
|
-
);
|
|
194
|
-
return tx_js.TxRaw.fromPartial({
|
|
195
|
-
bodyBytes: directSignResponse.signed.bodyBytes,
|
|
196
|
-
authInfoBytes: directSignResponse.signed.authInfoBytes,
|
|
197
|
-
signatures: [encoding.fromBase64(directSignResponse.signature.signature)]
|
|
198
|
-
});
|
|
199
|
-
};
|
|
200
109
|
var pubkeyType = {
|
|
201
110
|
ethsecp256k1: "ethermint/PubKeyEthSecp256k1",
|
|
202
111
|
...amino.pubkeyType
|
|
@@ -217,7 +126,7 @@ function encodeEthSecp256k1Pubkey(pubkey) {
|
|
|
217
126
|
|
|
218
127
|
// src/proto-signing/pubkey.ts
|
|
219
128
|
function makePubkeyAnyFromAccount(account, chainId) {
|
|
220
|
-
const isEthermint =
|
|
129
|
+
const isEthermint = chunk7H6XRQAX_cjs.getIsEthermint(chainId);
|
|
221
130
|
const pubkey = isEthermint ? encodeEthSecp256k1Pubkey(account.pubkey) : amino.encodeSecp256k1Pubkey(account.pubkey);
|
|
222
131
|
const pubkeyAny = encodePubkeyToAny(pubkey, chainId, isEthermint);
|
|
223
132
|
return pubkeyAny;
|
|
@@ -238,7 +147,7 @@ function encodePubkeyToAny(pubkey, chainId, isEthermint) {
|
|
|
238
147
|
value: Uint8Array.from(keys_js.PubKey.encode(pubkeyProto).finish())
|
|
239
148
|
});
|
|
240
149
|
} else {
|
|
241
|
-
const isInitia =
|
|
150
|
+
const isInitia = chunk7H6XRQAX_cjs.getIsInitia(chainId);
|
|
242
151
|
const pubkeyProto = keys_js.PubKey.fromPartial({
|
|
243
152
|
key: encoding.fromBase64(pubkey.value)
|
|
244
153
|
});
|
|
@@ -260,26 +169,12 @@ var signCosmosMessageDirect = async (options) => {
|
|
|
260
169
|
fee,
|
|
261
170
|
signerData: { accountNumber, sequence, chainId: signerChainId }
|
|
262
171
|
} = options;
|
|
263
|
-
if (chainId.includes("evmos")) {
|
|
264
|
-
return signCosmosMessageDirectEvmos(signerAddress, signer, cosmosMsgs, fee, {
|
|
265
|
-
accountNumber,
|
|
266
|
-
sequence,
|
|
267
|
-
chainId: signerChainId
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
if (chainId.includes("injective")) {
|
|
271
|
-
return signCosmosMessageDirectInjective(signerAddress, signer, cosmosMsgs, fee, {
|
|
272
|
-
accountNumber,
|
|
273
|
-
sequence,
|
|
274
|
-
chainId: signerChainId
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
172
|
const accounts = await signer.getAccounts();
|
|
278
173
|
const accountFromSigner = accounts.find((account) => account.address === signerAddress);
|
|
279
174
|
if (!accountFromSigner) {
|
|
280
175
|
throw new Error("signCosmosMessageDirect error: failed to retrieve account from signer");
|
|
281
176
|
}
|
|
282
|
-
const messages2 = cosmosMsgs.map((cosmosMsg) =>
|
|
177
|
+
const messages2 = cosmosMsgs.map((cosmosMsg) => chunkMN6HFZJA_cjs.getEncodeObjectFromCosmosMessage(cosmosMsg));
|
|
283
178
|
const txBodyEncodeObject = {
|
|
284
179
|
typeUrl: "/cosmos.tx.v1beta1.TxBody",
|
|
285
180
|
value: {
|
|
@@ -318,7 +213,7 @@ var signCosmosMessageAmino = async (options) => {
|
|
|
318
213
|
if (!accountFromSigner) {
|
|
319
214
|
throw new Error("signCosmosMessageAmino: failed to retrieve account from signer");
|
|
320
215
|
}
|
|
321
|
-
const messages2 = cosmosMsgs.map((cosmosMsg) =>
|
|
216
|
+
const messages2 = cosmosMsgs.map((cosmosMsg) => chunkMN6HFZJA_cjs.getEncodeObjectFromCosmosMessage(cosmosMsg));
|
|
322
217
|
const signMode = signing_js.SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
|
|
323
218
|
const msgs = messages2.map((msg) => chunkQSISUSYP_cjs.ClientState.aminoTypes.toAmino(msg));
|
|
324
219
|
console.log("sign cosmos message amino", msgs, fee, signerChainId, "", accountNumber, sequence);
|
|
@@ -380,7 +275,7 @@ var signCosmosTransaction = async ({
|
|
|
380
275
|
if (messages2 === void 0) {
|
|
381
276
|
throw new Error("no messages found for tx");
|
|
382
277
|
}
|
|
383
|
-
const { signer } = await
|
|
278
|
+
const { signer } = await chunkYN66ABRQ_cjs.getSigningStargateClient({
|
|
384
279
|
chainId,
|
|
385
280
|
getOfflineSigner: options?.getCosmosSigner
|
|
386
281
|
});
|
|
@@ -811,7 +706,7 @@ var executeSvmTransaction = async (tx, options, index) => {
|
|
|
811
706
|
if (!signedTx) {
|
|
812
707
|
throw new Error("executeSvmTransaction error: signedTx is undefined");
|
|
813
708
|
}
|
|
814
|
-
const endpoint = await
|
|
709
|
+
const endpoint = await chunkYN66ABRQ_cjs.getRpcEndpointForChain(svmTx.chainId);
|
|
815
710
|
const connection = new web3_js.Connection(endpoint);
|
|
816
711
|
let signature;
|
|
817
712
|
const submitTxResponse = await chunk2CCLIBCC_cjs.submitTransaction({
|
|
@@ -1042,7 +937,7 @@ var validateSvmGasBalance = async ({
|
|
|
1042
937
|
fee: null
|
|
1043
938
|
};
|
|
1044
939
|
}
|
|
1045
|
-
const endpoint = await
|
|
940
|
+
const endpoint = await chunkYN66ABRQ_cjs.getRpcEndpointForChain(tx.chainId ?? "");
|
|
1046
941
|
const connection = new web3_js.Connection(endpoint);
|
|
1047
942
|
if (!connection) throw new Error(`Failed to connect to ${tx.chainId}`);
|
|
1048
943
|
if (!tx.tx) {
|
|
@@ -1122,7 +1017,7 @@ var validateGasBalances = async ({
|
|
|
1122
1017
|
throw new Error(`invalid msgs ${tx?.cosmosTx?.msgs}`);
|
|
1123
1018
|
}
|
|
1124
1019
|
try {
|
|
1125
|
-
const res = await
|
|
1020
|
+
const res = await chunkE2P5MVX3_cjs.validateCosmosGasBalance({
|
|
1126
1021
|
chainId: tx.cosmosTx.chainId ?? "",
|
|
1127
1022
|
signerAddress: tx.cosmosTx.signerAddress ?? "",
|
|
1128
1023
|
messages: tx.cosmosTx.msgs,
|
|
@@ -1283,6 +1178,24 @@ var executeTransactions = async (options) => {
|
|
|
1283
1178
|
}
|
|
1284
1179
|
if ("cosmosTx" in tx) {
|
|
1285
1180
|
await validateEnabledChainIds(tx.cosmosTx?.chainId ?? "");
|
|
1181
|
+
const isAllowedToBatchSignTxsUpfront = await (async () => {
|
|
1182
|
+
try {
|
|
1183
|
+
const currentUserAddress = options.userAddresses.find((x) => x.chainId === tx.cosmosTx?.chainId)?.address;
|
|
1184
|
+
if (!currentUserAddress) {
|
|
1185
|
+
return false;
|
|
1186
|
+
}
|
|
1187
|
+
const { accountNumber } = await getAccountNumberAndSequence(currentUserAddress, tx.cosmosTx?.chainId);
|
|
1188
|
+
if (accountNumber) {
|
|
1189
|
+
return true;
|
|
1190
|
+
}
|
|
1191
|
+
return false;
|
|
1192
|
+
} catch (_error) {
|
|
1193
|
+
return false;
|
|
1194
|
+
}
|
|
1195
|
+
})();
|
|
1196
|
+
if (!isAllowedToBatchSignTxsUpfront) {
|
|
1197
|
+
continue;
|
|
1198
|
+
}
|
|
1286
1199
|
const signedTx = await signCosmosTransaction({
|
|
1287
1200
|
tx,
|
|
1288
1201
|
options,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkKZOSEIWH_cjs = require('./chunk-KZOSEIWH.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunk7H6XRQAX_cjs = require('./chunk-7H6XRQAX.cjs');
|
|
5
5
|
var chunkQSISUSYP_cjs = require('./chunk-QSISUSYP.cjs');
|
|
6
6
|
|
|
7
7
|
// src/private-functions/getDefaultGasTokenForChain.ts
|
|
@@ -10,7 +10,7 @@ var getDefaultGasTokenForChain = async (chainId) => {
|
|
|
10
10
|
if (gasDenom) {
|
|
11
11
|
return gasDenom;
|
|
12
12
|
}
|
|
13
|
-
const chain =
|
|
13
|
+
const chain = chunk7H6XRQAX_cjs.chains().find((chain2) => chain2.chainId === chainId);
|
|
14
14
|
if (!chain) {
|
|
15
15
|
return void 0;
|
|
16
16
|
}
|
|
@@ -39,7 +39,7 @@ var getDefaultGasTokenForChain = async (chainId) => {
|
|
|
39
39
|
return chain.fees.feeTokens[0]?.denom;
|
|
40
40
|
};
|
|
41
41
|
var getStakingTokensForChain = (chainId) => {
|
|
42
|
-
const chain =
|
|
42
|
+
const chain = chunk7H6XRQAX_cjs.chains().find((chain2) => chain2.chainId === chainId);
|
|
43
43
|
if (!chain) {
|
|
44
44
|
throw new Error(
|
|
45
45
|
`getStakingTokensForChain error: failed to find chain id '${chainId}' in registry`
|
|
@@ -69,7 +69,7 @@ var getFeeInfoForChain = async ({ chainId, apiUrl, apiKey }) => {
|
|
|
69
69
|
if (skipFeeInfo && skipFeeInfo.gasPrice !== null) {
|
|
70
70
|
return skipFeeInfo;
|
|
71
71
|
}
|
|
72
|
-
const chain =
|
|
72
|
+
const chain = chunk7H6XRQAX_cjs.chains().find((chain2) => chain2.chainId === chainId);
|
|
73
73
|
if (!chain) {
|
|
74
74
|
return void 0;
|
|
75
75
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk7H6XRQAX_cjs = require('./chunk-7H6XRQAX.cjs');
|
|
4
4
|
var chunkQSISUSYP_cjs = require('./chunk-QSISUSYP.cjs');
|
|
5
5
|
var stargate = require('@cosmjs/stargate');
|
|
6
6
|
var utils = require('@cosmjs/utils');
|
|
@@ -224,7 +224,7 @@ var getRpcEndpointForChain = async (chainId) => {
|
|
|
224
224
|
console.warn(
|
|
225
225
|
"Warning: You are using unreliable public endpoints. We strongly recommend overriding them via endpointOptions for use beyond development settings."
|
|
226
226
|
);
|
|
227
|
-
const chain =
|
|
227
|
+
const chain = chunk7H6XRQAX_cjs.chains().find((chain2) => chain2.chainId === chainId);
|
|
228
228
|
if (!chain) {
|
|
229
229
|
throw new Error(`getRpcEndpointForChain: failed to find chain id '${chainId}' in registry`);
|
|
230
230
|
}
|
|
@@ -234,7 +234,7 @@ var getRpcEndpointForChain = async (chainId) => {
|
|
|
234
234
|
);
|
|
235
235
|
}
|
|
236
236
|
const endpoints = chain.apis?.rpc?.map((api) => api.address);
|
|
237
|
-
const endpoint = await
|
|
237
|
+
const endpoint = await chunk7H6XRQAX_cjs.findFirstWorkingEndpoint(endpoints, "rpc");
|
|
238
238
|
if (!endpoint) {
|
|
239
239
|
throw new Error(
|
|
240
240
|
`getRpcEndpointForChain error: failed to find RPC endpoint for chain id '${chainId}'`
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkOEYY7NXT_cjs = require('./chunk-OEYY7NXT.cjs');
|
|
4
|
+
var chunkE2P5MVX3_cjs = require('./chunk-E2P5MVX3.cjs');
|
|
5
5
|
var chunkJ5RC6ZU5_cjs = require('./chunk-J5RC6ZU5.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunkMN6HFZJA_cjs = require('./chunk-MN6HFZJA.cjs');
|
|
7
7
|
var chunkF3EB2AQG_cjs = require('./chunk-F3EB2AQG.cjs');
|
|
8
|
-
var
|
|
8
|
+
var chunkAF7EI5BT_cjs = require('./chunk-AF7EI5BT.cjs');
|
|
9
9
|
require('./chunk-4R6OCWRR.cjs');
|
|
10
|
-
var
|
|
10
|
+
var chunkVKVHMUDR_cjs = require('./chunk-VKVHMUDR.cjs');
|
|
11
11
|
var chunkKZOSEIWH_cjs = require('./chunk-KZOSEIWH.cjs');
|
|
12
|
-
var
|
|
13
|
-
require('./chunk-
|
|
12
|
+
var chunkYN66ABRQ_cjs = require('./chunk-YN66ABRQ.cjs');
|
|
13
|
+
require('./chunk-7H6XRQAX.cjs');
|
|
14
14
|
var chunkFO25SR66_cjs = require('./chunk-FO25SR66.cjs');
|
|
15
15
|
var chunk2EKCOIWV_cjs = require('./chunk-2EKCOIWV.cjs');
|
|
16
16
|
require('./chunk-WMXUOVHN.cjs');
|
|
@@ -176,11 +176,11 @@ var FeeBehaviorJson = /* @__PURE__ */ ((FeeBehaviorJson2) => {
|
|
|
176
176
|
|
|
177
177
|
Object.defineProperty(exports, "executeRoute", {
|
|
178
178
|
enumerable: true,
|
|
179
|
-
get: function () { return
|
|
179
|
+
get: function () { return chunkOEYY7NXT_cjs.executeRoute; }
|
|
180
180
|
});
|
|
181
181
|
Object.defineProperty(exports, "validateCosmosGasBalance", {
|
|
182
182
|
enumerable: true,
|
|
183
|
-
get: function () { return
|
|
183
|
+
get: function () { return chunkE2P5MVX3_cjs.validateCosmosGasBalance; }
|
|
184
184
|
});
|
|
185
185
|
Object.defineProperty(exports, "waitForTransaction", {
|
|
186
186
|
enumerable: true,
|
|
@@ -188,7 +188,7 @@ Object.defineProperty(exports, "waitForTransaction", {
|
|
|
188
188
|
});
|
|
189
189
|
Object.defineProperty(exports, "getCosmosGasAmountForMessage", {
|
|
190
190
|
enumerable: true,
|
|
191
|
-
get: function () { return
|
|
191
|
+
get: function () { return chunkMN6HFZJA_cjs.getCosmosGasAmountForMessage; }
|
|
192
192
|
});
|
|
193
193
|
Object.defineProperty(exports, "getEVMGasAmountForMessage", {
|
|
194
194
|
enumerable: true,
|
|
@@ -196,11 +196,11 @@ Object.defineProperty(exports, "getEVMGasAmountForMessage", {
|
|
|
196
196
|
});
|
|
197
197
|
Object.defineProperty(exports, "getRecommendedGasPrice", {
|
|
198
198
|
enumerable: true,
|
|
199
|
-
get: function () { return
|
|
199
|
+
get: function () { return chunkAF7EI5BT_cjs.getRecommendedGasPrice; }
|
|
200
200
|
});
|
|
201
201
|
Object.defineProperty(exports, "getFeeInfoForChain", {
|
|
202
202
|
enumerable: true,
|
|
203
|
-
get: function () { return
|
|
203
|
+
get: function () { return chunkVKVHMUDR_cjs.getFeeInfoForChain; }
|
|
204
204
|
});
|
|
205
205
|
Object.defineProperty(exports, "GAS_STATION_CHAIN_IDS", {
|
|
206
206
|
enumerable: true,
|
|
@@ -208,7 +208,7 @@ Object.defineProperty(exports, "GAS_STATION_CHAIN_IDS", {
|
|
|
208
208
|
});
|
|
209
209
|
Object.defineProperty(exports, "getSigningStargateClient", {
|
|
210
210
|
enumerable: true,
|
|
211
|
-
get: function () { return
|
|
211
|
+
get: function () { return chunkYN66ABRQ_cjs.getSigningStargateClient; }
|
|
212
212
|
});
|
|
213
213
|
Object.defineProperty(exports, "setApiOptions", {
|
|
214
214
|
enumerable: true,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunkOEYY7NXT_cjs = require('../chunk-OEYY7NXT.cjs');
|
|
4
|
+
require('../chunk-E2P5MVX3.cjs');
|
|
5
5
|
require('../chunk-J5RC6ZU5.cjs');
|
|
6
|
-
require('../chunk-
|
|
6
|
+
require('../chunk-MN6HFZJA.cjs');
|
|
7
7
|
require('../chunk-F3EB2AQG.cjs');
|
|
8
8
|
require('../chunk-4R6OCWRR.cjs');
|
|
9
9
|
require('../chunk-KZOSEIWH.cjs');
|
|
10
|
-
require('../chunk-
|
|
11
|
-
require('../chunk-
|
|
10
|
+
require('../chunk-YN66ABRQ.cjs');
|
|
11
|
+
require('../chunk-7H6XRQAX.cjs');
|
|
12
12
|
require('../chunk-WMXUOVHN.cjs');
|
|
13
13
|
require('../chunk-FY56EEFB.cjs');
|
|
14
14
|
require('../chunk-2CCLIBCC.cjs');
|
|
@@ -23,5 +23,5 @@ require('../chunk-IDDRJJO5.cjs');
|
|
|
23
23
|
|
|
24
24
|
Object.defineProperty(exports, "executeRoute", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkOEYY7NXT_cjs.executeRoute; }
|
|
27
27
|
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkMN6HFZJA_cjs = require('../chunk-MN6HFZJA.cjs');
|
|
4
4
|
require('../chunk-WMXUOVHN.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "DEFAULT_GAS_MULTIPLIER", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkMN6HFZJA_cjs.DEFAULT_GAS_MULTIPLIER; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "getCosmosGasAmountForMessage", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkMN6HFZJA_cjs.getCosmosGasAmountForMessage; }
|
|
15
15
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkVKVHMUDR_cjs = require('../chunk-VKVHMUDR.cjs');
|
|
4
4
|
require('../chunk-KZOSEIWH.cjs');
|
|
5
|
-
require('../chunk-
|
|
5
|
+
require('../chunk-7H6XRQAX.cjs');
|
|
6
6
|
require('../chunk-QSISUSYP.cjs');
|
|
7
7
|
require('../chunk-HKQ5VION.cjs');
|
|
8
8
|
require('../chunk-IDDRJJO5.cjs');
|
|
@@ -11,5 +11,5 @@ require('../chunk-IDDRJJO5.cjs');
|
|
|
11
11
|
|
|
12
12
|
Object.defineProperty(exports, "getFeeInfoForChain", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkVKVHMUDR_cjs.getFeeInfoForChain; }
|
|
15
15
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkAF7EI5BT_cjs = require('../chunk-AF7EI5BT.cjs');
|
|
4
4
|
require('../chunk-4R6OCWRR.cjs');
|
|
5
|
-
require('../chunk-
|
|
5
|
+
require('../chunk-VKVHMUDR.cjs');
|
|
6
6
|
require('../chunk-KZOSEIWH.cjs');
|
|
7
|
-
require('../chunk-
|
|
7
|
+
require('../chunk-7H6XRQAX.cjs');
|
|
8
8
|
require('../chunk-QSISUSYP.cjs');
|
|
9
9
|
require('../chunk-HKQ5VION.cjs');
|
|
10
10
|
require('../chunk-IDDRJJO5.cjs');
|
|
@@ -13,5 +13,5 @@ require('../chunk-IDDRJJO5.cjs');
|
|
|
13
13
|
|
|
14
14
|
Object.defineProperty(exports, "getRecommendedGasPrice", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunkAF7EI5BT_cjs.getRecommendedGasPrice; }
|
|
17
17
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunkYN66ABRQ_cjs = require('../chunk-YN66ABRQ.cjs');
|
|
4
|
+
require('../chunk-7H6XRQAX.cjs');
|
|
5
5
|
require('../chunk-QSISUSYP.cjs');
|
|
6
6
|
require('../chunk-HKQ5VION.cjs');
|
|
7
7
|
require('../chunk-IDDRJJO5.cjs');
|
|
@@ -10,5 +10,5 @@ require('../chunk-IDDRJJO5.cjs');
|
|
|
10
10
|
|
|
11
11
|
Object.defineProperty(exports, "getSigningStargateClient", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkYN66ABRQ_cjs.getSigningStargateClient; }
|
|
14
14
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunkE2P5MVX3_cjs = require('../chunk-E2P5MVX3.cjs');
|
|
4
|
+
require('../chunk-MN6HFZJA.cjs');
|
|
5
5
|
require('../chunk-4R6OCWRR.cjs');
|
|
6
|
-
require('../chunk-
|
|
7
|
-
require('../chunk-
|
|
6
|
+
require('../chunk-YN66ABRQ.cjs');
|
|
7
|
+
require('../chunk-7H6XRQAX.cjs');
|
|
8
8
|
require('../chunk-WMXUOVHN.cjs');
|
|
9
9
|
require('../chunk-QSISUSYP.cjs');
|
|
10
10
|
require('../chunk-HKQ5VION.cjs');
|
|
@@ -14,5 +14,5 @@ require('../chunk-IDDRJJO5.cjs');
|
|
|
14
14
|
|
|
15
15
|
Object.defineProperty(exports, "validateCosmosGasBalance", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkE2P5MVX3_cjs.validateCosmosGasBalance; }
|
|
18
18
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_GAS_DENOM_OVERRIDES } from './chunk-SWYON2RG.js';
|
|
2
|
-
import { chains } from './chunk-
|
|
2
|
+
import { chains } from './chunk-U6AH2WOP.js';
|
|
3
3
|
import { ClientState } from './chunk-2L7PKZDY.js';
|
|
4
4
|
|
|
5
5
|
// src/private-functions/getDefaultGasTokenForChain.ts
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
import { validateCosmosGasBalance } from './chunk-
|
|
1
|
+
import { validateCosmosGasBalance } from './chunk-IQQDEBLI.js';
|
|
2
2
|
import { waitForTransaction } from './chunk-CU6W3622.js';
|
|
3
|
-
import { getEncodeObjectFromCosmosMessage
|
|
3
|
+
import { getEncodeObjectFromCosmosMessage } from './chunk-P76IRSIS.js';
|
|
4
4
|
import { getEVMGasAmountForMessage } from './chunk-GV2QOWB4.js';
|
|
5
5
|
import { BigNumber } from './chunk-VQ5SIQWU.js';
|
|
6
6
|
import { GAS_STATION_CHAIN_IDS } from './chunk-SWYON2RG.js';
|
|
7
|
-
import {
|
|
8
|
-
import { chains, findFirstWorkingEndpoint, getIsEthermint, getIsInitia } from './chunk-
|
|
7
|
+
import { getRpcEndpointForChain, accountParser, getSigningStargateClient } from './chunk-KJVD5P3Q.js';
|
|
8
|
+
import { chains, findFirstWorkingEndpoint, getIsEthermint, getIsInitia } from './chunk-U6AH2WOP.js';
|
|
9
9
|
import { messages } from './chunk-7LSTJXAF.js';
|
|
10
10
|
import { submitTransaction } from './chunk-OHV2LZEG.js';
|
|
11
11
|
import { venues } from './chunk-JSY7M43P.js';
|
|
12
12
|
import { ClientState, balances } from './chunk-2L7PKZDY.js';
|
|
13
|
-
import { ApiState,
|
|
13
|
+
import { ApiState, toCamel, wait } from './chunk-LZI7A4JI.js';
|
|
14
14
|
import { PublicKey, Transaction, Connection, LAMPORTS_PER_SOL } from '@solana/web3.js';
|
|
15
15
|
import { bech32m, bech32 } from 'bech32';
|
|
16
16
|
import { StargateClient } from '@cosmjs/stargate';
|
|
17
17
|
import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx.js';
|
|
18
18
|
import { isOfflineDirectSigner, makeAuthInfoBytes, makeSignDoc, encodePubkey } from '@cosmjs/proto-signing';
|
|
19
|
-
import { fromBase64, toBase64 } from '@cosmjs/encoding';
|
|
20
|
-
import { ChainRestTendermintApi, createTransactionWithSigners } from '@injectivelabs/sdk-ts';
|
|
21
|
-
import { BigNumberInBase, DEFAULT_BLOCK_TIMEOUT_HEIGHT, DEFAULT_STD_FEE } from '@injectivelabs/utils';
|
|
22
19
|
import { pubkeyType as pubkeyType$1, makeSignDoc as makeSignDoc$1, encodeSecp256k1Pubkey } from '@cosmjs/amino';
|
|
20
|
+
import { fromBase64, toBase64 } from '@cosmjs/encoding';
|
|
23
21
|
import { PubKey } from 'cosmjs-types/cosmos/crypto/secp256k1/keys.js';
|
|
24
22
|
import { Any } from 'cosmjs-types/google/protobuf/any.js';
|
|
25
23
|
import { Int53 } from '@cosmjs/math';
|
|
@@ -106,95 +104,6 @@ var getAccountNumberAndSequenceFromDymension = async (address, chainId) => {
|
|
|
106
104
|
sequence
|
|
107
105
|
};
|
|
108
106
|
};
|
|
109
|
-
function createTransaction({
|
|
110
|
-
chainId,
|
|
111
|
-
message,
|
|
112
|
-
timeoutHeight,
|
|
113
|
-
memo = "",
|
|
114
|
-
fee = DEFAULT_STD_FEE,
|
|
115
|
-
signMode = 1,
|
|
116
|
-
pubKey,
|
|
117
|
-
accountNumber,
|
|
118
|
-
sequence
|
|
119
|
-
}) {
|
|
120
|
-
const signers = {
|
|
121
|
-
pubKey,
|
|
122
|
-
accountNumber,
|
|
123
|
-
sequence
|
|
124
|
-
};
|
|
125
|
-
return createTransactionWithSigners({
|
|
126
|
-
fee,
|
|
127
|
-
memo,
|
|
128
|
-
message,
|
|
129
|
-
signers,
|
|
130
|
-
chainId,
|
|
131
|
-
signMode,
|
|
132
|
-
timeoutHeight
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// src/private-functions/cosmos/signCosmosMessageDirectEvmos.ts
|
|
137
|
-
var signCosmosMessageDirectEvmos = async (signerAddress, signer, cosmosMsgs, fee, { accountNumber, sequence, chainId }) => {
|
|
138
|
-
const accounts = await signer.getAccounts();
|
|
139
|
-
const accountFromSigner = accounts.find((account) => account.address === signerAddress);
|
|
140
|
-
if (!accountFromSigner) {
|
|
141
|
-
throw new Error("signCosmosMessageDirectEvmos: failed to retrieve account from signer");
|
|
142
|
-
}
|
|
143
|
-
const messages2 = cosmosMsgs.map(
|
|
144
|
-
(cosmosMsg) => getEncodeObjectFromCosmosMessageInjective(cosmosMsg)
|
|
145
|
-
);
|
|
146
|
-
const pk = Buffer.from(accountFromSigner.pubkey).toString("base64");
|
|
147
|
-
const { signDoc } = createTransaction({
|
|
148
|
-
pubKey: pk,
|
|
149
|
-
chainId,
|
|
150
|
-
message: messages2,
|
|
151
|
-
sequence,
|
|
152
|
-
accountNumber,
|
|
153
|
-
timeoutHeight: 0,
|
|
154
|
-
fee
|
|
155
|
-
});
|
|
156
|
-
const directSignResponse = await signer.signDirect(signerAddress, signDoc);
|
|
157
|
-
return TxRaw.fromPartial({
|
|
158
|
-
bodyBytes: directSignResponse.signed.bodyBytes,
|
|
159
|
-
authInfoBytes: directSignResponse.signed.authInfoBytes,
|
|
160
|
-
signatures: [fromBase64(directSignResponse.signature.signature)]
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
var signCosmosMessageDirectInjective = async (signerAddress, signer, cosmosMsgs, fee, { accountNumber, sequence, chainId }) => {
|
|
164
|
-
const accounts = await signer.getAccounts();
|
|
165
|
-
const accountFromSigner = accounts.find((account) => account.address === signerAddress);
|
|
166
|
-
if (!accountFromSigner) {
|
|
167
|
-
throw new Error("signCosmosMessageDirectInjective: failed to retrieve account from signer");
|
|
168
|
-
}
|
|
169
|
-
const restEndpoint = await getRestEndpointForChain(chainId);
|
|
170
|
-
const chainRestTendermintApi = new ChainRestTendermintApi(restEndpoint);
|
|
171
|
-
const latestBlock = await chainRestTendermintApi.fetchLatestBlock();
|
|
172
|
-
const latestHeight = latestBlock.header.height;
|
|
173
|
-
const timeoutHeight = new BigNumberInBase(latestHeight).plus(DEFAULT_BLOCK_TIMEOUT_HEIGHT);
|
|
174
|
-
const pk = Buffer.from(accountFromSigner.pubkey).toString("base64");
|
|
175
|
-
const messages2 = cosmosMsgs.map(
|
|
176
|
-
(cosmosMsg) => getEncodeObjectFromCosmosMessageInjective(cosmosMsg)
|
|
177
|
-
);
|
|
178
|
-
const { signDoc } = createTransaction({
|
|
179
|
-
pubKey: pk,
|
|
180
|
-
chainId,
|
|
181
|
-
message: messages2,
|
|
182
|
-
sequence,
|
|
183
|
-
accountNumber,
|
|
184
|
-
timeoutHeight: timeoutHeight.toNumber(),
|
|
185
|
-
fee
|
|
186
|
-
});
|
|
187
|
-
const directSignResponse = await signer.signDirect(
|
|
188
|
-
signerAddress,
|
|
189
|
-
// @ts-expect-error TODO: Fix this
|
|
190
|
-
signDoc
|
|
191
|
-
);
|
|
192
|
-
return TxRaw.fromPartial({
|
|
193
|
-
bodyBytes: directSignResponse.signed.bodyBytes,
|
|
194
|
-
authInfoBytes: directSignResponse.signed.authInfoBytes,
|
|
195
|
-
signatures: [fromBase64(directSignResponse.signature.signature)]
|
|
196
|
-
});
|
|
197
|
-
};
|
|
198
107
|
var pubkeyType = {
|
|
199
108
|
ethsecp256k1: "ethermint/PubKeyEthSecp256k1",
|
|
200
109
|
...pubkeyType$1
|
|
@@ -258,20 +167,6 @@ var signCosmosMessageDirect = async (options) => {
|
|
|
258
167
|
fee,
|
|
259
168
|
signerData: { accountNumber, sequence, chainId: signerChainId }
|
|
260
169
|
} = options;
|
|
261
|
-
if (chainId.includes("evmos")) {
|
|
262
|
-
return signCosmosMessageDirectEvmos(signerAddress, signer, cosmosMsgs, fee, {
|
|
263
|
-
accountNumber,
|
|
264
|
-
sequence,
|
|
265
|
-
chainId: signerChainId
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
if (chainId.includes("injective")) {
|
|
269
|
-
return signCosmosMessageDirectInjective(signerAddress, signer, cosmosMsgs, fee, {
|
|
270
|
-
accountNumber,
|
|
271
|
-
sequence,
|
|
272
|
-
chainId: signerChainId
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
170
|
const accounts = await signer.getAccounts();
|
|
276
171
|
const accountFromSigner = accounts.find((account) => account.address === signerAddress);
|
|
277
172
|
if (!accountFromSigner) {
|
|
@@ -1281,6 +1176,24 @@ var executeTransactions = async (options) => {
|
|
|
1281
1176
|
}
|
|
1282
1177
|
if ("cosmosTx" in tx) {
|
|
1283
1178
|
await validateEnabledChainIds(tx.cosmosTx?.chainId ?? "");
|
|
1179
|
+
const isAllowedToBatchSignTxsUpfront = await (async () => {
|
|
1180
|
+
try {
|
|
1181
|
+
const currentUserAddress = options.userAddresses.find((x) => x.chainId === tx.cosmosTx?.chainId)?.address;
|
|
1182
|
+
if (!currentUserAddress) {
|
|
1183
|
+
return false;
|
|
1184
|
+
}
|
|
1185
|
+
const { accountNumber } = await getAccountNumberAndSequence(currentUserAddress, tx.cosmosTx?.chainId);
|
|
1186
|
+
if (accountNumber) {
|
|
1187
|
+
return true;
|
|
1188
|
+
}
|
|
1189
|
+
return false;
|
|
1190
|
+
} catch (_error) {
|
|
1191
|
+
return false;
|
|
1192
|
+
}
|
|
1193
|
+
})();
|
|
1194
|
+
if (!isAllowedToBatchSignTxsUpfront) {
|
|
1195
|
+
continue;
|
|
1196
|
+
}
|
|
1284
1197
|
const signedTx = await signCosmosTransaction({
|
|
1285
1198
|
tx,
|
|
1286
1199
|
options,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getCosmosGasAmountForMessage } from './chunk-
|
|
1
|
+
import { getCosmosGasAmountForMessage } from './chunk-P76IRSIS.js';
|
|
2
2
|
import { BigNumber } from './chunk-VQ5SIQWU.js';
|
|
3
|
-
import { getSigningStargateClient } from './chunk-
|
|
3
|
+
import { getSigningStargateClient } from './chunk-KJVD5P3Q.js';
|
|
4
4
|
import { ClientState, balances } from './chunk-2L7PKZDY.js';
|
|
5
5
|
import { GasPrice, calculateFee } from '@cosmjs/stargate';
|
|
6
6
|
import { Decimal } from '@cosmjs/math';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { chains, findFirstWorkingEndpoint } from './chunk-
|
|
1
|
+
import { chains, findFirstWorkingEndpoint } from './chunk-U6AH2WOP.js';
|
|
2
2
|
import { ClientState } from './chunk-2L7PKZDY.js';
|
|
3
3
|
import { accountFromAny, SigningStargateClient } from '@cosmjs/stargate';
|
|
4
4
|
import { assertDefinedAndNotNull } from '@cosmjs/utils';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MsgDepositForBurn, MsgDepositForBurnWithCaller, MsgExecute, MsgInitiateTokenDeposit, BaseVestingAccount, Timestamp, toTimestamp, Period, fromTimestamp, isSet, fromJsonTimestamp } from './chunk-TD63P2AG.js';
|
|
2
2
|
import '@cosmjs/stargate';
|
|
3
3
|
import { toUtf8 } from '@cosmjs/encoding';
|
|
4
|
-
import
|
|
4
|
+
import '@injectivelabs/sdk-ts';
|
|
5
5
|
import { MsgSend } from 'cosmjs-types/cosmos/bank/v1beta1/tx.js';
|
|
6
6
|
import { MsgExecuteContract } from 'cosmjs-types/cosmwasm/wasm/v1/tx.js';
|
|
7
7
|
import { MsgTransfer } from 'cosmjs-types/ibc/applications/transfer/v1/tx.js';
|
|
@@ -246,29 +246,6 @@ function getEncodeObjectFromCosmosMessage(message) {
|
|
|
246
246
|
value: msgJson
|
|
247
247
|
};
|
|
248
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
249
|
|
|
273
250
|
// src/public-functions/getCosmosGasAmountForMessage.ts
|
|
274
251
|
var DEFAULT_GAS_MULTIPLIER = 1.5;
|
|
@@ -292,4 +269,4 @@ async function getCosmosGasAmountForMessage(client, signerAddress, chainId, mess
|
|
|
292
269
|
return Math.ceil(estimatedGasWithBuffer).toFixed(0);
|
|
293
270
|
}
|
|
294
271
|
|
|
295
|
-
export { DEFAULT_GAS_MULTIPLIER, getCosmosGasAmountForMessage, getEncodeObjectFromCosmosMessage
|
|
272
|
+
export { DEFAULT_GAS_MULTIPLIER, getCosmosGasAmountForMessage, getEncodeObjectFromCosmosMessage };
|
|
@@ -132,6 +132,7 @@ function chains() {
|
|
|
132
132
|
}
|
|
133
133
|
var getIsEthermint = (chainId) => {
|
|
134
134
|
const chain = chains().find((c) => c.chainId === chainId);
|
|
135
|
+
if (chain?.chainId?.includes("injective")) return true;
|
|
135
136
|
if (!chain) return false;
|
|
136
137
|
const keyAlgos = chain.keyAlgos;
|
|
137
138
|
const extraCodecs = chain.extraCodecs;
|
|
@@ -149,14 +150,11 @@ async function findFirstWorkingEndpoint(endpoints, type) {
|
|
|
149
150
|
const url = (() => {
|
|
150
151
|
switch (type) {
|
|
151
152
|
case "rpc": {
|
|
152
|
-
const rpc = new URL(
|
|
153
|
+
const rpc = new URL(endpoint);
|
|
153
154
|
return rpc.toString();
|
|
154
155
|
}
|
|
155
156
|
case "rest": {
|
|
156
|
-
const url2 = new URL(
|
|
157
|
-
"cosmos/base/tendermint/v1beta1/node_info",
|
|
158
|
-
endpoint
|
|
159
|
-
);
|
|
157
|
+
const url2 = new URL(endpoint);
|
|
160
158
|
return url2.toString();
|
|
161
159
|
}
|
|
162
160
|
default:
|
package/dist/esm/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export { executeRoute } from './chunk-
|
|
2
|
-
export { validateCosmosGasBalance } from './chunk-
|
|
1
|
+
export { executeRoute } from './chunk-FFFVITWF.js';
|
|
2
|
+
export { validateCosmosGasBalance } from './chunk-IQQDEBLI.js';
|
|
3
3
|
export { waitForTransaction } from './chunk-CU6W3622.js';
|
|
4
|
-
export { getCosmosGasAmountForMessage } from './chunk-
|
|
4
|
+
export { getCosmosGasAmountForMessage } from './chunk-P76IRSIS.js';
|
|
5
5
|
export { getEVMGasAmountForMessage } from './chunk-GV2QOWB4.js';
|
|
6
|
-
export { getRecommendedGasPrice } from './chunk-
|
|
6
|
+
export { getRecommendedGasPrice } from './chunk-5JZOTYDC.js';
|
|
7
7
|
import './chunk-VQ5SIQWU.js';
|
|
8
|
-
export { getFeeInfoForChain } from './chunk-
|
|
8
|
+
export { getFeeInfoForChain } from './chunk-5FKIW2ZL.js';
|
|
9
9
|
export { GAS_STATION_CHAIN_IDS } from './chunk-SWYON2RG.js';
|
|
10
|
-
export { getSigningStargateClient } from './chunk-
|
|
11
|
-
import './chunk-
|
|
10
|
+
export { getSigningStargateClient } from './chunk-KJVD5P3Q.js';
|
|
11
|
+
import './chunk-U6AH2WOP.js';
|
|
12
12
|
export { setApiOptions } from './chunk-JYUNVL4F.js';
|
|
13
13
|
export { setClientOptions } from './chunk-OL7CWCPB.js';
|
|
14
14
|
import './chunk-TD63P2AG.js';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export { executeRoute } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { executeRoute } from '../chunk-FFFVITWF.js';
|
|
2
|
+
import '../chunk-IQQDEBLI.js';
|
|
3
3
|
import '../chunk-CU6W3622.js';
|
|
4
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-P76IRSIS.js';
|
|
5
5
|
import '../chunk-GV2QOWB4.js';
|
|
6
6
|
import '../chunk-VQ5SIQWU.js';
|
|
7
7
|
import '../chunk-SWYON2RG.js';
|
|
8
|
-
import '../chunk-
|
|
9
|
-
import '../chunk-
|
|
8
|
+
import '../chunk-KJVD5P3Q.js';
|
|
9
|
+
import '../chunk-U6AH2WOP.js';
|
|
10
10
|
import '../chunk-TD63P2AG.js';
|
|
11
11
|
import '../chunk-7LSTJXAF.js';
|
|
12
12
|
import '../chunk-OHV2LZEG.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { DEFAULT_GAS_MULTIPLIER, getCosmosGasAmountForMessage } from '../chunk-
|
|
1
|
+
export { DEFAULT_GAS_MULTIPLIER, getCosmosGasAmountForMessage } from '../chunk-P76IRSIS.js';
|
|
2
2
|
import '../chunk-TD63P2AG.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { getFeeInfoForChain } from '../chunk-
|
|
1
|
+
export { getFeeInfoForChain } from '../chunk-5FKIW2ZL.js';
|
|
2
2
|
import '../chunk-SWYON2RG.js';
|
|
3
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-U6AH2WOP.js';
|
|
4
4
|
import '../chunk-2L7PKZDY.js';
|
|
5
5
|
import '../chunk-LZI7A4JI.js';
|
|
6
6
|
import '../chunk-OQDBWVET.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { getRecommendedGasPrice } from '../chunk-
|
|
1
|
+
export { getRecommendedGasPrice } from '../chunk-5JZOTYDC.js';
|
|
2
2
|
import '../chunk-VQ5SIQWU.js';
|
|
3
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-5FKIW2ZL.js';
|
|
4
4
|
import '../chunk-SWYON2RG.js';
|
|
5
|
-
import '../chunk-
|
|
5
|
+
import '../chunk-U6AH2WOP.js';
|
|
6
6
|
import '../chunk-2L7PKZDY.js';
|
|
7
7
|
import '../chunk-LZI7A4JI.js';
|
|
8
8
|
import '../chunk-OQDBWVET.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { getSigningStargateClient } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { getSigningStargateClient } from '../chunk-KJVD5P3Q.js';
|
|
2
|
+
import '../chunk-U6AH2WOP.js';
|
|
3
3
|
import '../chunk-2L7PKZDY.js';
|
|
4
4
|
import '../chunk-LZI7A4JI.js';
|
|
5
5
|
import '../chunk-OQDBWVET.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { validateCosmosGasBalance } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { validateCosmosGasBalance } from '../chunk-IQQDEBLI.js';
|
|
2
|
+
import '../chunk-P76IRSIS.js';
|
|
3
3
|
import '../chunk-VQ5SIQWU.js';
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-KJVD5P3Q.js';
|
|
5
|
+
import '../chunk-U6AH2WOP.js';
|
|
6
6
|
import '../chunk-TD63P2AG.js';
|
|
7
7
|
import '../chunk-2L7PKZDY.js';
|
|
8
8
|
import '../chunk-LZI7A4JI.js';
|