@skip-go/client 1.0.4 → 1.0.6
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/api/{getAssets.d.cts → getAssets.d.ts} +2 -2
- package/dist/api/getAssets.js +2 -0
- package/dist/api/{getAssetsBetweenChains.d.cts → getAssetsBetweenChains.d.ts} +2 -2
- package/dist/api/getAssetsBetweenChains.js +2 -0
- package/dist/api/{getBridges.d.cts → getBridges.d.ts} +2 -2
- package/dist/api/getBridges.js +2 -0
- package/dist/api/{getChains.d.cts → getChains.d.ts} +2 -2
- package/dist/api/getChains.js +2 -0
- package/dist/api/{getVenues.d.cts → getVenues.d.ts} +1 -1
- package/dist/api/getVenues.js +2 -0
- package/dist/api/{postAssetsFromSource.d.cts → postAssetsFromSource.d.ts} +2 -2
- package/dist/api/postAssetsFromSource.js +3 -0
- package/dist/api/{postBalances.d.cts → postBalances.d.ts} +3 -3
- package/dist/api/postBalances.js +2 -0
- package/dist/api/{postIbcOriginAssets.d.cts → postIbcOriginAssets.d.ts} +1 -1
- package/dist/api/postIbcOriginAssets.js +2 -0
- package/dist/api/{postMessages.d.cts → postMessages.d.ts} +3 -3
- package/dist/api/postMessages.js +2 -0
- package/dist/api/{postMessagesDirect.d.cts → postMessagesDirect.d.ts} +2 -2
- package/dist/api/postMessagesDirect.js +2 -0
- package/dist/api/{postRecommendAssets.d.cts → postRecommendAssets.d.ts} +2 -2
- package/dist/api/postRecommendAssets.js +2 -0
- package/dist/api/{postRoute.d.cts → postRoute.d.ts} +3 -3
- package/dist/api/postRoute.js +2 -0
- package/dist/api/{postSubmitTransaction.d.cts → postSubmitTransaction.d.ts} +1 -1
- package/dist/api/postSubmitTransaction.js +2 -0
- package/dist/api/{postTrackTransaction.d.cts → postTrackTransaction.d.ts} +1 -1
- package/dist/api/postTrackTransaction.js +2 -0
- package/dist/api/{postTransactionStatus.d.cts → postTransactionStatus.d.ts} +3 -3
- package/dist/api/postTransactionStatus.js +2 -0
- package/dist/chunk-33K6EESX.js +10 -0
- package/dist/{chunk-77ITCT75.cjs → chunk-4JJWOILI.js} +3 -5
- package/dist/chunk-BQTQJQ5E.js +10 -0
- package/dist/{chunk-ED2OY55G.cjs → chunk-BRMONS6A.js} +5 -11
- package/dist/{chunk-PNWIJSMA.cjs → chunk-C2EDPY6J.js} +3 -5
- package/dist/chunk-DW4U6YI6.js +10 -0
- package/dist/{chunk-GQYZQCOJ.cjs → chunk-F75DC5RW.js} +179 -185
- package/dist/{chunk-SFMBRLUS.cjs → chunk-GARVPN2H.js} +4 -6
- package/dist/{chunk-7SK3IFXJ.cjs → chunk-JTIHU43D.js} +1 -6
- package/dist/{chunk-VI7UMBQ7.cjs → chunk-KNV72XRZ.js} +3 -5
- package/dist/chunk-MGVXJ2U4.js +11 -0
- package/dist/chunk-MTMPHY3Y.js +9 -0
- package/dist/{chunk-UO54MR5Z.cjs → chunk-PHTQQIAH.js} +220 -226
- package/dist/{chunk-RDOSNDAQ.cjs → chunk-PRQ2NHRZ.js} +3 -5
- package/dist/chunk-RDRDFJQE.js +10 -0
- package/dist/chunk-RMP3HM5N.js +14 -0
- package/dist/{chunk-D2MDLQQZ.cjs → chunk-SONZJVQM.js} +47 -51
- package/dist/{chunk-KZOSEIWH.cjs → chunk-SWYON2RG.js} +1 -4
- package/dist/{chunk-WMXUOVHN.cjs → chunk-TD63P2AG.js} +111 -156
- package/dist/{chunk-ZNXE6PUV.cjs → chunk-TW77BXMT.js} +7 -9
- package/dist/chunk-UNF72WYO.js +22 -0
- package/dist/{chunk-J4LI33TK.cjs → chunk-VMPFHQ7U.js} +9 -11
- package/dist/{chunk-4R6OCWRR.cjs → chunk-VQ5SIQWU.js} +1 -3
- package/dist/{chunk-HAR3IXDE.cjs → chunk-W6TBGBV3.js} +1 -31
- package/dist/{client-types-qvyKvyFh.d.cts → client-types-CxjtffyG.d.ts} +1 -1
- package/dist/{executeRoute-BKRpODCc.d.cts → executeRoute-BKvMVd1I.d.ts} +3 -3
- package/dist/{generateApi-C0amiydg.d.cts → generateApi-DqCp36fX.d.ts} +1 -1
- package/dist/{index.d.cts → index.d.ts} +25 -25
- package/dist/index.js +24 -0
- package/dist/public-functions/{executeRoute.d.cts → executeRoute.d.ts} +4 -4
- package/dist/public-functions/executeRoute.js +12 -0
- package/dist/public-functions/{getFeeInfoForChain.d.cts → getFeeInfoForChain.d.ts} +2 -2
- package/dist/public-functions/getFeeInfoForChain.js +5 -0
- package/dist/public-functions/{getRecommendedGasPrice.d.cts → getRecommendedGasPrice.d.ts} +1 -1
- package/dist/public-functions/getRecommendedGasPrice.js +7 -0
- package/dist/public-functions/getSigningStargateClient.js +4 -0
- package/dist/public-functions/{setApiOptions.d.cts → setApiOptions.d.ts} +2 -2
- package/dist/public-functions/setApiOptions.js +2 -0
- package/dist/public-functions/setClientOptions.d.ts +9 -0
- package/dist/public-functions/setClientOptions.js +4 -0
- package/dist/{setClientOptions-CT6CHI9I.d.cts → setClientOptions-DbanEIwL.d.ts} +2 -2
- package/package.json +6 -6
- package/dist/api/getAssets.cjs +0 -15
- package/dist/api/getAssetsBetweenChains.cjs +0 -11
- package/dist/api/getBridges.cjs +0 -11
- package/dist/api/getChains.cjs +0 -11
- package/dist/api/getVenues.cjs +0 -11
- package/dist/api/postAssetsFromSource.cjs +0 -12
- package/dist/api/postBalances.cjs +0 -11
- package/dist/api/postIbcOriginAssets.cjs +0 -11
- package/dist/api/postMessages.cjs +0 -11
- package/dist/api/postMessagesDirect.cjs +0 -11
- package/dist/api/postRecommendAssets.cjs +0 -11
- package/dist/api/postRoute.cjs +0 -11
- package/dist/api/postSubmitTransaction.cjs +0 -11
- package/dist/api/postTrackTransaction.cjs +0 -11
- package/dist/api/postTransactionStatus.cjs +0 -11
- package/dist/chunk-32MRDO7V.cjs +0 -12
- package/dist/chunk-4RVEOKQU.cjs +0 -24
- package/dist/chunk-DAMZSSOH.cjs +0 -12
- package/dist/chunk-ISHM4QWP.cjs +0 -16
- package/dist/chunk-KDN7RCGP.cjs +0 -13
- package/dist/chunk-L5V5PASH.cjs +0 -12
- package/dist/chunk-LXYLWTNZ.cjs +0 -12
- package/dist/chunk-URLFWBSC.cjs +0 -11
- package/dist/index.cjs +0 -209
- package/dist/public-functions/executeRoute.cjs +0 -21
- package/dist/public-functions/getFeeInfoForChain.cjs +0 -14
- package/dist/public-functions/getRecommendedGasPrice.cjs +0 -16
- package/dist/public-functions/getSigningStargateClient.cjs +0 -13
- package/dist/public-functions/setApiOptions.cjs +0 -11
- package/dist/public-functions/setClientOptions.cjs +0 -13
- package/dist/public-functions/setClientOptions.d.cts +0 -9
- /package/dist/{apiState-CdzxTxYd.d.cts → apiState-CdzxTxYd.d.ts} +0 -0
- /package/dist/public-functions/{getSigningStargateClient.d.cts → getSigningStargateClient.d.ts} +0 -0
- /package/dist/{swaggerTypes-O9-gvCT1.d.cts → swaggerTypes-O9-gvCT1.d.ts} +0 -0
|
@@ -1,51 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var signing_js = require('cosmjs-types/cosmos/tx/signing/v1beta1/signing.js');
|
|
31
|
-
var viem = require('viem');
|
|
32
|
-
|
|
33
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
34
|
-
|
|
35
|
-
var _m0__default = /*#__PURE__*/_interopDefault(_m0);
|
|
1
|
+
import { BigNumber } from './chunk-VQ5SIQWU.js';
|
|
2
|
+
import { GAS_STATION_CHAIN_IDS } from './chunk-SWYON2RG.js';
|
|
3
|
+
import { getSigningStargateClient, getRpcEndpointForChain, accountParser } from './chunk-SONZJVQM.js';
|
|
4
|
+
import { chains, findFirstWorkingEndpoint, getIsEthermint, getIsInitia } from './chunk-JTIHU43D.js';
|
|
5
|
+
import { MsgDepositForBurn, MsgDepositForBurnWithCaller, MsgExecute, MsgInitiateTokenDeposit, BaseVestingAccount, Timestamp, toTimestamp, Period, fromTimestamp, isSet, fromJsonTimestamp } from './chunk-TD63P2AG.js';
|
|
6
|
+
import { messages } from './chunk-DW4U6YI6.js';
|
|
7
|
+
import { submitTransaction } from './chunk-RDRDFJQE.js';
|
|
8
|
+
import { trackTransaction } from './chunk-MGVXJ2U4.js';
|
|
9
|
+
import { transactionStatus } from './chunk-33K6EESX.js';
|
|
10
|
+
import { ClientState, balances } from './chunk-BRMONS6A.js';
|
|
11
|
+
import { ApiState, wait, createRequestClient, toCamel } from './chunk-W6TBGBV3.js';
|
|
12
|
+
import { PublicKey, Transaction, Connection, LAMPORTS_PER_SOL } from '@solana/web3.js';
|
|
13
|
+
import { bech32m, bech32 } from 'bech32';
|
|
14
|
+
import { StargateClient, GasPrice, calculateFee } from '@cosmjs/stargate';
|
|
15
|
+
import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx.js';
|
|
16
|
+
import { isOfflineDirectSigner, makeAuthInfoBytes, makeSignDoc, encodePubkey } from '@cosmjs/proto-signing';
|
|
17
|
+
import { fromBase64, toUtf8, toBase64 } from '@cosmjs/encoding';
|
|
18
|
+
import { ChainRestTendermintApi, MsgTransfer as MsgTransfer$1, MsgExecuteContractCompat, createTransactionWithSigners } from '@injectivelabs/sdk-ts';
|
|
19
|
+
import { MsgSend } from 'cosmjs-types/cosmos/bank/v1beta1/tx.js';
|
|
20
|
+
import { MsgExecuteContract } from 'cosmjs-types/cosmwasm/wasm/v1/tx.js';
|
|
21
|
+
import { MsgTransfer } from 'cosmjs-types/ibc/applications/transfer/v1/tx.js';
|
|
22
|
+
import _m0 from 'protobufjs/minimal.js';
|
|
23
|
+
import { BigNumberInBase, DEFAULT_BLOCK_TIMEOUT_HEIGHT, DEFAULT_STD_FEE } from '@injectivelabs/utils';
|
|
24
|
+
import { pubkeyType as pubkeyType$1, makeSignDoc as makeSignDoc$1, encodeSecp256k1Pubkey } from '@cosmjs/amino';
|
|
25
|
+
import { PubKey } from 'cosmjs-types/cosmos/crypto/secp256k1/keys.js';
|
|
26
|
+
import { Any } from 'cosmjs-types/google/protobuf/any.js';
|
|
27
|
+
import { Int53, Decimal } from '@cosmjs/math';
|
|
28
|
+
import { SignMode } from 'cosmjs-types/cosmos/tx/signing/v1beta1/signing.js';
|
|
29
|
+
import { isAddress, publicActions, maxUint256, formatUnits } from 'viem';
|
|
36
30
|
|
|
37
31
|
// src/private-functions/getRestEndpointForChain.ts
|
|
38
32
|
var getRestEndpointForChain = async (chainId) => {
|
|
39
|
-
if (
|
|
40
|
-
return
|
|
33
|
+
if (ClientState.endpointOptions.getRestEndpointForChain) {
|
|
34
|
+
return ClientState.endpointOptions.getRestEndpointForChain(chainId);
|
|
41
35
|
}
|
|
42
|
-
if (
|
|
43
|
-
const endpointOptions =
|
|
36
|
+
if (ClientState.endpointOptions.endpoints && ClientState.endpointOptions.endpoints[chainId]) {
|
|
37
|
+
const endpointOptions = ClientState.endpointOptions.endpoints[chainId];
|
|
44
38
|
if (endpointOptions?.rest) {
|
|
45
39
|
return endpointOptions.rest;
|
|
46
40
|
}
|
|
47
41
|
}
|
|
48
|
-
const chain =
|
|
42
|
+
const chain = chains().find((chain2) => chain2.chain_id === chainId);
|
|
49
43
|
if (!chain) {
|
|
50
44
|
throw new Error(
|
|
51
45
|
`getRestEndpointForChain error: failed to find chain id '${chainId}' in registry`
|
|
@@ -57,7 +51,7 @@ var getRestEndpointForChain = async (chainId) => {
|
|
|
57
51
|
);
|
|
58
52
|
}
|
|
59
53
|
const endpoints = chain.apis?.rest?.map((api) => api.address);
|
|
60
|
-
const endpoint = await
|
|
54
|
+
const endpoint = await findFirstWorkingEndpoint(endpoints, "rest");
|
|
61
55
|
if (!endpoint) {
|
|
62
56
|
throw new Error(
|
|
63
57
|
`getRestEndpointForChain error: failed to find REST endpoint for chain '${chainId}'`
|
|
@@ -71,9 +65,9 @@ var getAccountNumberAndSequence = async (address, chainId) => {
|
|
|
71
65
|
if (chainId.includes("dymension")) {
|
|
72
66
|
return getAccountNumberAndSequenceFromDymension(address, chainId);
|
|
73
67
|
}
|
|
74
|
-
const endpoint = await
|
|
75
|
-
const client =
|
|
76
|
-
accountParser
|
|
68
|
+
const endpoint = await getRpcEndpointForChain(chainId);
|
|
69
|
+
const client = ClientState.signingStargateClientByChainId[chainId] ?? await StargateClient.connect(endpoint, {
|
|
70
|
+
accountParser
|
|
77
71
|
});
|
|
78
72
|
const account = await client.getAccount(address);
|
|
79
73
|
if (!account) {
|
|
@@ -87,10 +81,10 @@ var getAccountNumberAndSequence = async (address, chainId) => {
|
|
|
87
81
|
};
|
|
88
82
|
var getAccountNumberAndSequenceFromDymension = async (address, chainId) => {
|
|
89
83
|
const endpoint = await getRestEndpointForChain(chainId);
|
|
90
|
-
const jsonResponse = await
|
|
84
|
+
const jsonResponse = await createRequestClient({
|
|
91
85
|
baseUrl: `${endpoint}/cosmos/auth/v1beta1/accounts/${address}`
|
|
92
86
|
}).get();
|
|
93
|
-
const response =
|
|
87
|
+
const response = toCamel(jsonResponse);
|
|
94
88
|
let sequence = 0;
|
|
95
89
|
let accountNumber = 0;
|
|
96
90
|
if (response.account.baseAccount) {
|
|
@@ -116,45 +110,45 @@ function createBaseClawbackVestingAccount() {
|
|
|
116
110
|
}
|
|
117
111
|
var ClawbackVestingAccount = {
|
|
118
112
|
typeUrl: "/evmos.vesting.v2.ClawbackVestingAccount",
|
|
119
|
-
encode(message, writer =
|
|
113
|
+
encode(message, writer = _m0.Writer.create()) {
|
|
120
114
|
if (message.baseVestingAccount !== void 0) {
|
|
121
|
-
|
|
115
|
+
BaseVestingAccount.encode(message.baseVestingAccount, writer.uint32(10).fork()).ldelim();
|
|
122
116
|
}
|
|
123
117
|
if (message.funderAddress !== "") {
|
|
124
118
|
writer.uint32(18).string(message.funderAddress);
|
|
125
119
|
}
|
|
126
120
|
if (message.startTime !== void 0) {
|
|
127
|
-
|
|
121
|
+
Timestamp.encode(toTimestamp(message.startTime), writer.uint32(26).fork()).ldelim();
|
|
128
122
|
}
|
|
129
123
|
for (const v of message.lockupPeriods) {
|
|
130
|
-
|
|
124
|
+
Period.encode(v, writer.uint32(34).fork()).ldelim();
|
|
131
125
|
}
|
|
132
126
|
for (const v of message.vestingPeriods) {
|
|
133
|
-
|
|
127
|
+
Period.encode(v, writer.uint32(42).fork()).ldelim();
|
|
134
128
|
}
|
|
135
129
|
return writer;
|
|
136
130
|
},
|
|
137
131
|
decode(input, length) {
|
|
138
|
-
const reader = input instanceof
|
|
132
|
+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
139
133
|
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
140
134
|
const message = createBaseClawbackVestingAccount();
|
|
141
135
|
while (reader.pos < end) {
|
|
142
136
|
const tag = reader.uint32();
|
|
143
137
|
switch (tag >>> 3) {
|
|
144
138
|
case 1:
|
|
145
|
-
message.baseVestingAccount =
|
|
139
|
+
message.baseVestingAccount = BaseVestingAccount.decode(reader, reader.uint32());
|
|
146
140
|
break;
|
|
147
141
|
case 2:
|
|
148
142
|
message.funderAddress = reader.string();
|
|
149
143
|
break;
|
|
150
144
|
case 3:
|
|
151
|
-
message.startTime =
|
|
145
|
+
message.startTime = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
|
|
152
146
|
break;
|
|
153
147
|
case 4:
|
|
154
|
-
message.lockupPeriods.push(
|
|
148
|
+
message.lockupPeriods.push(Period.decode(reader, reader.uint32()));
|
|
155
149
|
break;
|
|
156
150
|
case 5:
|
|
157
|
-
message.vestingPeriods.push(
|
|
151
|
+
message.vestingPeriods.push(Period.decode(reader, reader.uint32()));
|
|
158
152
|
break;
|
|
159
153
|
default:
|
|
160
154
|
reader.skipType(tag & 7);
|
|
@@ -165,25 +159,25 @@ var ClawbackVestingAccount = {
|
|
|
165
159
|
},
|
|
166
160
|
fromJSON(object) {
|
|
167
161
|
return {
|
|
168
|
-
baseVestingAccount:
|
|
169
|
-
funderAddress:
|
|
170
|
-
startTime:
|
|
171
|
-
lockupPeriods: Array.isArray(object?.lockupPeriods) ? object.lockupPeriods.map((e) =>
|
|
172
|
-
vestingPeriods: Array.isArray(object?.vestingPeriods) ? object.vestingPeriods.map((e) =>
|
|
162
|
+
baseVestingAccount: isSet(object.baseVestingAccount) ? BaseVestingAccount.fromJSON(object.baseVestingAccount) : void 0,
|
|
163
|
+
funderAddress: isSet(object.funderAddress) ? String(object.funderAddress) : "",
|
|
164
|
+
startTime: isSet(object.startTime) ? fromJsonTimestamp(object.startTime) : void 0,
|
|
165
|
+
lockupPeriods: Array.isArray(object?.lockupPeriods) ? object.lockupPeriods.map((e) => Period.fromJSON(e)) : [],
|
|
166
|
+
vestingPeriods: Array.isArray(object?.vestingPeriods) ? object.vestingPeriods.map((e) => Period.fromJSON(e)) : []
|
|
173
167
|
};
|
|
174
168
|
},
|
|
175
169
|
toJSON(message) {
|
|
176
170
|
const obj = {};
|
|
177
|
-
message.baseVestingAccount !== void 0 && (obj.baseVestingAccount = message.baseVestingAccount ?
|
|
171
|
+
message.baseVestingAccount !== void 0 && (obj.baseVestingAccount = message.baseVestingAccount ? BaseVestingAccount.toJSON(message.baseVestingAccount) : void 0);
|
|
178
172
|
message.funderAddress !== void 0 && (obj.funderAddress = message.funderAddress);
|
|
179
173
|
message.startTime !== void 0 && (obj.startTime = message.startTime.toISOString());
|
|
180
174
|
if (message.lockupPeriods) {
|
|
181
|
-
obj.lockupPeriods = message.lockupPeriods.map((e) => e ?
|
|
175
|
+
obj.lockupPeriods = message.lockupPeriods.map((e) => e ? Period.toJSON(e) : void 0);
|
|
182
176
|
} else {
|
|
183
177
|
obj.lockupPeriods = [];
|
|
184
178
|
}
|
|
185
179
|
if (message.vestingPeriods) {
|
|
186
|
-
obj.vestingPeriods = message.vestingPeriods.map((e) => e ?
|
|
180
|
+
obj.vestingPeriods = message.vestingPeriods.map((e) => e ? Period.toJSON(e) : void 0);
|
|
187
181
|
} else {
|
|
188
182
|
obj.vestingPeriods = [];
|
|
189
183
|
}
|
|
@@ -191,40 +185,40 @@ var ClawbackVestingAccount = {
|
|
|
191
185
|
},
|
|
192
186
|
fromPartial(object) {
|
|
193
187
|
const message = createBaseClawbackVestingAccount();
|
|
194
|
-
message.baseVestingAccount = object.baseVestingAccount !== void 0 && object.baseVestingAccount !== null ?
|
|
188
|
+
message.baseVestingAccount = object.baseVestingAccount !== void 0 && object.baseVestingAccount !== null ? BaseVestingAccount.fromPartial(object.baseVestingAccount) : void 0;
|
|
195
189
|
message.funderAddress = object.funderAddress ?? "";
|
|
196
190
|
message.startTime = object.startTime ?? void 0;
|
|
197
|
-
message.lockupPeriods = object.lockupPeriods?.map((e) =>
|
|
198
|
-
message.vestingPeriods = object.vestingPeriods?.map((e) =>
|
|
191
|
+
message.lockupPeriods = object.lockupPeriods?.map((e) => Period.fromPartial(e)) || [];
|
|
192
|
+
message.vestingPeriods = object.vestingPeriods?.map((e) => Period.fromPartial(e)) || [];
|
|
199
193
|
return message;
|
|
200
194
|
},
|
|
201
195
|
fromAmino(object) {
|
|
202
196
|
const message = createBaseClawbackVestingAccount();
|
|
203
197
|
if (object.base_vesting_account !== void 0 && object.base_vesting_account !== null) {
|
|
204
|
-
message.baseVestingAccount =
|
|
198
|
+
message.baseVestingAccount = BaseVestingAccount.fromAmino(object.base_vesting_account);
|
|
205
199
|
}
|
|
206
200
|
if (object.funder_address !== void 0 && object.funder_address !== null) {
|
|
207
201
|
message.funderAddress = object.funder_address;
|
|
208
202
|
}
|
|
209
203
|
if (object.start_time !== void 0 && object.start_time !== null) {
|
|
210
|
-
message.startTime =
|
|
204
|
+
message.startTime = fromTimestamp(Timestamp.fromAmino(object.start_time));
|
|
211
205
|
}
|
|
212
|
-
message.lockupPeriods = object.lockup_periods?.map((e) =>
|
|
213
|
-
message.vestingPeriods = object.vesting_periods?.map((e) =>
|
|
206
|
+
message.lockupPeriods = object.lockup_periods?.map((e) => Period.fromAmino(e)) || [];
|
|
207
|
+
message.vestingPeriods = object.vesting_periods?.map((e) => Period.fromAmino(e)) || [];
|
|
214
208
|
return message;
|
|
215
209
|
},
|
|
216
210
|
toAmino(message) {
|
|
217
211
|
const obj = {};
|
|
218
|
-
obj.base_vesting_account = message.baseVestingAccount ?
|
|
212
|
+
obj.base_vesting_account = message.baseVestingAccount ? BaseVestingAccount.toAmino(message.baseVestingAccount) : void 0;
|
|
219
213
|
obj.funder_address = message.funderAddress === "" ? void 0 : message.funderAddress;
|
|
220
|
-
obj.start_time = message.startTime ?
|
|
214
|
+
obj.start_time = message.startTime ? Timestamp.toAmino(toTimestamp(message.startTime)) : void 0;
|
|
221
215
|
if (message.lockupPeriods) {
|
|
222
|
-
obj.lockup_periods = message.lockupPeriods.map((e) => e ?
|
|
216
|
+
obj.lockup_periods = message.lockupPeriods.map((e) => e ? Period.toAmino(e) : void 0);
|
|
223
217
|
} else {
|
|
224
218
|
obj.lockup_periods = message.lockupPeriods;
|
|
225
219
|
}
|
|
226
220
|
if (message.vestingPeriods) {
|
|
227
|
-
obj.vesting_periods = message.vestingPeriods.map((e) => e ?
|
|
221
|
+
obj.vesting_periods = message.vestingPeriods.map((e) => e ? Period.toAmino(e) : void 0);
|
|
228
222
|
} else {
|
|
229
223
|
obj.vesting_periods = message.vestingPeriods;
|
|
230
224
|
}
|
|
@@ -259,7 +253,7 @@ function getEncodeObjectFromCosmosMessage(message) {
|
|
|
259
253
|
if (message.msgTypeUrl === "/ibc.applications.transfer.v1.MsgTransfer") {
|
|
260
254
|
return {
|
|
261
255
|
typeUrl: "/ibc.applications.transfer.v1.MsgTransfer",
|
|
262
|
-
value:
|
|
256
|
+
value: MsgTransfer.fromJSON({
|
|
263
257
|
sourcePort: msgJson.source_port,
|
|
264
258
|
sourceChannel: msgJson.source_channel,
|
|
265
259
|
token: msgJson.token,
|
|
@@ -274,10 +268,10 @@ function getEncodeObjectFromCosmosMessage(message) {
|
|
|
274
268
|
if (message.msgTypeUrl === "/cosmwasm.wasm.v1.MsgExecuteContract") {
|
|
275
269
|
return {
|
|
276
270
|
typeUrl: message.msgTypeUrl,
|
|
277
|
-
value:
|
|
271
|
+
value: MsgExecuteContract.fromPartial({
|
|
278
272
|
sender: msgJson.sender,
|
|
279
273
|
contract: msgJson.contract,
|
|
280
|
-
msg:
|
|
274
|
+
msg: toUtf8(JSON.stringify(msgJson.msg)),
|
|
281
275
|
funds: msgJson.funds
|
|
282
276
|
})
|
|
283
277
|
};
|
|
@@ -285,7 +279,7 @@ function getEncodeObjectFromCosmosMessage(message) {
|
|
|
285
279
|
if (message.msgTypeUrl === "/cosmos.bank.v1beta1.MsgSend") {
|
|
286
280
|
return {
|
|
287
281
|
typeUrl: message.msgTypeUrl,
|
|
288
|
-
value:
|
|
282
|
+
value: MsgSend.fromPartial({
|
|
289
283
|
fromAddress: msgJson.from_address,
|
|
290
284
|
toAddress: msgJson.to_address,
|
|
291
285
|
amount: msgJson.amount
|
|
@@ -295,19 +289,19 @@ function getEncodeObjectFromCosmosMessage(message) {
|
|
|
295
289
|
if (message.msgTypeUrl === "/circle.cctp.v1.MsgDepositForBurn") {
|
|
296
290
|
return {
|
|
297
291
|
typeUrl: message.msgTypeUrl,
|
|
298
|
-
value:
|
|
292
|
+
value: MsgDepositForBurn.fromAmino(msgJson)
|
|
299
293
|
};
|
|
300
294
|
}
|
|
301
295
|
if (message.msgTypeUrl === "/circle.cctp.v1.MsgDepositForBurnWithCaller") {
|
|
302
296
|
return {
|
|
303
297
|
typeUrl: message.msgTypeUrl,
|
|
304
|
-
value:
|
|
298
|
+
value: MsgDepositForBurnWithCaller.fromAmino(msgJson)
|
|
305
299
|
};
|
|
306
300
|
}
|
|
307
301
|
if (message.msgTypeUrl === "/initia.move.v1.MsgExecute") {
|
|
308
302
|
return {
|
|
309
303
|
typeUrl: message.msgTypeUrl,
|
|
310
|
-
value:
|
|
304
|
+
value: MsgExecute.fromPartial({
|
|
311
305
|
sender: msgJson.sender,
|
|
312
306
|
moduleAddress: msgJson.module_address,
|
|
313
307
|
moduleName: msgJson.module_name,
|
|
@@ -319,7 +313,7 @@ function getEncodeObjectFromCosmosMessage(message) {
|
|
|
319
313
|
if (message.msgTypeUrl === "/opinit.ophost.v1.MsgInitiateTokenDeposit") {
|
|
320
314
|
return {
|
|
321
315
|
typeUrl: message.msgTypeUrl,
|
|
322
|
-
value:
|
|
316
|
+
value: MsgInitiateTokenDeposit.fromPartial({
|
|
323
317
|
sender: msgJson.sender,
|
|
324
318
|
to: msgJson.to,
|
|
325
319
|
amount: msgJson.amount,
|
|
@@ -347,7 +341,7 @@ function getEncodeObjectFromCosmosMessage(message) {
|
|
|
347
341
|
function getEncodeObjectFromCosmosMessageInjective(message) {
|
|
348
342
|
const msgJson = JSON.parse(message.msg ?? "");
|
|
349
343
|
if (message.msgTypeUrl === "/ibc.applications.transfer.v1.MsgTransfer") {
|
|
350
|
-
return
|
|
344
|
+
return MsgTransfer$1.fromJSON({
|
|
351
345
|
port: msgJson.source_port,
|
|
352
346
|
channelId: msgJson.source_channel,
|
|
353
347
|
amount: msgJson.token,
|
|
@@ -358,7 +352,7 @@ function getEncodeObjectFromCosmosMessageInjective(message) {
|
|
|
358
352
|
});
|
|
359
353
|
}
|
|
360
354
|
if (message.msgTypeUrl === "/cosmwasm.wasm.v1.MsgExecuteContract") {
|
|
361
|
-
return
|
|
355
|
+
return MsgExecuteContractCompat.fromJSON({
|
|
362
356
|
sender: msgJson.sender,
|
|
363
357
|
contractAddress: msgJson.contract,
|
|
364
358
|
msg: msgJson.msg,
|
|
@@ -372,7 +366,7 @@ function createTransaction({
|
|
|
372
366
|
message,
|
|
373
367
|
timeoutHeight,
|
|
374
368
|
memo = "",
|
|
375
|
-
fee =
|
|
369
|
+
fee = DEFAULT_STD_FEE,
|
|
376
370
|
signMode = 1,
|
|
377
371
|
pubKey,
|
|
378
372
|
accountNumber,
|
|
@@ -383,7 +377,7 @@ function createTransaction({
|
|
|
383
377
|
accountNumber,
|
|
384
378
|
sequence
|
|
385
379
|
};
|
|
386
|
-
return
|
|
380
|
+
return createTransactionWithSigners({
|
|
387
381
|
fee,
|
|
388
382
|
memo,
|
|
389
383
|
message,
|
|
@@ -415,10 +409,10 @@ var signCosmosMessageDirectEvmos = async (signerAddress, signer, cosmosMsgs, fee
|
|
|
415
409
|
fee
|
|
416
410
|
});
|
|
417
411
|
const directSignResponse = await signer.signDirect(signerAddress, signDoc);
|
|
418
|
-
return
|
|
412
|
+
return TxRaw.fromPartial({
|
|
419
413
|
bodyBytes: directSignResponse.signed.bodyBytes,
|
|
420
414
|
authInfoBytes: directSignResponse.signed.authInfoBytes,
|
|
421
|
-
signatures: [
|
|
415
|
+
signatures: [fromBase64(directSignResponse.signature.signature)]
|
|
422
416
|
});
|
|
423
417
|
};
|
|
424
418
|
var signCosmosMessageDirectInjective = async (signerAddress, signer, cosmosMsgs, fee, { accountNumber, sequence, chainId }) => {
|
|
@@ -428,10 +422,10 @@ var signCosmosMessageDirectInjective = async (signerAddress, signer, cosmosMsgs,
|
|
|
428
422
|
throw new Error("signCosmosMessageDirectInjective: failed to retrieve account from signer");
|
|
429
423
|
}
|
|
430
424
|
const restEndpoint = await getRestEndpointForChain(chainId);
|
|
431
|
-
const chainRestTendermintApi = new
|
|
425
|
+
const chainRestTendermintApi = new ChainRestTendermintApi(restEndpoint);
|
|
432
426
|
const latestBlock = await chainRestTendermintApi.fetchLatestBlock();
|
|
433
427
|
const latestHeight = latestBlock.header.height;
|
|
434
|
-
const timeoutHeight = new
|
|
428
|
+
const timeoutHeight = new BigNumberInBase(latestHeight).plus(DEFAULT_BLOCK_TIMEOUT_HEIGHT);
|
|
435
429
|
const pk = Buffer.from(accountFromSigner.pubkey).toString("base64");
|
|
436
430
|
const messages2 = cosmosMsgs.map(
|
|
437
431
|
(cosmosMsg) => getEncodeObjectFromCosmosMessageInjective(cosmosMsg)
|
|
@@ -450,15 +444,15 @@ var signCosmosMessageDirectInjective = async (signerAddress, signer, cosmosMsgs,
|
|
|
450
444
|
// @ts-expect-error TODO: Fix this
|
|
451
445
|
signDoc
|
|
452
446
|
);
|
|
453
|
-
return
|
|
447
|
+
return TxRaw.fromPartial({
|
|
454
448
|
bodyBytes: directSignResponse.signed.bodyBytes,
|
|
455
449
|
authInfoBytes: directSignResponse.signed.authInfoBytes,
|
|
456
|
-
signatures: [
|
|
450
|
+
signatures: [fromBase64(directSignResponse.signature.signature)]
|
|
457
451
|
});
|
|
458
452
|
};
|
|
459
453
|
var pubkeyType = {
|
|
460
454
|
ethsecp256k1: "ethermint/PubKeyEthSecp256k1",
|
|
461
|
-
...
|
|
455
|
+
...pubkeyType$1
|
|
462
456
|
};
|
|
463
457
|
|
|
464
458
|
// src/amino/encoding.ts
|
|
@@ -470,21 +464,21 @@ function encodeEthSecp256k1Pubkey(pubkey) {
|
|
|
470
464
|
}
|
|
471
465
|
return {
|
|
472
466
|
type: pubkeyType.ethsecp256k1,
|
|
473
|
-
value:
|
|
467
|
+
value: toBase64(pubkey)
|
|
474
468
|
};
|
|
475
469
|
}
|
|
476
470
|
|
|
477
471
|
// src/proto-signing/pubkey.ts
|
|
478
472
|
function makePubkeyAnyFromAccount(account, chainId) {
|
|
479
|
-
const isEthermint =
|
|
480
|
-
const pubkey = isEthermint ? encodeEthSecp256k1Pubkey(account.pubkey) :
|
|
473
|
+
const isEthermint = getIsEthermint(chainId);
|
|
474
|
+
const pubkey = isEthermint ? encodeEthSecp256k1Pubkey(account.pubkey) : encodeSecp256k1Pubkey(account.pubkey);
|
|
481
475
|
const pubkeyAny = encodePubkeyToAny(pubkey, chainId, isEthermint);
|
|
482
476
|
return pubkeyAny;
|
|
483
477
|
}
|
|
484
478
|
function encodePubkeyToAny(pubkey, chainId, isEthermint) {
|
|
485
479
|
if (isEthermint) {
|
|
486
|
-
const pubkeyProto =
|
|
487
|
-
key:
|
|
480
|
+
const pubkeyProto = PubKey.fromPartial({
|
|
481
|
+
key: fromBase64(pubkey.value)
|
|
488
482
|
});
|
|
489
483
|
let typeUrl = "";
|
|
490
484
|
if (chainId?.includes("injective")) {
|
|
@@ -492,22 +486,22 @@ function encodePubkeyToAny(pubkey, chainId, isEthermint) {
|
|
|
492
486
|
} else {
|
|
493
487
|
typeUrl = "/ethermint.crypto.v1.ethsecp256k1.PubKey";
|
|
494
488
|
}
|
|
495
|
-
return
|
|
489
|
+
return Any.fromPartial({
|
|
496
490
|
typeUrl,
|
|
497
|
-
value: Uint8Array.from(
|
|
491
|
+
value: Uint8Array.from(PubKey.encode(pubkeyProto).finish())
|
|
498
492
|
});
|
|
499
493
|
} else {
|
|
500
|
-
const isInitia =
|
|
501
|
-
const pubkeyProto =
|
|
502
|
-
key:
|
|
494
|
+
const isInitia = getIsInitia(chainId);
|
|
495
|
+
const pubkeyProto = PubKey.fromPartial({
|
|
496
|
+
key: fromBase64(pubkey.value)
|
|
503
497
|
});
|
|
504
498
|
if (isInitia) {
|
|
505
|
-
return
|
|
499
|
+
return Any.fromPartial({
|
|
506
500
|
typeUrl: "/initia.crypto.v1beta1.ethsecp256k1.PubKey",
|
|
507
|
-
value: Uint8Array.from(
|
|
501
|
+
value: Uint8Array.from(PubKey.encode(pubkeyProto).finish())
|
|
508
502
|
});
|
|
509
503
|
}
|
|
510
|
-
return
|
|
504
|
+
return encodePubkey(pubkey);
|
|
511
505
|
}
|
|
512
506
|
}
|
|
513
507
|
var signCosmosMessageDirect = async (options) => {
|
|
@@ -545,22 +539,22 @@ var signCosmosMessageDirect = async (options) => {
|
|
|
545
539
|
messages: messages2
|
|
546
540
|
}
|
|
547
541
|
};
|
|
548
|
-
const txBodyBytes =
|
|
549
|
-
const gasLimit =
|
|
542
|
+
const txBodyBytes = ClientState.registry.encode(txBodyEncodeObject);
|
|
543
|
+
const gasLimit = Int53.fromString(fee.gas).toNumber();
|
|
550
544
|
const pubkeyAny = makePubkeyAnyFromAccount(accountFromSigner, chainId);
|
|
551
|
-
const authInfoBytes =
|
|
545
|
+
const authInfoBytes = makeAuthInfoBytes(
|
|
552
546
|
[{ pubkey: pubkeyAny, sequence }],
|
|
553
547
|
fee.amount,
|
|
554
548
|
gasLimit,
|
|
555
549
|
fee.granter,
|
|
556
550
|
fee.payer
|
|
557
551
|
);
|
|
558
|
-
const signDoc =
|
|
552
|
+
const signDoc = makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber);
|
|
559
553
|
const { signature, signed } = await signer.signDirect(signerAddress, signDoc);
|
|
560
|
-
return
|
|
554
|
+
return TxRaw.fromPartial({
|
|
561
555
|
bodyBytes: signed.bodyBytes,
|
|
562
556
|
authInfoBytes: signed.authInfoBytes,
|
|
563
|
-
signatures: [
|
|
557
|
+
signatures: [fromBase64(signature.signature)]
|
|
564
558
|
});
|
|
565
559
|
};
|
|
566
560
|
var signCosmosMessageAmino = async (options) => {
|
|
@@ -578,13 +572,13 @@ var signCosmosMessageAmino = async (options) => {
|
|
|
578
572
|
throw new Error("signCosmosMessageAmino: failed to retrieve account from signer");
|
|
579
573
|
}
|
|
580
574
|
const messages2 = cosmosMsgs.map((cosmosMsg) => getEncodeObjectFromCosmosMessage(cosmosMsg));
|
|
581
|
-
const signMode =
|
|
582
|
-
const msgs = messages2.map((msg) =>
|
|
575
|
+
const signMode = SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
|
|
576
|
+
const msgs = messages2.map((msg) => ClientState.aminoTypes.toAmino(msg));
|
|
583
577
|
console.log("sign cosmos message amino", msgs, fee, signerChainId, "", accountNumber, sequence);
|
|
584
|
-
const signDoc =
|
|
578
|
+
const signDoc = makeSignDoc$1(msgs, fee, signerChainId, "", accountNumber, sequence);
|
|
585
579
|
const { signature, signed } = await signer.signAmino(signerAddress, signDoc);
|
|
586
580
|
const signedTxBody = {
|
|
587
|
-
messages: signed.msgs.map((msg) =>
|
|
581
|
+
messages: signed.msgs.map((msg) => ClientState.aminoTypes.fromAmino(msg)),
|
|
588
582
|
memo: signed.memo
|
|
589
583
|
};
|
|
590
584
|
signedTxBody.messages[0].value.memo = messages2[0].value.memo;
|
|
@@ -592,11 +586,11 @@ var signCosmosMessageAmino = async (options) => {
|
|
|
592
586
|
typeUrl: "/cosmos.tx.v1beta1.TxBody",
|
|
593
587
|
value: signedTxBody
|
|
594
588
|
};
|
|
595
|
-
const signedTxBodyBytes =
|
|
596
|
-
const signedGasLimit =
|
|
597
|
-
const signedSequence =
|
|
589
|
+
const signedTxBodyBytes = ClientState.registry.encode(signedTxBodyEncodeObject);
|
|
590
|
+
const signedGasLimit = Int53.fromString(signed.fee.gas).toNumber();
|
|
591
|
+
const signedSequence = Int53.fromString(signed.sequence).toNumber();
|
|
598
592
|
const pubkeyAny = makePubkeyAnyFromAccount(accountFromSigner, chainId);
|
|
599
|
-
const signedAuthInfoBytes =
|
|
593
|
+
const signedAuthInfoBytes = makeAuthInfoBytes(
|
|
600
594
|
[{ pubkey: pubkeyAny, sequence: signedSequence }],
|
|
601
595
|
signed.fee.amount,
|
|
602
596
|
signedGasLimit,
|
|
@@ -604,10 +598,10 @@ var signCosmosMessageAmino = async (options) => {
|
|
|
604
598
|
signed.fee.payer,
|
|
605
599
|
signMode
|
|
606
600
|
);
|
|
607
|
-
return
|
|
601
|
+
return TxRaw.fromPartial({
|
|
608
602
|
bodyBytes: signedTxBodyBytes,
|
|
609
603
|
authInfoBytes: signedAuthInfoBytes,
|
|
610
|
-
signatures: [
|
|
604
|
+
signatures: [fromBase64(signature.signature)]
|
|
611
605
|
});
|
|
612
606
|
};
|
|
613
607
|
|
|
@@ -624,7 +618,7 @@ var executeCosmosTransaction = async ({
|
|
|
624
618
|
const chainId = tx.cosmosTx?.chainId;
|
|
625
619
|
const messages2 = tx.cosmosTx?.msgs;
|
|
626
620
|
const currentUserAddress = userAddresses.find((x) => x.chainId === tx.cosmosTx?.chainId)?.address;
|
|
627
|
-
const gasArray =
|
|
621
|
+
const gasArray = ClientState.validateGasResults;
|
|
628
622
|
const gas = gasArray?.find((gas2) => gas2?.error !== null && gas2?.error !== void 0);
|
|
629
623
|
if (typeof gas?.error === "string") {
|
|
630
624
|
throw new Error(gas?.error);
|
|
@@ -639,7 +633,7 @@ var executeCosmosTransaction = async ({
|
|
|
639
633
|
if (messages2 === void 0) {
|
|
640
634
|
throw new Error("no messages found for tx");
|
|
641
635
|
}
|
|
642
|
-
const { stargateClient, signer } = await
|
|
636
|
+
const { stargateClient, signer } = await getSigningStargateClient({
|
|
643
637
|
chainId,
|
|
644
638
|
getOfflineSigner: options?.getCosmosSigner
|
|
645
639
|
});
|
|
@@ -673,7 +667,7 @@ var executeCosmosTransaction = async ({
|
|
|
673
667
|
chainId
|
|
674
668
|
}
|
|
675
669
|
};
|
|
676
|
-
if (
|
|
670
|
+
if (isOfflineDirectSigner(signer)) {
|
|
677
671
|
rawTx = await signCosmosMessageDirect({
|
|
678
672
|
...commonRawTxBody,
|
|
679
673
|
signer
|
|
@@ -684,7 +678,7 @@ var executeCosmosTransaction = async ({
|
|
|
684
678
|
options?.onTransactionSigned?.({
|
|
685
679
|
chainId
|
|
686
680
|
});
|
|
687
|
-
const txBytes =
|
|
681
|
+
const txBytes = TxRaw.encode(rawTx).finish();
|
|
688
682
|
const txResponse = await stargateClient.broadcastTx(txBytes);
|
|
689
683
|
return {
|
|
690
684
|
chainId: tx?.cosmosTx?.chainId ?? "",
|
|
@@ -894,13 +888,13 @@ var erc20ABI = /* @__PURE__ */ createAbi([
|
|
|
894
888
|
|
|
895
889
|
// src/private-functions/evm/executeEvmTransaction.ts
|
|
896
890
|
var executeEvmTransaction = async (message, options) => {
|
|
897
|
-
const gasArray =
|
|
891
|
+
const gasArray = ClientState.validateGasResults;
|
|
898
892
|
const gas = gasArray?.find((gas2) => gas2?.error !== null && gas2?.error !== void 0);
|
|
899
893
|
if (typeof gas?.error === "string") {
|
|
900
894
|
throw new Error(gas?.error);
|
|
901
895
|
}
|
|
902
896
|
const { evmTx } = message;
|
|
903
|
-
const getEvmSigner = options.getEvmSigner ||
|
|
897
|
+
const getEvmSigner = options.getEvmSigner || ClientState.getEvmSigner;
|
|
904
898
|
if (!getEvmSigner) {
|
|
905
899
|
throw new Error("Unable to get EVM signer");
|
|
906
900
|
}
|
|
@@ -918,7 +912,7 @@ var executeEvmTransaction = async (message, options) => {
|
|
|
918
912
|
throw new Error("executeEVMTransaction error: no value found in evmTx");
|
|
919
913
|
}
|
|
920
914
|
const { onApproveAllowance, onTransactionSigned, bypassApprovalCheck, useUnlimitedApproval } = options;
|
|
921
|
-
const extendedSigner = evmSigner.extend(
|
|
915
|
+
const extendedSigner = evmSigner.extend(publicActions);
|
|
922
916
|
if (!bypassApprovalCheck && evmTx.requiredErc20Approvals) {
|
|
923
917
|
for (const requiredApproval of evmTx.requiredErc20Approvals) {
|
|
924
918
|
const allowance = await extendedSigner.readContract({
|
|
@@ -947,7 +941,7 @@ var executeEvmTransaction = async (message, options) => {
|
|
|
947
941
|
functionName: "approve",
|
|
948
942
|
args: [
|
|
949
943
|
requiredApproval.spender,
|
|
950
|
-
useUnlimitedApproval ?
|
|
944
|
+
useUnlimitedApproval ? maxUint256 : BigInt(requiredApproval.amount) + BigInt(1e3)
|
|
951
945
|
],
|
|
952
946
|
chain: evmSigner.chain
|
|
953
947
|
});
|
|
@@ -980,7 +974,7 @@ var executeEvmTransaction = async (message, options) => {
|
|
|
980
974
|
return receipt;
|
|
981
975
|
};
|
|
982
976
|
var executeSvmTransaction = async (tx, options) => {
|
|
983
|
-
const gasArray =
|
|
977
|
+
const gasArray = ClientState.validateGasResults;
|
|
984
978
|
if (tx === void 0) {
|
|
985
979
|
throw new Error("executeSvmTransaction error: tx is undefined");
|
|
986
980
|
}
|
|
@@ -989,7 +983,7 @@ var executeSvmTransaction = async (tx, options) => {
|
|
|
989
983
|
throw new Error(gas?.error);
|
|
990
984
|
}
|
|
991
985
|
const svmTx = tx?.svmTx;
|
|
992
|
-
const getSvmSigner = options?.getSvmSigner ||
|
|
986
|
+
const getSvmSigner = options?.getSvmSigner || ClientState.getSvmSigner;
|
|
993
987
|
if (!getSvmSigner) {
|
|
994
988
|
throw new Error(
|
|
995
989
|
"executeRoute error: 'getSVMSigner' is not provided or configured in skip router"
|
|
@@ -1000,15 +994,15 @@ var executeSvmTransaction = async (tx, options) => {
|
|
|
1000
994
|
throw new Error("executeSvmTransaction error: chainId not found in svmTx");
|
|
1001
995
|
}
|
|
1002
996
|
const txBuffer = Buffer.from(svmTx.tx ?? "", "base64");
|
|
1003
|
-
const transaction =
|
|
1004
|
-
const endpoint = await
|
|
1005
|
-
const connection = new
|
|
997
|
+
const transaction = Transaction.from(txBuffer);
|
|
998
|
+
const endpoint = await getRpcEndpointForChain(svmTx.chainId);
|
|
999
|
+
const connection = new Connection(endpoint);
|
|
1006
1000
|
let signature;
|
|
1007
1001
|
if ("signTransaction" in signer) {
|
|
1008
1002
|
const signedTx = await signer.signTransaction(transaction);
|
|
1009
1003
|
options?.onTransactionSigned?.({ chainId: svmTx.chainId });
|
|
1010
1004
|
const serializedTx = signedTx.serialize();
|
|
1011
|
-
await
|
|
1005
|
+
await submitTransaction({
|
|
1012
1006
|
chainId: svmTx.chainId,
|
|
1013
1007
|
tx: serializedTx.toString("base64")
|
|
1014
1008
|
}).then((res) => {
|
|
@@ -1037,13 +1031,13 @@ var executeSvmTransaction = async (tx, options) => {
|
|
|
1037
1031
|
};
|
|
1038
1032
|
}
|
|
1039
1033
|
if (getStatusCount > 12) {
|
|
1040
|
-
await
|
|
1034
|
+
await wait(3e3);
|
|
1041
1035
|
throw new Error(
|
|
1042
1036
|
`executeSvmTransaction error: waiting finalized status timed out for ${signature}`
|
|
1043
1037
|
);
|
|
1044
1038
|
}
|
|
1045
1039
|
getStatusCount++;
|
|
1046
|
-
await
|
|
1040
|
+
await wait(3e3);
|
|
1047
1041
|
} catch (error) {
|
|
1048
1042
|
errorCount++;
|
|
1049
1043
|
if (errorCount > 12) {
|
|
@@ -1083,8 +1077,8 @@ var validateCosmosGasBalance = async ({
|
|
|
1083
1077
|
txIndex,
|
|
1084
1078
|
simulate
|
|
1085
1079
|
}) => {
|
|
1086
|
-
const skipAssets = (await
|
|
1087
|
-
const skipChains = await
|
|
1080
|
+
const skipAssets = (await ClientState.getSkipAssets({ chainId }))?.[chainId];
|
|
1081
|
+
const skipChains = await ClientState.getSkipChains();
|
|
1088
1082
|
const chain = skipChains?.find((c) => c.chainId === chainId);
|
|
1089
1083
|
if (!chain) {
|
|
1090
1084
|
throw new Error(`failed to find chain id for '${chainId}'`);
|
|
@@ -1099,7 +1093,7 @@ var validateCosmosGasBalance = async ({
|
|
|
1099
1093
|
if (txIndex !== 0 && chainId === "noble-1") {
|
|
1100
1094
|
return "0";
|
|
1101
1095
|
}
|
|
1102
|
-
const { stargateClient } = await
|
|
1096
|
+
const { stargateClient } = await getSigningStargateClient({
|
|
1103
1097
|
chainId,
|
|
1104
1098
|
getOfflineSigner
|
|
1105
1099
|
});
|
|
@@ -1136,8 +1130,8 @@ var validateCosmosGasBalance = async ({
|
|
|
1136
1130
|
price = asset.gasPrice.low;
|
|
1137
1131
|
}
|
|
1138
1132
|
if (!price) return;
|
|
1139
|
-
return new
|
|
1140
|
-
|
|
1133
|
+
return new GasPrice(
|
|
1134
|
+
Decimal.fromUserInput(BigNumber(price).toFixed(), 18),
|
|
1141
1135
|
asset?.denom ?? ""
|
|
1142
1136
|
);
|
|
1143
1137
|
})();
|
|
@@ -1145,12 +1139,12 @@ var validateCosmosGasBalance = async ({
|
|
|
1145
1139
|
return null;
|
|
1146
1140
|
}
|
|
1147
1141
|
if (chainId === "noble-1") {
|
|
1148
|
-
const fee =
|
|
1142
|
+
const fee = calculateFee(2e5, gasPrice);
|
|
1149
1143
|
return fee;
|
|
1150
1144
|
}
|
|
1151
|
-
return
|
|
1145
|
+
return calculateFee(Math.ceil(parseFloat(estimatedGasAmount)), gasPrice);
|
|
1152
1146
|
});
|
|
1153
|
-
const feeBalance = await
|
|
1147
|
+
const feeBalance = await balances({
|
|
1154
1148
|
chains: {
|
|
1155
1149
|
[chainId]: {
|
|
1156
1150
|
address: signerAddress,
|
|
@@ -1199,8 +1193,8 @@ var validateCosmosGasBalance = async ({
|
|
|
1199
1193
|
};
|
|
1200
1194
|
}
|
|
1201
1195
|
if (parseInt(balance?.amount ?? "") < parseInt(fee.amount[0]?.amount)) {
|
|
1202
|
-
const userAmount = new
|
|
1203
|
-
const feeAmount = new
|
|
1196
|
+
const userAmount = new BigNumber(parseFloat(balance?.amount ?? "")).shiftedBy(-decimal).toFixed(decimal);
|
|
1197
|
+
const feeAmount = new BigNumber(parseFloat(fee.amount[0]?.amount)).shiftedBy(-decimal).toFixed(decimal);
|
|
1204
1198
|
return {
|
|
1205
1199
|
error: `Insufficient balance for gas on ${chain?.prettyName}. Need ${feeAmount} ${symbol} but only have ${userAmount} ${symbol}.`,
|
|
1206
1200
|
asset
|
|
@@ -1237,7 +1231,7 @@ var validateEvmTokenApproval = async ({
|
|
|
1237
1231
|
throw new Error("validateEvmGasBalance: Signer address not found");
|
|
1238
1232
|
}
|
|
1239
1233
|
for (const requiredApproval of requiredErc20Approvals) {
|
|
1240
|
-
const extendedSigner = signer.extend(
|
|
1234
|
+
const extendedSigner = signer.extend(publicActions);
|
|
1241
1235
|
const allowance = await extendedSigner.readContract({
|
|
1242
1236
|
address: requiredApproval.tokenContract,
|
|
1243
1237
|
abi: erc20ABI,
|
|
@@ -1250,7 +1244,7 @@ var validateEvmTokenApproval = async ({
|
|
|
1250
1244
|
const fee = await extendedSigner.estimateFeesPerGas();
|
|
1251
1245
|
const allowanceGasFee = BigInt(fee.maxFeePerGas) * BigInt(1e5);
|
|
1252
1246
|
if (!gasBalance) {
|
|
1253
|
-
const chainAssets = (await
|
|
1247
|
+
const chainAssets = (await ClientState.getSkipAssets({ chainId: tx.chainId }))[tx.chainId];
|
|
1254
1248
|
const nativeAsset = chainAssets?.find((x) => x.denom.includes("-native"));
|
|
1255
1249
|
const zeroAddressAsset = chainAssets?.find(
|
|
1256
1250
|
(x) => x.denom.toLowerCase() === "0x0000000000000000000000000000000000000000"
|
|
@@ -1261,13 +1255,13 @@ var validateEvmTokenApproval = async ({
|
|
|
1261
1255
|
`Insufficient balance for gas on ${chain.prettyName}. Need ${allowanceGasFee} gwei.`
|
|
1262
1256
|
);
|
|
1263
1257
|
}
|
|
1264
|
-
const formattedGasAmount =
|
|
1258
|
+
const formattedGasAmount = formatUnits(allowanceGasFee, asset?.decimals);
|
|
1265
1259
|
throw new Error(
|
|
1266
1260
|
`Insufficient balance for gas on ${chain.prettyName}. Need ${formattedGasAmount} ${asset.symbol}.`
|
|
1267
1261
|
);
|
|
1268
1262
|
}
|
|
1269
|
-
if (
|
|
1270
|
-
const chainAssets = (await
|
|
1263
|
+
if (BigNumber(gasBalance.amount).lt(Number(allowanceGasFee))) {
|
|
1264
|
+
const chainAssets = (await ClientState.getSkipAssets({ chainId: tx.chainId }))[tx.chainId];
|
|
1271
1265
|
const asset = chainAssets?.find(
|
|
1272
1266
|
(x) => x.denom.includes("-native") || x.denom.toLowerCase() === "0x0000000000000000000000000000000000000000"
|
|
1273
1267
|
);
|
|
@@ -1278,7 +1272,7 @@ var validateEvmTokenApproval = async ({
|
|
|
1278
1272
|
fee: null
|
|
1279
1273
|
};
|
|
1280
1274
|
}
|
|
1281
|
-
const formattedGasAmount =
|
|
1275
|
+
const formattedGasAmount = formatUnits(allowanceGasFee, asset?.decimals);
|
|
1282
1276
|
return {
|
|
1283
1277
|
error: `Insufficient balance for gas on ${chain.prettyName}. Need ${formattedGasAmount} ${asset.symbol} but only have ${gasBalance.formattedAmount} ${asset.symbol}.`,
|
|
1284
1278
|
asset: null,
|
|
@@ -1292,7 +1286,7 @@ var validateEvmTokenApproval = async ({
|
|
|
1292
1286
|
functionName: "approve",
|
|
1293
1287
|
args: [
|
|
1294
1288
|
requiredApproval.spender,
|
|
1295
|
-
useUnlimitedApproval ?
|
|
1289
|
+
useUnlimitedApproval ? maxUint256 : BigInt(requiredApproval.amount) + BigInt(1e3)
|
|
1296
1290
|
],
|
|
1297
1291
|
chain: signer.chain
|
|
1298
1292
|
});
|
|
@@ -1309,7 +1303,7 @@ var validateEvmTokenApproval = async ({
|
|
|
1309
1303
|
async function getEVMGasAmountForMessage(signer, tx, getFallbackGasAmount) {
|
|
1310
1304
|
const { to, data, value } = tx;
|
|
1311
1305
|
if (!signer.account) throw new Error("estimateGasForEvmTx: No account found");
|
|
1312
|
-
const extendedSigner = signer.extend(
|
|
1306
|
+
const extendedSigner = signer.extend(publicActions);
|
|
1313
1307
|
const fee = await extendedSigner.estimateFeesPerGas();
|
|
1314
1308
|
try {
|
|
1315
1309
|
const gasAmount = await extendedSigner.estimateGas({
|
|
@@ -1336,8 +1330,8 @@ var validateEvmGasBalance = async ({
|
|
|
1336
1330
|
useUnlimitedApproval
|
|
1337
1331
|
}) => {
|
|
1338
1332
|
const chainId = tx?.chainId ?? "";
|
|
1339
|
-
const skipAssets = (await
|
|
1340
|
-
const skipChains = await
|
|
1333
|
+
const skipAssets = (await ClientState.getSkipAssets({ chainId }))?.[chainId];
|
|
1334
|
+
const skipChains = await ClientState.getSkipChains();
|
|
1341
1335
|
const chain = skipChains?.find?.((chain2) => chain2.chainId === chainId);
|
|
1342
1336
|
if (!chain) {
|
|
1343
1337
|
throw new Error(`failed to find chain for chainId: '${chainId}'`);
|
|
@@ -1345,7 +1339,7 @@ var validateEvmGasBalance = async ({
|
|
|
1345
1339
|
if (!signer.account?.address) {
|
|
1346
1340
|
throw new Error("validateEvmGasBalance: Signer address not found");
|
|
1347
1341
|
}
|
|
1348
|
-
const skipBalances = (await
|
|
1342
|
+
const skipBalances = (await balances({
|
|
1349
1343
|
chains: {
|
|
1350
1344
|
[tx?.chainId ?? ""]: {
|
|
1351
1345
|
address: signer.account?.address
|
|
@@ -1391,14 +1385,14 @@ var validateEvmGasBalance = async ({
|
|
|
1391
1385
|
fee: null
|
|
1392
1386
|
};
|
|
1393
1387
|
}
|
|
1394
|
-
const formattedGasAmount =
|
|
1388
|
+
const formattedGasAmount = formatUnits(gasAmount, asset?.decimals);
|
|
1395
1389
|
return {
|
|
1396
1390
|
error: `Insufficient balance for gas on ${chain.prettyName}. Need ${formattedGasAmount} ${asset.symbol}.`,
|
|
1397
1391
|
asset: null,
|
|
1398
1392
|
fee: null
|
|
1399
1393
|
};
|
|
1400
1394
|
}
|
|
1401
|
-
if (
|
|
1395
|
+
if (BigNumber(gasBalance.amount ?? "").lt(Number(gasAmount))) {
|
|
1402
1396
|
const asset = skipAssets?.find(
|
|
1403
1397
|
(x) => x.denom?.includes("-native") || x.denom?.toLowerCase() === "0x0000000000000000000000000000000000000000"
|
|
1404
1398
|
);
|
|
@@ -1409,7 +1403,7 @@ var validateEvmGasBalance = async ({
|
|
|
1409
1403
|
fee: null
|
|
1410
1404
|
};
|
|
1411
1405
|
}
|
|
1412
|
-
const formattedGasAmount =
|
|
1406
|
+
const formattedGasAmount = formatUnits(gasAmount, asset?.decimals);
|
|
1413
1407
|
return {
|
|
1414
1408
|
error: `Insufficient balance for gas on ${chain.prettyName}. Need ${formattedGasAmount} ${asset.symbol} but only have ${gasBalance.formattedAmount} ${asset.symbol}.`,
|
|
1415
1409
|
asset: null,
|
|
@@ -1421,8 +1415,8 @@ var validateSvmGasBalance = async ({
|
|
|
1421
1415
|
tx
|
|
1422
1416
|
}) => {
|
|
1423
1417
|
if (!tx) throw new Error("Transaction is required");
|
|
1424
|
-
const endpoint = await
|
|
1425
|
-
const connection = new
|
|
1418
|
+
const endpoint = await getRpcEndpointForChain(tx.chainId ?? "");
|
|
1419
|
+
const connection = new Connection(endpoint);
|
|
1426
1420
|
if (!connection) throw new Error(`Failed to connect to ${tx.chainId}`);
|
|
1427
1421
|
if (!tx.tx) {
|
|
1428
1422
|
throw new Error("Transaction is required");
|
|
@@ -1430,7 +1424,7 @@ var validateSvmGasBalance = async ({
|
|
|
1430
1424
|
const txBuffer = Buffer.from(tx.tx, "base64");
|
|
1431
1425
|
let transaction;
|
|
1432
1426
|
try {
|
|
1433
|
-
transaction =
|
|
1427
|
+
transaction = Transaction.from(txBuffer);
|
|
1434
1428
|
} catch (decodeError) {
|
|
1435
1429
|
return {
|
|
1436
1430
|
success: false,
|
|
@@ -1472,7 +1466,7 @@ function getSolShortfall(logs) {
|
|
|
1472
1466
|
const have = parseInt(m[1] ?? "0", 10);
|
|
1473
1467
|
const need = parseInt(m[2] ?? "0", 10);
|
|
1474
1468
|
const shortfallLamports = need - have;
|
|
1475
|
-
return shortfallLamports /
|
|
1469
|
+
return shortfallLamports / LAMPORTS_PER_SOL;
|
|
1476
1470
|
}
|
|
1477
1471
|
|
|
1478
1472
|
// src/private-functions/validateGasBalances.ts
|
|
@@ -1569,13 +1563,13 @@ var validateGasBalances = async ({
|
|
|
1569
1563
|
onValidateGasBalance?.({
|
|
1570
1564
|
status: "error"
|
|
1571
1565
|
});
|
|
1572
|
-
|
|
1566
|
+
ClientState.validateGasResults = validateResult;
|
|
1573
1567
|
throw new Error(`${txError.error}`);
|
|
1574
1568
|
}
|
|
1575
1569
|
onValidateGasBalance?.({
|
|
1576
1570
|
status: "completed"
|
|
1577
1571
|
});
|
|
1578
|
-
|
|
1572
|
+
ClientState.validateGasResults = validateResult;
|
|
1579
1573
|
};
|
|
1580
1574
|
|
|
1581
1575
|
// src/private-functions/waitForTransaction.ts
|
|
@@ -1584,13 +1578,13 @@ var waitForTransaction = async ({
|
|
|
1584
1578
|
txHash,
|
|
1585
1579
|
onTransactionTracked
|
|
1586
1580
|
}) => {
|
|
1587
|
-
const { explorerLink } = await
|
|
1581
|
+
const { explorerLink } = await trackTransaction({
|
|
1588
1582
|
chainId,
|
|
1589
1583
|
txHash
|
|
1590
1584
|
});
|
|
1591
1585
|
await onTransactionTracked?.({ txHash, chainId, explorerLink });
|
|
1592
1586
|
while (true) {
|
|
1593
|
-
const txStatusResponse = await
|
|
1587
|
+
const txStatusResponse = await transactionStatus({
|
|
1594
1588
|
chainId,
|
|
1595
1589
|
txHash
|
|
1596
1590
|
});
|
|
@@ -1603,7 +1597,7 @@ var waitForTransaction = async ({
|
|
|
1603
1597
|
if (txStatusResponse.state === "STATE_ABANDONED") {
|
|
1604
1598
|
throw new Error("Tracking for the transaction has been abandoned");
|
|
1605
1599
|
}
|
|
1606
|
-
await
|
|
1600
|
+
await wait(1e3);
|
|
1607
1601
|
}
|
|
1608
1602
|
};
|
|
1609
1603
|
|
|
@@ -1640,10 +1634,10 @@ var executeTransactions = async (options) => {
|
|
|
1640
1634
|
}
|
|
1641
1635
|
});
|
|
1642
1636
|
const isGasStationSourceEVM = chainIds.find((item, i, array) => {
|
|
1643
|
-
return
|
|
1637
|
+
return GAS_STATION_CHAIN_IDS.includes(item?.chainId ?? "") && array[i - 1]?.chainType === "evm";
|
|
1644
1638
|
});
|
|
1645
|
-
|
|
1646
|
-
const validateChainIds = !batchSimulate ? chainIds.map((x) => x?.chainId ?? "") : isGasStationSourceEVM ?
|
|
1639
|
+
ClientState.validateGasResults = void 0;
|
|
1640
|
+
const validateChainIds = !batchSimulate ? chainIds.map((x) => x?.chainId ?? "") : isGasStationSourceEVM ? GAS_STATION_CHAIN_IDS : [];
|
|
1647
1641
|
await validateGasBalances({
|
|
1648
1642
|
txs,
|
|
1649
1643
|
getFallbackGasAmount: options.getFallbackGasAmount,
|
|
@@ -1722,7 +1716,7 @@ var executeRoute = async (options) => {
|
|
|
1722
1716
|
if (!isUserAddressesValid) {
|
|
1723
1717
|
throw new Error("executeRoute error: invalid user addresses");
|
|
1724
1718
|
}
|
|
1725
|
-
const response = await
|
|
1719
|
+
const response = await messages({
|
|
1726
1720
|
timeoutSeconds,
|
|
1727
1721
|
amountIn: route?.amountIn,
|
|
1728
1722
|
amountOut: route.estimatedAmountOut || "0",
|
|
@@ -1733,7 +1727,7 @@ var executeRoute = async (options) => {
|
|
|
1733
1727
|
operations: route?.operations,
|
|
1734
1728
|
addressList,
|
|
1735
1729
|
slippageTolerancePercent: options.slippageTolerancePercent || "1",
|
|
1736
|
-
chainIdsToAffiliates:
|
|
1730
|
+
chainIdsToAffiliates: ApiState.chainIdsToAffiliates
|
|
1737
1731
|
});
|
|
1738
1732
|
if (beforeMsg && (response?.txs?.length ?? 0) > 0) {
|
|
1739
1733
|
const firstTx = response?.txs?.[0];
|
|
@@ -1750,7 +1744,7 @@ var executeRoute = async (options) => {
|
|
|
1750
1744
|
await executeTransactions({ ...options, txs: response?.txs });
|
|
1751
1745
|
};
|
|
1752
1746
|
var validateUserAddresses = async (userAddresses) => {
|
|
1753
|
-
const chains2 = await
|
|
1747
|
+
const chains2 = await ClientState.getSkipChains();
|
|
1754
1748
|
const validations = userAddresses.map((userAddress) => {
|
|
1755
1749
|
const chain = chains2.find((chain2) => chain2.chainId === userAddress.chainId);
|
|
1756
1750
|
switch (chain?.chainType) {
|
|
@@ -1758,27 +1752,27 @@ var validateUserAddresses = async (userAddresses) => {
|
|
|
1758
1752
|
try {
|
|
1759
1753
|
if (chain.chainId?.includes("penumbra")) {
|
|
1760
1754
|
try {
|
|
1761
|
-
return chain.bech32Prefix ===
|
|
1755
|
+
return chain.bech32Prefix === bech32m.decode(userAddress.address, 143)?.prefix;
|
|
1762
1756
|
} catch {
|
|
1763
1757
|
return ["penumbracompat1", "tpenumbra"].includes(
|
|
1764
|
-
bech32.
|
|
1758
|
+
bech32.decode(userAddress.address, 1023).prefix
|
|
1765
1759
|
);
|
|
1766
1760
|
}
|
|
1767
1761
|
}
|
|
1768
|
-
return chain.bech32Prefix === bech32.
|
|
1762
|
+
return chain.bech32Prefix === bech32.decode(userAddress.address, 1023).prefix;
|
|
1769
1763
|
} catch {
|
|
1770
1764
|
return false;
|
|
1771
1765
|
}
|
|
1772
1766
|
case "evm" /* Evm */:
|
|
1773
1767
|
try {
|
|
1774
|
-
return
|
|
1768
|
+
return isAddress(userAddress.address);
|
|
1775
1769
|
} catch (_error) {
|
|
1776
1770
|
return false;
|
|
1777
1771
|
}
|
|
1778
1772
|
case "svm" /* Svm */:
|
|
1779
1773
|
try {
|
|
1780
|
-
const publicKey = new
|
|
1781
|
-
return
|
|
1774
|
+
const publicKey = new PublicKey(userAddress.address);
|
|
1775
|
+
return PublicKey.isOnCurve(publicKey);
|
|
1782
1776
|
} catch (_error) {
|
|
1783
1777
|
return false;
|
|
1784
1778
|
}
|
|
@@ -1789,4 +1783,4 @@ var validateUserAddresses = async (userAddresses) => {
|
|
|
1789
1783
|
return validations.every((validation) => validation);
|
|
1790
1784
|
};
|
|
1791
1785
|
|
|
1792
|
-
|
|
1786
|
+
export { executeRoute };
|