@firmachain/firma-js 0.3.4 → 0.3.6-beta1
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/index.js +5 -1
- package/dist/sdk/FirmaAuthzService.d.ts +8 -7
- package/dist/sdk/FirmaAuthzService.js +12 -22
- package/dist/sdk/FirmaBankService.js +2 -2
- package/dist/sdk/FirmaChainService.js +1 -1
- package/dist/sdk/FirmaContractService.d.ts +1 -1
- package/dist/sdk/FirmaContractService.js +6 -6
- package/dist/sdk/FirmaCosmWasmCw20.d.ts +2 -2
- package/dist/sdk/FirmaCosmWasmCw20.js +8 -8
- package/dist/sdk/FirmaCosmWasmCw721.d.ts +2 -2
- package/dist/sdk/FirmaCosmWasmCw721.js +12 -12
- package/dist/sdk/FirmaCosmWasmCwBridge.d.ts +1 -1
- package/dist/sdk/FirmaCosmWasmCwBridge.js +8 -8
- package/dist/sdk/FirmaCosmWasmCwMarketplace.d.ts +1 -1
- package/dist/sdk/FirmaCosmWasmCwMarketplace.js +5 -5
- package/dist/sdk/FirmaCosmWasmService.d.ts +1 -1
- package/dist/sdk/FirmaCosmWasmService.js +13 -13
- package/dist/sdk/FirmaDistributionService.d.ts +1 -1
- package/dist/sdk/FirmaDistributionService.js +6 -6
- package/dist/sdk/FirmaFeeGrantService.d.ts +7 -6
- package/dist/sdk/FirmaFeeGrantService.js +9 -26
- package/dist/sdk/FirmaGovService.d.ts +1 -1
- package/dist/sdk/FirmaGovService.js +14 -14
- package/dist/sdk/FirmaIbcService.d.ts +3 -3
- package/dist/sdk/FirmaIbcService.js +11 -8
- package/dist/sdk/FirmaIpfsService.js +1 -1
- package/dist/sdk/FirmaMintService.js +1 -1
- package/dist/sdk/FirmaNftService.d.ts +1 -1
- package/dist/sdk/FirmaNftService.js +6 -6
- package/dist/sdk/FirmaSlashingService.js +1 -1
- package/dist/sdk/FirmaStakingService.d.ts +3 -3
- package/dist/sdk/FirmaStakingService.js +6 -6
- package/dist/sdk/FirmaTokenService.d.ts +1 -1
- package/dist/sdk/FirmaTokenService.js +5 -5
- package/dist/sdk/FirmaUtil.d.ts +26 -23
- package/dist/sdk/FirmaUtil.js +157 -137
- package/dist/sdk/FirmaWalletService.d.ts +5 -9
- package/dist/sdk/FirmaWalletService.js +86 -52
- package/dist/sdk/firmachain/authz/AuthzQueryClient.js +4 -4
- package/dist/sdk/firmachain/authz/AuthzTxTypes.d.ts +8 -11
- package/dist/sdk/firmachain/authz/AuthzTxTypes.js +6 -10
- package/dist/sdk/firmachain/authz/index.js +5 -1
- package/dist/sdk/firmachain/bank/BankQueryClient.js +5 -5
- package/dist/sdk/firmachain/bank/index.js +5 -1
- package/dist/sdk/firmachain/common/ITxClient.d.ts +3 -3
- package/dist/sdk/firmachain/common/ITxClient.js +25 -83
- package/dist/sdk/firmachain/common/LedgerWallet.d.ts +19 -3
- package/dist/sdk/firmachain/common/LedgerWallet.js +138 -68
- package/dist/sdk/firmachain/common/TendermintQueryClient.js +1 -1
- package/dist/sdk/firmachain/common/TxCommon.d.ts +14 -30
- package/dist/sdk/firmachain/common/accounts.d.ts +1 -1
- package/dist/sdk/firmachain/common/accounts.js +7 -7
- package/dist/sdk/firmachain/common/events.js +2 -2
- package/dist/sdk/firmachain/common/fee.d.ts +2 -2
- package/dist/sdk/firmachain/common/fee.js +4 -2
- package/dist/sdk/firmachain/common/index.d.ts +0 -1
- package/dist/sdk/firmachain/common/index.js +5 -4
- package/dist/sdk/firmachain/common/signing.d.ts +13 -9
- package/dist/sdk/firmachain/common/signing.js +81 -36
- package/dist/sdk/firmachain/common/signingprotobufstargateclient.d.ts +34 -0
- package/dist/sdk/firmachain/common/signingprotobufstargateclient.js +319 -0
- package/dist/sdk/firmachain/common/signingstargateclient.d.ts +21 -105
- package/dist/sdk/firmachain/common/signingstargateclient.js +120 -472
- package/dist/sdk/firmachain/common/{stargateclient.d.ts → stargateClient.d.ts} +11 -60
- package/dist/sdk/firmachain/common/{stargateclient.js → stargateClient.js} +109 -203
- package/dist/sdk/firmachain/{amino → common}/wallet.js +15 -11
- package/dist/sdk/firmachain/contract/ContractQueryClient.js +3 -3
- package/dist/sdk/firmachain/contract/ContractTxTypes.d.ts +6 -6
- package/dist/sdk/firmachain/contract/index.js +5 -1
- package/dist/sdk/firmachain/cosmwasm/CosmWasmQueryClient.js +9 -9
- package/dist/sdk/firmachain/cosmwasm/index.js +5 -1
- package/dist/sdk/firmachain/distribution/DistributionQueryClient.js +6 -6
- package/dist/sdk/firmachain/distribution/index.js +5 -1
- package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.js +3 -3
- package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.d.ts +4 -45
- package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.js +3 -82
- package/dist/sdk/firmachain/feegrant/index.js +5 -1
- package/dist/sdk/firmachain/google/protobuf/any.d.ts +3 -3
- package/dist/sdk/firmachain/google/protobuf/descriptor.d.ts +29 -29
- package/dist/sdk/firmachain/google/protobuf/duration.d.ts +3 -3
- package/dist/sdk/firmachain/gov/GovQueryClient.js +3 -3
- package/dist/sdk/firmachain/gov/index.js +5 -1
- package/dist/sdk/firmachain/ibc/IbcQueryClient.js +2 -2
- package/dist/sdk/firmachain/ibc/index.js +5 -1
- package/dist/sdk/firmachain/mint/MintQueryClient.js +1 -1
- package/dist/sdk/firmachain/mint/index.js +5 -1
- package/dist/sdk/firmachain/nft/NftQueryClient.js +1 -1
- package/dist/sdk/firmachain/nft/NftTxTypes.d.ts +8 -8
- package/dist/sdk/firmachain/nft/index.js +5 -1
- package/dist/sdk/firmachain/slashing/SlashingQueryClient.js +1 -1
- package/dist/sdk/firmachain/slashing/index.js +5 -1
- package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +2 -2
- package/dist/sdk/firmachain/staking/StakingQueryClient.js +10 -9
- package/dist/sdk/firmachain/staking/index.js +5 -1
- package/dist/sdk/firmachain/token/TokenQueryClient.js +1 -1
- package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +11 -11
- package/dist/sdk/firmachain/token/TokenTxTypes.js +1 -1
- package/dist/sdk/firmachain/token/index.js +5 -1
- package/dist/test/00.wallet.test.js +4 -4
- package/dist/test/01.contract_tx.test.js +5 -5
- package/dist/test/02.contract_query.test.js +15 -15
- package/dist/test/03.contract_scenario.test.js +28 -28
- package/dist/test/04.bank_tx.test.js +4 -4
- package/dist/test/05.bank_query.test.js +9 -9
- package/dist/test/06.feegrant_tx.test.js +59 -35
- package/dist/test/07.feegrant_query.test.js +18 -15
- package/dist/test/08.gas_estimate.test.js +110 -70
- package/dist/test/09.ipfs.test.js +4 -4
- package/dist/test/10.nft_tx.test.js +7 -7
- package/dist/test/11.nft_query.test.js +9 -9
- package/dist/test/12.staking_tx.test.js +27 -15
- package/dist/test/13.staking_query.test.js +20 -20
- package/dist/test/14.distribution_tx.test.js +8 -8
- package/dist/test/15.distribution_query.test.js +15 -15
- package/dist/test/16.gov_tx.test.js +17 -17
- package/dist/test/17.gov_query.test.js +19 -19
- package/dist/test/18.util.test.js +105 -63
- package/dist/test/19.chain.test.js +38 -38
- package/dist/test/20.slashing_query.test.js +25 -25
- package/dist/test/21.token_tx.test.js +6 -6
- package/dist/test/22.token_query.test.js +4 -4
- package/dist/test/23.authz_tx.test.js +77 -47
- package/dist/test/24.authz_query.test.js +66 -67
- package/dist/test/25.cosmwasm_tx.test.js +7 -7
- package/dist/test/26.cosmwasm_query.test.js +127 -59
- package/dist/test/{27.arbitary_sign.test.js → 27.arbitrary_sign.test.js} +41 -40
- package/dist/test/28.ibc_tx.test.js +8 -8
- package/dist/test/29.mint_query.test.js +2 -2
- package/dist/test/30.cw20_tx.test.js +20 -20
- package/dist/test/31.cw20_query.test.js +24 -24
- package/dist/test/32.cw721_tx.test.js +19 -19
- package/dist/test/33.cw721_query.test.js +32 -32
- package/dist/test/34.cw_bridge_tx.test.js +19 -19
- package/dist/test/35.cw_bridge_tx_low.test.js +13 -13
- package/dist/test/36.cw_bridge_query.test.js +20 -20
- package/dist/test/37.cw_marketplace_tx.test.js +32 -32
- package/dist/test/38.cw_marketplace_query.test.js +2 -2
- package/dist/test/config_test.d.ts +2 -2
- package/dist/test/config_test.js +22 -5
- package/package.json +9 -10
- package/dist/sdk/firmachain/amino/addresses.d.ts +0 -5
- package/dist/sdk/firmachain/amino/addresses.js +0 -46
- package/dist/sdk/firmachain/amino/aminomsgs.d.ts +0 -291
- package/dist/sdk/firmachain/amino/aminomsgs.js +0 -81
- package/dist/sdk/firmachain/amino/aminotypes.d.ts +0 -22
- package/dist/sdk/firmachain/amino/aminotypes.js +0 -538
- package/dist/sdk/firmachain/amino/coins.d.ts +0 -42
- package/dist/sdk/firmachain/amino/coins.js +0 -90
- package/dist/sdk/firmachain/amino/encoding.d.ts +0 -33
- package/dist/sdk/firmachain/amino/encoding.js +0 -252
- package/dist/sdk/firmachain/amino/multisig.d.ts +0 -10
- package/dist/sdk/firmachain/amino/multisig.js +0 -42
- package/dist/sdk/firmachain/amino/pubkeys.d.ts +0 -47
- package/dist/sdk/firmachain/amino/pubkeys.js +0 -29
- package/dist/sdk/firmachain/amino/signature.d.ts +0 -16
- package/dist/sdk/firmachain/amino/signature.js +0 -36
- package/dist/sdk/firmachain/amino/signdoc.d.ts +0 -44
- package/dist/sdk/firmachain/amino/signdoc.js +0 -68
- package/dist/sdk/firmachain/amino/signer.d.ts +0 -33
- package/dist/sdk/firmachain/amino/signer.js +0 -2
- package/dist/sdk/firmachain/amino/stdtx.d.ts +0 -15
- package/dist/sdk/firmachain/amino/stdtx.js +0 -17
- package/dist/sdk/firmachain/common/LedgerSigningStargateClient.d.ts +0 -22
- package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +0 -170
- package/dist/sdk/firmachain/common/aminotypes.d.ts +0 -19
- package/dist/sdk/firmachain/common/aminotypes.js +0 -74
- package/dist/sdk/firmachain/common/modules/auth/queries.d.ts +0 -15
- package/dist/sdk/firmachain/common/modules/auth/queries.js +0 -64
- package/dist/sdk/firmachain/common/modules/authz/aminomessages.d.ts +0 -2
- package/dist/sdk/firmachain/common/modules/authz/aminomessages.js +0 -15
- package/dist/sdk/firmachain/common/modules/authz/messages.d.ts +0 -2
- package/dist/sdk/firmachain/common/modules/authz/messages.js +0 -9
- package/dist/sdk/firmachain/common/modules/authz/queries.d.ts +0 -10
- package/dist/sdk/firmachain/common/modules/authz/queries.js +0 -88
- package/dist/sdk/firmachain/common/modules/bank/aminomessages.d.ts +0 -35
- package/dist/sdk/firmachain/common/modules/bank/aminomessages.js +0 -85
- package/dist/sdk/firmachain/common/modules/bank/messages.d.ts +0 -8
- package/dist/sdk/firmachain/common/modules/bank/messages.js +0 -12
- package/dist/sdk/firmachain/common/modules/bank/queries.d.ts +0 -15
- package/dist/sdk/firmachain/common/modules/bank/queries.js +0 -128
- package/dist/sdk/firmachain/common/modules/crisis/aminomessages.d.ts +0 -14
- package/dist/sdk/firmachain/common/modules/crisis/aminomessages.js +0 -11
- package/dist/sdk/firmachain/common/modules/distribution/aminomessages.d.ts +0 -44
- package/dist/sdk/firmachain/common/modules/distribution/aminomessages.js +0 -113
- package/dist/sdk/firmachain/common/modules/distribution/messages.d.ts +0 -8
- package/dist/sdk/firmachain/common/modules/distribution/messages.js +0 -15
- package/dist/sdk/firmachain/common/modules/distribution/queries.d.ts +0 -16
- package/dist/sdk/firmachain/common/modules/distribution/queries.js +0 -171
- package/dist/sdk/firmachain/common/modules/evidence/aminomessages.d.ts +0 -18
- package/dist/sdk/firmachain/common/modules/evidence/aminomessages.js +0 -11
- package/dist/sdk/firmachain/common/modules/feegrant/aminomessages.d.ts +0 -2
- package/dist/sdk/firmachain/common/modules/feegrant/aminomessages.js +0 -14
- package/dist/sdk/firmachain/common/modules/feegrant/messages.d.ts +0 -2
- package/dist/sdk/firmachain/common/modules/feegrant/messages.js +0 -8
- package/dist/sdk/firmachain/common/modules/feegrant/queries.d.ts +0 -9
- package/dist/sdk/firmachain/common/modules/feegrant/queries.js +0 -81
- package/dist/sdk/firmachain/common/modules/gov/aminomessages.d.ts +0 -79
- package/dist/sdk/firmachain/common/modules/gov/aminomessages.js +0 -152
- package/dist/sdk/firmachain/common/modules/gov/messages.d.ts +0 -29
- package/dist/sdk/firmachain/common/modules/gov/messages.js +0 -39
- package/dist/sdk/firmachain/common/modules/gov/queries.d.ts +0 -19
- package/dist/sdk/firmachain/common/modules/gov/queries.js +0 -160
- package/dist/sdk/firmachain/common/modules/group/aminomessages.d.ts +0 -2
- package/dist/sdk/firmachain/common/modules/group/aminomessages.js +0 -8
- package/dist/sdk/firmachain/common/modules/group/messages.d.ts +0 -2
- package/dist/sdk/firmachain/common/modules/group/messages.js +0 -28
- package/dist/sdk/firmachain/common/modules/ibc/aminomessages.d.ts +0 -38
- package/dist/sdk/firmachain/common/modules/ibc/aminomessages.js +0 -55
- package/dist/sdk/firmachain/common/modules/ibc/messages.d.ts +0 -8
- package/dist/sdk/firmachain/common/modules/ibc/messages.js +0 -32
- package/dist/sdk/firmachain/common/modules/ibc/queries.d.ts +0 -58
- package/dist/sdk/firmachain/common/modules/ibc/queries.js +0 -576
- package/dist/sdk/firmachain/common/modules/index.d.ts +0 -32
- package/dist/sdk/firmachain/common/modules/index.js +0 -101
- package/dist/sdk/firmachain/common/modules/mint/queries.d.ts +0 -21
- package/dist/sdk/firmachain/common/modules/mint/queries.js +0 -95
- package/dist/sdk/firmachain/common/modules/slashing/aminomessages.d.ts +0 -12
- package/dist/sdk/firmachain/common/modules/slashing/aminomessages.js +0 -11
- package/dist/sdk/firmachain/common/modules/slashing/queries.d.ts +0 -10
- package/dist/sdk/firmachain/common/modules/slashing/queries.js +0 -88
- package/dist/sdk/firmachain/common/modules/staking/aminomessages.d.ts +0 -112
- package/dist/sdk/firmachain/common/modules/staking/aminomessages.js +0 -234
- package/dist/sdk/firmachain/common/modules/staking/messages.d.ts +0 -33
- package/dist/sdk/firmachain/common/modules/staking/messages.js +0 -37
- package/dist/sdk/firmachain/common/modules/staking/queries.d.ts +0 -23
- package/dist/sdk/firmachain/common/modules/staking/queries.js +0 -242
- package/dist/sdk/firmachain/common/modules/tx/queries.d.ts +0 -11
- package/dist/sdk/firmachain/common/modules/tx/queries.js +0 -103
- package/dist/sdk/firmachain/common/modules/vesting/aminomessages.d.ts +0 -16
- package/dist/sdk/firmachain/common/modules/vesting/aminomessages.js +0 -56
- package/dist/sdk/firmachain/common/modules/vesting/messages.d.ts +0 -2
- package/dist/sdk/firmachain/common/modules/vesting/messages.js +0 -7
- package/dist/sdk/firmachain/common/queryclient/index.d.ts +0 -2
- package/dist/sdk/firmachain/common/queryclient/index.js +0 -10
- package/dist/sdk/firmachain/common/queryclient/queryclient.d.ts +0 -75
- package/dist/sdk/firmachain/common/queryclient/queryclient.js +0 -157
- package/dist/sdk/firmachain/common/queryclient/utils.d.ts +0 -33
- package/dist/sdk/firmachain/common/queryclient/utils.js +0 -101
- package/dist/sdk/firmachain/common/search.d.ts +0 -10
- package/dist/sdk/firmachain/common/search.js +0 -7
- package/dist/sdk/firmachain/google/protobuf/timestamp.d.ts +0 -110
- package/dist/sdk/firmachain/google/protobuf/timestamp.js +0 -108
- /package/dist/sdk/firmachain/{amino → common}/paths.d.ts +0 -0
- /package/dist/sdk/firmachain/{amino → common}/paths.js +0 -0
- /package/dist/sdk/firmachain/{amino → common}/wallet.d.ts +0 -0
- /package/dist/test/{27.arbitary_sign.test.d.ts → 27.arbitrary_sign.test.d.ts} +0 -0
|
@@ -15,26 +15,25 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
15
15
|
}
|
|
16
16
|
return ar;
|
|
17
17
|
};
|
|
18
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
19
|
-
for (var i = 0,
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
+
if (ar || !(i in from)) {
|
|
21
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
+
ar[i] = from[i];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
22
26
|
};
|
|
23
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.makeSignBytes = exports.makeSignDoc = exports.makeAuthInfoBytes = void 0;
|
|
28
|
+
exports.makeSignDocProtobuf = exports.makeAuthInfoBytesProtobuf = exports.makeSignBytes = exports.makeSignDoc = exports.makeAuthInfoBytes = void 0;
|
|
25
29
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
26
|
-
var
|
|
30
|
+
var coin_1 = require("cosmjs-types/cosmos/base/v1beta1/coin");
|
|
27
31
|
var signing_1 = require("cosmjs-types/cosmos/tx/signing/v1beta1/signing");
|
|
28
32
|
var tx_1 = require("cosmjs-types/cosmos/tx/v1beta1/tx");
|
|
29
|
-
/**
|
|
30
|
-
* Create signer infos from the provided signers.
|
|
31
|
-
*
|
|
32
|
-
* This implementation does not support different signing modes for the different signers.
|
|
33
|
-
*/
|
|
34
33
|
function makeSignerInfos(signers, signMode) {
|
|
35
34
|
return signers.map(function (_a) {
|
|
36
35
|
var pubkey = _a.pubkey, sequence = _a.sequence;
|
|
37
|
-
return ({
|
|
36
|
+
return tx_1.SignerInfo.fromPartial({
|
|
38
37
|
publicKey: pubkey,
|
|
39
38
|
modeInfo: {
|
|
40
39
|
single: { mode: signMode },
|
|
@@ -43,45 +42,91 @@ function makeSignerInfos(signers, signMode) {
|
|
|
43
42
|
});
|
|
44
43
|
});
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
* Creates and serializes an AuthInfo document.
|
|
48
|
-
*
|
|
49
|
-
* This implementation does not support different signing modes for the different signers.
|
|
50
|
-
*/
|
|
51
|
-
function makeAuthInfoBytes(signers, feeAmount, gasLimit, feeGranter, feePayer, signMode) {
|
|
45
|
+
function makeAuthInfoBytes(signers, feeAmount, gasLimit, granter, payer, signMode) {
|
|
52
46
|
if (signMode === void 0) { signMode = signing_1.SignMode.SIGN_MODE_DIRECT; }
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
var fee = tx_1.Fee.fromPartial({
|
|
48
|
+
amount: __spreadArray([], __read(feeAmount), false),
|
|
49
|
+
gasLimit: BigInt(gasLimit),
|
|
50
|
+
granter: granter || "",
|
|
51
|
+
payer: payer || "",
|
|
52
|
+
});
|
|
56
53
|
var authInfo = tx_1.AuthInfo.fromPartial({
|
|
57
54
|
signerInfos: makeSignerInfos(signers, signMode),
|
|
58
|
-
fee:
|
|
59
|
-
amount: __spreadArray([], __read(feeAmount)),
|
|
60
|
-
gasLimit: BigInt(gasLimit),
|
|
61
|
-
granter: feeGranter,
|
|
62
|
-
payer: feePayer,
|
|
63
|
-
},
|
|
55
|
+
fee: fee,
|
|
64
56
|
});
|
|
65
57
|
return tx_1.AuthInfo.encode(authInfo).finish();
|
|
66
58
|
}
|
|
67
59
|
exports.makeAuthInfoBytes = makeAuthInfoBytes;
|
|
68
60
|
function makeSignDoc(bodyBytes, authInfoBytes, chainId, accountNumber) {
|
|
69
|
-
return {
|
|
61
|
+
return tx_1.SignDoc.fromPartial({
|
|
70
62
|
bodyBytes: bodyBytes,
|
|
71
63
|
authInfoBytes: authInfoBytes,
|
|
72
64
|
chainId: chainId,
|
|
73
65
|
accountNumber: BigInt(accountNumber),
|
|
74
|
-
};
|
|
66
|
+
});
|
|
75
67
|
}
|
|
76
68
|
exports.makeSignDoc = makeSignDoc;
|
|
77
|
-
function makeSignBytes(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
69
|
+
function makeSignBytes(signDoc) {
|
|
70
|
+
// Ensure all required fields are present
|
|
71
|
+
if (!signDoc.bodyBytes || !signDoc.authInfoBytes || !signDoc.chainId || signDoc.accountNumber === undefined) {
|
|
72
|
+
throw new Error("SignDoc is missing required fields");
|
|
73
|
+
}
|
|
74
|
+
var doc = tx_1.SignDoc.fromPartial({
|
|
75
|
+
accountNumber: signDoc.accountNumber,
|
|
76
|
+
authInfoBytes: signDoc.authInfoBytes,
|
|
77
|
+
bodyBytes: signDoc.bodyBytes,
|
|
78
|
+
chainId: signDoc.chainId,
|
|
79
|
+
});
|
|
80
|
+
return tx_1.SignDoc.encode(doc).finish();
|
|
81
|
+
}
|
|
82
|
+
exports.makeSignBytes = makeSignBytes;
|
|
83
|
+
/**
|
|
84
|
+
* Creates AuthInfo bytes for protobuf signing with enhanced type safety
|
|
85
|
+
*/
|
|
86
|
+
function makeAuthInfoBytesProtobuf(signers, feeAmount, gasLimit, granter, payer) {
|
|
87
|
+
var normalizedGasLimit = typeof gasLimit === 'bigint' ? gasLimit : BigInt(gasLimit);
|
|
88
|
+
var fee = tx_1.Fee.fromPartial({
|
|
89
|
+
amount: feeAmount.map(function (coin) { return coin_1.Coin.fromPartial(coin); }),
|
|
90
|
+
gasLimit: normalizedGasLimit,
|
|
91
|
+
granter: granter || "",
|
|
92
|
+
payer: payer || "",
|
|
93
|
+
});
|
|
94
|
+
var signerInfos = signers.map(function (_a) {
|
|
95
|
+
var pubkey = _a.pubkey, sequence = _a.sequence;
|
|
96
|
+
return tx_1.SignerInfo.fromPartial({
|
|
97
|
+
publicKey: pubkey,
|
|
98
|
+
modeInfo: {
|
|
99
|
+
single: { mode: signing_1.SignMode.SIGN_MODE_DIRECT },
|
|
100
|
+
},
|
|
101
|
+
sequence: BigInt(sequence),
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
var authInfo = tx_1.AuthInfo.fromPartial({
|
|
105
|
+
signerInfos: signerInfos,
|
|
106
|
+
fee: fee,
|
|
107
|
+
});
|
|
108
|
+
return tx_1.AuthInfo.encode(authInfo).finish();
|
|
109
|
+
}
|
|
110
|
+
exports.makeAuthInfoBytesProtobuf = makeAuthInfoBytesProtobuf;
|
|
111
|
+
/**
|
|
112
|
+
* Creates a protobuf SignDoc with validation
|
|
113
|
+
*/
|
|
114
|
+
function makeSignDocProtobuf(bodyBytes, authInfoBytes, chainId, accountNumber) {
|
|
115
|
+
if (!bodyBytes || bodyBytes.length === 0) {
|
|
116
|
+
throw new Error("bodyBytes cannot be empty");
|
|
117
|
+
}
|
|
118
|
+
if (!authInfoBytes || authInfoBytes.length === 0) {
|
|
119
|
+
throw new Error("authInfoBytes cannot be empty");
|
|
120
|
+
}
|
|
121
|
+
if (!chainId) {
|
|
122
|
+
throw new Error("chainId cannot be empty");
|
|
123
|
+
}
|
|
124
|
+
var normalizedAccountNumber = typeof accountNumber === 'bigint' ? accountNumber : BigInt(accountNumber);
|
|
125
|
+
return tx_1.SignDoc.fromPartial({
|
|
82
126
|
bodyBytes: bodyBytes,
|
|
127
|
+
authInfoBytes: authInfoBytes,
|
|
83
128
|
chainId: chainId,
|
|
129
|
+
accountNumber: normalizedAccountNumber,
|
|
84
130
|
});
|
|
85
|
-
return tx_1.SignDoc.encode(signDoc).finish();
|
|
86
131
|
}
|
|
87
|
-
exports.
|
|
132
|
+
exports.makeSignDocProtobuf = makeSignDocProtobuf;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { OfflineDirectSigner } from "@cosmjs/proto-signing";
|
|
2
|
+
import { Comet38Client } from "@cosmjs/tendermint-rpc";
|
|
3
|
+
import { Account } from "./accounts";
|
|
4
|
+
import { StargateClient, StargateClientOptions } from "./stargateClient";
|
|
5
|
+
export interface SignerData {
|
|
6
|
+
readonly accountNumber: number;
|
|
7
|
+
readonly sequence: number;
|
|
8
|
+
readonly chainId: string;
|
|
9
|
+
}
|
|
10
|
+
export interface SequenceResponse {
|
|
11
|
+
readonly accountNumber: number;
|
|
12
|
+
readonly sequence: number;
|
|
13
|
+
}
|
|
14
|
+
export interface ArbitraryVerifyData {
|
|
15
|
+
type: string;
|
|
16
|
+
signer: string;
|
|
17
|
+
data: string;
|
|
18
|
+
pubkey: string;
|
|
19
|
+
signature: string;
|
|
20
|
+
}
|
|
21
|
+
export interface MsgSignData {
|
|
22
|
+
readonly signer: string;
|
|
23
|
+
readonly data: string;
|
|
24
|
+
}
|
|
25
|
+
export declare class SigningProtobufStargateClient extends StargateClient {
|
|
26
|
+
private readonly signer;
|
|
27
|
+
private readonly _endpoint;
|
|
28
|
+
constructor(cometClient: Comet38Client, options: StargateClientOptions, signer: OfflineDirectSigner, endpoint: string);
|
|
29
|
+
static connectWithSigner(endpoint: string, signer: OfflineDirectSigner, options: StargateClientOptions): Promise<SigningProtobufStargateClient>;
|
|
30
|
+
experimentalAdr36Sign(signerAddress: string, data: Uint8Array | Uint8Array[]): Promise<ArbitraryVerifyData>;
|
|
31
|
+
static experimentalAdr36Verify(data: ArbitraryVerifyData, checkMsg: string): Promise<boolean>;
|
|
32
|
+
private toAccAddress;
|
|
33
|
+
getAccount(address: string): Promise<Account | null>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
54
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
55
|
+
if (!m) return o;
|
|
56
|
+
var i = m.call(o), r, ar = [], e;
|
|
57
|
+
try {
|
|
58
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
59
|
+
}
|
|
60
|
+
catch (error) { e = { error: error }; }
|
|
61
|
+
finally {
|
|
62
|
+
try {
|
|
63
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
64
|
+
}
|
|
65
|
+
finally { if (e) throw e.error; }
|
|
66
|
+
}
|
|
67
|
+
return ar;
|
|
68
|
+
};
|
|
69
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
70
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
71
|
+
if (ar || !(i in from)) {
|
|
72
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
73
|
+
ar[i] = from[i];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
77
|
+
};
|
|
78
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
79
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
80
|
+
};
|
|
81
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
82
|
+
exports.SigningProtobufStargateClient = void 0;
|
|
83
|
+
var encoding_1 = require("@cosmjs/encoding");
|
|
84
|
+
var proto_signing_1 = require("@cosmjs/proto-signing");
|
|
85
|
+
var tendermint_rpc_1 = require("@cosmjs/tendermint-rpc");
|
|
86
|
+
var utils_1 = require("@cosmjs/utils");
|
|
87
|
+
var crypto_1 = require("@cosmjs/crypto");
|
|
88
|
+
var tendermint_rpc_2 = require("@cosmjs/tendermint-rpc");
|
|
89
|
+
var tx_1 = require("cosmjs-types/cosmos/tx/v1beta1/tx");
|
|
90
|
+
var any_1 = require("cosmjs-types/google/protobuf/any");
|
|
91
|
+
var signing_1 = require("cosmjs-types/cosmos/tx/signing/v1beta1/signing");
|
|
92
|
+
var keys_1 = require("cosmjs-types/cosmos/crypto/secp256k1/keys");
|
|
93
|
+
var accounts_1 = require("./accounts");
|
|
94
|
+
var axios_1 = __importDefault(require("axios"));
|
|
95
|
+
var stargateClient_1 = require("./stargateClient");
|
|
96
|
+
var SigningProtobufStargateClient = /** @class */ (function (_super) {
|
|
97
|
+
__extends(SigningProtobufStargateClient, _super);
|
|
98
|
+
function SigningProtobufStargateClient(cometClient, options, signer, endpoint) {
|
|
99
|
+
var _this = _super.call(this, cometClient, options) || this;
|
|
100
|
+
_this.signer = signer;
|
|
101
|
+
_this._endpoint = endpoint;
|
|
102
|
+
return _this;
|
|
103
|
+
}
|
|
104
|
+
SigningProtobufStargateClient.connectWithSigner = function (endpoint, signer, options) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
+
var cometClient;
|
|
107
|
+
return __generator(this, function (_a) {
|
|
108
|
+
switch (_a.label) {
|
|
109
|
+
case 0: return [4 /*yield*/, tendermint_rpc_1.Comet38Client.connect(endpoint)];
|
|
110
|
+
case 1:
|
|
111
|
+
cometClient = _a.sent();
|
|
112
|
+
return [2 /*return*/, new SigningProtobufStargateClient(cometClient, options, signer, endpoint)];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
SigningProtobufStargateClient.prototype.experimentalAdr36Sign = function (signerAddress, data) {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
119
|
+
var accountNumber, sequence, chainId, datas, msgs, accountFromSigner, txBody, fee, pubkey, signerInfo, authInfo, signDoc, signBytes, hash, rawWallet, privKey, signature, signatureBytes, jsonData;
|
|
120
|
+
return __generator(this, function (_a) {
|
|
121
|
+
switch (_a.label) {
|
|
122
|
+
case 0:
|
|
123
|
+
accountNumber = 0;
|
|
124
|
+
sequence = 0;
|
|
125
|
+
chainId = "";
|
|
126
|
+
datas = Array.isArray(data) ? data : [data];
|
|
127
|
+
msgs = datas.map(function (d) { return ({
|
|
128
|
+
typeUrl: "/cosmos.tx.v1beta1.MsgSignData",
|
|
129
|
+
value: any_1.Any.fromPartial({
|
|
130
|
+
typeUrl: "/cosmos.tx.v1beta1.MsgSignData",
|
|
131
|
+
value: new TextEncoder().encode(JSON.stringify({
|
|
132
|
+
signer: signerAddress,
|
|
133
|
+
data: (0, encoding_1.toBase64)(d),
|
|
134
|
+
})),
|
|
135
|
+
}),
|
|
136
|
+
}); });
|
|
137
|
+
return [4 /*yield*/, this.signer.getAccounts()];
|
|
138
|
+
case 1:
|
|
139
|
+
accountFromSigner = (_a.sent()).find(function (account) { return account.address === signerAddress; });
|
|
140
|
+
if (!accountFromSigner) {
|
|
141
|
+
throw new Error("Failed to retrieve account from signer");
|
|
142
|
+
}
|
|
143
|
+
txBody = tx_1.TxBody.fromPartial({
|
|
144
|
+
messages: msgs.map(function (msg) { return any_1.Any.fromPartial({
|
|
145
|
+
typeUrl: msg.typeUrl,
|
|
146
|
+
value: new Uint8Array(), // Simplified for ADR-036
|
|
147
|
+
}); }),
|
|
148
|
+
memo: "",
|
|
149
|
+
});
|
|
150
|
+
fee = tx_1.Fee.fromPartial({
|
|
151
|
+
amount: [],
|
|
152
|
+
gasLimit: BigInt(0),
|
|
153
|
+
});
|
|
154
|
+
pubkey = keys_1.PubKey.fromPartial({
|
|
155
|
+
key: accountFromSigner.pubkey,
|
|
156
|
+
});
|
|
157
|
+
signerInfo = tx_1.SignerInfo.fromPartial({
|
|
158
|
+
publicKey: any_1.Any.fromPartial({
|
|
159
|
+
typeUrl: "/cosmos.crypto.secp256k1.PubKey",
|
|
160
|
+
value: keys_1.PubKey.encode(pubkey).finish(),
|
|
161
|
+
}),
|
|
162
|
+
modeInfo: {
|
|
163
|
+
single: {
|
|
164
|
+
mode: signing_1.SignMode.SIGN_MODE_DIRECT,
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
sequence: BigInt(sequence),
|
|
168
|
+
});
|
|
169
|
+
authInfo = tx_1.AuthInfo.fromPartial({
|
|
170
|
+
signerInfos: [signerInfo],
|
|
171
|
+
fee: fee,
|
|
172
|
+
});
|
|
173
|
+
signDoc = tx_1.SignDoc.fromPartial({
|
|
174
|
+
bodyBytes: tx_1.TxBody.encode(txBody).finish(),
|
|
175
|
+
authInfoBytes: tx_1.AuthInfo.encode(authInfo).finish(),
|
|
176
|
+
chainId: chainId,
|
|
177
|
+
accountNumber: BigInt(accountNumber),
|
|
178
|
+
});
|
|
179
|
+
signBytes = (0, proto_signing_1.makeSignBytes)(signDoc);
|
|
180
|
+
hash = (0, crypto_1.sha256)(signBytes);
|
|
181
|
+
rawWallet = this.signer;
|
|
182
|
+
privKey = rawWallet.privkey;
|
|
183
|
+
if (!privKey) {
|
|
184
|
+
throw new Error("Private key not accessible for ADR-036 signing");
|
|
185
|
+
}
|
|
186
|
+
return [4 /*yield*/, crypto_1.Secp256k1.createSignature(hash, privKey)];
|
|
187
|
+
case 2:
|
|
188
|
+
signature = _a.sent();
|
|
189
|
+
signatureBytes = new Uint8Array(__spreadArray(__spreadArray([], __read(signature.r(32)), false), __read(signature.s(32)), false));
|
|
190
|
+
jsonData = {
|
|
191
|
+
type: "sign/MsgSignData",
|
|
192
|
+
signer: signerAddress,
|
|
193
|
+
data: (0, encoding_1.toBase64)(datas[0]),
|
|
194
|
+
pubkey: (0, encoding_1.toBase64)(accountFromSigner.pubkey),
|
|
195
|
+
signature: (0, encoding_1.toBase64)(signatureBytes)
|
|
196
|
+
};
|
|
197
|
+
return [2 /*return*/, jsonData];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
SigningProtobufStargateClient.experimentalAdr36Verify = function (data, checkMsg) {
|
|
203
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
204
|
+
var pubkeyBytes, signatureBytes, sourceMsg, accountNumber, sequence, chainId, txBody, fee, pubkey, signerInfo, authInfo, signDoc, signBytes, prehashed, secpSignature, rawSignerAddress, decodedSignerData, ok, error_1;
|
|
205
|
+
return __generator(this, function (_a) {
|
|
206
|
+
switch (_a.label) {
|
|
207
|
+
case 0:
|
|
208
|
+
_a.trys.push([0, 2, , 3]);
|
|
209
|
+
pubkeyBytes = (0, encoding_1.fromBase64)(data.pubkey);
|
|
210
|
+
signatureBytes = (0, encoding_1.fromBase64)(data.signature);
|
|
211
|
+
sourceMsg = Buffer.from(data.data, 'base64').toString();
|
|
212
|
+
if (sourceMsg !== checkMsg) {
|
|
213
|
+
throw new Error("Different Msg error. source:" + sourceMsg + ", target:" + checkMsg);
|
|
214
|
+
}
|
|
215
|
+
accountNumber = 0;
|
|
216
|
+
sequence = 0;
|
|
217
|
+
chainId = "";
|
|
218
|
+
txBody = tx_1.TxBody.fromPartial({
|
|
219
|
+
messages: [{
|
|
220
|
+
typeUrl: "/cosmos.tx.v1beta1.MsgSignData",
|
|
221
|
+
value: new Uint8Array(),
|
|
222
|
+
}],
|
|
223
|
+
memo: "",
|
|
224
|
+
});
|
|
225
|
+
fee = tx_1.Fee.fromPartial({
|
|
226
|
+
amount: [],
|
|
227
|
+
gasLimit: BigInt(0),
|
|
228
|
+
});
|
|
229
|
+
pubkey = keys_1.PubKey.fromPartial({
|
|
230
|
+
key: pubkeyBytes,
|
|
231
|
+
});
|
|
232
|
+
signerInfo = tx_1.SignerInfo.fromPartial({
|
|
233
|
+
publicKey: any_1.Any.fromPartial({
|
|
234
|
+
typeUrl: "/cosmos.crypto.secp256k1.PubKey",
|
|
235
|
+
value: keys_1.PubKey.encode(pubkey).finish(),
|
|
236
|
+
}),
|
|
237
|
+
modeInfo: {
|
|
238
|
+
single: {
|
|
239
|
+
mode: signing_1.SignMode.SIGN_MODE_DIRECT,
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
sequence: BigInt(sequence),
|
|
243
|
+
});
|
|
244
|
+
authInfo = tx_1.AuthInfo.fromPartial({
|
|
245
|
+
signerInfos: [signerInfo],
|
|
246
|
+
fee: fee,
|
|
247
|
+
});
|
|
248
|
+
signDoc = tx_1.SignDoc.fromPartial({
|
|
249
|
+
bodyBytes: tx_1.TxBody.encode(txBody).finish(),
|
|
250
|
+
authInfoBytes: tx_1.AuthInfo.encode(authInfo).finish(),
|
|
251
|
+
chainId: chainId,
|
|
252
|
+
accountNumber: BigInt(accountNumber),
|
|
253
|
+
});
|
|
254
|
+
signBytes = (0, proto_signing_1.makeSignBytes)(signDoc);
|
|
255
|
+
prehashed = (0, crypto_1.sha256)(signBytes);
|
|
256
|
+
secpSignature = crypto_1.Secp256k1Signature.fromFixedLength(signatureBytes);
|
|
257
|
+
rawSignerAddress = (0, tendermint_rpc_2.rawSecp256k1PubkeyToRawAddress)(pubkeyBytes);
|
|
258
|
+
decodedSignerData = (0, encoding_1.fromBech32)(data.signer).data;
|
|
259
|
+
if (!(0, utils_1.arrayContentEquals)(decodedSignerData, rawSignerAddress)) {
|
|
260
|
+
throw new Error("Found mismatch between signer in message and public key");
|
|
261
|
+
}
|
|
262
|
+
return [4 /*yield*/, crypto_1.Secp256k1.verifySignature(secpSignature, prehashed, pubkeyBytes)];
|
|
263
|
+
case 1:
|
|
264
|
+
ok = _a.sent();
|
|
265
|
+
return [2 /*return*/, ok];
|
|
266
|
+
case 2:
|
|
267
|
+
error_1 = _a.sent();
|
|
268
|
+
return [2 /*return*/, false];
|
|
269
|
+
case 3: return [2 /*return*/];
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
};
|
|
274
|
+
SigningProtobufStargateClient.prototype.toAccAddress = function (address) {
|
|
275
|
+
return (0, encoding_1.fromBech32)(address).data;
|
|
276
|
+
};
|
|
277
|
+
SigningProtobufStargateClient.prototype.getAccount = function (address) {
|
|
278
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
279
|
+
var accAddress, hexAccAddress, axiosInstance, path, result, finalData, account, finalAccount, error_2;
|
|
280
|
+
return __generator(this, function (_a) {
|
|
281
|
+
switch (_a.label) {
|
|
282
|
+
case 0:
|
|
283
|
+
_a.trys.push([0, 2, , 3]);
|
|
284
|
+
accAddress = this.toAccAddress(address);
|
|
285
|
+
hexAccAddress = "0x01".concat(Buffer.from(accAddress).toString("hex"));
|
|
286
|
+
axiosInstance = axios_1.default.create({
|
|
287
|
+
baseURL: this._endpoint,
|
|
288
|
+
headers: {
|
|
289
|
+
Accept: "application/json",
|
|
290
|
+
},
|
|
291
|
+
timeout: 15000
|
|
292
|
+
});
|
|
293
|
+
path = "/abci_query";
|
|
294
|
+
return [4 /*yield*/, axiosInstance.get(path, {
|
|
295
|
+
params: {
|
|
296
|
+
path: '"store/acc/key"',
|
|
297
|
+
data: hexAccAddress
|
|
298
|
+
}
|
|
299
|
+
})];
|
|
300
|
+
case 1:
|
|
301
|
+
result = _a.sent();
|
|
302
|
+
finalData = result.data.result.response.value;
|
|
303
|
+
if (!finalData) {
|
|
304
|
+
return [2 /*return*/, null];
|
|
305
|
+
}
|
|
306
|
+
account = any_1.Any.decode(Buffer.from(finalData, "base64"));
|
|
307
|
+
finalAccount = (0, accounts_1.accountFromAny)(account);
|
|
308
|
+
return [2 /*return*/, finalAccount];
|
|
309
|
+
case 2:
|
|
310
|
+
error_2 = _a.sent();
|
|
311
|
+
return [2 /*return*/, null];
|
|
312
|
+
case 3: return [2 /*return*/];
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
};
|
|
317
|
+
return SigningProtobufStargateClient;
|
|
318
|
+
}(stargateClient_1.StargateClient));
|
|
319
|
+
exports.SigningProtobufStargateClient = SigningProtobufStargateClient;
|
|
@@ -1,121 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing";
|
|
1
|
+
import { EncodeObject, OfflineDirectSigner, Registry, GeneratedType } from "@cosmjs/proto-signing";
|
|
3
2
|
import { CometClient, HttpEndpoint } from "@cosmjs/tendermint-rpc";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { AminoConverters, AminoTypes } from "./aminotypes";
|
|
8
|
-
import { GasPrice } from "./fee";
|
|
9
|
-
import { DeliverTxResponse, StargateClient, StargateClientOptions } from "./stargateclient";
|
|
3
|
+
import { SignDoc, TxRaw, Fee } from "cosmjs-types/cosmos/tx/v1beta1/tx";
|
|
4
|
+
import { Account } from "./accounts";
|
|
5
|
+
import { DeliverTxResponse, StargateClient, StargateClientOptions } from "./stargateClient";
|
|
10
6
|
export declare const defaultRegistryTypes: ReadonlyArray<[string, GeneratedType]>;
|
|
11
|
-
export interface ArbitraryVerifyData {
|
|
12
|
-
type: string;
|
|
13
|
-
signer: string;
|
|
14
|
-
data: string;
|
|
15
|
-
pubkey: string;
|
|
16
|
-
signature: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Signing information for a single signer that is not included in the transaction.
|
|
20
|
-
*
|
|
21
|
-
* @see https://github.com/cosmos/cosmos-sdk/blob/v0.42.2/x/auth/signing/sign_mode_handler.go#L23-L37
|
|
22
|
-
*/
|
|
23
7
|
export interface SignerData {
|
|
24
8
|
readonly accountNumber: number;
|
|
25
9
|
readonly sequence: number;
|
|
26
10
|
readonly chainId: string;
|
|
27
11
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
readonly
|
|
12
|
+
export interface SequenceResponse {
|
|
13
|
+
readonly accountNumber: number;
|
|
14
|
+
readonly sequence: number;
|
|
15
|
+
}
|
|
16
|
+
export interface TxRawExt {
|
|
17
|
+
readonly txRaw: TxRaw;
|
|
18
|
+
readonly signature: string;
|
|
31
19
|
}
|
|
32
20
|
export interface SigningStargateClientOptions extends StargateClientOptions {
|
|
33
21
|
readonly registry?: Registry;
|
|
34
|
-
readonly aminoTypes?: AminoTypes;
|
|
35
|
-
readonly broadcastTimeoutMs?: number;
|
|
36
|
-
readonly broadcastPollIntervalMs?: number;
|
|
37
|
-
readonly gasPrice?: GasPrice;
|
|
38
|
-
}
|
|
39
|
-
export declare function createDefaultAminoConverters(): AminoConverters;
|
|
40
|
-
export interface MsgSignData extends AminoMsg {
|
|
41
|
-
readonly type: "sign/MsgSignData";
|
|
42
|
-
readonly value: {
|
|
43
|
-
/** Bech32 account address */
|
|
44
|
-
signer: string;
|
|
45
|
-
/** Base64 encoded data */
|
|
46
|
-
data: string;
|
|
47
|
-
};
|
|
48
22
|
}
|
|
49
|
-
export declare function isMsgSignData(msg: AminoMsg): msg is MsgSignData;
|
|
50
23
|
export declare class SigningStargateClient extends StargateClient {
|
|
51
24
|
readonly registry: Registry;
|
|
52
|
-
private chainId;
|
|
53
|
-
readonly broadcastTimeoutMs: number | undefined;
|
|
54
|
-
readonly broadcastPollIntervalMs: number | undefined;
|
|
55
25
|
private readonly signer;
|
|
56
|
-
private
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
* To set the Comet client explicitly, use `createWithSigner`.
|
|
64
|
-
*/
|
|
65
|
-
static connectWithSigner(endpoint: string | HttpEndpoint, signer: OfflineSigner, options?: SigningStargateClientOptions): Promise<SigningStargateClient>;
|
|
66
|
-
/**
|
|
67
|
-
* Creates an instance from a manually created Comet client.
|
|
68
|
-
* Use this to use `Comet38Client` or `Tendermint37Client` instead of `Tendermint34Client`.
|
|
69
|
-
*/
|
|
70
|
-
static createWithSigner(cometClient: CometClient, signer: OfflineSigner, options?: SigningStargateClientOptions): Promise<SigningStargateClient>;
|
|
71
|
-
/**
|
|
72
|
-
* Creates a client in offline mode.
|
|
73
|
-
*
|
|
74
|
-
* This should only be used in niche cases where you know exactly what you're doing,
|
|
75
|
-
* e.g. when building an offline signing application.
|
|
76
|
-
*
|
|
77
|
-
* When you try to use online functionality with such a signer, an
|
|
78
|
-
* exception will be raised.
|
|
79
|
-
*/
|
|
80
|
-
static offline(signer: OfflineSigner, options?: SigningStargateClientOptions): Promise<SigningStargateClient>;
|
|
81
|
-
protected constructor(cometClient: CometClient | undefined, signer: OfflineSigner, options: SigningStargateClientOptions);
|
|
82
|
-
simulate(signerAddress: string, messages: readonly EncodeObject[], memo: string | undefined): Promise<number>;
|
|
83
|
-
sendTokens(senderAddress: string, recipientAddress: string, amount: readonly Coin[], fee: StdFee | "auto" | number, memo?: string): Promise<DeliverTxResponse>;
|
|
84
|
-
delegateTokens(delegatorAddress: string, validatorAddress: string, amount: Coin, fee: StdFee | "auto" | number, memo?: string): Promise<DeliverTxResponse>;
|
|
85
|
-
undelegateTokens(delegatorAddress: string, validatorAddress: string, amount: Coin, fee: StdFee | "auto" | number, memo?: string): Promise<DeliverTxResponse>;
|
|
86
|
-
withdrawRewards(delegatorAddress: string, validatorAddress: string, fee: StdFee | "auto" | number, memo?: string): Promise<DeliverTxResponse>;
|
|
87
|
-
/**
|
|
88
|
-
* @deprecated This API does not support setting the memo field of `MsgTransfer` (only the transaction memo).
|
|
89
|
-
* We'll remove this method at some point because trying to wrap the various message types is a losing strategy.
|
|
90
|
-
* Please migrate to `signAndBroadcast` with an `MsgTransferEncodeObject` created in the caller code instead.
|
|
91
|
-
* @see https://github.com/cosmos/cosmjs/issues/1493
|
|
92
|
-
*/
|
|
93
|
-
sendIbcTokens(senderAddress: string, recipientAddress: string, transferAmount: Coin, sourcePort: string, sourceChannel: string, timeoutHeight: Height | undefined,
|
|
94
|
-
/** timeout in seconds */
|
|
95
|
-
timeoutTimestamp: number | undefined, fee: StdFee | "auto" | number, memo?: string): Promise<DeliverTxResponse>;
|
|
96
|
-
signAndBroadcast(signerAddress: string, messages: readonly EncodeObject[], fee: StdFee | "auto" | number, memo?: string, timeoutHeight?: bigint): Promise<DeliverTxResponse>;
|
|
97
|
-
/**
|
|
98
|
-
* This method is useful if you want to send a transaction in broadcast,
|
|
99
|
-
* without waiting for it to be placed inside a block, because for example
|
|
100
|
-
* I would like to receive the hash to later track the transaction with another tool.
|
|
101
|
-
* @returns Returns the hash of the transaction
|
|
102
|
-
*/
|
|
103
|
-
signAndBroadcastSync(signerAddress: string, messages: readonly EncodeObject[], fee: StdFee | "auto" | number, memo?: string, timeoutHeight?: bigint): Promise<string>;
|
|
104
|
-
static makeSignDocForSend(signerAddress: string, pubkeyStr: string, messages: readonly EncodeObject[], fee: StdFee, memo: string, serverUrl: string, chainId: string, registry: Registry): Promise<SignDoc>;
|
|
105
|
-
/**
|
|
106
|
-
* Gets account number and sequence from the API, creates a sign doc,
|
|
107
|
-
* creates a single signature and assembles the signed transaction.
|
|
108
|
-
*
|
|
109
|
-
* The sign mode (SIGN_MODE_DIRECT or SIGN_MODE_LEGACY_AMINO_JSON) is determined by this client's signer.
|
|
110
|
-
*
|
|
111
|
-
* You can pass signer data (account number, sequence and chain ID) explicitly instead of querying them
|
|
112
|
-
* from the chain. This is needed when signing for a multisig account, but it also allows for offline signing
|
|
113
|
-
* (See the SigningStargateClient.offline constructor).
|
|
114
|
-
*/
|
|
115
|
-
sign(signerAddress: string, messages: readonly EncodeObject[], fee: StdFee, memo: string, explicitSignerData?: SignerData, timeoutHeight?: bigint): Promise<TxRaw>;
|
|
116
|
-
getChainId(): Promise<string>;
|
|
117
|
-
private signAmino;
|
|
26
|
+
private static _endpoint;
|
|
27
|
+
static connectWithSigner(endpoint: string | HttpEndpoint, signer: OfflineDirectSigner, options?: SigningStargateClientOptions): Promise<SigningStargateClient>;
|
|
28
|
+
static createWithSigner(cometClient: CometClient, signer: OfflineDirectSigner, options?: SigningStargateClientOptions): Promise<SigningStargateClient>;
|
|
29
|
+
protected constructor(cometClient: CometClient | undefined, signer: OfflineDirectSigner, options: SigningStargateClientOptions);
|
|
30
|
+
signAndBroadcast(signerAddress: string, messages: readonly EncodeObject[], fee: Fee, memo?: string): Promise<DeliverTxResponse>;
|
|
31
|
+
static makeSignDocForSend(signerAddress: string, pubkeyStr: string, messages: readonly EncodeObject[], fee: Fee, memo: string, serverUrl: string, chainId: string, registry: Registry): Promise<SignDoc>;
|
|
32
|
+
sign(signerAddress: string, messages: readonly EncodeObject[], fee: Fee, memo: string, explicitSignerData?: SignerData): Promise<TxRaw>;
|
|
118
33
|
private signDirect;
|
|
119
|
-
|
|
120
|
-
|
|
34
|
+
signDirectForSignDoc(signerAddress: string, signDoc: SignDoc): Promise<TxRawExt>;
|
|
35
|
+
static getSequence(address: string): Promise<SequenceResponse>;
|
|
36
|
+
static getAccount(address: string): Promise<Account | null>;
|
|
121
37
|
}
|