@firmachain/firma-js 0.2.64 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/sdk/FirmaAuthzService.d.ts +8 -8
- package/dist/sdk/FirmaAuthzService.js +12 -6
- package/dist/sdk/FirmaBankService.d.ts +4 -4
- package/dist/sdk/FirmaContractService.d.ts +4 -4
- package/dist/sdk/FirmaCosmWasmCw20.d.ts +14 -14
- package/dist/sdk/FirmaCosmWasmCw721.d.ts +14 -14
- package/dist/sdk/FirmaCosmWasmCwBridge.d.ts +9 -9
- package/dist/sdk/FirmaCosmWasmCwMarketplace.d.ts +8 -8
- package/dist/sdk/FirmaCosmWasmService.d.ts +8 -8
- package/dist/sdk/FirmaCosmWasmService.js +2 -3
- package/dist/sdk/FirmaDistributionService.d.ts +6 -6
- package/dist/sdk/FirmaFeeGrantService.d.ts +4 -4
- package/dist/sdk/FirmaGovService.d.ts +27 -16
- package/dist/sdk/FirmaGovService.js +305 -195
- package/dist/sdk/FirmaIbcService.d.ts +3 -4
- package/dist/sdk/FirmaIbcService.js +5 -2
- package/dist/sdk/FirmaNftService.d.ts +5 -5
- package/dist/sdk/FirmaStakingService.d.ts +6 -6
- package/dist/sdk/FirmaTokenService.d.ts +5 -5
- package/dist/sdk/FirmaUtil.d.ts +1 -1
- package/dist/sdk/FirmaUtil.js +12 -14
- package/dist/sdk/firmachain/amino/addresses.js +1 -1
- package/dist/sdk/firmachain/amino/aminomsgs.d.ts +10 -0
- package/dist/sdk/firmachain/amino/aminomsgs.js +5 -1
- package/dist/sdk/firmachain/amino/aminotypes.js +27 -10
- package/dist/sdk/firmachain/amino/coins.d.ts +14 -2
- package/dist/sdk/firmachain/amino/coins.js +26 -5
- package/dist/sdk/firmachain/amino/encoding.d.ts +10 -1
- package/dist/sdk/firmachain/amino/encoding.js +21 -3
- package/dist/sdk/firmachain/amino/signdoc.d.ts +21 -3
- package/dist/sdk/firmachain/amino/signdoc.js +37 -11
- package/dist/sdk/firmachain/amino/signer.d.ts +2 -1
- package/dist/sdk/firmachain/authz/AuthzTxTypes.d.ts +7 -6
- package/dist/sdk/firmachain/authz/AuthzTxTypes.js +7 -6
- package/dist/sdk/firmachain/bank/BankQueryClient.js +1 -1
- package/dist/sdk/firmachain/common/CommonTxClient.js +11 -9
- package/dist/sdk/firmachain/common/ITxClient.d.ts +6 -6
- package/dist/sdk/firmachain/common/ITxClient.js +82 -24
- package/dist/sdk/firmachain/common/LedgerSigningStargateClient.d.ts +4 -9
- package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +37 -32
- package/dist/sdk/firmachain/common/LedgerWallet.js +4 -8
- package/dist/sdk/firmachain/common/TxCommon.d.ts +1 -2
- package/dist/sdk/firmachain/common/accounts.d.ts +7 -3
- package/dist/sdk/firmachain/common/accounts.js +28 -33
- package/dist/sdk/firmachain/common/aminotypes.d.ts +19 -0
- package/dist/sdk/firmachain/common/aminotypes.js +74 -0
- package/dist/sdk/firmachain/common/events.d.ts +32 -0
- package/dist/sdk/firmachain/common/events.js +18 -0
- package/dist/sdk/firmachain/common/fee.d.ts +26 -0
- package/dist/sdk/firmachain/common/fee.js +83 -0
- package/dist/sdk/firmachain/common/index.d.ts +1 -0
- package/dist/sdk/firmachain/common/index.js +3 -0
- package/dist/sdk/firmachain/common/modules/auth/queries.d.ts +15 -0
- package/dist/sdk/firmachain/common/modules/auth/queries.js +64 -0
- package/dist/sdk/firmachain/common/modules/authz/aminomessages.d.ts +2 -0
- package/dist/sdk/firmachain/common/modules/authz/aminomessages.js +15 -0
- package/dist/sdk/firmachain/common/modules/authz/messages.d.ts +2 -0
- package/dist/sdk/firmachain/common/modules/authz/messages.js +9 -0
- package/dist/sdk/firmachain/common/modules/authz/queries.d.ts +10 -0
- package/dist/sdk/firmachain/common/modules/authz/queries.js +88 -0
- package/dist/sdk/firmachain/common/modules/bank/aminomessages.d.ts +35 -0
- package/dist/sdk/firmachain/common/modules/bank/aminomessages.js +85 -0
- package/dist/sdk/firmachain/common/modules/bank/messages.d.ts +8 -0
- package/dist/sdk/firmachain/common/modules/bank/messages.js +12 -0
- package/dist/sdk/firmachain/common/modules/bank/queries.d.ts +15 -0
- package/dist/sdk/firmachain/common/modules/bank/queries.js +128 -0
- package/dist/sdk/firmachain/common/modules/crisis/aminomessages.d.ts +14 -0
- package/dist/sdk/firmachain/common/modules/crisis/aminomessages.js +11 -0
- package/dist/sdk/firmachain/common/modules/distribution/aminomessages.d.ts +44 -0
- package/dist/sdk/firmachain/common/modules/distribution/aminomessages.js +113 -0
- package/dist/sdk/firmachain/common/modules/distribution/messages.d.ts +8 -0
- package/dist/sdk/firmachain/common/modules/distribution/messages.js +15 -0
- package/dist/sdk/firmachain/common/modules/distribution/queries.d.ts +16 -0
- package/dist/sdk/firmachain/common/modules/distribution/queries.js +171 -0
- package/dist/sdk/firmachain/common/modules/evidence/aminomessages.d.ts +18 -0
- package/dist/sdk/firmachain/common/modules/evidence/aminomessages.js +11 -0
- package/dist/sdk/firmachain/common/modules/feegrant/aminomessages.d.ts +2 -0
- package/dist/sdk/firmachain/common/modules/feegrant/aminomessages.js +14 -0
- package/dist/sdk/firmachain/common/modules/feegrant/messages.d.ts +2 -0
- package/dist/sdk/firmachain/common/modules/feegrant/messages.js +8 -0
- package/dist/sdk/firmachain/common/modules/feegrant/queries.d.ts +9 -0
- package/dist/sdk/firmachain/common/modules/feegrant/queries.js +81 -0
- package/dist/sdk/firmachain/common/modules/gov/aminomessages.d.ts +79 -0
- package/dist/sdk/firmachain/common/modules/gov/aminomessages.js +152 -0
- package/dist/sdk/firmachain/common/modules/gov/messages.d.ts +29 -0
- package/dist/sdk/firmachain/common/modules/gov/messages.js +38 -0
- package/dist/sdk/firmachain/common/modules/gov/queries.d.ts +19 -0
- package/dist/sdk/firmachain/common/modules/gov/queries.js +160 -0
- package/dist/sdk/firmachain/common/modules/group/aminomessages.d.ts +2 -0
- package/dist/sdk/firmachain/common/modules/group/aminomessages.js +8 -0
- package/dist/sdk/firmachain/common/modules/group/messages.d.ts +2 -0
- package/dist/sdk/firmachain/common/modules/group/messages.js +28 -0
- package/dist/sdk/firmachain/common/modules/ibc/aminomessages.d.ts +38 -0
- package/dist/sdk/firmachain/common/modules/ibc/aminomessages.js +55 -0
- package/dist/sdk/firmachain/common/modules/ibc/messages.d.ts +8 -0
- package/dist/sdk/firmachain/common/modules/ibc/messages.js +32 -0
- package/dist/sdk/firmachain/common/modules/ibc/queries.d.ts +58 -0
- package/dist/sdk/firmachain/common/modules/ibc/queries.js +576 -0
- package/dist/sdk/firmachain/common/modules/index.d.ts +32 -0
- package/dist/sdk/firmachain/common/modules/index.js +101 -0
- package/dist/sdk/firmachain/common/modules/mint/queries.d.ts +21 -0
- package/dist/sdk/firmachain/common/modules/mint/queries.js +95 -0
- package/dist/sdk/firmachain/common/modules/slashing/aminomessages.d.ts +12 -0
- package/dist/sdk/firmachain/common/modules/slashing/aminomessages.js +11 -0
- package/dist/sdk/firmachain/common/modules/slashing/queries.d.ts +10 -0
- package/dist/sdk/firmachain/common/modules/slashing/queries.js +88 -0
- package/dist/sdk/firmachain/common/modules/staking/aminomessages.d.ts +112 -0
- package/dist/sdk/firmachain/common/modules/staking/aminomessages.js +234 -0
- package/dist/sdk/firmachain/common/modules/staking/messages.d.ts +33 -0
- package/dist/sdk/firmachain/common/modules/staking/messages.js +37 -0
- package/dist/sdk/firmachain/common/modules/staking/queries.d.ts +23 -0
- package/dist/sdk/firmachain/common/modules/staking/queries.js +242 -0
- package/dist/sdk/firmachain/common/modules/tx/queries.d.ts +11 -0
- package/dist/sdk/firmachain/common/modules/tx/queries.js +103 -0
- package/dist/sdk/firmachain/common/modules/vesting/aminomessages.d.ts +16 -0
- package/dist/sdk/firmachain/common/modules/vesting/aminomessages.js +56 -0
- package/dist/sdk/firmachain/common/modules/vesting/messages.d.ts +2 -0
- package/dist/sdk/firmachain/common/modules/vesting/messages.js +7 -0
- package/dist/sdk/firmachain/common/queryclient/index.d.ts +2 -0
- package/dist/sdk/firmachain/common/queryclient/index.js +10 -0
- package/dist/sdk/firmachain/common/queryclient/queryclient.d.ts +75 -0
- package/dist/sdk/firmachain/common/queryclient/queryclient.js +157 -0
- package/dist/sdk/firmachain/common/queryclient/utils.d.ts +33 -0
- package/dist/sdk/firmachain/common/queryclient/utils.js +101 -0
- package/dist/sdk/firmachain/common/search.d.ts +10 -0
- package/dist/sdk/firmachain/common/search.js +7 -0
- package/dist/sdk/firmachain/common/signing.d.ts +8 -3
- package/dist/sdk/firmachain/common/signing.js +24 -12
- package/dist/sdk/firmachain/common/signingstargateclient.d.ts +107 -30
- package/dist/sdk/firmachain/common/signingstargateclient.js +445 -128
- package/dist/sdk/firmachain/common/stargateclient.d.ts +184 -20
- package/dist/sdk/firmachain/common/stargateclient.js +351 -35
- package/dist/sdk/firmachain/contract/ContractTxClient.d.ts +2 -2
- package/dist/sdk/firmachain/contract/ContractTxClient.js +4 -4
- package/dist/sdk/firmachain/contract/ContractTxTypes.d.ts +1 -1
- package/dist/sdk/firmachain/contract/ContractTxTypes.js +3 -3
- package/dist/sdk/firmachain/cosmwasm/CosmWasmQueryClient.js +1 -1
- package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.d.ts +5 -5
- package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.js +10 -8
- package/dist/sdk/firmachain/google/protobuf/any.d.ts +3 -2
- package/dist/sdk/firmachain/google/protobuf/any.js +2 -1
- package/dist/sdk/firmachain/google/protobuf/duration.d.ts +3 -2
- package/dist/sdk/firmachain/google/protobuf/duration.js +2 -1
- package/dist/sdk/firmachain/google/protobuf/timestamp.d.ts +3 -2
- package/dist/sdk/firmachain/google/protobuf/timestamp.js +2 -1
- package/dist/sdk/firmachain/gov/GovQueryClient.d.ts +13 -1
- package/dist/sdk/firmachain/gov/GovQueryClient.js +9 -2
- package/dist/sdk/firmachain/gov/GovTxClient.d.ts +12 -0
- package/dist/sdk/firmachain/gov/GovTxClient.js +11 -1
- package/dist/sdk/firmachain/nft/NftTxClient.d.ts +3 -3
- package/dist/sdk/firmachain/nft/NftTxClient.js +6 -6
- package/dist/sdk/firmachain/nft/NftTxTypes.d.ts +1 -1
- package/dist/sdk/firmachain/nft/NftTxTypes.js +4 -4
- package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +1 -0
- package/dist/sdk/firmachain/staking/StakingQueryClient.js +0 -1
- package/dist/sdk/firmachain/token/TokenTxClient.d.ts +4 -4
- package/dist/sdk/firmachain/token/TokenTxClient.js +8 -8
- package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +1 -1
- package/dist/sdk/firmachain/token/TokenTxTypes.js +5 -5
- package/dist/test/00.wallet.test.js +15 -9
- package/dist/test/01.contract_tx.test.js +53 -45
- package/dist/test/02.contract_query.test.js +54 -31
- package/dist/test/03.contract_scenario.test.js +170 -326
- package/dist/test/04.bank_tx.test.js +58 -59
- package/dist/test/05.bank_query.test.js +51 -56
- package/dist/test/06.feegrant_tx.test.js +74 -89
- package/dist/test/07.feegrant_query.test.js +69 -27
- package/dist/test/08.gas_estimate.test.js +422 -392
- package/dist/test/09.ipfs.test.js +3 -3
- package/dist/test/10.nft_tx.test.js +108 -76
- package/dist/test/11.nft_query.test.js +41 -46
- package/dist/test/12.staking_tx.test.js +81 -98
- package/dist/test/13.staking_query.test.js +66 -12
- package/dist/test/14.distribution_tx.test.js +69 -78
- package/dist/test/15.distribution_query.test.js +81 -57
- package/dist/test/16.gov_tx.test.js +247 -107
- package/dist/test/17.gov_query.test.js +48 -9
- package/dist/test/18.util.test.js +6 -1
- package/dist/test/19.chain.test.js +50 -4
- package/dist/test/20.slashing_query.test.js +31 -1
- package/dist/test/21.token_tx.test.js +48 -56
- package/dist/test/22.token_query.test.js +24 -20
- package/dist/test/23.authz_tx.test.js +119 -240
- package/dist/test/24.authz_query.test.js +116 -56
- package/dist/test/25.cosmwasm_tx.test.js +95 -57
- package/dist/test/26.cosmwasm_query.test.js +66 -26
- package/dist/test/27.arbitary_sign.test.js +59 -67
- package/dist/test/28.ibc_tx.test.js +29 -17
- package/dist/test/29.mint_query.test.js +2 -0
- package/dist/test/30.cw20_tx.test.js +161 -226
- package/dist/test/31.cw20_query.test.js +183 -37
- package/dist/test/32.cw721_tx.test.js +147 -149
- package/dist/test/33.cw721_query.test.js +188 -36
- package/dist/test/34.cw_bridge_tx.test.js +266 -155
- package/dist/test/35.cw_bridge_tx_low.test.js +221 -81
- package/dist/test/36.cw_bridge_query.test.js +157 -21
- package/dist/test/37.cw_marketplace_tx.test.js +22 -22
- package/dist/test/38.cw_marketplace_query.test.js +9 -9
- package/dist/test/config_test.d.ts +10 -4
- package/dist/test/config_test.js +16 -9
- package/dist/test/config_test.sample.d.ts +11 -0
- package/dist/test/config_test.sample.js +14 -0
- package/package.json +9 -7
- package/dist/sdk/firmachain/common/signingaminostargateclient.d.ts +0 -50
- package/dist/sdk/firmachain/common/signingaminostargateclient.js +0 -267
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { FirmaWalletService } from "./FirmaWalletService";
|
|
2
2
|
import { FirmaConfig } from "./FirmaConfig";
|
|
3
|
-
import {
|
|
3
|
+
import { DeliverTxResponse } from "./firmachain/common/stargateclient";
|
|
4
4
|
import { ClientState, IbcTxClient, TxMisc } from "./firmachain/ibc";
|
|
5
|
-
import Long from "long";
|
|
6
5
|
import { Height } from "cosmjs-types/ibc/core/client/v1/client";
|
|
7
6
|
export declare class FirmaIbcService {
|
|
8
7
|
private readonly config;
|
|
9
8
|
constructor(config: FirmaConfig);
|
|
10
9
|
getTxClient(wallet: FirmaWalletService): IbcTxClient;
|
|
11
|
-
getGasEstimationTransfer(wallet: FirmaWalletService, sourcePort: string, sourceChannel: string, denom: string, amount: string, receiver: string, timeoutHeight: Height, timeoutTimestamp:
|
|
12
|
-
transfer(wallet: FirmaWalletService, sourcePort: string, sourceChannel: string, denom: string, amount: string, receiver: string, timeoutHeight: Height, timeoutTimestamp:
|
|
10
|
+
getGasEstimationTransfer(wallet: FirmaWalletService, sourcePort: string, sourceChannel: string, denom: string, amount: string, receiver: string, timeoutHeight: Height, timeoutTimestamp: bigint, txMisc?: TxMisc): Promise<number>;
|
|
11
|
+
transfer(wallet: FirmaWalletService, sourcePort: string, sourceChannel: string, denom: string, amount: string, receiver: string, timeoutHeight: Height, timeoutTimestamp: bigint, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
13
12
|
private getSignedTxTransfer;
|
|
14
13
|
getClientState(sourceChannel: string, sourcePort: string): Promise<ClientState>;
|
|
15
14
|
}
|
|
@@ -102,9 +102,12 @@ var FirmaIbcService = /** @class */ (function () {
|
|
|
102
102
|
return [4 /*yield*/, wallet.getAddress()];
|
|
103
103
|
case 1:
|
|
104
104
|
address = _a.sent();
|
|
105
|
-
message = ibc_1.IbcTxClient.msgTransfer({
|
|
105
|
+
message = ibc_1.IbcTxClient.msgTransfer({
|
|
106
|
+
sourcePort: sourcePort, sourceChannel: sourceChannel, sender: address, receiver: receiver,
|
|
106
107
|
token: { denom: denom, amount: amount },
|
|
107
|
-
timeoutHeight: timeoutHeight, timeoutTimestamp: timeoutTimestamp
|
|
108
|
+
timeoutHeight: timeoutHeight, timeoutTimestamp: timeoutTimestamp,
|
|
109
|
+
memo: ""
|
|
110
|
+
});
|
|
108
111
|
ibcTxClient = new ibc_1.IbcTxClient(wallet, this.config.rpcAddress);
|
|
109
112
|
return [4 /*yield*/, ibcTxClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
|
|
110
113
|
case 2: return [2 /*return*/, _a.sent()];
|
|
@@ -2,7 +2,7 @@ import { NftItemType, Pagination, TxMisc } from "./firmachain/nft";
|
|
|
2
2
|
import { FirmaConfig } from "./FirmaConfig";
|
|
3
3
|
import { FirmaWalletService } from "./FirmaWalletService";
|
|
4
4
|
import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
|
|
5
|
-
import {
|
|
5
|
+
import { DeliverTxResponse } from "./firmachain/common/stargateclient";
|
|
6
6
|
import { EncodeObject } from "@cosmjs/proto-signing";
|
|
7
7
|
export declare class NftService {
|
|
8
8
|
private readonly config;
|
|
@@ -24,15 +24,15 @@ export declare class NftService {
|
|
|
24
24
|
getGasEstimationTransfer(wallet: FirmaWalletService, toAddress: string, nftID: string, txMisc?: TxMisc): Promise<number>;
|
|
25
25
|
getUnsignedTxTransfer(wallet: FirmaWalletService, toAddress: string, nftID: string): Promise<EncodeObject>;
|
|
26
26
|
getSignedTxTransfer(wallet: FirmaWalletService, toAddress: string, nftID: string, txMisc?: TxMisc): Promise<TxRaw>;
|
|
27
|
-
transfer(wallet: FirmaWalletService, toAddress: string, nftID: string, txMisc?: TxMisc): Promise<
|
|
27
|
+
transfer(wallet: FirmaWalletService, toAddress: string, nftID: string, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
28
28
|
getGasEstimationBurn(wallet: FirmaWalletService, nftID: string, txMisc?: TxMisc): Promise<number>;
|
|
29
29
|
getUnsignedTxBurn(wallet: FirmaWalletService, nftID: string): Promise<EncodeObject>;
|
|
30
30
|
getSignedTxBurn(wallet: FirmaWalletService, nftID: string, txMisc?: TxMisc): Promise<TxRaw>;
|
|
31
|
-
burn(wallet: FirmaWalletService, nftID: string, txMisc?: TxMisc): Promise<
|
|
31
|
+
burn(wallet: FirmaWalletService, nftID: string, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
32
32
|
getGasEstimationFromEncodeObject(wallet: FirmaWalletService, msgList: EncodeObject[], txMisc?: TxMisc): Promise<number>;
|
|
33
33
|
getGasEstimationMint(wallet: FirmaWalletService, tokenURI: string, txMisc?: TxMisc): Promise<number>;
|
|
34
34
|
getSignedTxMint(wallet: FirmaWalletService, tokenURI: string, txMisc?: TxMisc): Promise<TxRaw>;
|
|
35
35
|
getUnsignedTxMint(wallet: FirmaWalletService, tokenURI: string): Promise<EncodeObject>;
|
|
36
|
-
mint(wallet: FirmaWalletService, tokenURI: string, txMisc?: TxMisc): Promise<
|
|
37
|
-
signAndBroadcast(wallet: FirmaWalletService, msgList: EncodeObject[], txMisc?: TxMisc): Promise<
|
|
36
|
+
mint(wallet: FirmaWalletService, tokenURI: string, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
37
|
+
signAndBroadcast(wallet: FirmaWalletService, msgList: EncodeObject[], txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
38
38
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StakingTxClient, TxMisc, ValidatorDataType, PoolDataType, ParamsDataType, DelegationInfo, RedelegationInfo, UndelegationInfo, Pagination } from "./firmachain/staking";
|
|
2
2
|
import { FirmaWalletService } from "./FirmaWalletService";
|
|
3
3
|
import { FirmaConfig } from "./FirmaConfig";
|
|
4
|
-
import {
|
|
4
|
+
import { DeliverTxResponse } from "./firmachain/common/stargateclient";
|
|
5
5
|
import { Description } from "cosmjs-types/cosmos/staking/v1beta1/staking";
|
|
6
6
|
import { MsgCreateValidator } from "cosmjs-types/cosmos/staking/v1beta1/tx";
|
|
7
7
|
export declare enum StakingValidatorStatus {
|
|
@@ -22,11 +22,11 @@ export declare class FirmaStakingService {
|
|
|
22
22
|
private getSignedTxRedelegate;
|
|
23
23
|
private getSignedTxCreateValidator;
|
|
24
24
|
private getSignedTxEditValidator;
|
|
25
|
-
createValidator(wallet: FirmaWalletService, validatorInfo: MsgCreateValidator, txMisc?: TxMisc): Promise<
|
|
26
|
-
editValidator(wallet: FirmaWalletService, validatorAddress: string, description: Description, commissionRate: string, minSelfDelegation: string, txMisc?: TxMisc): Promise<
|
|
27
|
-
redelegate(wallet: FirmaWalletService, validatorSrcAddress: string, validatorDstAddress: string, amount: number, txMisc?: TxMisc): Promise<
|
|
28
|
-
undelegate(wallet: FirmaWalletService, targetAddress: string, amount: number, txMisc?: TxMisc): Promise<
|
|
29
|
-
delegate(wallet: FirmaWalletService, targetAddress: string, amount: number, txMisc?: TxMisc): Promise<
|
|
25
|
+
createValidator(wallet: FirmaWalletService, validatorInfo: MsgCreateValidator, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
26
|
+
editValidator(wallet: FirmaWalletService, validatorAddress: string, description: Description, commissionRate: string, minSelfDelegation: string, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
27
|
+
redelegate(wallet: FirmaWalletService, validatorSrcAddress: string, validatorDstAddress: string, amount: number, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
28
|
+
undelegate(wallet: FirmaWalletService, targetAddress: string, amount: number, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
29
|
+
delegate(wallet: FirmaWalletService, targetAddress: string, amount: number, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
30
30
|
getUndelegationInfoFromValidator(address: string, validatorAddress: string): Promise<UndelegationInfo>;
|
|
31
31
|
getDelegationInfoFromValidator(address: string, validatorAddress: string): Promise<DelegationInfo>;
|
|
32
32
|
getTotalUndelegateInfo(address: string): Promise<UndelegationInfo[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TxMisc, TokenDataType, Pagination } from "./firmachain/token";
|
|
2
2
|
import { FirmaConfig } from "./FirmaConfig";
|
|
3
3
|
import { FirmaWalletService } from "./FirmaWalletService";
|
|
4
|
-
import {
|
|
4
|
+
import { DeliverTxResponse } from "./firmachain/common/stargateclient";
|
|
5
5
|
export declare class TokenService {
|
|
6
6
|
private readonly config;
|
|
7
7
|
constructor(config: FirmaConfig);
|
|
@@ -13,10 +13,10 @@ export declare class TokenService {
|
|
|
13
13
|
private getSignedTxBurn;
|
|
14
14
|
private getSignedTxMint;
|
|
15
15
|
private getSignedTxCreateToken;
|
|
16
|
-
createToken(wallet: FirmaWalletService, tokenName: string, tokenSymbol: string, tokenURI: string, totalSupply: number, decimal: number, isMintable: boolean, isBurnable: boolean, txMisc?: TxMisc): Promise<
|
|
17
|
-
mint(wallet: FirmaWalletService, tokenID: string, amount: number, decimal: number, toAddress: string, txMisc?: TxMisc): Promise<
|
|
18
|
-
burn(wallet: FirmaWalletService, tokenID: string, amount: number, decimal: number, txMisc?: TxMisc): Promise<
|
|
19
|
-
updateTokenURI(wallet: FirmaWalletService, tokenID: string, tokenURI: string, txMisc?: TxMisc): Promise<
|
|
16
|
+
createToken(wallet: FirmaWalletService, tokenName: string, tokenSymbol: string, tokenURI: string, totalSupply: number, decimal: number, isMintable: boolean, isBurnable: boolean, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
17
|
+
mint(wallet: FirmaWalletService, tokenID: string, amount: number, decimal: number, toAddress: string, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
18
|
+
burn(wallet: FirmaWalletService, tokenID: string, amount: number, decimal: number, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
19
|
+
updateTokenURI(wallet: FirmaWalletService, tokenID: string, tokenURI: string, txMisc?: TxMisc): Promise<DeliverTxResponse>;
|
|
20
20
|
getTokenDataAll(paginationKey?: string): Promise<{
|
|
21
21
|
dataList: TokenDataType[];
|
|
22
22
|
pagination: Pagination;
|
package/dist/sdk/FirmaUtil.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { SignDoc, TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
|
|
|
2
2
|
import { FirmaConfig } from "./FirmaConfig";
|
|
3
3
|
import { SignerData } from "./firmachain/common/LedgerSigningStargateClient";
|
|
4
4
|
import { SignAndBroadcastOptions, TxMisc } from "./firmachain/common";
|
|
5
|
-
import { ArbitraryVerifyData } from "./firmachain/common/signingaminostargateclient";
|
|
6
5
|
import { EncodeObject, Registry } from "@cosmjs/proto-signing";
|
|
7
6
|
import { FirmaWalletService } from "./FirmaWalletService";
|
|
7
|
+
import { ArbitraryVerifyData } from "./firmachain/common/signingstargateclient";
|
|
8
8
|
import { Any } from "./firmachain/google/protobuf/any";
|
|
9
9
|
import { CommonTxClient } from "./firmachain/common/CommonTxClient";
|
|
10
10
|
export declare class FirmaUtil {
|
package/dist/sdk/FirmaUtil.js
CHANGED
|
@@ -80,7 +80,6 @@ var LedgerSigningStargateClient_1 = require("./firmachain/common/LedgerSigningSt
|
|
|
80
80
|
var encoding_2 = require("@cosmjs/encoding");
|
|
81
81
|
var crypto_1 = require("@cosmjs/crypto");
|
|
82
82
|
var amino_1 = require("@cosmjs/amino");
|
|
83
|
-
var signingaminostargateclient_1 = require("./firmachain/common/signingaminostargateclient");
|
|
84
83
|
var proto_signing_1 = require("@cosmjs/proto-signing");
|
|
85
84
|
var signingstargateclient_1 = require("./firmachain/common/signingstargateclient");
|
|
86
85
|
var any_1 = require("./firmachain/google/protobuf/any");
|
|
@@ -200,7 +199,7 @@ var FirmaUtil = /** @class */ (function () {
|
|
|
200
199
|
FirmaUtil.isValidAddress = function (address) {
|
|
201
200
|
try {
|
|
202
201
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
203
|
-
encoding_1.
|
|
202
|
+
encoding_1.fromBech32(address).data;
|
|
204
203
|
return true;
|
|
205
204
|
}
|
|
206
205
|
catch (e) {
|
|
@@ -213,21 +212,21 @@ var FirmaUtil = /** @class */ (function () {
|
|
|
213
212
|
};
|
|
214
213
|
// for evm address support
|
|
215
214
|
FirmaUtil.getHexAddressFromAddress = function (address) {
|
|
216
|
-
var data = encoding_1.
|
|
215
|
+
var data = encoding_1.fromBech32(address).data;
|
|
217
216
|
return "0x" + FirmaUtil.buf2hex(data);
|
|
218
217
|
};
|
|
219
218
|
FirmaUtil.getValOperAddressFromAccAddress = function (address) {
|
|
220
|
-
var data = encoding_1.
|
|
221
|
-
return encoding_1.
|
|
219
|
+
var data = encoding_1.fromBech32(address).data;
|
|
220
|
+
return encoding_1.toBech32(FirmaUtil.config.prefix + "valoper", data);
|
|
222
221
|
};
|
|
223
222
|
FirmaUtil.getValConsAddressFromAccAddress = function (consensusPubkey) {
|
|
224
223
|
var ed25519PubkeyRaw = encoding_2.fromBase64(consensusPubkey);
|
|
225
224
|
var addressData = crypto_1.sha256(ed25519PubkeyRaw).slice(0, 20);
|
|
226
|
-
return encoding_1.
|
|
225
|
+
return encoding_1.toBech32(FirmaUtil.config.prefix + "valcons", addressData);
|
|
227
226
|
};
|
|
228
227
|
FirmaUtil.getAccAddressFromValOperAddress = function (address) {
|
|
229
|
-
var data = encoding_1.
|
|
230
|
-
return encoding_1.
|
|
228
|
+
var data = encoding_1.fromBech32(address).data;
|
|
229
|
+
return encoding_1.toBech32(FirmaUtil.config.prefix, data);
|
|
231
230
|
};
|
|
232
231
|
FirmaUtil.getSignerDataForLedger = function (address) {
|
|
233
232
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -285,7 +284,6 @@ var FirmaUtil = /** @class */ (function () {
|
|
|
285
284
|
_a.trys.push([0, 2, , 3]);
|
|
286
285
|
encodedTx = Uint8Array.from(txRaw);
|
|
287
286
|
hexTx = "0x" + Buffer.from(encodedTx).toString("hex");
|
|
288
|
-
console.log("hexTx:" + hexTx);
|
|
289
287
|
queryClient = new TendermintQueryClient_1.TendermintQueryClient(FirmaUtil.config.rpcAddress);
|
|
290
288
|
return [4 /*yield*/, queryClient.queryEstimateGas(hexTx)];
|
|
291
289
|
case 1:
|
|
@@ -308,20 +306,20 @@ var FirmaUtil = /** @class */ (function () {
|
|
|
308
306
|
};
|
|
309
307
|
FirmaUtil.experimentalAdr36Sign = function (wallet, data) {
|
|
310
308
|
return __awaiter(this, void 0, void 0, function () {
|
|
311
|
-
var registry,
|
|
309
|
+
var registry, client, address, userData, error_4;
|
|
312
310
|
return __generator(this, function (_a) {
|
|
313
311
|
switch (_a.label) {
|
|
314
312
|
case 0:
|
|
315
313
|
_a.trys.push([0, 4, , 5]);
|
|
316
314
|
registry = new proto_signing_1.Registry();
|
|
317
|
-
return [4 /*yield*/,
|
|
315
|
+
return [4 /*yield*/, signingstargateclient_1.SigningStargateClient.connectWithSigner(FirmaUtil.config.rpcAddress, wallet.getRawAminoWallet(), { registry: registry })];
|
|
318
316
|
case 1:
|
|
319
|
-
|
|
317
|
+
client = _a.sent();
|
|
320
318
|
return [4 /*yield*/, wallet.getAddress()];
|
|
321
319
|
case 2:
|
|
322
320
|
address = _a.sent();
|
|
323
321
|
userData = Buffer.from(data);
|
|
324
|
-
return [4 /*yield*/,
|
|
322
|
+
return [4 /*yield*/, client.experimentalAdr36Sign(address, userData)];
|
|
325
323
|
case 3: return [2 /*return*/, _a.sent()];
|
|
326
324
|
case 4:
|
|
327
325
|
error_4 = _a.sent();
|
|
@@ -339,7 +337,7 @@ var FirmaUtil = /** @class */ (function () {
|
|
|
339
337
|
switch (_a.label) {
|
|
340
338
|
case 0:
|
|
341
339
|
_a.trys.push([0, 2, , 3]);
|
|
342
|
-
return [4 /*yield*/,
|
|
340
|
+
return [4 /*yield*/, signingstargateclient_1.SigningStargateClient.experimentalAdr36Verify(data, checkMsg)];
|
|
343
341
|
case 1: return [2 /*return*/, _a.sent()];
|
|
344
342
|
case 2:
|
|
345
343
|
error_5 = _a.sent();
|
|
@@ -41,6 +41,6 @@ function pubkeyToRawAddress(pubkey) {
|
|
|
41
41
|
}
|
|
42
42
|
exports.pubkeyToRawAddress = pubkeyToRawAddress;
|
|
43
43
|
function pubkeyToAddress(pubkey, prefix) {
|
|
44
|
-
return encoding_1.
|
|
44
|
+
return encoding_1.toBech32(prefix, pubkeyToRawAddress(pubkey));
|
|
45
45
|
}
|
|
46
46
|
exports.pubkeyToAddress = pubkeyToAddress;
|
|
@@ -124,6 +124,15 @@ export interface AminoMsgSubmitProposal extends AminoMsg {
|
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
export declare function isAminoMsgSubmitProposal(msg: AminoMsg): msg is AminoMsgSubmitProposal;
|
|
127
|
+
export interface AminoMsgCancelProposal extends AminoMsg {
|
|
128
|
+
readonly type: "cosmos-sdk/MsgCancelProposal";
|
|
129
|
+
readonly value: {
|
|
130
|
+
readonly proposalId: string;
|
|
131
|
+
/** Bech32 account address */
|
|
132
|
+
readonly proposer: string;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
export declare function isAminoMsgCancelProposal(msg: AminoMsg): msg is AminoMsgCancelProposal;
|
|
127
136
|
/** Casts a vote */
|
|
128
137
|
export interface AminoMsgVote extends AminoMsg {
|
|
129
138
|
readonly type: "cosmos-sdk/MsgVote";
|
|
@@ -275,6 +284,7 @@ export interface AminoMsgTransfer extends AminoMsg {
|
|
|
275
284
|
* 0 values must be omitted (https://github.com/cosmos/cosmos-sdk/blob/v0.42.7/x/ibc/applications/transfer/types/tx.pb.go#L52).
|
|
276
285
|
*/
|
|
277
286
|
readonly timeout_timestamp?: string;
|
|
287
|
+
readonly memo?: string;
|
|
278
288
|
};
|
|
279
289
|
}
|
|
280
290
|
export declare function isAminoMsgTransfer(msg: AminoMsg): msg is AminoMsgTransfer;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isAminoMsgTransfer = exports.isAminoMsgUndelegate = exports.isAminoMsgBeginRedelegate = exports.isAminoMsgDelegate = exports.isAminoMsgEditValidator = exports.isAminoMsgCreateValidator = exports.isAminoMsgUnjail = exports.isAminoMsgDeposit = exports.isAminoMsgVote = exports.isAminoMsgSubmitProposal = exports.isAminoMsgSubmitEvidence = exports.isAminoMsgFundCommunityPool = exports.isAminoMsgWithdrawValidatorCommission = exports.isAminoMsgWithdrawDelegatorReward = exports.isAminoMsgSetWithdrawAddress = exports.isAminoMsgVerifyInvariant = exports.isAminoMsgMultiSend = exports.isAminoMsgSend = void 0;
|
|
3
|
+
exports.isAminoMsgTransfer = exports.isAminoMsgUndelegate = exports.isAminoMsgBeginRedelegate = exports.isAminoMsgDelegate = exports.isAminoMsgEditValidator = exports.isAminoMsgCreateValidator = exports.isAminoMsgUnjail = exports.isAminoMsgDeposit = exports.isAminoMsgVote = exports.isAminoMsgCancelProposal = exports.isAminoMsgSubmitProposal = exports.isAminoMsgSubmitEvidence = exports.isAminoMsgFundCommunityPool = exports.isAminoMsgWithdrawValidatorCommission = exports.isAminoMsgWithdrawDelegatorReward = exports.isAminoMsgSetWithdrawAddress = exports.isAminoMsgVerifyInvariant = exports.isAminoMsgMultiSend = exports.isAminoMsgSend = void 0;
|
|
4
4
|
function isAminoMsgSend(msg) {
|
|
5
5
|
return msg.type === "cosmos-sdk/MsgSend";
|
|
6
6
|
}
|
|
@@ -39,6 +39,10 @@ function isAminoMsgSubmitProposal(msg) {
|
|
|
39
39
|
return msg.type === "cosmos-sdk/MsgSubmitProposal";
|
|
40
40
|
}
|
|
41
41
|
exports.isAminoMsgSubmitProposal = isAminoMsgSubmitProposal;
|
|
42
|
+
function isAminoMsgCancelProposal(msg) {
|
|
43
|
+
return msg.type === "cosmos-sdk/MsgCancelProposal";
|
|
44
|
+
}
|
|
45
|
+
exports.isAminoMsgCancelProposal = isAminoMsgCancelProposal;
|
|
42
46
|
function isAminoMsgVote(msg) {
|
|
43
47
|
return msg.type === "cosmos-sdk/MsgVote";
|
|
44
48
|
}
|
|
@@ -188,7 +188,7 @@ function createDefaultTypes(prefix) {
|
|
|
188
188
|
return {
|
|
189
189
|
amount: Array.from(amount),
|
|
190
190
|
depositor: depositor,
|
|
191
|
-
proposalId:
|
|
191
|
+
proposalId: BigInt(proposal_id),
|
|
192
192
|
};
|
|
193
193
|
},
|
|
194
194
|
},
|
|
@@ -206,7 +206,7 @@ function createDefaultTypes(prefix) {
|
|
|
206
206
|
var option = _a.option, proposal_id = _a.proposal_id, voter = _a.voter;
|
|
207
207
|
return {
|
|
208
208
|
option: gov_1.voteOptionFromJSON(option),
|
|
209
|
-
proposalId:
|
|
209
|
+
proposalId: BigInt(proposal_id),
|
|
210
210
|
voter: voter,
|
|
211
211
|
};
|
|
212
212
|
},
|
|
@@ -267,6 +267,24 @@ function createDefaultTypes(prefix) {
|
|
|
267
267
|
};
|
|
268
268
|
},
|
|
269
269
|
},
|
|
270
|
+
// cancel proposal
|
|
271
|
+
"/cosmos.gov.v1.MsgCancelProposal": {
|
|
272
|
+
aminoType: "cosmos-sdk/MsgCancelProposal",
|
|
273
|
+
toAmino: function (_a) {
|
|
274
|
+
var proposalId = _a.proposalId, proposer = _a.proposer;
|
|
275
|
+
return {
|
|
276
|
+
proposalId: proposalId.toString(),
|
|
277
|
+
proposer: proposer,
|
|
278
|
+
};
|
|
279
|
+
},
|
|
280
|
+
fromAmino: function (_a) {
|
|
281
|
+
var proposalId = _a.proposalId, proposer = _a.proposer;
|
|
282
|
+
return {
|
|
283
|
+
proposalId: BigInt(proposalId),
|
|
284
|
+
proposer: proposer,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
},
|
|
270
288
|
// staking
|
|
271
289
|
"/cosmos.staking.v1beta1.MsgBeginRedelegate": {
|
|
272
290
|
aminoType: "cosmos-sdk/MsgBeginRedelegate",
|
|
@@ -447,20 +465,19 @@ function createDefaultTypes(prefix) {
|
|
|
447
465
|
});
|
|
448
466
|
},
|
|
449
467
|
fromAmino: function (_a) {
|
|
450
|
-
var source_port = _a.source_port, source_channel = _a.source_channel, token = _a.token, sender = _a.sender, receiver = _a.receiver, timeout_height = _a.timeout_height, timeout_timestamp = _a.timeout_timestamp;
|
|
468
|
+
var source_port = _a.source_port, source_channel = _a.source_channel, token = _a.token, sender = _a.sender, receiver = _a.receiver, timeout_height = _a.timeout_height, timeout_timestamp = _a.timeout_timestamp, memo = _a.memo;
|
|
451
469
|
return ({
|
|
452
470
|
sourcePort: source_port,
|
|
453
471
|
sourceChannel: source_channel,
|
|
454
472
|
token: token,
|
|
455
473
|
sender: sender,
|
|
456
474
|
receiver: receiver,
|
|
457
|
-
timeoutHeight:
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
timeoutTimestamp: long_1.default.fromString(timeout_timestamp || "0", true),
|
|
475
|
+
timeoutHeight: {
|
|
476
|
+
revisionHeight: BigInt(timeout_height.revision_height || "0"),
|
|
477
|
+
revisionNumber: BigInt(timeout_height.revision_number || "0"),
|
|
478
|
+
},
|
|
479
|
+
timeoutTimestamp: BigInt(timeout_timestamp || "0"),
|
|
480
|
+
memo: memo
|
|
464
481
|
});
|
|
465
482
|
},
|
|
466
483
|
},
|
|
@@ -19,12 +19,24 @@ export declare function coins(amount: number | string, denom: string): Coin[];
|
|
|
19
19
|
/**
|
|
20
20
|
* Takes a coins list like "819966000ucosm,700000000ustake" and parses it.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
22
|
+
* Starting with CosmJS 0.32.3, the following imports are all synonym and support
|
|
23
|
+
* a variety of denom types such as IBC denoms or tokenfactory. If you need to
|
|
24
|
+
* restrict the denom to something very minimal, this needs to be implemented
|
|
25
|
+
* separately in the caller.
|
|
23
26
|
*
|
|
24
27
|
* ```
|
|
25
28
|
* import { parseCoins } from "@cosmjs/proto-signing";
|
|
26
|
-
* //
|
|
29
|
+
* // equals
|
|
27
30
|
* import { parseCoins } from "@cosmjs/stargate";
|
|
31
|
+
* // equals
|
|
32
|
+
* import { parseCoins } from "@cosmjs/amino";
|
|
28
33
|
* ```
|
|
34
|
+
*
|
|
35
|
+
* This function is not made for supporting decimal amounts and does not support
|
|
36
|
+
* parsing gas prices.
|
|
29
37
|
*/
|
|
30
38
|
export declare function parseCoins(input: string): Coin[];
|
|
39
|
+
/**
|
|
40
|
+
* Function to sum up coins with type Coin
|
|
41
|
+
*/
|
|
42
|
+
export declare function addCoins(lhs: Coin, rhs: Coin): Coin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCoins = exports.coins = exports.coin = void 0;
|
|
3
|
+
exports.addCoins = exports.parseCoins = exports.coins = exports.coin = void 0;
|
|
4
4
|
var math_1 = require("@cosmjs/math");
|
|
5
5
|
/**
|
|
6
6
|
* Creates a coin.
|
|
@@ -43,13 +43,21 @@ exports.coins = coins;
|
|
|
43
43
|
/**
|
|
44
44
|
* Takes a coins list like "819966000ucosm,700000000ustake" and parses it.
|
|
45
45
|
*
|
|
46
|
-
*
|
|
46
|
+
* Starting with CosmJS 0.32.3, the following imports are all synonym and support
|
|
47
|
+
* a variety of denom types such as IBC denoms or tokenfactory. If you need to
|
|
48
|
+
* restrict the denom to something very minimal, this needs to be implemented
|
|
49
|
+
* separately in the caller.
|
|
47
50
|
*
|
|
48
51
|
* ```
|
|
49
52
|
* import { parseCoins } from "@cosmjs/proto-signing";
|
|
50
|
-
* //
|
|
53
|
+
* // equals
|
|
51
54
|
* import { parseCoins } from "@cosmjs/stargate";
|
|
55
|
+
* // equals
|
|
56
|
+
* import { parseCoins } from "@cosmjs/amino";
|
|
52
57
|
* ```
|
|
58
|
+
*
|
|
59
|
+
* This function is not made for supporting decimal amounts and does not support
|
|
60
|
+
* parsing gas prices.
|
|
53
61
|
*/
|
|
54
62
|
function parseCoins(input) {
|
|
55
63
|
return input
|
|
@@ -57,13 +65,26 @@ function parseCoins(input) {
|
|
|
57
65
|
.split(",")
|
|
58
66
|
.filter(Boolean)
|
|
59
67
|
.map(function (part) {
|
|
60
|
-
|
|
68
|
+
// Denom regex from Stargate (https://github.com/cosmos/cosmos-sdk/blob/v0.42.7/types/coin.go#L599-L601)
|
|
69
|
+
var match = part.match(/^([0-9]+)([a-zA-Z][a-zA-Z0-9/]{2,127})$/);
|
|
61
70
|
if (!match)
|
|
62
71
|
throw new Error("Got an invalid coin string");
|
|
63
72
|
return {
|
|
64
|
-
amount:
|
|
73
|
+
amount: match[1].replace(/^0+/, "") || "0",
|
|
65
74
|
denom: match[2],
|
|
66
75
|
};
|
|
67
76
|
});
|
|
68
77
|
}
|
|
69
78
|
exports.parseCoins = parseCoins;
|
|
79
|
+
/**
|
|
80
|
+
* Function to sum up coins with type Coin
|
|
81
|
+
*/
|
|
82
|
+
function addCoins(lhs, rhs) {
|
|
83
|
+
if (lhs.denom !== rhs.denom)
|
|
84
|
+
throw new Error("Trying to add two coins with different denoms");
|
|
85
|
+
return {
|
|
86
|
+
amount: math_1.Decimal.fromAtomics(lhs.amount, 0).plus(math_1.Decimal.fromAtomics(rhs.amount, 0)).atomics,
|
|
87
|
+
denom: lhs.denom,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
exports.addCoins = addCoins;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import { Pubkey, Secp256k1Pubkey } from "./pubkeys";
|
|
1
|
+
import { Ed25519Pubkey, Pubkey, Secp256k1Pubkey } from "./pubkeys";
|
|
2
|
+
/**
|
|
3
|
+
* Takes a Secp256k1 public key as raw bytes and returns the Amino JSON
|
|
4
|
+
* representation of it (the type/value wrapper object).
|
|
5
|
+
*/
|
|
2
6
|
export declare function encodeSecp256k1Pubkey(pubkey: Uint8Array): Secp256k1Pubkey;
|
|
7
|
+
/**
|
|
8
|
+
* Takes an Edd25519 public key as raw bytes and returns the Amino JSON
|
|
9
|
+
* representation of it (the type/value wrapper object).
|
|
10
|
+
*/
|
|
11
|
+
export declare function encodeEd25519Pubkey(pubkey: Uint8Array): Ed25519Pubkey;
|
|
3
12
|
/**
|
|
4
13
|
* Decodes a pubkey in the Amino binary format to a type/value object.
|
|
5
14
|
*/
|
|
@@ -32,11 +32,15 @@ var __values = (this && this.__values) || function(o) {
|
|
|
32
32
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.encodeBech32Pubkey = exports.encodeAminoPubkey = exports.decodeBech32Pubkey = exports.decodeAminoPubkey = exports.encodeSecp256k1Pubkey = void 0;
|
|
35
|
+
exports.encodeBech32Pubkey = exports.encodeAminoPubkey = exports.decodeBech32Pubkey = exports.decodeAminoPubkey = exports.encodeEd25519Pubkey = exports.encodeSecp256k1Pubkey = void 0;
|
|
36
36
|
var encoding_1 = require("@cosmjs/encoding");
|
|
37
37
|
var math_1 = require("@cosmjs/math");
|
|
38
38
|
var utils_1 = require("@cosmjs/utils");
|
|
39
39
|
var pubkeys_1 = require("./pubkeys");
|
|
40
|
+
/**
|
|
41
|
+
* Takes a Secp256k1 public key as raw bytes and returns the Amino JSON
|
|
42
|
+
* representation of it (the type/value wrapper object).
|
|
43
|
+
*/
|
|
40
44
|
function encodeSecp256k1Pubkey(pubkey) {
|
|
41
45
|
if (pubkey.length !== 33 || (pubkey[0] !== 0x02 && pubkey[0] !== 0x03)) {
|
|
42
46
|
throw new Error("Public key must be compressed secp256k1, i.e. 33 bytes starting with 0x02 or 0x03");
|
|
@@ -47,6 +51,20 @@ function encodeSecp256k1Pubkey(pubkey) {
|
|
|
47
51
|
};
|
|
48
52
|
}
|
|
49
53
|
exports.encodeSecp256k1Pubkey = encodeSecp256k1Pubkey;
|
|
54
|
+
/**
|
|
55
|
+
* Takes an Edd25519 public key as raw bytes and returns the Amino JSON
|
|
56
|
+
* representation of it (the type/value wrapper object).
|
|
57
|
+
*/
|
|
58
|
+
function encodeEd25519Pubkey(pubkey) {
|
|
59
|
+
if (pubkey.length !== 32) {
|
|
60
|
+
throw new Error("Ed25519 public key must be 32 bytes long");
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
type: pubkeys_1.pubkeyType.ed25519,
|
|
64
|
+
value: encoding_1.toBase64(pubkey),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
exports.encodeEd25519Pubkey = encodeEd25519Pubkey;
|
|
50
68
|
// As discussed in https://github.com/binance-chain/javascript-sdk/issues/163
|
|
51
69
|
// Prefixes listed here: https://github.com/tendermint/tendermint/blob/d419fffe18531317c28c29a292ad7d253f6cafdf/docs/spec/blockchain/encoding.md#public-key-cryptography
|
|
52
70
|
// Last bytes is varint-encoded length prefix
|
|
@@ -105,7 +123,7 @@ exports.decodeAminoPubkey = decodeAminoPubkey;
|
|
|
105
123
|
* @param bechEncoded the bech32 encoded pubkey
|
|
106
124
|
*/
|
|
107
125
|
function decodeBech32Pubkey(bechEncoded) {
|
|
108
|
-
var data = encoding_1.
|
|
126
|
+
var data = encoding_1.fromBech32(bechEncoded).data;
|
|
109
127
|
return decodeAminoPubkey(data);
|
|
110
128
|
}
|
|
111
129
|
exports.decodeBech32Pubkey = decodeBech32Pubkey;
|
|
@@ -229,6 +247,6 @@ exports.encodeAminoPubkey = encodeAminoPubkey;
|
|
|
229
247
|
* @param prefix the bech32 prefix (human readable part)
|
|
230
248
|
*/
|
|
231
249
|
function encodeBech32Pubkey(pubkey, prefix) {
|
|
232
|
-
return encoding_1.
|
|
250
|
+
return encoding_1.toBech32(prefix, encodeAminoPubkey(pubkey));
|
|
233
251
|
}
|
|
234
252
|
exports.encodeBech32Pubkey = encodeBech32Pubkey;
|
|
@@ -4,8 +4,12 @@ export interface AminoMsg {
|
|
|
4
4
|
readonly value: any;
|
|
5
5
|
}
|
|
6
6
|
export interface StdFee {
|
|
7
|
-
amount: Coin[];
|
|
8
|
-
gas: string;
|
|
7
|
+
readonly amount: readonly Coin[];
|
|
8
|
+
readonly gas: string;
|
|
9
|
+
/** The granter address that is used for paying with feegrants */
|
|
10
|
+
readonly granter?: string;
|
|
11
|
+
/** The fee payer address. The payer must have signed the transaction. */
|
|
12
|
+
readonly payer?: string;
|
|
9
13
|
}
|
|
10
14
|
/**
|
|
11
15
|
* The document to be signed
|
|
@@ -19,8 +23,22 @@ export interface StdSignDoc {
|
|
|
19
23
|
readonly fee: StdFee;
|
|
20
24
|
readonly msgs: readonly AminoMsg[];
|
|
21
25
|
readonly memo: string;
|
|
26
|
+
readonly timeout_height?: string;
|
|
22
27
|
}
|
|
23
28
|
/** Returns a JSON string with objects sorted by key */
|
|
24
29
|
export declare function sortedJsonStringify(obj: any): string;
|
|
25
|
-
export declare function makeSignDoc(msgs: readonly AminoMsg[], fee: StdFee, chainId: string, memo: string | undefined, accountNumber: number | string, sequence: number | string): StdSignDoc;
|
|
30
|
+
export declare function makeSignDoc(msgs: readonly AminoMsg[], fee: StdFee, chainId: string, memo: string | undefined, accountNumber: number | string, sequence: number | string, timeout_height?: bigint): StdSignDoc;
|
|
31
|
+
/**
|
|
32
|
+
* Takes a valid JSON document and performs the following escapings in string values:
|
|
33
|
+
*
|
|
34
|
+
* `&` -> `\u0026`
|
|
35
|
+
* `<` -> `\u003c`
|
|
36
|
+
* `>` -> `\u003e`
|
|
37
|
+
*
|
|
38
|
+
* Since those characters do not occur in other places of the JSON document, only
|
|
39
|
+
* string values are affected.
|
|
40
|
+
*
|
|
41
|
+
* If the input is invalid JSON, the behaviour is undefined.
|
|
42
|
+
*/
|
|
43
|
+
export declare function escapeCharacters(input: string): string;
|
|
26
44
|
export declare function serializeSignDoc(signDoc: StdSignDoc): Uint8Array;
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serializeSignDoc = exports.makeSignDoc = exports.sortedJsonStringify = void 0;
|
|
14
|
+
exports.serializeSignDoc = exports.escapeCharacters = exports.makeSignDoc = exports.sortedJsonStringify = void 0;
|
|
4
15
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
5
16
|
var encoding_1 = require("@cosmjs/encoding");
|
|
6
17
|
var math_1 = require("@cosmjs/math");
|
|
@@ -25,18 +36,33 @@ function sortedJsonStringify(obj) {
|
|
|
25
36
|
return JSON.stringify(sortedObject(obj));
|
|
26
37
|
}
|
|
27
38
|
exports.sortedJsonStringify = sortedJsonStringify;
|
|
28
|
-
function makeSignDoc(msgs, fee, chainId, memo, accountNumber, sequence) {
|
|
29
|
-
return {
|
|
30
|
-
chain_id: chainId,
|
|
31
|
-
account_number: math_1.Uint53.fromString(accountNumber.toString()).toString(),
|
|
32
|
-
sequence: math_1.Uint53.fromString(sequence.toString()).toString(),
|
|
33
|
-
fee: fee,
|
|
34
|
-
msgs: msgs,
|
|
35
|
-
memo: memo || "",
|
|
36
|
-
};
|
|
39
|
+
function makeSignDoc(msgs, fee, chainId, memo, accountNumber, sequence, timeout_height) {
|
|
40
|
+
return __assign({ chain_id: chainId, account_number: math_1.Uint53.fromString(accountNumber.toString()).toString(), sequence: math_1.Uint53.fromString(sequence.toString()).toString(), fee: fee, msgs: msgs, memo: memo || "" }, (timeout_height && { timeout_height: timeout_height.toString() }));
|
|
37
41
|
}
|
|
38
42
|
exports.makeSignDoc = makeSignDoc;
|
|
43
|
+
/**
|
|
44
|
+
* Takes a valid JSON document and performs the following escapings in string values:
|
|
45
|
+
*
|
|
46
|
+
* `&` -> `\u0026`
|
|
47
|
+
* `<` -> `\u003c`
|
|
48
|
+
* `>` -> `\u003e`
|
|
49
|
+
*
|
|
50
|
+
* Since those characters do not occur in other places of the JSON document, only
|
|
51
|
+
* string values are affected.
|
|
52
|
+
*
|
|
53
|
+
* If the input is invalid JSON, the behaviour is undefined.
|
|
54
|
+
*/
|
|
55
|
+
function escapeCharacters(input) {
|
|
56
|
+
// When we migrate to target es2021 or above, we can use replaceAll instead of global patterns.
|
|
57
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll
|
|
58
|
+
var amp = /&/g;
|
|
59
|
+
var lt = /</g;
|
|
60
|
+
var gt = />/g;
|
|
61
|
+
return input.replace(amp, "\\u0026").replace(lt, "\\u003c").replace(gt, "\\u003e");
|
|
62
|
+
}
|
|
63
|
+
exports.escapeCharacters = escapeCharacters;
|
|
39
64
|
function serializeSignDoc(signDoc) {
|
|
40
|
-
|
|
65
|
+
var serialized = escapeCharacters(sortedJsonStringify(signDoc));
|
|
66
|
+
return encoding_1.toUtf8(serialized);
|
|
41
67
|
}
|
|
42
68
|
exports.serializeSignDoc = serializeSignDoc;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { StdSignature
|
|
1
|
+
import { StdSignature } from "./signature";
|
|
2
|
+
import { StdSignDoc } from "./signdoc";
|
|
2
3
|
export declare type Algo = "secp256k1" | "ed25519" | "sr25519";
|
|
3
4
|
export interface AccountData {
|
|
4
5
|
/** A printable address (typically bech32 encoded) */
|