@injectivelabs/sdk-ts 1.16.4-alpha.0 → 1.16.5-alpha.0
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/README.md +1 -1
- package/dist/cjs/client/indexer/grpc/IndexerGrpcTransactionApi.d.ts +3 -3
- package/dist/cjs/client/indexer/grpc/IndexerGrpcWeb3GwApi.d.ts +2 -2
- package/dist/cjs/core/accounts/PrivateKey.d.ts +2 -2
- package/dist/cjs/core/accounts/PrivateKey.js +17 -17
- package/dist/cjs/core/modules/msgs.d.ts +2 -1
- package/dist/cjs/core/modules/staking/index.d.ts +2 -1
- package/dist/cjs/core/modules/staking/index.js +3 -1
- package/dist/cjs/core/modules/staking/msgs/MsgTransferDelegation.d.ts +49 -0
- package/dist/cjs/core/modules/staking/msgs/MsgTransferDelegation.js +64 -0
- package/dist/cjs/core/modules/wasm/msgs/MsgExecuteContract.d.ts +1 -0
- package/dist/cjs/core/modules/wasm/msgs/MsgExecuteContract.js +3 -7
- package/dist/cjs/core/tx/broadcaster/MsgBroadcasterWithPk.d.ts +3 -3
- package/dist/cjs/core/tx/broadcaster/MsgBroadcasterWithPk.js +6 -7
- package/dist/cjs/core/tx/eip712/eip712.d.ts +5 -5
- package/dist/cjs/core/tx/eip712/eip712.js +4 -4
- package/dist/cjs/core/tx/eip712/maps.js +2 -0
- package/dist/cjs/core/tx/eip712/utils.d.ts +3 -3
- package/dist/cjs/core/tx/eip712/utils.js +4 -4
- package/dist/cjs/core/tx/utils/tx.d.ts +3 -3
- package/dist/cjs/core/tx/utils/tx.js +2 -2
- package/dist/cjs/utils/grpc.d.ts +1 -1
- package/dist/cjs/utils/pagination.d.ts +1 -1
- package/dist/cjs/utils/pagination.js +5 -12
- package/dist/esm/client/indexer/grpc/IndexerGrpcTransactionApi.d.ts +3 -3
- package/dist/esm/client/indexer/grpc/IndexerGrpcWeb3GwApi.d.ts +2 -2
- package/dist/esm/core/accounts/PrivateKey.d.ts +2 -2
- package/dist/esm/core/accounts/PrivateKey.js +17 -17
- package/dist/esm/core/modules/msgs.d.ts +2 -1
- package/dist/esm/core/modules/staking/index.d.ts +2 -1
- package/dist/esm/core/modules/staking/index.js +2 -1
- package/dist/esm/core/modules/staking/msgs/MsgTransferDelegation.d.ts +49 -0
- package/dist/esm/core/modules/staking/msgs/MsgTransferDelegation.js +58 -0
- package/dist/esm/core/modules/wasm/msgs/MsgExecuteContract.d.ts +1 -0
- package/dist/esm/core/modules/wasm/msgs/MsgExecuteContract.js +3 -7
- package/dist/esm/core/tx/broadcaster/MsgBroadcasterWithPk.d.ts +3 -3
- package/dist/esm/core/tx/broadcaster/MsgBroadcasterWithPk.js +6 -7
- package/dist/esm/core/tx/eip712/eip712.d.ts +5 -5
- package/dist/esm/core/tx/eip712/eip712.js +5 -5
- package/dist/esm/core/tx/eip712/maps.js +2 -0
- package/dist/esm/core/tx/eip712/utils.d.ts +3 -3
- package/dist/esm/core/tx/eip712/utils.js +4 -4
- package/dist/esm/core/tx/utils/tx.d.ts +3 -3
- package/dist/esm/core/tx/utils/tx.js +2 -2
- package/dist/esm/utils/grpc.d.ts +1 -1
- package/dist/esm/utils/pagination.d.ts +1 -1
- package/dist/esm/utils/pagination.js +5 -12
- package/package.json +9 -13
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { AccountAddress,
|
|
1
|
+
import { AccountAddress, EvmChainId } from '@injectivelabs/ts-types';
|
|
2
2
|
import { InjectiveExchangeRpc } from '@injectivelabs/indexer-proto-ts';
|
|
3
3
|
import { CosmosTxV1Beta1Tx } from '@injectivelabs/core-proto-ts';
|
|
4
4
|
import BaseGrpcConsumer from '../../base/BaseIndexerGrpcConsumer.js';
|
|
5
5
|
interface PrepareTxArgs {
|
|
6
6
|
address: AccountAddress;
|
|
7
|
-
chainId:
|
|
7
|
+
chainId: EvmChainId;
|
|
8
8
|
message: any;
|
|
9
9
|
estimateGas?: boolean;
|
|
10
10
|
gasLimit?: number;
|
|
@@ -41,7 +41,7 @@ export declare class IndexerGrpcTransactionApi extends BaseGrpcConsumer {
|
|
|
41
41
|
*/
|
|
42
42
|
broadcastTxRequest({ signature, chainId, message, txResponse, }: {
|
|
43
43
|
signature: string;
|
|
44
|
-
chainId:
|
|
44
|
+
chainId: EvmChainId;
|
|
45
45
|
useCorrectEIP712Hash?: boolean;
|
|
46
46
|
txResponse: InjectiveExchangeRpc.PrepareTxResponse;
|
|
47
47
|
message: Record<string, any>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountAddress,
|
|
1
|
+
import { AccountAddress, EvmChainId } from '@injectivelabs/ts-types';
|
|
2
2
|
import { InjectiveExchangeRpc } from '@injectivelabs/indexer-proto-ts';
|
|
3
3
|
import { IndexerGrpcTransactionApi } from './IndexerGrpcTransactionApi.js';
|
|
4
4
|
/**
|
|
@@ -9,7 +9,7 @@ export declare class IndexerGrpcWeb3GwApi extends IndexerGrpcTransactionApi {
|
|
|
9
9
|
constructor(endpoint: string);
|
|
10
10
|
prepareEip712Request({ address, chainId, message, memo, sequence, accountNumber, estimateGas, gasLimit, feeDenom, feePrice, timeoutHeight, eip712Version, }: {
|
|
11
11
|
address: AccountAddress;
|
|
12
|
-
chainId:
|
|
12
|
+
chainId: EvmChainId;
|
|
13
13
|
message: any;
|
|
14
14
|
estimateGas?: boolean;
|
|
15
15
|
gasLimit?: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PublicKey } from './PublicKey.js';
|
|
2
|
-
import { Address } from './Address.js';
|
|
3
1
|
import { CosmosTxV1Beta1Tx } from '@injectivelabs/core-proto-ts';
|
|
2
|
+
import { Address } from './Address.js';
|
|
3
|
+
import { PublicKey } from './PublicKey.js';
|
|
4
4
|
/**
|
|
5
5
|
* Class for wrapping SigningKey that is used for signature creation and public key derivation.
|
|
6
6
|
*
|
|
@@ -4,19 +4,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.PrivateKey = void 0;
|
|
7
|
-
const bip39_1 = require("bip39");
|
|
8
|
-
const ethers_1 = require("ethers");
|
|
9
7
|
const secp256k1_1 = __importDefault(require("secp256k1"));
|
|
10
8
|
const keccak256_1 = __importDefault(require("keccak256"));
|
|
11
|
-
const
|
|
12
|
-
const
|
|
9
|
+
const bip39_1 = require("bip39");
|
|
10
|
+
const core_proto_ts_1 = require("@injectivelabs/core-proto-ts");
|
|
11
|
+
const exceptions_1 = require("@injectivelabs/exceptions");
|
|
12
|
+
const ts_types_1 = require("@injectivelabs/ts-types");
|
|
13
|
+
const ethers_1 = require("ethers");
|
|
13
14
|
const eth_sig_util_1 = require("@metamask/eth-sig-util");
|
|
14
15
|
const index_js_1 = require("../../utils/index.js");
|
|
15
|
-
const
|
|
16
|
+
const Address_js_1 = require("./Address.js");
|
|
17
|
+
const PublicKey_js_1 = require("./PublicKey.js");
|
|
16
18
|
const tx_js_1 = require("../tx/utils/tx.js");
|
|
17
19
|
const index_js_2 = require("../tx/eip712/index.js");
|
|
18
|
-
const exceptions_1 = require("@injectivelabs/exceptions");
|
|
19
|
-
const ts_types_1 = require("@injectivelabs/ts-types");
|
|
20
20
|
/**
|
|
21
21
|
* Class for wrapping SigningKey that is used for signature creation and public key derivation.
|
|
22
22
|
*
|
|
@@ -266,31 +266,31 @@ class PrivateKey {
|
|
|
266
266
|
const getChainIds = () => {
|
|
267
267
|
if (!body.extensionOptions.length) {
|
|
268
268
|
return {
|
|
269
|
-
ethereumChainId: ts_types_1.EthereumChainId.Mainnet,
|
|
270
269
|
chainId: ts_types_1.ChainId.Mainnet,
|
|
270
|
+
EvmChainId: ts_types_1.EvmChainId.Mainnet,
|
|
271
271
|
};
|
|
272
272
|
}
|
|
273
273
|
const extension = body.extensionOptions.find((extension) => extension.typeUrl.includes('ExtensionOptionsWeb3Tx'));
|
|
274
274
|
if (!extension) {
|
|
275
275
|
return {
|
|
276
|
-
ethereumChainId: ts_types_1.EthereumChainId.Mainnet,
|
|
277
276
|
chainId: ts_types_1.ChainId.Mainnet,
|
|
277
|
+
EvmChainId: ts_types_1.EvmChainId.Mainnet,
|
|
278
278
|
};
|
|
279
279
|
}
|
|
280
280
|
const decodedExtension = core_proto_ts_1.InjectiveTypesV1Beta1TxExt.ExtensionOptionsWeb3Tx.decode(extension.value);
|
|
281
|
-
const
|
|
281
|
+
const evmChainId = Number(decodedExtension.typedDataChainID);
|
|
282
282
|
return {
|
|
283
|
-
|
|
283
|
+
evmChainId: ts_types_1.EvmChainId,
|
|
284
284
|
chainId: [
|
|
285
|
-
ts_types_1.
|
|
286
|
-
ts_types_1.
|
|
287
|
-
ts_types_1.
|
|
288
|
-
].includes(
|
|
285
|
+
ts_types_1.EvmChainId.Kovan,
|
|
286
|
+
ts_types_1.EvmChainId.Goerli,
|
|
287
|
+
ts_types_1.EvmChainId.Sepolia,
|
|
288
|
+
].includes(evmChainId)
|
|
289
289
|
? ts_types_1.ChainId.Testnet
|
|
290
290
|
: ts_types_1.ChainId.Mainnet,
|
|
291
291
|
};
|
|
292
292
|
};
|
|
293
|
-
const {
|
|
293
|
+
const { evmChainId, chainId } = getChainIds();
|
|
294
294
|
const [signerInfo] = authInfo.signerInfos;
|
|
295
295
|
const [signature] = signatures;
|
|
296
296
|
const [msg] = body.messages;
|
|
@@ -305,7 +305,7 @@ class PrivateKey {
|
|
|
305
305
|
timeoutHeight: body.timeoutHeight.toString(),
|
|
306
306
|
chainId,
|
|
307
307
|
},
|
|
308
|
-
|
|
308
|
+
evmChainId: evmChainId,
|
|
309
309
|
});
|
|
310
310
|
return this.verifySignature({
|
|
311
311
|
eip712: eip712TypedData,
|
|
@@ -36,6 +36,7 @@ import MsgUnderwrite from './insurance/msgs/MsgUnderwrite.js';
|
|
|
36
36
|
import MsgSendToEth from './peggy/msgs/MsgSendToEth.js';
|
|
37
37
|
import MsgDelegate from './staking/msgs/MsgDelegate.js';
|
|
38
38
|
import MsgUndelegate from './staking/msgs/MsgUndelegate.js';
|
|
39
|
+
import MsgTransferDelegation from './staking/msgs/MsgTransferDelegation.js';
|
|
39
40
|
import MsgEditValidator from './staking/msgs/MsgEditValidator.js';
|
|
40
41
|
import MsgCreateValidator from './staking/msgs/MsgCreateValidator.js';
|
|
41
42
|
import MsgBeginRedelegate from './staking/msgs/MsgBeginRedelegate.js';
|
|
@@ -62,7 +63,7 @@ import { MsgSubmitProposal } from './gov/index.js';
|
|
|
62
63
|
/**
|
|
63
64
|
* @category Messages
|
|
64
65
|
*/
|
|
65
|
-
export type Msgs = MsgBid | MsgRevoke | MsgGrant | MsgAuthzExec | MsgSend | MsgMultiSend | MsgBatchUpdateOrders | MsgWithdrawDelegatorReward | MsgBatchCancelDerivativeOrders | MsgBatchCancelSpotOrders | MsgCancelDerivativeOrder | MsgCancelSpotOrder | MsgCreateDerivativeLimitOrder | MsgCreateDerivativeMarketOrder | MsgCreateSpotLimitOrder | MsgCreateSpotMarketOrder | MsgDeposit | MsgIncreasePositionMargin | MsgInstantSpotMarketLaunch | MsgWithdraw | MsgGovDeposit | MsgSubmitProposal | MsgVote | MsgTransfer | MsgCreateInsuranceFund | MsgRequestRedemption | MsgUnderwrite | MsgSendToEth | MsgDelegate | MsgUndelegate | MsgBeginRedelegate | MsgCancelUnbondingDelegation | MsgExecuteContract | MsgExecuteContractCompat | MsgMigrateContract | MsgUpdateAdmin | MsgExec | MsgInstantiateContract | MsgCreateBinaryOptionsLimitOrder | MsgCreateBinaryOptionsMarketOrder | MsgCancelBinaryOptionsOrder | MsgBatchCancelBinaryOptionsOrders | MsgWithdrawValidatorCommission | MsgEditValidator | MsgReclaimLockedFunds | MsgExternalTransfer | MsgStoreCode | MsgRewardsOptOut | MsgCreateValidator | MsgMint | MsgBurn | MsgChangeAdmin | MsgCreateDenom | MsgSetDenomMetadata | MsgGrantAllowance | MsgRevokeAllowance | MsgAdminUpdateBinaryOptionsMarket | MsgLiquidatePosition | MsgSignData | MsgGrantWithAuthorization | MsgAuthorizeStakeGrants;
|
|
66
|
+
export type Msgs = MsgBid | MsgRevoke | MsgGrant | MsgAuthzExec | MsgSend | MsgMultiSend | MsgBatchUpdateOrders | MsgWithdrawDelegatorReward | MsgBatchCancelDerivativeOrders | MsgBatchCancelSpotOrders | MsgCancelDerivativeOrder | MsgCancelSpotOrder | MsgCreateDerivativeLimitOrder | MsgCreateDerivativeMarketOrder | MsgCreateSpotLimitOrder | MsgCreateSpotMarketOrder | MsgDeposit | MsgIncreasePositionMargin | MsgInstantSpotMarketLaunch | MsgWithdraw | MsgGovDeposit | MsgSubmitProposal | MsgVote | MsgTransfer | MsgCreateInsuranceFund | MsgRequestRedemption | MsgUnderwrite | MsgSendToEth | MsgDelegate | MsgUndelegate | MsgBeginRedelegate | MsgTransferDelegation | MsgCancelUnbondingDelegation | MsgExecuteContract | MsgExecuteContractCompat | MsgMigrateContract | MsgUpdateAdmin | MsgExec | MsgInstantiateContract | MsgCreateBinaryOptionsLimitOrder | MsgCreateBinaryOptionsMarketOrder | MsgCancelBinaryOptionsOrder | MsgBatchCancelBinaryOptionsOrders | MsgWithdrawValidatorCommission | MsgEditValidator | MsgReclaimLockedFunds | MsgExternalTransfer | MsgStoreCode | MsgRewardsOptOut | MsgCreateValidator | MsgMint | MsgBurn | MsgChangeAdmin | MsgCreateDenom | MsgSetDenomMetadata | MsgGrantAllowance | MsgRevokeAllowance | MsgAdminUpdateBinaryOptionsMarket | MsgLiquidatePosition | MsgSignData | MsgGrantWithAuthorization | MsgAuthorizeStakeGrants;
|
|
66
67
|
/**
|
|
67
68
|
* @category Messages
|
|
68
69
|
*/
|
|
@@ -3,5 +3,6 @@ import MsgUndelegate from './msgs/MsgUndelegate.js';
|
|
|
3
3
|
import MsgEditValidator from './msgs/MsgEditValidator.js';
|
|
4
4
|
import MsgCreateValidator from './msgs/MsgCreateValidator.js';
|
|
5
5
|
import MsgBeginRedelegate from './msgs/MsgBeginRedelegate.js';
|
|
6
|
+
import MsgTransferDelegation from './msgs/MsgTransferDelegation.js';
|
|
6
7
|
import MsgCancelUnbondingDelegation from './msgs/MsgCancelUnbondingDelegation.js';
|
|
7
|
-
export { MsgDelegate, MsgUndelegate, MsgEditValidator, MsgCreateValidator, MsgBeginRedelegate, MsgCancelUnbondingDelegation, };
|
|
8
|
+
export { MsgDelegate, MsgUndelegate, MsgEditValidator, MsgCreateValidator, MsgBeginRedelegate, MsgTransferDelegation, MsgCancelUnbondingDelegation, };
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.MsgCancelUnbondingDelegation = exports.MsgBeginRedelegate = exports.MsgCreateValidator = exports.MsgEditValidator = exports.MsgUndelegate = exports.MsgDelegate = void 0;
|
|
6
|
+
exports.MsgCancelUnbondingDelegation = exports.MsgTransferDelegation = exports.MsgBeginRedelegate = exports.MsgCreateValidator = exports.MsgEditValidator = exports.MsgUndelegate = exports.MsgDelegate = void 0;
|
|
7
7
|
const MsgDelegate_js_1 = __importDefault(require("./msgs/MsgDelegate.js"));
|
|
8
8
|
exports.MsgDelegate = MsgDelegate_js_1.default;
|
|
9
9
|
const MsgUndelegate_js_1 = __importDefault(require("./msgs/MsgUndelegate.js"));
|
|
@@ -14,5 +14,7 @@ const MsgCreateValidator_js_1 = __importDefault(require("./msgs/MsgCreateValidat
|
|
|
14
14
|
exports.MsgCreateValidator = MsgCreateValidator_js_1.default;
|
|
15
15
|
const MsgBeginRedelegate_js_1 = __importDefault(require("./msgs/MsgBeginRedelegate.js"));
|
|
16
16
|
exports.MsgBeginRedelegate = MsgBeginRedelegate_js_1.default;
|
|
17
|
+
const MsgTransferDelegation_js_1 = __importDefault(require("./msgs/MsgTransferDelegation.js"));
|
|
18
|
+
exports.MsgTransferDelegation = MsgTransferDelegation_js_1.default;
|
|
17
19
|
const MsgCancelUnbondingDelegation_js_1 = __importDefault(require("./msgs/MsgCancelUnbondingDelegation.js"));
|
|
18
20
|
exports.MsgCancelUnbondingDelegation = MsgCancelUnbondingDelegation_js_1.default;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { MsgBase } from '../../MsgBase.js';
|
|
2
|
+
import { CosmosBaseV1Beta1Coin, CosmosStakingV1Beta1Tx } from '@injectivelabs/core-proto-ts';
|
|
3
|
+
export declare namespace MsgTransferDelegation {
|
|
4
|
+
interface Params {
|
|
5
|
+
amount: {
|
|
6
|
+
denom: string;
|
|
7
|
+
amount: string;
|
|
8
|
+
};
|
|
9
|
+
injectiveAddress: string;
|
|
10
|
+
validatorAddress: string;
|
|
11
|
+
receiverAddress: string;
|
|
12
|
+
}
|
|
13
|
+
type Proto = CosmosStakingV1Beta1Tx.MsgTransferDelegation;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @category Messages
|
|
17
|
+
*/
|
|
18
|
+
export default class MsgTransferDelegation extends MsgBase<MsgTransferDelegation.Params, MsgTransferDelegation.Proto> {
|
|
19
|
+
static fromJSON(params: MsgTransferDelegation.Params): MsgTransferDelegation;
|
|
20
|
+
toProto(): CosmosStakingV1Beta1Tx.MsgTransferDelegation;
|
|
21
|
+
toData(): {
|
|
22
|
+
delegatorAddress: string;
|
|
23
|
+
validatorAddress: string;
|
|
24
|
+
receiverAddress: string;
|
|
25
|
+
amount: CosmosBaseV1Beta1Coin.Coin | undefined;
|
|
26
|
+
'@type': string;
|
|
27
|
+
};
|
|
28
|
+
toAmino(): {
|
|
29
|
+
type: string;
|
|
30
|
+
value: {
|
|
31
|
+
delegator_address: string;
|
|
32
|
+
validator_address: string;
|
|
33
|
+
receiver_address: string;
|
|
34
|
+
amount: CosmosBaseV1Beta1Coin.Coin | undefined;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
toWeb3Gw(): {
|
|
38
|
+
delegator_address: string;
|
|
39
|
+
validator_address: string;
|
|
40
|
+
receiver_address: string;
|
|
41
|
+
amount: CosmosBaseV1Beta1Coin.Coin | undefined;
|
|
42
|
+
'@type': string;
|
|
43
|
+
};
|
|
44
|
+
toDirectSign(): {
|
|
45
|
+
type: string;
|
|
46
|
+
message: CosmosStakingV1Beta1Tx.MsgTransferDelegation;
|
|
47
|
+
};
|
|
48
|
+
toBinary(): Uint8Array;
|
|
49
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const MsgBase_js_1 = require("../../MsgBase.js");
|
|
7
|
+
const snakecase_keys_1 = __importDefault(require("snakecase-keys"));
|
|
8
|
+
const core_proto_ts_1 = require("@injectivelabs/core-proto-ts");
|
|
9
|
+
/**
|
|
10
|
+
* @category Messages
|
|
11
|
+
*/
|
|
12
|
+
class MsgTransferDelegation extends MsgBase_js_1.MsgBase {
|
|
13
|
+
static fromJSON(params) {
|
|
14
|
+
return new MsgTransferDelegation(params);
|
|
15
|
+
}
|
|
16
|
+
toProto() {
|
|
17
|
+
const { params } = this;
|
|
18
|
+
const coinAmount = core_proto_ts_1.CosmosBaseV1Beta1Coin.Coin.create();
|
|
19
|
+
coinAmount.denom = params.amount.denom;
|
|
20
|
+
coinAmount.amount = params.amount.amount;
|
|
21
|
+
const message = core_proto_ts_1.CosmosStakingV1Beta1Tx.MsgTransferDelegation.create();
|
|
22
|
+
message.delegatorAddress = params.injectiveAddress;
|
|
23
|
+
message.validatorAddress = params.validatorAddress;
|
|
24
|
+
message.receiverAddress = params.receiverAddress;
|
|
25
|
+
message.amount = coinAmount;
|
|
26
|
+
return core_proto_ts_1.CosmosStakingV1Beta1Tx.MsgTransferDelegation.fromPartial(message);
|
|
27
|
+
}
|
|
28
|
+
toData() {
|
|
29
|
+
const proto = this.toProto();
|
|
30
|
+
return {
|
|
31
|
+
'@type': '/cosmos.staking.v1beta1.MsgTransferDelegation',
|
|
32
|
+
...proto,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
toAmino() {
|
|
36
|
+
const proto = this.toProto();
|
|
37
|
+
const message = {
|
|
38
|
+
...(0, snakecase_keys_1.default)(proto),
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
type: 'cosmos-sdk/MsgTransferDelegation',
|
|
42
|
+
value: message,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
toWeb3Gw() {
|
|
46
|
+
const amino = this.toAmino();
|
|
47
|
+
const { value } = amino;
|
|
48
|
+
return {
|
|
49
|
+
'@type': '/cosmos.staking.v1beta1.MsgTransferDelegation',
|
|
50
|
+
...value,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
toDirectSign() {
|
|
54
|
+
const proto = this.toProto();
|
|
55
|
+
return {
|
|
56
|
+
type: '/cosmos.staking.v1beta1.MsgTransferDelegation',
|
|
57
|
+
message: proto,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
toBinary() {
|
|
61
|
+
return core_proto_ts_1.CosmosStakingV1Beta1Tx.MsgTransferDelegation.encode(this.toProto()).finish();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.default = MsgTransferDelegation;
|
|
@@ -62,13 +62,9 @@ class MsgExecuteContract extends MsgBase_js_1.MsgBase {
|
|
|
62
62
|
...value,
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
// 'EIP712_v1 is not supported for MsgExecuteContract. Please use EIP712_v2',
|
|
69
|
-
// ),
|
|
70
|
-
// )
|
|
71
|
-
// }
|
|
65
|
+
toEip712() {
|
|
66
|
+
throw new exceptions_1.GeneralException(new Error('EIP712_v1 is not supported for MsgExecuteContract. Please use EIP712_v2'));
|
|
67
|
+
}
|
|
72
68
|
toDirectSign() {
|
|
73
69
|
const proto = this.toProto();
|
|
74
70
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PrivateKey } from '../../accounts/index.js';
|
|
2
2
|
import { Msgs } from '../../modules/msgs.js';
|
|
3
|
-
import { ChainId,
|
|
3
|
+
import { ChainId, EvmChainId } from '@injectivelabs/ts-types';
|
|
4
4
|
import { Network, NetworkEndpoints } from '@injectivelabs/networks';
|
|
5
5
|
import { AccountDetails } from '../../../types/auth.js';
|
|
6
6
|
interface MsgBroadcasterTxOptions {
|
|
@@ -25,7 +25,7 @@ interface MsgBroadcasterWithPkOptions {
|
|
|
25
25
|
rest: string;
|
|
26
26
|
};
|
|
27
27
|
privateKey: string | PrivateKey;
|
|
28
|
-
|
|
28
|
+
evmChainId?: EvmChainId;
|
|
29
29
|
chainId?: ChainId;
|
|
30
30
|
simulateTx?: boolean;
|
|
31
31
|
loggingEnabled?: boolean;
|
|
@@ -45,7 +45,7 @@ interface MsgBroadcasterWithPkOptions {
|
|
|
45
45
|
export declare class MsgBroadcasterWithPk {
|
|
46
46
|
endpoints: NetworkEndpoints;
|
|
47
47
|
chainId: ChainId;
|
|
48
|
-
|
|
48
|
+
evmChainId?: EvmChainId;
|
|
49
49
|
privateKey: PrivateKey;
|
|
50
50
|
simulateTx: boolean;
|
|
51
51
|
txTimeoutOnFeeDelegation: boolean;
|
|
@@ -23,7 +23,7 @@ const index_js_5 = require("../../../json/index.js");
|
|
|
23
23
|
class MsgBroadcasterWithPk {
|
|
24
24
|
endpoints;
|
|
25
25
|
chainId;
|
|
26
|
-
|
|
26
|
+
evmChainId;
|
|
27
27
|
privateKey;
|
|
28
28
|
simulateTx = false;
|
|
29
29
|
txTimeoutOnFeeDelegation = false;
|
|
@@ -39,8 +39,7 @@ class MsgBroadcasterWithPk {
|
|
|
39
39
|
this.simulateTx = options.simulateTx || false;
|
|
40
40
|
this.chainId = options.chainId || networkInfo.chainId;
|
|
41
41
|
this.txTimeout = options.txTimeout || utils_1.DEFAULT_BLOCK_TIMEOUT_HEIGHT;
|
|
42
|
-
this.
|
|
43
|
-
options.ethereumChainId || networkInfo.ethereumChainId;
|
|
42
|
+
this.evmChainId = options.evmChainId || networkInfo.evmChainId;
|
|
44
43
|
this.endpoints = { ...endpoints, ...(options.endpoints || {}) };
|
|
45
44
|
this.privateKey =
|
|
46
45
|
options.privateKey instanceof index_js_1.PrivateKey
|
|
@@ -70,7 +69,7 @@ class MsgBroadcasterWithPk {
|
|
|
70
69
|
* @returns {string} transaction hash
|
|
71
70
|
*/
|
|
72
71
|
async broadcastWithFeeDelegation(transaction) {
|
|
73
|
-
const {
|
|
72
|
+
const { endpoints, txTimeout, simulateTx, privateKey, evmChainId, txTimeoutOnFeeDelegation, } = this;
|
|
74
73
|
const ethereumWallet = this.privateKey.toHex();
|
|
75
74
|
if (index_js_5.ofacWallets.includes(ethereumWallet)) {
|
|
76
75
|
throw new exceptions_1.GeneralException(new Error('You cannot execute this transaction'));
|
|
@@ -84,7 +83,7 @@ class MsgBroadcasterWithPk {
|
|
|
84
83
|
ethereumAddress: ethereumWallet,
|
|
85
84
|
};
|
|
86
85
|
const web3Msgs = msgs.map((msg) => msg.toWeb3());
|
|
87
|
-
if (!
|
|
86
|
+
if (!evmChainId) {
|
|
88
87
|
throw new exceptions_1.GeneralException(new Error('Please provide ethereumChainId'));
|
|
89
88
|
}
|
|
90
89
|
let timeoutHeight = undefined;
|
|
@@ -100,7 +99,7 @@ class MsgBroadcasterWithPk {
|
|
|
100
99
|
memo: tx.memo,
|
|
101
100
|
message: web3Msgs,
|
|
102
101
|
address: tx.ethereumAddress,
|
|
103
|
-
chainId:
|
|
102
|
+
chainId: evmChainId,
|
|
104
103
|
gasLimit: (0, msgs_js_1.getGasPriceBasedOnMessage)(msgs),
|
|
105
104
|
estimateGas: simulateTx || false,
|
|
106
105
|
timeoutHeight,
|
|
@@ -109,7 +108,7 @@ class MsgBroadcasterWithPk {
|
|
|
109
108
|
const response = await transactionApi.broadcastTxRequest({
|
|
110
109
|
txResponse,
|
|
111
110
|
message: web3Msgs,
|
|
112
|
-
chainId:
|
|
111
|
+
chainId: evmChainId,
|
|
113
112
|
signature: `0x${Buffer.from(signature).toString('hex')}`,
|
|
114
113
|
});
|
|
115
114
|
return await new TxGrpcApi_js_1.TxGrpcApi(endpoints.grpc).fetchTxPoll(response.txHash);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Msgs } from '../../modules/msgs.js';
|
|
2
|
-
import {
|
|
2
|
+
import { EvmChainId } from '@injectivelabs/ts-types';
|
|
3
3
|
import { Eip712ConvertFeeArgs, Eip712ConvertTxArgs } from './types.js';
|
|
4
|
-
export declare const getEip712TypedData: ({ msgs, tx, fee,
|
|
4
|
+
export declare const getEip712TypedData: ({ msgs, tx, fee, evmChainId, }: {
|
|
5
5
|
msgs: Msgs | Msgs[];
|
|
6
6
|
tx: Eip712ConvertTxArgs;
|
|
7
7
|
fee?: Eip712ConvertFeeArgs;
|
|
8
|
-
|
|
8
|
+
evmChainId: EvmChainId;
|
|
9
9
|
}) => {
|
|
10
10
|
message: {
|
|
11
11
|
msgs: {
|
|
@@ -57,11 +57,11 @@ export declare const getEip712TypedData: ({ msgs, tx, fee, ethereumChainId, }: {
|
|
|
57
57
|
}[];
|
|
58
58
|
};
|
|
59
59
|
};
|
|
60
|
-
export declare const getEip712TypedDataV2: ({ msgs, tx, fee,
|
|
60
|
+
export declare const getEip712TypedDataV2: ({ msgs, tx, fee, evmChainId, }: {
|
|
61
61
|
msgs: Msgs | Msgs[];
|
|
62
62
|
tx: Eip712ConvertTxArgs;
|
|
63
63
|
fee?: Eip712ConvertFeeArgs;
|
|
64
|
-
|
|
64
|
+
evmChainId: EvmChainId;
|
|
65
65
|
}) => {
|
|
66
66
|
message: {
|
|
67
67
|
context: string;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getEip712TypedDataV2 = exports.getEip712TypedData = void 0;
|
|
4
4
|
const utils_js_1 = require("./utils.js");
|
|
5
5
|
const utils_js_2 = require("./utils.js");
|
|
6
|
-
const getEip712TypedData = ({ msgs, tx, fee,
|
|
6
|
+
const getEip712TypedData = ({ msgs, tx, fee, evmChainId, }) => {
|
|
7
7
|
const messages = Array.isArray(msgs) ? msgs : [msgs];
|
|
8
8
|
const eip712Msgs = messages.map((m) => m.toEip712());
|
|
9
9
|
const eip712MessageTypes = messages[0].toEip712Types();
|
|
@@ -21,7 +21,7 @@ const getEip712TypedData = ({ msgs, tx, fee, ethereumChainId, }) => {
|
|
|
21
21
|
return {
|
|
22
22
|
...typesWithFeePayer,
|
|
23
23
|
primaryType: 'Tx',
|
|
24
|
-
...(0, utils_js_1.getEip712Domain)(
|
|
24
|
+
...(0, utils_js_1.getEip712Domain)(evmChainId),
|
|
25
25
|
message: {
|
|
26
26
|
...(0, utils_js_1.getEipTxDetails)(tx),
|
|
27
27
|
...(0, utils_js_1.getEip712Fee)(fee),
|
|
@@ -30,14 +30,14 @@ const getEip712TypedData = ({ msgs, tx, fee, ethereumChainId, }) => {
|
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
32
|
exports.getEip712TypedData = getEip712TypedData;
|
|
33
|
-
const getEip712TypedDataV2 = ({ msgs, tx, fee,
|
|
33
|
+
const getEip712TypedDataV2 = ({ msgs, tx, fee, evmChainId, }) => {
|
|
34
34
|
const messages = Array.isArray(msgs) ? msgs : [msgs];
|
|
35
35
|
const eip712Msgs = messages.map((m) => m.toEip712V2());
|
|
36
36
|
const types = (0, utils_js_1.getDefaultEip712TypesV2)();
|
|
37
37
|
return {
|
|
38
38
|
...types,
|
|
39
39
|
primaryType: 'Tx',
|
|
40
|
-
...(0, utils_js_1.getEip712DomainV2)(
|
|
40
|
+
...(0, utils_js_1.getEip712DomainV2)(evmChainId),
|
|
41
41
|
message: {
|
|
42
42
|
context: JSON.stringify((0, utils_js_2.getEipTxContext)({ ...tx, fee })),
|
|
43
43
|
msgs: JSON.stringify(eip712Msgs),
|
|
@@ -512,6 +512,8 @@ const protoTypeToAminoType = (type) => {
|
|
|
512
512
|
return 'cosmos-sdk/MsgUndelegate';
|
|
513
513
|
case 'cosmos.staking.v1beta1.MsgBeginRedelegate':
|
|
514
514
|
return 'cosmos-sdk/MsgBeginRedelegate';
|
|
515
|
+
case 'cosmos.staking.v1beta1.MsgTransferDelegation':
|
|
516
|
+
return 'cosmos-sdk/MsgTransferDelegation';
|
|
515
517
|
case 'cosmos.staking.v1beta1.MsgCancelUnbondingDelegation':
|
|
516
518
|
return 'cosmos-sdk/MsgCancelUnbondingDelegation';
|
|
517
519
|
case 'cosmos.staking.v1beta1.MsgUpdateParams':
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EvmChainId } from '@injectivelabs/ts-types';
|
|
2
2
|
import { Eip712ConvertFeeArgs, Eip712ConvertTxArgs } from './types.js';
|
|
3
|
-
export declare const getEip712Domain: (
|
|
3
|
+
export declare const getEip712Domain: (evmChainId: EvmChainId) => {
|
|
4
4
|
domain: {
|
|
5
5
|
name: string;
|
|
6
6
|
version: string;
|
|
@@ -9,7 +9,7 @@ export declare const getEip712Domain: (ethereumChainId: EthereumChainId) => {
|
|
|
9
9
|
verifyingContract: string;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
export declare const getEip712DomainV2: (
|
|
12
|
+
export declare const getEip712DomainV2: (evmChainId: EvmChainId) => {
|
|
13
13
|
domain: {
|
|
14
14
|
name: string;
|
|
15
15
|
version: string;
|
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getEipTxContext = exports.getEipTxDetails = exports.getTypesIncludingFeePayer = exports.getEip712FeeV2 = exports.getEip712Fee = exports.getDefaultEip712TypesV2 = exports.getDefaultEip712Types = exports.getEip712DomainV2 = exports.getEip712Domain = void 0;
|
|
4
4
|
const utils_1 = require("@injectivelabs/utils");
|
|
5
|
-
const getEip712Domain = (
|
|
5
|
+
const getEip712Domain = (evmChainId) => {
|
|
6
6
|
return {
|
|
7
7
|
domain: {
|
|
8
8
|
name: 'Injective Web3',
|
|
9
9
|
version: '1.0.0',
|
|
10
|
-
chainId: '0x' + new utils_1.BigNumberInBase(
|
|
10
|
+
chainId: '0x' + new utils_1.BigNumberInBase(evmChainId).toString(16),
|
|
11
11
|
salt: '0',
|
|
12
12
|
verifyingContract: 'cosmos',
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
exports.getEip712Domain = getEip712Domain;
|
|
17
|
-
const getEip712DomainV2 = (
|
|
17
|
+
const getEip712DomainV2 = (evmChainId) => {
|
|
18
18
|
return {
|
|
19
19
|
domain: {
|
|
20
20
|
name: 'Injective Web3',
|
|
21
21
|
version: '1.0.0',
|
|
22
|
-
chainId: '0x' + new utils_1.BigNumberInBase(
|
|
22
|
+
chainId: '0x' + new utils_1.BigNumberInBase(evmChainId).toString(16),
|
|
23
23
|
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
|
|
24
24
|
salt: '0',
|
|
25
25
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChainId,
|
|
1
|
+
import { ChainId, EvmChainId } from '@injectivelabs/ts-types';
|
|
2
2
|
import { Msgs } from '../../modules/msgs.js';
|
|
3
3
|
import { GoogleProtobufAny, CosmosTxV1Beta1Tx, InjectiveTypesV1Beta1TxExt, CosmosTxSigningV1Beta1Signing } from '@injectivelabs/core-proto-ts';
|
|
4
4
|
export declare const getPublicKey: ({ chainId, key, }: {
|
|
@@ -49,8 +49,8 @@ export declare const createSignDocFromTransaction: (args: {
|
|
|
49
49
|
accountNumber: number;
|
|
50
50
|
}) => CosmosTxV1Beta1Tx.SignDoc;
|
|
51
51
|
export declare const createTxRawEIP712: (txRaw: CosmosTxV1Beta1Tx.TxRaw, extension: InjectiveTypesV1Beta1TxExt.ExtensionOptionsWeb3Tx, nonCriticalExtension?: GoogleProtobufAny.Any | GoogleProtobufAny.Any[]) => CosmosTxV1Beta1Tx.TxRaw;
|
|
52
|
-
export declare const createWeb3Extension: ({
|
|
53
|
-
|
|
52
|
+
export declare const createWeb3Extension: ({ evmChainId, feePayer, feePayerSig, }: {
|
|
53
|
+
evmChainId: EvmChainId;
|
|
54
54
|
feePayer?: string;
|
|
55
55
|
feePayerSig?: Uint8Array;
|
|
56
56
|
}) => InjectiveTypesV1Beta1TxExt.ExtensionOptionsWeb3Tx;
|
|
@@ -120,9 +120,9 @@ const createTxRawEIP712 = (txRaw, extension, nonCriticalExtension) => {
|
|
|
120
120
|
return txRaw;
|
|
121
121
|
};
|
|
122
122
|
exports.createTxRawEIP712 = createTxRawEIP712;
|
|
123
|
-
const createWeb3Extension = ({
|
|
123
|
+
const createWeb3Extension = ({ evmChainId, feePayer, feePayerSig, }) => {
|
|
124
124
|
const web3Extension = core_proto_ts_1.InjectiveTypesV1Beta1TxExt.ExtensionOptionsWeb3Tx.create();
|
|
125
|
-
web3Extension.typedDataChainID =
|
|
125
|
+
web3Extension.typedDataChainID = evmChainId.toString();
|
|
126
126
|
if (feePayer) {
|
|
127
127
|
web3Extension.feePayer = feePayer;
|
|
128
128
|
}
|
package/dist/cjs/utils/grpc.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as grpcPkg from '@injectivelabs/grpc-web';
|
|
2
2
|
declare const grpc: typeof grpcPkg.grpc;
|
|
3
|
-
export declare const getGrpcTransport: () =>
|
|
3
|
+
export declare const getGrpcTransport: () => grpcPkg.grpc.TransportFactory;
|
|
4
4
|
export { grpc, grpcPkg };
|
|
@@ -19,4 +19,4 @@ export declare const fetchAllWithPagination: <T extends {
|
|
|
19
19
|
pagination: PaginationOption | undefined;
|
|
20
20
|
} | PaginationOption | undefined, Q extends {
|
|
21
21
|
pagination: Pagination;
|
|
22
|
-
}>(args: T, method: (args: T) => Promise<Q>) => Promise<Q>;
|
|
22
|
+
}>(args: T, method: (args: T) => Promise<Q>, result?: Array<unknown>) => Promise<Q>;
|
|
@@ -97,24 +97,17 @@ const grpcPagingToPaging = (pagination) => {
|
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
99
|
exports.grpcPagingToPaging = grpcPagingToPaging;
|
|
100
|
-
const fetchAllWithPagination = async (args, method) => {
|
|
101
|
-
let result = [];
|
|
100
|
+
const fetchAllWithPagination = async (args, method, result = []) => {
|
|
102
101
|
let response = await method(args);
|
|
103
102
|
if (!args) {
|
|
104
103
|
return response;
|
|
105
104
|
}
|
|
106
|
-
const paginationOption = args.pagination;
|
|
107
|
-
if (!paginationOption) {
|
|
108
|
-
return response;
|
|
109
|
-
}
|
|
110
105
|
const keys = Object.keys(response);
|
|
111
106
|
const valueKey = keys.find((key) => key !== 'pagination');
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
pagination: { ...paginationOption, key: response.pagination.next },
|
|
117
|
-
});
|
|
107
|
+
result.push(...response[valueKey]);
|
|
108
|
+
const paginationOption = args;
|
|
109
|
+
if (response.pagination.next) {
|
|
110
|
+
return (0, exports.fetchAllWithPagination)({ ...paginationOption, key: response.pagination.next }, method, result);
|
|
118
111
|
}
|
|
119
112
|
return { [valueKey]: result, pagination: response.pagination };
|
|
120
113
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { AccountAddress,
|
|
1
|
+
import { AccountAddress, EvmChainId } from '@injectivelabs/ts-types';
|
|
2
2
|
import { InjectiveExchangeRpc } from '@injectivelabs/indexer-proto-ts';
|
|
3
3
|
import { CosmosTxV1Beta1Tx } from '@injectivelabs/core-proto-ts';
|
|
4
4
|
import BaseGrpcConsumer from '../../base/BaseIndexerGrpcConsumer.js';
|
|
5
5
|
interface PrepareTxArgs {
|
|
6
6
|
address: AccountAddress;
|
|
7
|
-
chainId:
|
|
7
|
+
chainId: EvmChainId;
|
|
8
8
|
message: any;
|
|
9
9
|
estimateGas?: boolean;
|
|
10
10
|
gasLimit?: number;
|
|
@@ -41,7 +41,7 @@ export declare class IndexerGrpcTransactionApi extends BaseGrpcConsumer {
|
|
|
41
41
|
*/
|
|
42
42
|
broadcastTxRequest({ signature, chainId, message, txResponse, }: {
|
|
43
43
|
signature: string;
|
|
44
|
-
chainId:
|
|
44
|
+
chainId: EvmChainId;
|
|
45
45
|
useCorrectEIP712Hash?: boolean;
|
|
46
46
|
txResponse: InjectiveExchangeRpc.PrepareTxResponse;
|
|
47
47
|
message: Record<string, any>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountAddress,
|
|
1
|
+
import { AccountAddress, EvmChainId } from '@injectivelabs/ts-types';
|
|
2
2
|
import { InjectiveExchangeRpc } from '@injectivelabs/indexer-proto-ts';
|
|
3
3
|
import { IndexerGrpcTransactionApi } from './IndexerGrpcTransactionApi.js';
|
|
4
4
|
/**
|
|
@@ -9,7 +9,7 @@ export declare class IndexerGrpcWeb3GwApi extends IndexerGrpcTransactionApi {
|
|
|
9
9
|
constructor(endpoint: string);
|
|
10
10
|
prepareEip712Request({ address, chainId, message, memo, sequence, accountNumber, estimateGas, gasLimit, feeDenom, feePrice, timeoutHeight, eip712Version, }: {
|
|
11
11
|
address: AccountAddress;
|
|
12
|
-
chainId:
|
|
12
|
+
chainId: EvmChainId;
|
|
13
13
|
message: any;
|
|
14
14
|
estimateGas?: boolean;
|
|
15
15
|
gasLimit?: number;
|