@gnolang/tm2-js-client 2.0.3 → 2.0.4
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.cjs +9 -2
- package/dist/index.d.cts +3 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +3 -1
- package/dist/proto/index.cjs +2 -0
- package/dist/proto/index.d.cts +2 -0
- package/dist/proto/index.d.mts +2 -0
- package/dist/proto/index.mjs +2 -0
- package/dist/proto/tm2/abci.cjs +1 -0
- package/dist/proto/tm2/abci.d.cts +1 -1
- package/dist/proto/tm2/abci.d.mts +1 -1
- package/dist/proto/tm2/abci.mjs +1 -1
- package/dist/proto/tm2/multisig.cjs +199 -0
- package/dist/proto/tm2/multisig.cjs.map +1 -0
- package/dist/proto/tm2/multisig.d.cts +1 -1
- package/dist/proto/tm2/multisig.d.mts +1 -1
- package/dist/proto/tm2/multisig.mjs +196 -0
- package/dist/proto/tm2/multisig.mjs.map +1 -0
- package/dist/provider/utility/provider.utility.cjs +4 -4
- package/dist/provider/utility/provider.utility.cjs.map +1 -1
- package/dist/provider/utility/provider.utility.d.cts +1 -1
- package/dist/provider/utility/provider.utility.d.mts +1 -1
- package/dist/provider/utility/provider.utility.mjs +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_any = require("./proto/google/protobuf/any.cjs");
|
|
3
|
+
const require_abci = require("./proto/tm2/abci.cjs");
|
|
4
|
+
const require_multisig = require("./proto/tm2/multisig.cjs");
|
|
3
5
|
const require_tx = require("./proto/tm2/tx.cjs");
|
|
4
6
|
require("./proto/index.cjs");
|
|
5
7
|
const require_endpoints = require("./provider/endpoints.cjs");
|
|
6
8
|
const require_errors = require("./provider/errors/errors.cjs");
|
|
7
|
-
const require_abci = require("./provider/types/abci.cjs");
|
|
9
|
+
const require_abci$1 = require("./provider/types/abci.cjs");
|
|
8
10
|
const require_adapters = require("./provider/utility/adapters.cjs");
|
|
9
11
|
const require_requests_utility = require("./provider/utility/requests.utility.cjs");
|
|
10
12
|
const require_provider_utility = require("./provider/utility/provider.utility.cjs");
|
|
@@ -23,11 +25,12 @@ const require_sign = require("./wallet/types/sign.cjs");
|
|
|
23
25
|
const require_wallet = require("./wallet/wallet.cjs");
|
|
24
26
|
require("./wallet/index.cjs");
|
|
25
27
|
exports.ABCIEndpoint = require_endpoints.ABCIEndpoint;
|
|
26
|
-
exports.ABCIErrorKey = require_abci.ABCIErrorKey;
|
|
28
|
+
exports.ABCIErrorKey = require_abci$1.ABCIErrorKey;
|
|
27
29
|
exports.Any = require_any.Any;
|
|
28
30
|
exports.BaseTm2Provider = require_provider.BaseTm2Provider;
|
|
29
31
|
exports.BlockEndpoint = require_endpoints.BlockEndpoint;
|
|
30
32
|
exports.CommonEndpoint = require_endpoints.CommonEndpoint;
|
|
33
|
+
exports.CompactBitArray = require_multisig.CompactBitArray;
|
|
31
34
|
exports.ConsensusEndpoint = require_endpoints.ConsensusEndpoint;
|
|
32
35
|
exports.GasOverflowError = require_errors.GasOverflowError;
|
|
33
36
|
exports.InsufficientCoinsError = require_errors.InsufficientCoinsError;
|
|
@@ -43,9 +46,13 @@ exports.JSONRPCProvider = require_jsonrpc.JSONRPCProvider;
|
|
|
43
46
|
exports.KeySigner = require_key.KeySigner;
|
|
44
47
|
exports.LedgerSigner = require_ledger.LedgerSigner;
|
|
45
48
|
exports.MemoTooLargeError = require_errors.MemoTooLargeError;
|
|
49
|
+
exports.Multisignature = require_multisig.Multisignature;
|
|
46
50
|
exports.NoSignaturesError = require_errors.NoSignaturesError;
|
|
47
51
|
exports.OutOfGasError = require_errors.OutOfGasError;
|
|
52
|
+
exports.PubKeyMultisig = require_multisig.PubKeyMultisig;
|
|
48
53
|
exports.PubKeySecp256k1 = require_tx.PubKeySecp256k1;
|
|
54
|
+
exports.ResponseBase = require_abci.ResponseBase;
|
|
55
|
+
exports.ResponseDeliverTx = require_abci.ResponseDeliverTx;
|
|
49
56
|
exports.RestService = require_restService.RestService;
|
|
50
57
|
exports.Secp256k1PubKeyType = require_sign.Secp256k1PubKeyType;
|
|
51
58
|
exports.TM2Error = require_errors.TM2Error;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Any } from "./proto/google/protobuf/any.cjs";
|
|
2
|
+
import { ResponseBase, ResponseDeliverTx } from "./proto/tm2/abci.cjs";
|
|
3
|
+
import { CompactBitArray, Multisignature, PubKeyMultisig } from "./proto/tm2/multisig.cjs";
|
|
2
4
|
import { DeepPartial, Exact, MessageFns, PubKeySecp256k1, Tx, TxFee, TxSignature, protobufPackage } from "./proto/tm2/tx.cjs";
|
|
3
5
|
import { ABCIEndpoint, BlockEndpoint, CommonEndpoint, ConsensusEndpoint, TransactionEndpoint } from "./provider/endpoints.cjs";
|
|
4
6
|
import { GasOverflowError, InsufficientCoinsError, InsufficientFeeError, InsufficientFundsError, InternalError, InvalidAddressError, InvalidCoinsError, InvalidGasWantedError, InvalidPubKeyError, InvalidSequenceError, MemoTooLargeError, NoSignaturesError, OutOfGasError, TM2Error, TooManySignaturesError, TxDecodeError, UnauthorizedError, UnknownAddressError, UnknownRequestError } from "./provider/errors/errors.cjs";
|
|
@@ -21,4 +23,4 @@ import { Secp256k1PubKeyType, TxSignPayload } from "./wallet/types/sign.cjs";
|
|
|
21
23
|
import { AccountWalletOption, CreateWalletOptions } from "./wallet/types/wallet.cjs";
|
|
22
24
|
import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 } from "./wallet/utility/utility.cjs";
|
|
23
25
|
import { SignTransactionOptions, Wallet } from "./wallet/wallet.cjs";
|
|
24
|
-
export { ABCIAccount, ABCIEndpoint, ABCIErrorKey, ABCIResponse, ABCIResponseBase, AccountWalletOption, Any, BaseTm2Provider, BeginBlock, Block, BlockEndpoint, BlockHeader, BlockID, BlockInfo, BlockMeta, BlockResult, BroadcastAsGeneric, BroadcastTransactionCommit, BroadcastTransactionMap, BroadcastTransactionSync, BroadcastTxCommitResult, BroadcastTxSyncResult, BroadcastType, CommonEndpoint, ConsensusEndpoint, ConsensusParams, ConsensusState, CreateWalletOptions, DeepPartial, DeliverTx, EndBlock, Exact, GasOverflowError, InsufficientCoinsError, InsufficientFeeError, InsufficientFundsError, InternalError, InvalidAddressError, InvalidCoinsError, InvalidGasWantedError, InvalidPubKeyError, InvalidSequenceError, JSONRPCProvider, KeySigner, LedgerSigner, MemoTooLargeError, MessageFns, NetworkInfo, NoSignaturesError, OutOfGasError, PrecommitInfo, Provider, PubKeySecp256k1, RPCError, RPCRequest, RPCResponse, RequestParams, RestService, Secp256k1PubKeyType, SignTransactionOptions, Signer, Status, TM2Error, TooManySignaturesError, TransactionEndpoint, Tx, TxDecodeError, TxFee, TxResult, TxSignPayload, TxSignature, UnauthorizedError, UnknownAddressError, UnknownRequestError, WSProvider, Wallet, adaptAbciQueryResponse, adaptBlockResponse, adaptBlockResultsResponse, adaptBroadcastTxCommitResponse, adaptBroadcastTxSyncResponse, adaptConsensusParamsResponse, adaptNetInfoResponse, adaptStatusResponse, adaptTxResponse, base64ToUint8Array, compactBitArrayFromAmino, compactBitArrayToAmino, defaultAddressPrefix, encodeCharacterSet, extractAccountFromResponse, extractAccountNumberFromResponse, extractBalanceFromResponse, extractSequenceFromResponse, extractSimulateFromResponse, generateEntropy, generateHDPath, generateKeyPair, newRequest, newResponse, parseABCI, parseProto, protobufPackage, sortedJsonStringify, stringToBase64, stringToUTF8, toBase64, toHexString, uint8ArrayToBase64, waitForTransaction };
|
|
26
|
+
export { ABCIAccount, ABCIEndpoint, ABCIErrorKey, ABCIResponse, ABCIResponseBase, AccountWalletOption, Any, BaseTm2Provider, BeginBlock, Block, BlockEndpoint, BlockHeader, BlockID, BlockInfo, BlockMeta, BlockResult, BroadcastAsGeneric, BroadcastTransactionCommit, BroadcastTransactionMap, BroadcastTransactionSync, BroadcastTxCommitResult, BroadcastTxSyncResult, BroadcastType, CommonEndpoint, CompactBitArray, ConsensusEndpoint, ConsensusParams, ConsensusState, CreateWalletOptions, DeepPartial, DeliverTx, EndBlock, Exact, GasOverflowError, InsufficientCoinsError, InsufficientFeeError, InsufficientFundsError, InternalError, InvalidAddressError, InvalidCoinsError, InvalidGasWantedError, InvalidPubKeyError, InvalidSequenceError, JSONRPCProvider, KeySigner, LedgerSigner, MemoTooLargeError, MessageFns, Multisignature, NetworkInfo, NoSignaturesError, OutOfGasError, PrecommitInfo, Provider, PubKeyMultisig, PubKeySecp256k1, RPCError, RPCRequest, RPCResponse, RequestParams, ResponseBase, ResponseDeliverTx, RestService, Secp256k1PubKeyType, SignTransactionOptions, Signer, Status, TM2Error, TooManySignaturesError, TransactionEndpoint, Tx, TxDecodeError, TxFee, TxResult, TxSignPayload, TxSignature, UnauthorizedError, UnknownAddressError, UnknownRequestError, WSProvider, Wallet, adaptAbciQueryResponse, adaptBlockResponse, adaptBlockResultsResponse, adaptBroadcastTxCommitResponse, adaptBroadcastTxSyncResponse, adaptConsensusParamsResponse, adaptNetInfoResponse, adaptStatusResponse, adaptTxResponse, base64ToUint8Array, compactBitArrayFromAmino, compactBitArrayToAmino, defaultAddressPrefix, encodeCharacterSet, extractAccountFromResponse, extractAccountNumberFromResponse, extractBalanceFromResponse, extractSequenceFromResponse, extractSimulateFromResponse, generateEntropy, generateHDPath, generateKeyPair, newRequest, newResponse, parseABCI, parseProto, protobufPackage, sortedJsonStringify, stringToBase64, stringToUTF8, toBase64, toHexString, uint8ArrayToBase64, waitForTransaction };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Any } from "./proto/google/protobuf/any.mjs";
|
|
2
|
+
import { ResponseBase, ResponseDeliverTx } from "./proto/tm2/abci.mjs";
|
|
3
|
+
import { CompactBitArray, Multisignature, PubKeyMultisig } from "./proto/tm2/multisig.mjs";
|
|
2
4
|
import { DeepPartial, Exact, MessageFns, PubKeySecp256k1, Tx, TxFee, TxSignature, protobufPackage } from "./proto/tm2/tx.mjs";
|
|
3
5
|
import { ABCIEndpoint, BlockEndpoint, CommonEndpoint, ConsensusEndpoint, TransactionEndpoint } from "./provider/endpoints.mjs";
|
|
4
6
|
import { GasOverflowError, InsufficientCoinsError, InsufficientFeeError, InsufficientFundsError, InternalError, InvalidAddressError, InvalidCoinsError, InvalidGasWantedError, InvalidPubKeyError, InvalidSequenceError, MemoTooLargeError, NoSignaturesError, OutOfGasError, TM2Error, TooManySignaturesError, TxDecodeError, UnauthorizedError, UnknownAddressError, UnknownRequestError } from "./provider/errors/errors.mjs";
|
|
@@ -21,4 +23,4 @@ import { Secp256k1PubKeyType, TxSignPayload } from "./wallet/types/sign.mjs";
|
|
|
21
23
|
import { AccountWalletOption, CreateWalletOptions } from "./wallet/types/wallet.mjs";
|
|
22
24
|
import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 } from "./wallet/utility/utility.mjs";
|
|
23
25
|
import { SignTransactionOptions, Wallet } from "./wallet/wallet.mjs";
|
|
24
|
-
export { ABCIAccount, ABCIEndpoint, ABCIErrorKey, ABCIResponse, ABCIResponseBase, AccountWalletOption, Any, BaseTm2Provider, BeginBlock, Block, BlockEndpoint, BlockHeader, BlockID, BlockInfo, BlockMeta, BlockResult, BroadcastAsGeneric, BroadcastTransactionCommit, BroadcastTransactionMap, BroadcastTransactionSync, BroadcastTxCommitResult, BroadcastTxSyncResult, BroadcastType, CommonEndpoint, ConsensusEndpoint, ConsensusParams, ConsensusState, CreateWalletOptions, DeepPartial, DeliverTx, EndBlock, Exact, GasOverflowError, InsufficientCoinsError, InsufficientFeeError, InsufficientFundsError, InternalError, InvalidAddressError, InvalidCoinsError, InvalidGasWantedError, InvalidPubKeyError, InvalidSequenceError, JSONRPCProvider, KeySigner, LedgerSigner, MemoTooLargeError, MessageFns, NetworkInfo, NoSignaturesError, OutOfGasError, PrecommitInfo, Provider, PubKeySecp256k1, RPCError, RPCRequest, RPCResponse, RequestParams, RestService, Secp256k1PubKeyType, SignTransactionOptions, Signer, Status, TM2Error, TooManySignaturesError, TransactionEndpoint, Tx, TxDecodeError, TxFee, TxResult, TxSignPayload, TxSignature, UnauthorizedError, UnknownAddressError, UnknownRequestError, WSProvider, Wallet, adaptAbciQueryResponse, adaptBlockResponse, adaptBlockResultsResponse, adaptBroadcastTxCommitResponse, adaptBroadcastTxSyncResponse, adaptConsensusParamsResponse, adaptNetInfoResponse, adaptStatusResponse, adaptTxResponse, base64ToUint8Array, compactBitArrayFromAmino, compactBitArrayToAmino, defaultAddressPrefix, encodeCharacterSet, extractAccountFromResponse, extractAccountNumberFromResponse, extractBalanceFromResponse, extractSequenceFromResponse, extractSimulateFromResponse, generateEntropy, generateHDPath, generateKeyPair, newRequest, newResponse, parseABCI, parseProto, protobufPackage, sortedJsonStringify, stringToBase64, stringToUTF8, toBase64, toHexString, uint8ArrayToBase64, waitForTransaction };
|
|
26
|
+
export { ABCIAccount, ABCIEndpoint, ABCIErrorKey, ABCIResponse, ABCIResponseBase, AccountWalletOption, Any, BaseTm2Provider, BeginBlock, Block, BlockEndpoint, BlockHeader, BlockID, BlockInfo, BlockMeta, BlockResult, BroadcastAsGeneric, BroadcastTransactionCommit, BroadcastTransactionMap, BroadcastTransactionSync, BroadcastTxCommitResult, BroadcastTxSyncResult, BroadcastType, CommonEndpoint, CompactBitArray, ConsensusEndpoint, ConsensusParams, ConsensusState, CreateWalletOptions, DeepPartial, DeliverTx, EndBlock, Exact, GasOverflowError, InsufficientCoinsError, InsufficientFeeError, InsufficientFundsError, InternalError, InvalidAddressError, InvalidCoinsError, InvalidGasWantedError, InvalidPubKeyError, InvalidSequenceError, JSONRPCProvider, KeySigner, LedgerSigner, MemoTooLargeError, MessageFns, Multisignature, NetworkInfo, NoSignaturesError, OutOfGasError, PrecommitInfo, Provider, PubKeyMultisig, PubKeySecp256k1, RPCError, RPCRequest, RPCResponse, RequestParams, ResponseBase, ResponseDeliverTx, RestService, Secp256k1PubKeyType, SignTransactionOptions, Signer, Status, TM2Error, TooManySignaturesError, TransactionEndpoint, Tx, TxDecodeError, TxFee, TxResult, TxSignPayload, TxSignature, UnauthorizedError, UnknownAddressError, UnknownRequestError, WSProvider, Wallet, adaptAbciQueryResponse, adaptBlockResponse, adaptBlockResultsResponse, adaptBroadcastTxCommitResponse, adaptBroadcastTxSyncResponse, adaptConsensusParamsResponse, adaptNetInfoResponse, adaptStatusResponse, adaptTxResponse, base64ToUint8Array, compactBitArrayFromAmino, compactBitArrayToAmino, defaultAddressPrefix, encodeCharacterSet, extractAccountFromResponse, extractAccountNumberFromResponse, extractBalanceFromResponse, extractSequenceFromResponse, extractSimulateFromResponse, generateEntropy, generateHDPath, generateKeyPair, newRequest, newResponse, parseABCI, parseProto, protobufPackage, sortedJsonStringify, stringToBase64, stringToUTF8, toBase64, toHexString, uint8ArrayToBase64, waitForTransaction };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Any } from "./proto/google/protobuf/any.mjs";
|
|
2
|
+
import { ResponseBase, ResponseDeliverTx } from "./proto/tm2/abci.mjs";
|
|
3
|
+
import { CompactBitArray, Multisignature, PubKeyMultisig } from "./proto/tm2/multisig.mjs";
|
|
2
4
|
import { PubKeySecp256k1, Tx, TxFee, TxSignature, protobufPackage } from "./proto/tm2/tx.mjs";
|
|
3
5
|
import "./proto/index.mjs";
|
|
4
6
|
import { ABCIEndpoint, BlockEndpoint, CommonEndpoint, ConsensusEndpoint, TransactionEndpoint } from "./provider/endpoints.mjs";
|
|
@@ -21,4 +23,4 @@ import { LedgerSigner } from "./wallet/ledger/ledger.mjs";
|
|
|
21
23
|
import { Secp256k1PubKeyType } from "./wallet/types/sign.mjs";
|
|
22
24
|
import { Wallet } from "./wallet/wallet.mjs";
|
|
23
25
|
import "./wallet/index.mjs";
|
|
24
|
-
export { ABCIEndpoint, ABCIErrorKey, Any, BaseTm2Provider, BlockEndpoint, CommonEndpoint, ConsensusEndpoint, GasOverflowError, InsufficientCoinsError, InsufficientFeeError, InsufficientFundsError, InternalError, InvalidAddressError, InvalidCoinsError, InvalidGasWantedError, InvalidPubKeyError, InvalidSequenceError, JSONRPCProvider, KeySigner, LedgerSigner, MemoTooLargeError, NoSignaturesError, OutOfGasError, PubKeySecp256k1, RestService, Secp256k1PubKeyType, TM2Error, TooManySignaturesError, TransactionEndpoint, Tx, TxDecodeError, TxFee, TxSignature, UnauthorizedError, UnknownAddressError, UnknownRequestError, WSProvider, Wallet, adaptAbciQueryResponse, adaptBlockResponse, adaptBlockResultsResponse, adaptBroadcastTxCommitResponse, adaptBroadcastTxSyncResponse, adaptConsensusParamsResponse, adaptNetInfoResponse, adaptStatusResponse, adaptTxResponse, base64ToUint8Array, compactBitArrayFromAmino, compactBitArrayToAmino, defaultAddressPrefix, encodeCharacterSet, extractAccountFromResponse, extractAccountNumberFromResponse, extractBalanceFromResponse, extractSequenceFromResponse, extractSimulateFromResponse, generateEntropy, generateHDPath, generateKeyPair, newRequest, newResponse, parseABCI, parseProto, protobufPackage, sortedJsonStringify, stringToBase64, stringToUTF8, toBase64, toHexString, uint8ArrayToBase64, waitForTransaction };
|
|
26
|
+
export { ABCIEndpoint, ABCIErrorKey, Any, BaseTm2Provider, BlockEndpoint, CommonEndpoint, CompactBitArray, ConsensusEndpoint, GasOverflowError, InsufficientCoinsError, InsufficientFeeError, InsufficientFundsError, InternalError, InvalidAddressError, InvalidCoinsError, InvalidGasWantedError, InvalidPubKeyError, InvalidSequenceError, JSONRPCProvider, KeySigner, LedgerSigner, MemoTooLargeError, Multisignature, NoSignaturesError, OutOfGasError, PubKeyMultisig, PubKeySecp256k1, ResponseBase, ResponseDeliverTx, RestService, Secp256k1PubKeyType, TM2Error, TooManySignaturesError, TransactionEndpoint, Tx, TxDecodeError, TxFee, TxSignature, UnauthorizedError, UnknownAddressError, UnknownRequestError, WSProvider, Wallet, adaptAbciQueryResponse, adaptBlockResponse, adaptBlockResultsResponse, adaptBroadcastTxCommitResponse, adaptBroadcastTxSyncResponse, adaptConsensusParamsResponse, adaptNetInfoResponse, adaptStatusResponse, adaptTxResponse, base64ToUint8Array, compactBitArrayFromAmino, compactBitArrayToAmino, defaultAddressPrefix, encodeCharacterSet, extractAccountFromResponse, extractAccountNumberFromResponse, extractBalanceFromResponse, extractSequenceFromResponse, extractSimulateFromResponse, generateEntropy, generateHDPath, generateKeyPair, newRequest, newResponse, parseABCI, parseProto, protobufPackage, sortedJsonStringify, stringToBase64, stringToUTF8, toBase64, toHexString, uint8ArrayToBase64, waitForTransaction };
|
package/dist/proto/index.cjs
CHANGED
package/dist/proto/index.d.cts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { Any } from "./google/protobuf/any.cjs";
|
|
2
|
+
import { ResponseBase, ResponseDeliverTx } from "./tm2/abci.cjs";
|
|
3
|
+
import { CompactBitArray, Multisignature, PubKeyMultisig } from "./tm2/multisig.cjs";
|
|
2
4
|
import { DeepPartial, Exact, MessageFns, PubKeySecp256k1, Tx, TxFee, TxSignature, protobufPackage } from "./tm2/tx.cjs";
|
package/dist/proto/index.d.mts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { Any } from "./google/protobuf/any.mjs";
|
|
2
|
+
import { ResponseBase, ResponseDeliverTx } from "./tm2/abci.mjs";
|
|
3
|
+
import { CompactBitArray, Multisignature, PubKeyMultisig } from "./tm2/multisig.mjs";
|
|
2
4
|
import { DeepPartial, Exact, MessageFns, PubKeySecp256k1, Tx, TxFee, TxSignature, protobufPackage } from "./tm2/tx.mjs";
|
package/dist/proto/index.mjs
CHANGED
package/dist/proto/tm2/abci.cjs
CHANGED
package/dist/proto/tm2/abci.mjs
CHANGED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_any = require("../google/protobuf/any.cjs");
|
|
3
|
+
let _bufbuild_protobuf_wire = require("@bufbuild/protobuf/wire");
|
|
4
|
+
function createBasePubKeyMultisig() {
|
|
5
|
+
return {
|
|
6
|
+
k: 0n,
|
|
7
|
+
pub_keys: []
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
const PubKeyMultisig = {
|
|
11
|
+
encode(message, writer = new _bufbuild_protobuf_wire.BinaryWriter()) {
|
|
12
|
+
if (message.k !== 0n) {
|
|
13
|
+
if (BigInt.asUintN(64, message.k) !== message.k) throw new globalThis.Error("value provided for field message.k of type uint64 too large");
|
|
14
|
+
writer.uint32(8).uint64(message.k);
|
|
15
|
+
}
|
|
16
|
+
for (const v of message.pub_keys) require_any.Any.encode(v, writer.uint32(18).fork()).join();
|
|
17
|
+
return writer;
|
|
18
|
+
},
|
|
19
|
+
decode(input, length) {
|
|
20
|
+
const reader = input instanceof _bufbuild_protobuf_wire.BinaryReader ? input : new _bufbuild_protobuf_wire.BinaryReader(input);
|
|
21
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
22
|
+
const message = createBasePubKeyMultisig();
|
|
23
|
+
while (reader.pos < end) {
|
|
24
|
+
const tag = reader.uint32();
|
|
25
|
+
switch (tag >>> 3) {
|
|
26
|
+
case 1:
|
|
27
|
+
if (tag !== 8) break;
|
|
28
|
+
message.k = reader.uint64();
|
|
29
|
+
continue;
|
|
30
|
+
case 2:
|
|
31
|
+
if (tag !== 18) break;
|
|
32
|
+
message.pub_keys.push(require_any.Any.decode(reader, reader.uint32()));
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
36
|
+
reader.skip(tag & 7);
|
|
37
|
+
}
|
|
38
|
+
return message;
|
|
39
|
+
},
|
|
40
|
+
fromJSON(object) {
|
|
41
|
+
return {
|
|
42
|
+
k: isSet(object.threshold) ? BigInt(object.threshold) : 0n,
|
|
43
|
+
pub_keys: globalThis.Array.isArray(object?.pubkeys) ? object.pubkeys.map((e) => require_any.Any.fromJSON(e)) : []
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
toJSON(message) {
|
|
47
|
+
const obj = {};
|
|
48
|
+
if (message.k !== void 0) obj.threshold = message.k.toString();
|
|
49
|
+
if (message.pub_keys?.length) obj.pubkeys = message.pub_keys.map((e) => require_any.Any.toJSON(e));
|
|
50
|
+
return obj;
|
|
51
|
+
},
|
|
52
|
+
create(base) {
|
|
53
|
+
return PubKeyMultisig.fromPartial(base ?? {});
|
|
54
|
+
},
|
|
55
|
+
fromPartial(object) {
|
|
56
|
+
const message = createBasePubKeyMultisig();
|
|
57
|
+
message.k = object.k ?? 0n;
|
|
58
|
+
message.pub_keys = object.pub_keys?.map((e) => require_any.Any.fromPartial(e)) || [];
|
|
59
|
+
return message;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
function createBaseMultisignature() {
|
|
63
|
+
return {
|
|
64
|
+
bit_array: void 0,
|
|
65
|
+
sigs: []
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const Multisignature = {
|
|
69
|
+
encode(message, writer = new _bufbuild_protobuf_wire.BinaryWriter()) {
|
|
70
|
+
if (message.bit_array !== void 0) CompactBitArray.encode(message.bit_array, writer.uint32(10).fork()).join();
|
|
71
|
+
for (const v of message.sigs) writer.uint32(18).bytes(v);
|
|
72
|
+
return writer;
|
|
73
|
+
},
|
|
74
|
+
decode(input, length) {
|
|
75
|
+
const reader = input instanceof _bufbuild_protobuf_wire.BinaryReader ? input : new _bufbuild_protobuf_wire.BinaryReader(input);
|
|
76
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
77
|
+
const message = createBaseMultisignature();
|
|
78
|
+
while (reader.pos < end) {
|
|
79
|
+
const tag = reader.uint32();
|
|
80
|
+
switch (tag >>> 3) {
|
|
81
|
+
case 1:
|
|
82
|
+
if (tag !== 10) break;
|
|
83
|
+
message.bit_array = CompactBitArray.decode(reader, reader.uint32());
|
|
84
|
+
continue;
|
|
85
|
+
case 2:
|
|
86
|
+
if (tag !== 18) break;
|
|
87
|
+
message.sigs.push(reader.bytes());
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
91
|
+
reader.skip(tag & 7);
|
|
92
|
+
}
|
|
93
|
+
return message;
|
|
94
|
+
},
|
|
95
|
+
fromJSON(object) {
|
|
96
|
+
return {
|
|
97
|
+
bit_array: isSet(object.bit_array) ? CompactBitArray.fromJSON(object.bit_array) : void 0,
|
|
98
|
+
sigs: globalThis.Array.isArray(object?.sigs) ? object.sigs.map((e) => bytesFromBase64(e)) : []
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
toJSON(message) {
|
|
102
|
+
const obj = {};
|
|
103
|
+
if (message.bit_array !== void 0) obj.bit_array = CompactBitArray.toJSON(message.bit_array);
|
|
104
|
+
if (message.sigs?.length) obj.sigs = message.sigs.map((e) => base64FromBytes(e));
|
|
105
|
+
return obj;
|
|
106
|
+
},
|
|
107
|
+
create(base) {
|
|
108
|
+
return Multisignature.fromPartial(base ?? {});
|
|
109
|
+
},
|
|
110
|
+
fromPartial(object) {
|
|
111
|
+
const message = createBaseMultisignature();
|
|
112
|
+
message.bit_array = object.bit_array !== void 0 && object.bit_array !== null ? CompactBitArray.fromPartial(object.bit_array) : void 0;
|
|
113
|
+
message.sigs = object.sigs?.map((e) => e) || [];
|
|
114
|
+
return message;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
function createBaseCompactBitArray() {
|
|
118
|
+
return {
|
|
119
|
+
extra_bits_stored: 0,
|
|
120
|
+
elems: new Uint8Array(0)
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const CompactBitArray = {
|
|
124
|
+
encode(message, writer = new _bufbuild_protobuf_wire.BinaryWriter()) {
|
|
125
|
+
if (message.extra_bits_stored !== 0) writer.uint32(8).uint32(message.extra_bits_stored);
|
|
126
|
+
if (message.elems.length !== 0) writer.uint32(18).bytes(message.elems);
|
|
127
|
+
return writer;
|
|
128
|
+
},
|
|
129
|
+
decode(input, length) {
|
|
130
|
+
const reader = input instanceof _bufbuild_protobuf_wire.BinaryReader ? input : new _bufbuild_protobuf_wire.BinaryReader(input);
|
|
131
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
132
|
+
const message = createBaseCompactBitArray();
|
|
133
|
+
while (reader.pos < end) {
|
|
134
|
+
const tag = reader.uint32();
|
|
135
|
+
switch (tag >>> 3) {
|
|
136
|
+
case 1:
|
|
137
|
+
if (tag !== 8) break;
|
|
138
|
+
message.extra_bits_stored = reader.uint32();
|
|
139
|
+
continue;
|
|
140
|
+
case 2:
|
|
141
|
+
if (tag !== 18) break;
|
|
142
|
+
message.elems = reader.bytes();
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
146
|
+
reader.skip(tag & 7);
|
|
147
|
+
}
|
|
148
|
+
return message;
|
|
149
|
+
},
|
|
150
|
+
fromJSON(object) {
|
|
151
|
+
return {
|
|
152
|
+
extra_bits_stored: isSet(object.extra_bits) ? globalThis.Number(object.extra_bits) : 0,
|
|
153
|
+
elems: isSet(object.bits) ? bytesFromBase64(object.bits) : new Uint8Array(0)
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
toJSON(message) {
|
|
157
|
+
const obj = {};
|
|
158
|
+
if (message.extra_bits_stored !== void 0) obj.extra_bits = Math.round(message.extra_bits_stored);
|
|
159
|
+
if (message.elems !== void 0) obj.bits = base64FromBytes(message.elems);
|
|
160
|
+
return obj;
|
|
161
|
+
},
|
|
162
|
+
create(base) {
|
|
163
|
+
return CompactBitArray.fromPartial(base ?? {});
|
|
164
|
+
},
|
|
165
|
+
fromPartial(object) {
|
|
166
|
+
const message = createBaseCompactBitArray();
|
|
167
|
+
message.extra_bits_stored = object.extra_bits_stored ?? 0;
|
|
168
|
+
message.elems = object.elems ?? new Uint8Array(0);
|
|
169
|
+
return message;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
function bytesFromBase64(b64) {
|
|
173
|
+
if (globalThis.Buffer) return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
|
|
174
|
+
else {
|
|
175
|
+
const bin = globalThis.atob(b64);
|
|
176
|
+
const arr = new Uint8Array(bin.length);
|
|
177
|
+
for (let i = 0; i < bin.length; ++i) arr[i] = bin.charCodeAt(i);
|
|
178
|
+
return arr;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function base64FromBytes(arr) {
|
|
182
|
+
if (globalThis.Buffer) return globalThis.Buffer.from(arr).toString("base64");
|
|
183
|
+
else {
|
|
184
|
+
const bin = [];
|
|
185
|
+
arr.forEach((byte) => {
|
|
186
|
+
bin.push(globalThis.String.fromCharCode(byte));
|
|
187
|
+
});
|
|
188
|
+
return globalThis.btoa(bin.join(""));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function isSet(value) {
|
|
192
|
+
return value !== null && value !== void 0;
|
|
193
|
+
}
|
|
194
|
+
//#endregion
|
|
195
|
+
exports.CompactBitArray = CompactBitArray;
|
|
196
|
+
exports.Multisignature = Multisignature;
|
|
197
|
+
exports.PubKeyMultisig = PubKeyMultisig;
|
|
198
|
+
|
|
199
|
+
//# sourceMappingURL=multisig.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multisig.cjs","names":["BinaryWriter","BinaryReader","Any"],"sources":["../../../src/proto/tm2/multisig.ts"],"sourcesContent":["// Code generated by protoc-gen-ts_proto. DO NOT EDIT.\n// versions:\n// protoc-gen-ts_proto v2.11.6\n// protoc v6.33.4\n// source: tm2/multisig.proto\n\n/* eslint-disable */\nimport { BinaryReader, BinaryWriter } from \"@bufbuild/protobuf/wire\";\nimport { Any } from \"../google/protobuf/any.js\";\n\nexport const protobufPackage = \"tm\";\n\n/** messages */\nexport interface PubKeyMultisig {\n k: bigint;\n pub_keys: Any[];\n}\n\nexport interface Multisignature {\n bit_array?: CompactBitArray | undefined;\n sigs: Uint8Array[];\n}\n\nexport interface CompactBitArray {\n /** The number of extra bits in elems. */\n extra_bits_stored: number;\n elems: Uint8Array;\n}\n\nfunction createBasePubKeyMultisig(): PubKeyMultisig {\n return { k: 0n, pub_keys: [] };\n}\n\nexport const PubKeyMultisig: MessageFns<PubKeyMultisig> = {\n encode(message: PubKeyMultisig, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.k !== 0n) {\n if (BigInt.asUintN(64, message.k) !== message.k) {\n throw new globalThis.Error(\"value provided for field message.k of type uint64 too large\");\n }\n writer.uint32(8).uint64(message.k);\n }\n for (const v of message.pub_keys) {\n Any.encode(v!, writer.uint32(18).fork()).join();\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): PubKeyMultisig {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBasePubKeyMultisig();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 8) {\n break;\n }\n\n message.k = reader.uint64() as bigint;\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.pub_keys.push(Any.decode(reader, reader.uint32()));\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): PubKeyMultisig {\n return {\n k: isSet(object.threshold) ? BigInt(object.threshold) : 0n,\n pub_keys: globalThis.Array.isArray(object?.pubkeys) ? object.pubkeys.map((e: any) => Any.fromJSON(e)) : [],\n };\n },\n\n toJSON(message: PubKeyMultisig): unknown {\n const obj: any = {};\n if (message.k !== undefined) {\n obj.threshold = message.k.toString();\n }\n if (message.pub_keys?.length) {\n obj.pubkeys = message.pub_keys.map((e) => Any.toJSON(e));\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<PubKeyMultisig>, I>>(base?: I): PubKeyMultisig {\n return PubKeyMultisig.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<PubKeyMultisig>, I>>(object: I): PubKeyMultisig {\n const message = createBasePubKeyMultisig();\n message.k = object.k ?? 0n;\n message.pub_keys = object.pub_keys?.map((e) => Any.fromPartial(e)) || [];\n return message;\n },\n};\n\nfunction createBaseMultisignature(): Multisignature {\n return { bit_array: undefined, sigs: [] };\n}\n\nexport const Multisignature: MessageFns<Multisignature> = {\n encode(message: Multisignature, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.bit_array !== undefined) {\n CompactBitArray.encode(message.bit_array, writer.uint32(10).fork()).join();\n }\n for (const v of message.sigs) {\n writer.uint32(18).bytes(v!);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): Multisignature {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseMultisignature();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.bit_array = CompactBitArray.decode(reader, reader.uint32());\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.sigs.push(reader.bytes());\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): Multisignature {\n return {\n bit_array: isSet(object.bit_array) ? CompactBitArray.fromJSON(object.bit_array) : undefined,\n sigs: globalThis.Array.isArray(object?.sigs) ? object.sigs.map((e: any) => bytesFromBase64(e)) : [],\n };\n },\n\n toJSON(message: Multisignature): unknown {\n const obj: any = {};\n if (message.bit_array !== undefined) {\n obj.bit_array = CompactBitArray.toJSON(message.bit_array);\n }\n if (message.sigs?.length) {\n obj.sigs = message.sigs.map((e) => base64FromBytes(e));\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<Multisignature>, I>>(base?: I): Multisignature {\n return Multisignature.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<Multisignature>, I>>(object: I): Multisignature {\n const message = createBaseMultisignature();\n message.bit_array = (object.bit_array !== undefined && object.bit_array !== null)\n ? CompactBitArray.fromPartial(object.bit_array)\n : undefined;\n message.sigs = object.sigs?.map((e) => e) || [];\n return message;\n },\n};\n\nfunction createBaseCompactBitArray(): CompactBitArray {\n return { extra_bits_stored: 0, elems: new Uint8Array(0) };\n}\n\nexport const CompactBitArray: MessageFns<CompactBitArray> = {\n encode(message: CompactBitArray, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.extra_bits_stored !== 0) {\n writer.uint32(8).uint32(message.extra_bits_stored);\n }\n if (message.elems.length !== 0) {\n writer.uint32(18).bytes(message.elems);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): CompactBitArray {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseCompactBitArray();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 8) {\n break;\n }\n\n message.extra_bits_stored = reader.uint32();\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.elems = reader.bytes();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): CompactBitArray {\n return {\n extra_bits_stored: isSet(object.extra_bits) ? globalThis.Number(object.extra_bits) : 0,\n elems: isSet(object.bits) ? bytesFromBase64(object.bits) : new Uint8Array(0),\n };\n },\n\n toJSON(message: CompactBitArray): unknown {\n const obj: any = {};\n if (message.extra_bits_stored !== undefined) {\n obj.extra_bits = Math.round(message.extra_bits_stored);\n }\n if (message.elems !== undefined) {\n obj.bits = base64FromBytes(message.elems);\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<CompactBitArray>, I>>(base?: I): CompactBitArray {\n return CompactBitArray.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<CompactBitArray>, I>>(object: I): CompactBitArray {\n const message = createBaseCompactBitArray();\n message.extra_bits_stored = object.extra_bits_stored ?? 0;\n message.elems = object.elems ?? new Uint8Array(0);\n return message;\n },\n};\n\nfunction bytesFromBase64(b64: string): Uint8Array {\n if ((globalThis as any).Buffer) {\n return Uint8Array.from((globalThis as any).Buffer.from(b64, \"base64\"));\n } else {\n const bin = globalThis.atob(b64);\n const arr = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; ++i) {\n arr[i] = bin.charCodeAt(i);\n }\n return arr;\n }\n}\n\nfunction base64FromBytes(arr: Uint8Array): string {\n if ((globalThis as any).Buffer) {\n return (globalThis as any).Buffer.from(arr).toString(\"base64\");\n } else {\n const bin: string[] = [];\n arr.forEach((byte) => {\n bin.push(globalThis.String.fromCharCode(byte));\n });\n return globalThis.btoa(bin.join(\"\"));\n }\n}\n\ntype Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;\n\nexport type DeepPartial<T> = T extends Builtin ? T\n : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>\n : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>\n : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }\n : Partial<T>;\n\ntype KeysOfUnion<T> = T extends T ? keyof T : never;\nexport type Exact<P, I extends P> = P extends Builtin ? P\n : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };\n\nfunction isSet(value: any): boolean {\n return value !== null && value !== undefined;\n}\n\nexport interface MessageFns<T> {\n encode(message: T, writer?: BinaryWriter): BinaryWriter;\n decode(input: BinaryReader | Uint8Array, length?: number): T;\n fromJSON(object: any): T;\n toJSON(message: T): unknown;\n create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;\n fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;\n}\n"],"mappings":";;;AA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EAChC,MAAM,MAAM,IAAI,WAAW,IAAI,OAAO;AACtC,OAAK,IAAI,IAAI,GAAG,IAAI,IAAI,QAAQ,EAAE,EAChC,KAAI,KAAK,IAAI,WAAW,EAAE;AAE5B,SAAO;;;AAIX,SAAS,gBAAgB,KAAyB;AAChD,KAAK,WAAmB,OACtB,QAAQ,WAAmB,OAAO,KAAK,IAAI,CAAC,SAAS,SAAS;MACzD;EACL,MAAM,MAAgB,EAAE;AACxB,MAAI,SAAS,SAAS;AACpB,OAAI,KAAK,WAAW,OAAO,aAAa,KAAK,CAAC;IAC9C;AACF,SAAO,WAAW,KAAK,IAAI,KAAK,GAAG,CAAC;;;AAgBxC,SAAS,MAAM,OAAqB;AAClC,QAAO,UAAU,QAAQ,UAAU"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { Any } from "../google/protobuf/any.mjs";
|
|
2
|
+
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
3
|
+
function createBasePubKeyMultisig() {
|
|
4
|
+
return {
|
|
5
|
+
k: 0n,
|
|
6
|
+
pub_keys: []
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
const PubKeyMultisig = {
|
|
10
|
+
encode(message, writer = new BinaryWriter()) {
|
|
11
|
+
if (message.k !== 0n) {
|
|
12
|
+
if (BigInt.asUintN(64, message.k) !== message.k) throw new globalThis.Error("value provided for field message.k of type uint64 too large");
|
|
13
|
+
writer.uint32(8).uint64(message.k);
|
|
14
|
+
}
|
|
15
|
+
for (const v of message.pub_keys) Any.encode(v, writer.uint32(18).fork()).join();
|
|
16
|
+
return writer;
|
|
17
|
+
},
|
|
18
|
+
decode(input, length) {
|
|
19
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
20
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
21
|
+
const message = createBasePubKeyMultisig();
|
|
22
|
+
while (reader.pos < end) {
|
|
23
|
+
const tag = reader.uint32();
|
|
24
|
+
switch (tag >>> 3) {
|
|
25
|
+
case 1:
|
|
26
|
+
if (tag !== 8) break;
|
|
27
|
+
message.k = reader.uint64();
|
|
28
|
+
continue;
|
|
29
|
+
case 2:
|
|
30
|
+
if (tag !== 18) break;
|
|
31
|
+
message.pub_keys.push(Any.decode(reader, reader.uint32()));
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
35
|
+
reader.skip(tag & 7);
|
|
36
|
+
}
|
|
37
|
+
return message;
|
|
38
|
+
},
|
|
39
|
+
fromJSON(object) {
|
|
40
|
+
return {
|
|
41
|
+
k: isSet(object.threshold) ? BigInt(object.threshold) : 0n,
|
|
42
|
+
pub_keys: globalThis.Array.isArray(object?.pubkeys) ? object.pubkeys.map((e) => Any.fromJSON(e)) : []
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
toJSON(message) {
|
|
46
|
+
const obj = {};
|
|
47
|
+
if (message.k !== void 0) obj.threshold = message.k.toString();
|
|
48
|
+
if (message.pub_keys?.length) obj.pubkeys = message.pub_keys.map((e) => Any.toJSON(e));
|
|
49
|
+
return obj;
|
|
50
|
+
},
|
|
51
|
+
create(base) {
|
|
52
|
+
return PubKeyMultisig.fromPartial(base ?? {});
|
|
53
|
+
},
|
|
54
|
+
fromPartial(object) {
|
|
55
|
+
const message = createBasePubKeyMultisig();
|
|
56
|
+
message.k = object.k ?? 0n;
|
|
57
|
+
message.pub_keys = object.pub_keys?.map((e) => Any.fromPartial(e)) || [];
|
|
58
|
+
return message;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
function createBaseMultisignature() {
|
|
62
|
+
return {
|
|
63
|
+
bit_array: void 0,
|
|
64
|
+
sigs: []
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const Multisignature = {
|
|
68
|
+
encode(message, writer = new BinaryWriter()) {
|
|
69
|
+
if (message.bit_array !== void 0) CompactBitArray.encode(message.bit_array, writer.uint32(10).fork()).join();
|
|
70
|
+
for (const v of message.sigs) writer.uint32(18).bytes(v);
|
|
71
|
+
return writer;
|
|
72
|
+
},
|
|
73
|
+
decode(input, length) {
|
|
74
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
75
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
76
|
+
const message = createBaseMultisignature();
|
|
77
|
+
while (reader.pos < end) {
|
|
78
|
+
const tag = reader.uint32();
|
|
79
|
+
switch (tag >>> 3) {
|
|
80
|
+
case 1:
|
|
81
|
+
if (tag !== 10) break;
|
|
82
|
+
message.bit_array = CompactBitArray.decode(reader, reader.uint32());
|
|
83
|
+
continue;
|
|
84
|
+
case 2:
|
|
85
|
+
if (tag !== 18) break;
|
|
86
|
+
message.sigs.push(reader.bytes());
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
90
|
+
reader.skip(tag & 7);
|
|
91
|
+
}
|
|
92
|
+
return message;
|
|
93
|
+
},
|
|
94
|
+
fromJSON(object) {
|
|
95
|
+
return {
|
|
96
|
+
bit_array: isSet(object.bit_array) ? CompactBitArray.fromJSON(object.bit_array) : void 0,
|
|
97
|
+
sigs: globalThis.Array.isArray(object?.sigs) ? object.sigs.map((e) => bytesFromBase64(e)) : []
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
toJSON(message) {
|
|
101
|
+
const obj = {};
|
|
102
|
+
if (message.bit_array !== void 0) obj.bit_array = CompactBitArray.toJSON(message.bit_array);
|
|
103
|
+
if (message.sigs?.length) obj.sigs = message.sigs.map((e) => base64FromBytes(e));
|
|
104
|
+
return obj;
|
|
105
|
+
},
|
|
106
|
+
create(base) {
|
|
107
|
+
return Multisignature.fromPartial(base ?? {});
|
|
108
|
+
},
|
|
109
|
+
fromPartial(object) {
|
|
110
|
+
const message = createBaseMultisignature();
|
|
111
|
+
message.bit_array = object.bit_array !== void 0 && object.bit_array !== null ? CompactBitArray.fromPartial(object.bit_array) : void 0;
|
|
112
|
+
message.sigs = object.sigs?.map((e) => e) || [];
|
|
113
|
+
return message;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
function createBaseCompactBitArray() {
|
|
117
|
+
return {
|
|
118
|
+
extra_bits_stored: 0,
|
|
119
|
+
elems: new Uint8Array(0)
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
const CompactBitArray = {
|
|
123
|
+
encode(message, writer = new BinaryWriter()) {
|
|
124
|
+
if (message.extra_bits_stored !== 0) writer.uint32(8).uint32(message.extra_bits_stored);
|
|
125
|
+
if (message.elems.length !== 0) writer.uint32(18).bytes(message.elems);
|
|
126
|
+
return writer;
|
|
127
|
+
},
|
|
128
|
+
decode(input, length) {
|
|
129
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
130
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
131
|
+
const message = createBaseCompactBitArray();
|
|
132
|
+
while (reader.pos < end) {
|
|
133
|
+
const tag = reader.uint32();
|
|
134
|
+
switch (tag >>> 3) {
|
|
135
|
+
case 1:
|
|
136
|
+
if (tag !== 8) break;
|
|
137
|
+
message.extra_bits_stored = reader.uint32();
|
|
138
|
+
continue;
|
|
139
|
+
case 2:
|
|
140
|
+
if (tag !== 18) break;
|
|
141
|
+
message.elems = reader.bytes();
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
145
|
+
reader.skip(tag & 7);
|
|
146
|
+
}
|
|
147
|
+
return message;
|
|
148
|
+
},
|
|
149
|
+
fromJSON(object) {
|
|
150
|
+
return {
|
|
151
|
+
extra_bits_stored: isSet(object.extra_bits) ? globalThis.Number(object.extra_bits) : 0,
|
|
152
|
+
elems: isSet(object.bits) ? bytesFromBase64(object.bits) : new Uint8Array(0)
|
|
153
|
+
};
|
|
154
|
+
},
|
|
155
|
+
toJSON(message) {
|
|
156
|
+
const obj = {};
|
|
157
|
+
if (message.extra_bits_stored !== void 0) obj.extra_bits = Math.round(message.extra_bits_stored);
|
|
158
|
+
if (message.elems !== void 0) obj.bits = base64FromBytes(message.elems);
|
|
159
|
+
return obj;
|
|
160
|
+
},
|
|
161
|
+
create(base) {
|
|
162
|
+
return CompactBitArray.fromPartial(base ?? {});
|
|
163
|
+
},
|
|
164
|
+
fromPartial(object) {
|
|
165
|
+
const message = createBaseCompactBitArray();
|
|
166
|
+
message.extra_bits_stored = object.extra_bits_stored ?? 0;
|
|
167
|
+
message.elems = object.elems ?? new Uint8Array(0);
|
|
168
|
+
return message;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
function bytesFromBase64(b64) {
|
|
172
|
+
if (globalThis.Buffer) return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
|
|
173
|
+
else {
|
|
174
|
+
const bin = globalThis.atob(b64);
|
|
175
|
+
const arr = new Uint8Array(bin.length);
|
|
176
|
+
for (let i = 0; i < bin.length; ++i) arr[i] = bin.charCodeAt(i);
|
|
177
|
+
return arr;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function base64FromBytes(arr) {
|
|
181
|
+
if (globalThis.Buffer) return globalThis.Buffer.from(arr).toString("base64");
|
|
182
|
+
else {
|
|
183
|
+
const bin = [];
|
|
184
|
+
arr.forEach((byte) => {
|
|
185
|
+
bin.push(globalThis.String.fromCharCode(byte));
|
|
186
|
+
});
|
|
187
|
+
return globalThis.btoa(bin.join(""));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function isSet(value) {
|
|
191
|
+
return value !== null && value !== void 0;
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
194
|
+
export { CompactBitArray, Multisignature, PubKeyMultisig };
|
|
195
|
+
|
|
196
|
+
//# sourceMappingURL=multisig.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multisig.mjs","names":[],"sources":["../../../src/proto/tm2/multisig.ts"],"sourcesContent":["// Code generated by protoc-gen-ts_proto. DO NOT EDIT.\n// versions:\n// protoc-gen-ts_proto v2.11.6\n// protoc v6.33.4\n// source: tm2/multisig.proto\n\n/* eslint-disable */\nimport { BinaryReader, BinaryWriter } from \"@bufbuild/protobuf/wire\";\nimport { Any } from \"../google/protobuf/any.js\";\n\nexport const protobufPackage = \"tm\";\n\n/** messages */\nexport interface PubKeyMultisig {\n k: bigint;\n pub_keys: Any[];\n}\n\nexport interface Multisignature {\n bit_array?: CompactBitArray | undefined;\n sigs: Uint8Array[];\n}\n\nexport interface CompactBitArray {\n /** The number of extra bits in elems. */\n extra_bits_stored: number;\n elems: Uint8Array;\n}\n\nfunction createBasePubKeyMultisig(): PubKeyMultisig {\n return { k: 0n, pub_keys: [] };\n}\n\nexport const PubKeyMultisig: MessageFns<PubKeyMultisig> = {\n encode(message: PubKeyMultisig, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.k !== 0n) {\n if (BigInt.asUintN(64, message.k) !== message.k) {\n throw new globalThis.Error(\"value provided for field message.k of type uint64 too large\");\n }\n writer.uint32(8).uint64(message.k);\n }\n for (const v of message.pub_keys) {\n Any.encode(v!, writer.uint32(18).fork()).join();\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): PubKeyMultisig {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBasePubKeyMultisig();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 8) {\n break;\n }\n\n message.k = reader.uint64() as bigint;\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.pub_keys.push(Any.decode(reader, reader.uint32()));\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): PubKeyMultisig {\n return {\n k: isSet(object.threshold) ? BigInt(object.threshold) : 0n,\n pub_keys: globalThis.Array.isArray(object?.pubkeys) ? object.pubkeys.map((e: any) => Any.fromJSON(e)) : [],\n };\n },\n\n toJSON(message: PubKeyMultisig): unknown {\n const obj: any = {};\n if (message.k !== undefined) {\n obj.threshold = message.k.toString();\n }\n if (message.pub_keys?.length) {\n obj.pubkeys = message.pub_keys.map((e) => Any.toJSON(e));\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<PubKeyMultisig>, I>>(base?: I): PubKeyMultisig {\n return PubKeyMultisig.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<PubKeyMultisig>, I>>(object: I): PubKeyMultisig {\n const message = createBasePubKeyMultisig();\n message.k = object.k ?? 0n;\n message.pub_keys = object.pub_keys?.map((e) => Any.fromPartial(e)) || [];\n return message;\n },\n};\n\nfunction createBaseMultisignature(): Multisignature {\n return { bit_array: undefined, sigs: [] };\n}\n\nexport const Multisignature: MessageFns<Multisignature> = {\n encode(message: Multisignature, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.bit_array !== undefined) {\n CompactBitArray.encode(message.bit_array, writer.uint32(10).fork()).join();\n }\n for (const v of message.sigs) {\n writer.uint32(18).bytes(v!);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): Multisignature {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseMultisignature();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.bit_array = CompactBitArray.decode(reader, reader.uint32());\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.sigs.push(reader.bytes());\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): Multisignature {\n return {\n bit_array: isSet(object.bit_array) ? CompactBitArray.fromJSON(object.bit_array) : undefined,\n sigs: globalThis.Array.isArray(object?.sigs) ? object.sigs.map((e: any) => bytesFromBase64(e)) : [],\n };\n },\n\n toJSON(message: Multisignature): unknown {\n const obj: any = {};\n if (message.bit_array !== undefined) {\n obj.bit_array = CompactBitArray.toJSON(message.bit_array);\n }\n if (message.sigs?.length) {\n obj.sigs = message.sigs.map((e) => base64FromBytes(e));\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<Multisignature>, I>>(base?: I): Multisignature {\n return Multisignature.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<Multisignature>, I>>(object: I): Multisignature {\n const message = createBaseMultisignature();\n message.bit_array = (object.bit_array !== undefined && object.bit_array !== null)\n ? CompactBitArray.fromPartial(object.bit_array)\n : undefined;\n message.sigs = object.sigs?.map((e) => e) || [];\n return message;\n },\n};\n\nfunction createBaseCompactBitArray(): CompactBitArray {\n return { extra_bits_stored: 0, elems: new Uint8Array(0) };\n}\n\nexport const CompactBitArray: MessageFns<CompactBitArray> = {\n encode(message: CompactBitArray, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.extra_bits_stored !== 0) {\n writer.uint32(8).uint32(message.extra_bits_stored);\n }\n if (message.elems.length !== 0) {\n writer.uint32(18).bytes(message.elems);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): CompactBitArray {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseCompactBitArray();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 8) {\n break;\n }\n\n message.extra_bits_stored = reader.uint32();\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.elems = reader.bytes();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): CompactBitArray {\n return {\n extra_bits_stored: isSet(object.extra_bits) ? globalThis.Number(object.extra_bits) : 0,\n elems: isSet(object.bits) ? bytesFromBase64(object.bits) : new Uint8Array(0),\n };\n },\n\n toJSON(message: CompactBitArray): unknown {\n const obj: any = {};\n if (message.extra_bits_stored !== undefined) {\n obj.extra_bits = Math.round(message.extra_bits_stored);\n }\n if (message.elems !== undefined) {\n obj.bits = base64FromBytes(message.elems);\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<CompactBitArray>, I>>(base?: I): CompactBitArray {\n return CompactBitArray.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<CompactBitArray>, I>>(object: I): CompactBitArray {\n const message = createBaseCompactBitArray();\n message.extra_bits_stored = object.extra_bits_stored ?? 0;\n message.elems = object.elems ?? new Uint8Array(0);\n return message;\n },\n};\n\nfunction bytesFromBase64(b64: string): Uint8Array {\n if ((globalThis as any).Buffer) {\n return Uint8Array.from((globalThis as any).Buffer.from(b64, \"base64\"));\n } else {\n const bin = globalThis.atob(b64);\n const arr = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; ++i) {\n arr[i] = bin.charCodeAt(i);\n }\n return arr;\n }\n}\n\nfunction base64FromBytes(arr: Uint8Array): string {\n if ((globalThis as any).Buffer) {\n return (globalThis as any).Buffer.from(arr).toString(\"base64\");\n } else {\n const bin: string[] = [];\n arr.forEach((byte) => {\n bin.push(globalThis.String.fromCharCode(byte));\n });\n return globalThis.btoa(bin.join(\"\"));\n }\n}\n\ntype Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;\n\nexport type DeepPartial<T> = T extends Builtin ? T\n : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>\n : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>\n : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }\n : Partial<T>;\n\ntype KeysOfUnion<T> = T extends T ? keyof T : never;\nexport type Exact<P, I extends P> = P extends Builtin ? P\n : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };\n\nfunction isSet(value: any): boolean {\n return value !== null && value !== undefined;\n}\n\nexport interface MessageFns<T> {\n encode(message: T, writer?: BinaryWriter): BinaryWriter;\n decode(input: BinaryReader | Uint8Array, length?: number): T;\n fromJSON(object: any): T;\n toJSON(message: T): unknown;\n create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;\n fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;\n}\n"],"mappings":";;AA6BA,SAAS,2BAA2C;AAClD,QAAO;EAAE,GAAG;EAAI,UAAU,EAAE;EAAE;;AAGhC,MAAa,iBAA6C;CACxD,OAAO,SAAyB,SAAuB,IAAI,cAAc,EAAgB;AACvF,MAAI,QAAQ,MAAM,IAAI;AACpB,OAAI,OAAO,QAAQ,IAAI,QAAQ,EAAE,KAAK,QAAQ,EAC5C,OAAM,IAAI,WAAW,MAAM,8DAA8D;AAE3F,UAAO,OAAO,EAAE,CAAC,OAAO,QAAQ,EAAE;;AAEpC,OAAK,MAAM,KAAK,QAAQ,SACtB,KAAI,OAAO,GAAI,OAAO,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM;AAEjD,SAAO;;CAGT,OAAO,OAAkC,QAAiC;EACxE,MAAM,SAAS,iBAAiB,eAAe,QAAQ,IAAI,aAAa,MAAM;EAC9E,MAAM,MAAM,WAAW,SAAY,OAAO,MAAM,OAAO,MAAM;EAC7D,MAAM,UAAU,0BAA0B;AAC1C,SAAO,OAAO,MAAM,KAAK;GACvB,MAAM,MAAM,OAAO,QAAQ;AAC3B,WAAQ,QAAQ,GAAhB;IACE,KAAK;AACH,SAAI,QAAQ,EACV;AAGF,aAAQ,IAAI,OAAO,QAAQ;AAC3B;IAEF,KAAK;AACH,SAAI,QAAQ,GACV;AAGF,aAAQ,SAAS,KAAK,IAAI,OAAO,QAAQ,OAAO,QAAQ,CAAC,CAAC;AAC1D;;AAGJ,QAAK,MAAM,OAAO,KAAK,QAAQ,EAC7B;AAEF,UAAO,KAAK,MAAM,EAAE;;AAEtB,SAAO;;CAGT,S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AAyB;AAChD,KAAK,WAAmB,OACtB,QAAO,WAAW,KAAM,WAAmB,OAAO,KAAK,KAAK,SAAS,CAAC;MACjE;EACL,MAAM,MAAM,WAAW,KAAK,IAAI;EAChC,MAAM,MAAM,IAAI,WAAW,IAAI,OAAO;AACtC,OAAK,IAAI,IAAI,GAAG,IAAI,IAAI,QAAQ,EAAE,EAChC,KAAI,KAAK,IAAI,WAAW,EAAE;AAE5B,SAAO;;;AAIX,SAAS,gBAAgB,KAAyB;AAChD,KAAK,WAAmB,OACtB,QAAQ,WAAmB,OAAO,KAAK,IAAI,CAAC,SAAS,SAAS;MACzD;EACL,MAAM,MAAgB,EAAE;AACxB,MAAI,SAAS,SAAS;AACpB,OAAI,KAAK,WAAW,OAAO,aAAa,KAAK,CAAC;IAC9C;AACF,SAAO,WAAW,KAAK,IAAI,KAAK,GAAG,CAAC;;;AAgBxC,SAAS,MAAM,OAAqB;AAClC,QAAO,UAAU,QAAQ,UAAU"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_abci = require("../../proto/tm2/abci.cjs");
|
|
2
3
|
const require_tx = require("../../proto/tm2/tx.cjs");
|
|
3
4
|
require("../../proto/index.cjs");
|
|
4
|
-
const require_abci = require("../types/abci.cjs");
|
|
5
|
+
const require_abci$1 = require("../types/abci.cjs");
|
|
5
6
|
require("../types/index.cjs");
|
|
6
7
|
const require_errors_utility = require("./errors.utility.cjs");
|
|
7
|
-
const require_abci$1 = require("../../proto/tm2/abci.cjs");
|
|
8
8
|
const require_requests_utility = require("./requests.utility.cjs");
|
|
9
9
|
let _cosmjs_crypto = require("@cosmjs/crypto");
|
|
10
10
|
//#region src/provider/utility/provider.utility.ts
|
|
@@ -68,11 +68,11 @@ const extractAccountFromResponse = (abciData) => {
|
|
|
68
68
|
const extractSimulateFromResponse = (abciResponse) => {
|
|
69
69
|
if (!abciResponse) throw new Error("abci data is not initialized");
|
|
70
70
|
const error = abciResponse.response?.ResponseBase?.Error;
|
|
71
|
-
if (error && error["@type"]) throw require_errors_utility.constructRequestError(error[require_abci.ABCIErrorKey]);
|
|
71
|
+
if (error && error["@type"]) throw require_errors_utility.constructRequestError(error[require_abci$1.ABCIErrorKey]);
|
|
72
72
|
const value = abciResponse.response.Value;
|
|
73
73
|
if (!value) throw new Error("abci data is not initialized");
|
|
74
74
|
try {
|
|
75
|
-
return require_requests_utility.parseProto(value, require_abci
|
|
75
|
+
return require_requests_utility.parseProto(value, require_abci.ResponseDeliverTx.decode);
|
|
76
76
|
} catch (e) {
|
|
77
77
|
throw new Error("unable to parse simulate response", { cause: e });
|
|
78
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.utility.cjs","names":["parseABCI","constructRequestError","ABCIErrorKey","parseProto","ResponseDeliverTx","base64ToUint8Array","uint8ArrayToBase64","Tx"],"sources":["../../../src/provider/utility/provider.utility.ts"],"sourcesContent":["import {\n sha256,\n} from \"@cosmjs/crypto\";\n\nimport {\n Tx,\n} from \"../../proto/index.js\";\nimport {\n ResponseDeliverTx,\n} from \"../../proto/tm2/abci.js\";\nimport {\n Provider,\n} from \"../provider.js\";\nimport {\n ABCIAccount, ABCIErrorKey, ABCIResponse, BlockInfo,\n} from \"../types/index.js\";\nimport {\n constructRequestError,\n} from \"./errors.utility.js\";\nimport {\n base64ToUint8Array,\n parseABCI,\n parseProto,\n uint8ArrayToBase64,\n} from \"./requests.utility.js\";\n\n/**\n * Extracts the specific balance denomination from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n * @param {string} denomination the required denomination\n */\nexport const extractBalanceFromResponse = (\n abciData: string | null,\n denomination: string,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n return 0;\n }\n\n // Extract the balances\n const balancesRaw = Buffer.from(abciData, \"base64\")\n .toString()\n .replace(/\"/gi, \"\");\n\n // Find the correct balance denomination\n const balances: string[] = balancesRaw.split(\",\");\n if (balances.length < 1) {\n return 0;\n }\n\n // Find the correct denomination\n const pattern = new RegExp(`^(\\\\d+)${denomination}$`);\n for (const balance of balances) {\n const match = balance.match(pattern);\n if (match) {\n return parseInt(match[1], 10);\n }\n }\n\n return 0;\n};\n\n/**\n * Extracts the account sequence from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractSequenceFromResponse = (\n abciData: string | null,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n return 0;\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return parseInt(account.BaseAccount.sequence, 10);\n }\n catch (_e) {\n // unused case\n }\n\n // Account not initialized,\n // return default value (0)\n return 0;\n};\n\n/**\n * Extracts the account number from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractAccountNumberFromResponse = (\n abciData: string | null,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n throw new Error(\"account is not initialized\");\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return parseInt(account.BaseAccount.account_number, 10);\n }\n catch (e) {\n throw new Error(\"account is not initialized\", {\n cause: e,\n });\n }\n};\n\n/**\n * Extracts the account from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractAccountFromResponse = (\n abciData: string | null,\n): ABCIAccount => {\n // Make sure the response is initialized\n if (!abciData) {\n throw new Error(\"account is not initialized\");\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return account;\n }\n catch (e) {\n throw new Error(\"account is not initialized\", {\n cause: e,\n });\n }\n};\n\n/**\n * Extracts the simulate transaction response from the ABCI response value\n * @param {string | null} abciData the base64-encoded ResponseDeliverTx proto message\n */\nexport const extractSimulateFromResponse = (\n abciResponse: ABCIResponse | null,\n): ResponseDeliverTx => {\n // Make sure the response is initialized\n if (!abciResponse) {\n throw new Error(\"abci data is not initialized\");\n }\n\n const error = abciResponse.response?.ResponseBase?.Error;\n if (error && error[ABCIErrorKey]) {\n throw constructRequestError(error[ABCIErrorKey]);\n }\n\n const value = abciResponse.response.Value;\n if (!value) {\n throw new Error(\"abci data is not initialized\");\n }\n\n try {\n return parseProto(value, ResponseDeliverTx.decode);\n }\n catch (e) {\n throw new Error(\"unable to parse simulate response\", {\n cause: e,\n });\n }\n};\n\n/**\n * Waits for the transaction to be committed to a block in the chain\n * of the specified provider. This helper does a search for incoming blocks\n * and checks if a transaction\n * @param {Provider} provider the provider instance\n * @param {string} hash the base64-encoded hash of the transaction\n * @param {number} [fromHeight=latest] the starting height for the search. If omitted, it is the latest block in the chain\n * @param {number} [timeout=15000] the timeout in MS for the search\n */\nexport const waitForTransaction = async (\n provider: Provider,\n hash: string,\n fromHeight?: number,\n timeout?: number,\n): Promise<Tx> => {\n // Fetch the starting point\n let currentHeight = fromHeight\n ? fromHeight\n : await provider.getBlockNumber();\n\n return new Promise((resolve, reject) => {\n const exitTimeout = timeout ? timeout : 15000;\n\n const fetchInterval = setInterval(async () => {\n // Fetch the latest block height\n const latestHeight = await provider.getBlockNumber();\n\n if (latestHeight < currentHeight) {\n // No need to parse older blocks\n return;\n }\n\n for (let blockNum = currentHeight; blockNum <= latestHeight; blockNum++) {\n // Fetch the block from the chain\n const block: BlockInfo = await provider.getBlock(blockNum);\n\n // Check if there are any transactions at all in the block\n if (!block.block.data.txs || block.block.data.txs.length == 0) {\n continue;\n }\n\n // Find the transaction among the block transactions\n for (const tx of block.block.data.txs) {\n // Decode the base-64 transaction\n const txRaw = base64ToUint8Array(tx);\n\n // Calculate the transaction hash\n const txHash = sha256(txRaw);\n\n if (uint8ArrayToBase64(txHash) == hash) {\n // Clear the interval\n clearInterval(fetchInterval);\n\n // Decode the transaction from amino\n resolve(Tx.decode(txRaw));\n }\n }\n }\n\n currentHeight = latestHeight + 1;\n }, 1000);\n\n setTimeout(() => {\n // Clear the fetch interval\n clearInterval(fetchInterval);\n\n reject(\"transaction fetch timeout\");\n }, exitTimeout);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"version":3,"file":"provider.utility.cjs","names":["parseABCI","constructRequestError","ABCIErrorKey","parseProto","ResponseDeliverTx","base64ToUint8Array","uint8ArrayToBase64","Tx"],"sources":["../../../src/provider/utility/provider.utility.ts"],"sourcesContent":["import {\n sha256,\n} from \"@cosmjs/crypto\";\n\nimport {\n Tx,\n} from \"../../proto/index.js\";\nimport {\n ResponseDeliverTx,\n} from \"../../proto/tm2/abci.js\";\nimport {\n Provider,\n} from \"../provider.js\";\nimport {\n ABCIAccount, ABCIErrorKey, ABCIResponse, BlockInfo,\n} from \"../types/index.js\";\nimport {\n constructRequestError,\n} from \"./errors.utility.js\";\nimport {\n base64ToUint8Array,\n parseABCI,\n parseProto,\n uint8ArrayToBase64,\n} from \"./requests.utility.js\";\n\n/**\n * Extracts the specific balance denomination from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n * @param {string} denomination the required denomination\n */\nexport const extractBalanceFromResponse = (\n abciData: string | null,\n denomination: string,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n return 0;\n }\n\n // Extract the balances\n const balancesRaw = Buffer.from(abciData, \"base64\")\n .toString()\n .replace(/\"/gi, \"\");\n\n // Find the correct balance denomination\n const balances: string[] = balancesRaw.split(\",\");\n if (balances.length < 1) {\n return 0;\n }\n\n // Find the correct denomination\n const pattern = new RegExp(`^(\\\\d+)${denomination}$`);\n for (const balance of balances) {\n const match = balance.match(pattern);\n if (match) {\n return parseInt(match[1], 10);\n }\n }\n\n return 0;\n};\n\n/**\n * Extracts the account sequence from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractSequenceFromResponse = (\n abciData: string | null,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n return 0;\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return parseInt(account.BaseAccount.sequence, 10);\n }\n catch (_e) {\n // unused case\n }\n\n // Account not initialized,\n // return default value (0)\n return 0;\n};\n\n/**\n * Extracts the account number from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractAccountNumberFromResponse = (\n abciData: string | null,\n): number => {\n // Make sure the response is initialized\n if (!abciData) {\n throw new Error(\"account is not initialized\");\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return parseInt(account.BaseAccount.account_number, 10);\n }\n catch (e) {\n throw new Error(\"account is not initialized\", {\n cause: e,\n });\n }\n};\n\n/**\n * Extracts the account from the ABCI response\n * @param {string | null} abciData the base64-encoded ABCI data\n */\nexport const extractAccountFromResponse = (\n abciData: string | null,\n): ABCIAccount => {\n // Make sure the response is initialized\n if (!abciData) {\n throw new Error(\"account is not initialized\");\n }\n\n try {\n // Parse the account\n const account: ABCIAccount = parseABCI<ABCIAccount>(abciData);\n\n return account;\n }\n catch (e) {\n throw new Error(\"account is not initialized\", {\n cause: e,\n });\n }\n};\n\n/**\n * Extracts the simulate transaction response from the ABCI response value\n * @param {string | null} abciData the base64-encoded ResponseDeliverTx proto message\n */\nexport const extractSimulateFromResponse = (\n abciResponse: ABCIResponse | null,\n): ResponseDeliverTx => {\n // Make sure the response is initialized\n if (!abciResponse) {\n throw new Error(\"abci data is not initialized\");\n }\n\n const error = abciResponse.response?.ResponseBase?.Error;\n if (error && error[ABCIErrorKey]) {\n throw constructRequestError(error[ABCIErrorKey]);\n }\n\n const value = abciResponse.response.Value;\n if (!value) {\n throw new Error(\"abci data is not initialized\");\n }\n\n try {\n return parseProto(value, ResponseDeliverTx.decode);\n }\n catch (e) {\n throw new Error(\"unable to parse simulate response\", {\n cause: e,\n });\n }\n};\n\n/**\n * Waits for the transaction to be committed to a block in the chain\n * of the specified provider. This helper does a search for incoming blocks\n * and checks if a transaction\n * @param {Provider} provider the provider instance\n * @param {string} hash the base64-encoded hash of the transaction\n * @param {number} [fromHeight=latest] the starting height for the search. If omitted, it is the latest block in the chain\n * @param {number} [timeout=15000] the timeout in MS for the search\n */\nexport const waitForTransaction = async (\n provider: Provider,\n hash: string,\n fromHeight?: number,\n timeout?: number,\n): Promise<Tx> => {\n // Fetch the starting point\n let currentHeight = fromHeight\n ? fromHeight\n : await provider.getBlockNumber();\n\n return new Promise((resolve, reject) => {\n const exitTimeout = timeout ? timeout : 15000;\n\n const fetchInterval = setInterval(async () => {\n // Fetch the latest block height\n const latestHeight = await provider.getBlockNumber();\n\n if (latestHeight < currentHeight) {\n // No need to parse older blocks\n return;\n }\n\n for (let blockNum = currentHeight; blockNum <= latestHeight; blockNum++) {\n // Fetch the block from the chain\n const block: BlockInfo = await provider.getBlock(blockNum);\n\n // Check if there are any transactions at all in the block\n if (!block.block.data.txs || block.block.data.txs.length == 0) {\n continue;\n }\n\n // Find the transaction among the block transactions\n for (const tx of block.block.data.txs) {\n // Decode the base-64 transaction\n const txRaw = base64ToUint8Array(tx);\n\n // Calculate the transaction hash\n const txHash = sha256(txRaw);\n\n if (uint8ArrayToBase64(txHash) == hash) {\n // Clear the interval\n clearInterval(fetchInterval);\n\n // Decode the transaction from amino\n resolve(Tx.decode(txRaw));\n }\n }\n }\n\n currentHeight = latestHeight + 1;\n }, 1000);\n\n setTimeout(() => {\n // Clear the fetch interval\n clearInterval(fetchInterval);\n\n reject(\"transaction fetch timeout\");\n }, exitTimeout);\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;AA+BA,MAAa,8BACX,UACA,iBACW;AAEX,KAAI,CAAC,SACH,QAAO;CAST,MAAM,WALc,OAAO,KAAK,UAAU,SAAS,CAChD,UAAU,CACV,QAAQ,OAAO,GAAG,CAGkB,MAAM,IAAI;AACjD,KAAI,SAAS,SAAS,EACpB,QAAO;CAIT,MAAM,UAAU,IAAI,OAAO,UAAU,aAAa,GAAG;AACrD,MAAK,MAAM,WAAW,UAAU;EAC9B,MAAM,QAAQ,QAAQ,MAAM,QAAQ;AACpC,MAAI,MACF,QAAO,SAAS,MAAM,IAAI,GAAG;;AAIjC,QAAO;;;;;;AAOT,MAAa,+BACX,aACW;AAEX,KAAI,CAAC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M,SAAS,gBAAgB;AAEpD,OAAI,eAAe,cAEjB;AAGF,QAAK,IAAI,WAAW,eAAe,YAAY,cAAc,YAAY;IAEvE,MAAM,QAAmB,MAAM,SAAS,SAAS,SAAS;AAG1D,QAAI,CAAC,MAAM,MAAM,KAAK,OAAO,MAAM,MAAM,KAAK,IAAI,UAAU,EAC1D;AAIF,SAAK,MAAM,MAAM,MAAM,MAAM,KAAK,KAAK;KAErC,MAAM,QAAQC,yBAAAA,mBAAmB,GAAG;KAGpC,MAAM,UAAA,GAAA,eAAA,QAAgB,MAAM;AAE5B,SAAIC,yBAAAA,mBAAmB,OAAO,IAAI,MAAM;AAEtC,oBAAc,cAAc;AAG5B,cAAQC,WAAAA,GAAG,OAAO,MAAM,CAAC;;;;AAK/B,mBAAgB,eAAe;KAC9B,IAAK;AAER,mBAAiB;AAEf,iBAAc,cAAc;AAE5B,UAAO,4BAA4B;KAClC,YAAY;GACf"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { ResponseDeliverTx } from "../../proto/tm2/abci.cjs";
|
|
1
2
|
import { Tx } from "../../proto/tm2/tx.cjs";
|
|
2
3
|
import { ABCIAccount, ABCIResponse } from "../types/abci.cjs";
|
|
3
4
|
import { Provider } from "../provider.cjs";
|
|
4
|
-
import { ResponseDeliverTx } from "../../proto/tm2/abci.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/provider/utility/provider.utility.d.ts
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { ResponseDeliverTx } from "../../proto/tm2/abci.mjs";
|
|
1
2
|
import { Tx } from "../../proto/tm2/tx.mjs";
|
|
2
3
|
import { ABCIAccount, ABCIResponse } from "../types/abci.mjs";
|
|
3
4
|
import { Provider } from "../provider.mjs";
|
|
4
|
-
import { ResponseDeliverTx } from "../../proto/tm2/abci.mjs";
|
|
5
5
|
|
|
6
6
|
//#region src/provider/utility/provider.utility.d.ts
|
|
7
7
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { ResponseDeliverTx } from "../../proto/tm2/abci.mjs";
|
|
1
2
|
import { Tx } from "../../proto/tm2/tx.mjs";
|
|
2
3
|
import "../../proto/index.mjs";
|
|
3
4
|
import { ABCIErrorKey } from "../types/abci.mjs";
|
|
4
5
|
import "../types/index.mjs";
|
|
5
6
|
import { constructRequestError } from "./errors.utility.mjs";
|
|
6
|
-
import { ResponseDeliverTx } from "../../proto/tm2/abci.mjs";
|
|
7
7
|
import { base64ToUint8Array, parseABCI, parseProto, uint8ArrayToBase64 } from "./requests.utility.mjs";
|
|
8
8
|
import { sha256 } from "@cosmjs/crypto";
|
|
9
9
|
//#region src/provider/utility/provider.utility.ts
|