@gnolang/tm2-js-client 2.1.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/index.cjs +1 -0
  3. package/dist/index.d.cts +3 -3
  4. package/dist/index.d.mts +3 -3
  5. package/dist/index.mjs +2 -2
  6. package/dist/wallet/index.cjs +1 -0
  7. package/dist/wallet/index.d.cts +3 -3
  8. package/dist/wallet/index.d.mts +3 -3
  9. package/dist/wallet/index.mjs +2 -2
  10. package/dist/wallet/types/index.d.cts +2 -2
  11. package/dist/wallet/types/index.d.mts +2 -2
  12. package/dist/wallet/types/sign.cjs.map +1 -1
  13. package/dist/wallet/types/sign.d.cts +10 -3
  14. package/dist/wallet/types/sign.d.cts.map +1 -1
  15. package/dist/wallet/types/sign.d.mts +10 -3
  16. package/dist/wallet/types/sign.d.mts.map +1 -1
  17. package/dist/wallet/types/sign.mjs.map +1 -1
  18. package/dist/wallet/utility/index.cjs +1 -0
  19. package/dist/wallet/utility/index.d.cts +2 -2
  20. package/dist/wallet/utility/index.d.mts +2 -2
  21. package/dist/wallet/utility/index.mjs +2 -2
  22. package/dist/wallet/utility/utility.cjs +24 -0
  23. package/dist/wallet/utility/utility.cjs.map +1 -1
  24. package/dist/wallet/utility/utility.d.cts +11 -1
  25. package/dist/wallet/utility/utility.d.cts.map +1 -1
  26. package/dist/wallet/utility/utility.d.mts +11 -1
  27. package/dist/wallet/utility/utility.d.mts.map +1 -1
  28. package/dist/wallet/utility/utility.mjs +24 -1
  29. package/dist/wallet/utility/utility.mjs.map +1 -1
  30. package/dist/wallet/wallet.cjs +2 -2
  31. package/dist/wallet/wallet.cjs.map +1 -1
  32. package/dist/wallet/wallet.d.cts.map +1 -1
  33. package/dist/wallet/wallet.d.mts.map +1 -1
  34. package/dist/wallet/wallet.mjs +3 -3
  35. package/dist/wallet/wallet.mjs.map +1 -1
  36. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#287](https://github.com/gnolang/tm2-js-client/pull/287) [`1876fb4`](https://github.com/gnolang/tm2-js-client/commit/1876fb4ffd9d16edac96ac8b7d0b21602c5cc71c) Thanks [@clockworkgr](https://github.com/clockworkgr)! - Render the signature payload fee in the shape the Ledger Cosmos app accepts (`{"amount":[{"amount","denom"}],"gas"}`), matching gnolang/gno#6173. This changes the signed bytes for every signer; nodes without gnolang/gno#6173 reject transactions signed by this version. `gas_fee` is now parsed with the same rules as `std.ParseCoin` on the chain.
8
+
3
9
  ## 2.1.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -93,6 +93,7 @@ exports.newRequest = require_requests_utility.newRequest;
93
93
  exports.newResponse = require_requests_utility.newResponse;
94
94
  exports.parseABCI = require_requests_utility.parseABCI;
95
95
  exports.parseProto = require_requests_utility.parseProto;
96
+ exports.parseSignCoin = require_utility.parseSignCoin;
96
97
  exports.protobufPackage = require_tx.protobufPackage;
97
98
  exports.sortedJsonStringify = require_utility.sortedJsonStringify;
98
99
  exports.stringToBase64 = require_requests_utility.stringToBase64;
package/dist/index.d.cts CHANGED
@@ -23,9 +23,9 @@ import "./utility/index.cjs";
23
23
  import { Signer } from "./wallet/signer.cjs";
24
24
  import { KeySigner } from "./wallet/key/key.cjs";
25
25
  import { LedgerSigner } from "./wallet/ledger/ledger.cjs";
26
- import { Secp256k1PubKeyType, TxSignPayload } from "./wallet/types/sign.cjs";
26
+ import { Secp256k1PubKeyType, TxSignCoin, TxSignPayload } from "./wallet/types/sign.cjs";
27
27
  import { AccountWalletOption, CreateWalletOptions } from "./wallet/types/wallet.cjs";
28
- import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 } from "./wallet/utility/utility.cjs";
28
+ import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, parseSignCoin, sortedJsonStringify, stringToUTF8 } from "./wallet/utility/utility.cjs";
29
29
  import { SignTransactionOptions, Wallet } from "./wallet/wallet.cjs";
30
30
  import "./wallet/index.cjs";
31
- 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 };
31
+ 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, TxSignCoin, 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, parseSignCoin, protobufPackage, sortedJsonStringify, stringToBase64, stringToUTF8, toBase64, toHexString, uint8ArrayToBase64, waitForTransaction };
package/dist/index.d.mts CHANGED
@@ -23,9 +23,9 @@ import "./utility/index.mjs";
23
23
  import { Signer } from "./wallet/signer.mjs";
24
24
  import { KeySigner } from "./wallet/key/key.mjs";
25
25
  import { LedgerSigner } from "./wallet/ledger/ledger.mjs";
26
- import { Secp256k1PubKeyType, TxSignPayload } from "./wallet/types/sign.mjs";
26
+ import { Secp256k1PubKeyType, TxSignCoin, TxSignPayload } from "./wallet/types/sign.mjs";
27
27
  import { AccountWalletOption, CreateWalletOptions } from "./wallet/types/wallet.mjs";
28
- import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 } from "./wallet/utility/utility.mjs";
28
+ import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, parseSignCoin, sortedJsonStringify, stringToUTF8 } from "./wallet/utility/utility.mjs";
29
29
  import { SignTransactionOptions, Wallet } from "./wallet/wallet.mjs";
30
30
  import "./wallet/index.mjs";
31
- 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 };
31
+ 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, TxSignCoin, 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, parseSignCoin, protobufPackage, sortedJsonStringify, stringToBase64, stringToUTF8, toBase64, toHexString, uint8ArrayToBase64, waitForTransaction };
package/dist/index.mjs CHANGED
@@ -17,10 +17,10 @@ import { RestService } from "./services/rest/restService.mjs";
17
17
  import "./services/index.mjs";
18
18
  import { compactBitArrayFromAmino, compactBitArrayToAmino } from "./utility/compact-bit-array.mjs";
19
19
  import "./utility/index.mjs";
20
- import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 } from "./wallet/utility/utility.mjs";
20
+ import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, parseSignCoin, sortedJsonStringify, stringToUTF8 } from "./wallet/utility/utility.mjs";
21
21
  import { KeySigner } from "./wallet/key/key.mjs";
22
22
  import { LedgerSigner } from "./wallet/ledger/ledger.mjs";
23
23
  import { Secp256k1PubKeyType } from "./wallet/types/sign.mjs";
24
24
  import { Wallet } from "./wallet/wallet.mjs";
25
25
  import "./wallet/index.mjs";
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 };
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, parseSignCoin, protobufPackage, sortedJsonStringify, stringToBase64, stringToUTF8, toBase64, toHexString, uint8ArrayToBase64, waitForTransaction };
@@ -17,5 +17,6 @@ exports.encodeCharacterSet = require_utility.encodeCharacterSet;
17
17
  exports.generateEntropy = require_utility.generateEntropy;
18
18
  exports.generateHDPath = require_utility.generateHDPath;
19
19
  exports.generateKeyPair = require_utility.generateKeyPair;
20
+ exports.parseSignCoin = require_utility.parseSignCoin;
20
21
  exports.sortedJsonStringify = require_utility.sortedJsonStringify;
21
22
  exports.stringToUTF8 = require_utility.stringToUTF8;
@@ -3,10 +3,10 @@ import { KeySigner } from "./key/key.cjs";
3
3
  import "./key/index.cjs";
4
4
  import { LedgerSigner } from "./ledger/ledger.cjs";
5
5
  import "./ledger/index.cjs";
6
- import { Secp256k1PubKeyType, TxSignPayload } from "./types/sign.cjs";
6
+ import { Secp256k1PubKeyType, TxSignCoin, TxSignPayload } from "./types/sign.cjs";
7
7
  import { AccountWalletOption, CreateWalletOptions } from "./types/wallet.cjs";
8
8
  import "./types/index.cjs";
9
- import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 } from "./utility/utility.cjs";
9
+ import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, parseSignCoin, sortedJsonStringify, stringToUTF8 } from "./utility/utility.cjs";
10
10
  import "./utility/index.cjs";
11
11
  import { SignTransactionOptions, Wallet } from "./wallet.cjs";
12
- export { AccountWalletOption, CreateWalletOptions, KeySigner, LedgerSigner, Secp256k1PubKeyType, SignTransactionOptions, Signer, TxSignPayload, Wallet, defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 };
12
+ export { AccountWalletOption, CreateWalletOptions, KeySigner, LedgerSigner, Secp256k1PubKeyType, SignTransactionOptions, Signer, TxSignCoin, TxSignPayload, Wallet, defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, parseSignCoin, sortedJsonStringify, stringToUTF8 };
@@ -3,10 +3,10 @@ import { KeySigner } from "./key/key.mjs";
3
3
  import "./key/index.mjs";
4
4
  import { LedgerSigner } from "./ledger/ledger.mjs";
5
5
  import "./ledger/index.mjs";
6
- import { Secp256k1PubKeyType, TxSignPayload } from "./types/sign.mjs";
6
+ import { Secp256k1PubKeyType, TxSignCoin, TxSignPayload } from "./types/sign.mjs";
7
7
  import { AccountWalletOption, CreateWalletOptions } from "./types/wallet.mjs";
8
8
  import "./types/index.mjs";
9
- import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 } from "./utility/utility.mjs";
9
+ import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, parseSignCoin, sortedJsonStringify, stringToUTF8 } from "./utility/utility.mjs";
10
10
  import "./utility/index.mjs";
11
11
  import { SignTransactionOptions, Wallet } from "./wallet.mjs";
12
- export { AccountWalletOption, CreateWalletOptions, KeySigner, LedgerSigner, Secp256k1PubKeyType, SignTransactionOptions, Signer, TxSignPayload, Wallet, defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 };
12
+ export { AccountWalletOption, CreateWalletOptions, KeySigner, LedgerSigner, Secp256k1PubKeyType, SignTransactionOptions, Signer, TxSignCoin, TxSignPayload, Wallet, defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, parseSignCoin, sortedJsonStringify, stringToUTF8 };
@@ -1,4 +1,4 @@
1
- import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 } from "./utility/utility.mjs";
1
+ import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, parseSignCoin, sortedJsonStringify, stringToUTF8 } from "./utility/utility.mjs";
2
2
  import "./utility/index.mjs";
3
3
  import { KeySigner } from "./key/key.mjs";
4
4
  import "./key/index.mjs";
@@ -8,4 +8,4 @@ import "./signer.mjs";
8
8
  import { Secp256k1PubKeyType } from "./types/sign.mjs";
9
9
  import "./types/index.mjs";
10
10
  import { Wallet } from "./wallet.mjs";
11
- export { KeySigner, LedgerSigner, Secp256k1PubKeyType, Wallet, defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 };
11
+ export { KeySigner, LedgerSigner, Secp256k1PubKeyType, Wallet, defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, parseSignCoin, sortedJsonStringify, stringToUTF8 };
@@ -1,3 +1,3 @@
1
- import { Secp256k1PubKeyType, TxSignPayload } from "./sign.cjs";
1
+ import { Secp256k1PubKeyType, TxSignCoin, TxSignPayload } from "./sign.cjs";
2
2
  import { AccountWalletOption, CreateWalletOptions } from "./wallet.cjs";
3
- export { AccountWalletOption, CreateWalletOptions, Secp256k1PubKeyType, TxSignPayload };
3
+ export { AccountWalletOption, CreateWalletOptions, Secp256k1PubKeyType, TxSignCoin, TxSignPayload };
@@ -1,3 +1,3 @@
1
- import { Secp256k1PubKeyType, TxSignPayload } from "./sign.mjs";
1
+ import { Secp256k1PubKeyType, TxSignCoin, TxSignPayload } from "./sign.mjs";
2
2
  import { AccountWalletOption, CreateWalletOptions } from "./wallet.mjs";
3
- export { AccountWalletOption, CreateWalletOptions, Secp256k1PubKeyType, TxSignPayload };
3
+ export { AccountWalletOption, CreateWalletOptions, Secp256k1PubKeyType, TxSignCoin, TxSignPayload };
@@ -1 +1 @@
1
- {"version":3,"file":"sign.cjs","names":[],"sources":["../../../src/wallet/types/sign.ts"],"sourcesContent":["/**\n * The transaction payload that is signed to generate\n * a valid transaction signature\n */\nexport interface TxSignPayload {\n // the ID of the chain\n chain_id: string\n // the account number of the\n // account that's signing (decimal)\n account_number: string\n // the sequence number of the\n // account that's signing (decimal)\n sequence: string\n // the fee of the transaction\n fee: {\n // gas price of the transaction\n // in the format <amount (decimal)><denomination>\n gas_fee: string\n // gas limit of the transaction (decimal)\n gas_wanted: string\n }\n // the messages associated\n // with the transaction.\n // These messages have the form: \\\n // @type: ...\n // value: ...\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n msgs: any[]\n // the transaction memo\n memo: string\n}\n\nexport const Secp256k1PubKeyType = \"/tm.PubKeySecp256k1\";\n"],"mappings":";AAiCA,MAAa,sBAAsB"}
1
+ {"version":3,"file":"sign.cjs","names":[],"sources":["../../../src/wallet/types/sign.ts"],"sourcesContent":["/**\n * The transaction payload that is signed to generate\n * a valid transaction signature\n */\nexport interface TxSignPayload {\n // the ID of the chain\n chain_id: string\n // the account number of the\n // account that's signing (decimal)\n account_number: string\n // the sequence number of the\n // account that's signing (decimal)\n sequence: string\n // the fee of the transaction,\n // in the shape accepted by the Ledger Cosmos app\n fee: {\n // gas fee coins of the transaction\n amount: TxSignCoin[]\n // gas limit of the transaction (decimal)\n gas: string\n }\n // the messages associated\n // with the transaction.\n // These messages have the form: \\\n // @type: ...\n // value: ...\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n msgs: any[]\n // the transaction memo\n memo: string\n}\n\n/**\n * A coin as it appears in the signature payload\n */\nexport interface TxSignCoin {\n // the coin denomination\n denom: string\n // the coin amount (decimal)\n amount: string\n}\n\nexport const Secp256k1PubKeyType = \"/tm.PubKeySecp256k1\";\n"],"mappings":";AA2CA,MAAa,sBAAsB"}
@@ -8,13 +8,20 @@ interface TxSignPayload {
8
8
  account_number: string;
9
9
  sequence: string;
10
10
  fee: {
11
- gas_fee: string;
12
- gas_wanted: string;
11
+ amount: TxSignCoin[];
12
+ gas: string;
13
13
  };
14
14
  msgs: any[];
15
15
  memo: string;
16
16
  }
17
+ /**
18
+ * A coin as it appears in the signature payload
19
+ */
20
+ interface TxSignCoin {
21
+ denom: string;
22
+ amount: string;
23
+ }
17
24
  declare const Secp256k1PubKeyType = "/tm.PubKeySecp256k1";
18
25
  //#endregion
19
- export { Secp256k1PubKeyType, TxSignPayload };
26
+ export { Secp256k1PubKeyType, TxSignCoin, TxSignPayload };
20
27
  //# sourceMappingURL=sign.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sign.d.cts","names":[],"sources":["../../../src/wallet/types/sign.ts"],"mappings":";;;;;UAIiB;EAEf;EAGA;EAGA;EAEA;IAGE;IAEA;;EASF;EAEA;;cAGW"}
1
+ {"version":3,"file":"sign.d.cts","names":[],"sources":["../../../src/wallet/types/sign.ts"],"mappings":";;;;;UAIiB;EAEf;EAGA;EAGA;EAGA;IAEE,QAAQ;IAER;;EASF;EAEA;;;;;UAMe;EAEf;EAEA;;cAGW"}
@@ -8,13 +8,20 @@ interface TxSignPayload {
8
8
  account_number: string;
9
9
  sequence: string;
10
10
  fee: {
11
- gas_fee: string;
12
- gas_wanted: string;
11
+ amount: TxSignCoin[];
12
+ gas: string;
13
13
  };
14
14
  msgs: any[];
15
15
  memo: string;
16
16
  }
17
+ /**
18
+ * A coin as it appears in the signature payload
19
+ */
20
+ interface TxSignCoin {
21
+ denom: string;
22
+ amount: string;
23
+ }
17
24
  declare const Secp256k1PubKeyType = "/tm.PubKeySecp256k1";
18
25
  //#endregion
19
- export { Secp256k1PubKeyType, TxSignPayload };
26
+ export { Secp256k1PubKeyType, TxSignCoin, TxSignPayload };
20
27
  //# sourceMappingURL=sign.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sign.d.mts","names":[],"sources":["../../../src/wallet/types/sign.ts"],"mappings":";;;;;UAIiB;EAEf;EAGA;EAGA;EAEA;IAGE;IAEA;;EASF;EAEA;;cAGW"}
1
+ {"version":3,"file":"sign.d.mts","names":[],"sources":["../../../src/wallet/types/sign.ts"],"mappings":";;;;;UAIiB;EAEf;EAGA;EAGA;EAGA;IAEE,QAAQ;IAER;;EASF;EAEA;;;;;UAMe;EAEf;EAEA;;cAGW"}
@@ -1 +1 @@
1
- {"version":3,"file":"sign.mjs","names":[],"sources":["../../../src/wallet/types/sign.ts"],"sourcesContent":["/**\n * The transaction payload that is signed to generate\n * a valid transaction signature\n */\nexport interface TxSignPayload {\n // the ID of the chain\n chain_id: string\n // the account number of the\n // account that's signing (decimal)\n account_number: string\n // the sequence number of the\n // account that's signing (decimal)\n sequence: string\n // the fee of the transaction\n fee: {\n // gas price of the transaction\n // in the format <amount (decimal)><denomination>\n gas_fee: string\n // gas limit of the transaction (decimal)\n gas_wanted: string\n }\n // the messages associated\n // with the transaction.\n // These messages have the form: \\\n // @type: ...\n // value: ...\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n msgs: any[]\n // the transaction memo\n memo: string\n}\n\nexport const Secp256k1PubKeyType = \"/tm.PubKeySecp256k1\";\n"],"mappings":";AAiCA,MAAa,sBAAsB"}
1
+ {"version":3,"file":"sign.mjs","names":[],"sources":["../../../src/wallet/types/sign.ts"],"sourcesContent":["/**\n * The transaction payload that is signed to generate\n * a valid transaction signature\n */\nexport interface TxSignPayload {\n // the ID of the chain\n chain_id: string\n // the account number of the\n // account that's signing (decimal)\n account_number: string\n // the sequence number of the\n // account that's signing (decimal)\n sequence: string\n // the fee of the transaction,\n // in the shape accepted by the Ledger Cosmos app\n fee: {\n // gas fee coins of the transaction\n amount: TxSignCoin[]\n // gas limit of the transaction (decimal)\n gas: string\n }\n // the messages associated\n // with the transaction.\n // These messages have the form: \\\n // @type: ...\n // value: ...\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n msgs: any[]\n // the transaction memo\n memo: string\n}\n\n/**\n * A coin as it appears in the signature payload\n */\nexport interface TxSignCoin {\n // the coin denomination\n denom: string\n // the coin amount (decimal)\n amount: string\n}\n\nexport const Secp256k1PubKeyType = \"/tm.PubKeySecp256k1\";\n"],"mappings":";AA2CA,MAAa,sBAAsB"}
@@ -4,5 +4,6 @@ exports.encodeCharacterSet = require_utility.encodeCharacterSet;
4
4
  exports.generateEntropy = require_utility.generateEntropy;
5
5
  exports.generateHDPath = require_utility.generateHDPath;
6
6
  exports.generateKeyPair = require_utility.generateKeyPair;
7
+ exports.parseSignCoin = require_utility.parseSignCoin;
7
8
  exports.sortedJsonStringify = require_utility.sortedJsonStringify;
8
9
  exports.stringToUTF8 = require_utility.stringToUTF8;
@@ -1,2 +1,2 @@
1
- import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 } from "./utility.cjs";
2
- export { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 };
1
+ import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, parseSignCoin, sortedJsonStringify, stringToUTF8 } from "./utility.cjs";
2
+ export { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, parseSignCoin, sortedJsonStringify, stringToUTF8 };
@@ -1,2 +1,2 @@
1
- import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 } from "./utility.mjs";
2
- export { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 };
1
+ import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, parseSignCoin, sortedJsonStringify, stringToUTF8 } from "./utility.mjs";
2
+ export { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, parseSignCoin, sortedJsonStringify, stringToUTF8 };
@@ -1,2 +1,2 @@
1
- import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 } from "./utility.mjs";
2
- export { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 };
1
+ import { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, parseSignCoin, sortedJsonStringify, stringToUTF8 } from "./utility.mjs";
2
+ export { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, parseSignCoin, sortedJsonStringify, stringToUTF8 };
@@ -26,6 +26,29 @@ const generateEntropy = (size) => {
26
26
  crypto.default.randomFillSync(array);
27
27
  return array;
28
28
  };
29
+ const reSignCoin = /^(\d+)\s*([a-z/][a-z0-9_.:/-]{2,})$/;
30
+ const maxCoinAmount = 9223372036854775807n;
31
+ /**
32
+ * Parses a coin string in the format <amount (decimal)><denomination>
33
+ * into the signature payload coin shape, following the same rules as
34
+ * std.ParseCoin on the chain. A missing, empty or zero coin yields
35
+ * an empty list
36
+ * @param {string} [coin] the coin string, ex. 1000000ugnot
37
+ */
38
+ const parseSignCoin = (coin) => {
39
+ const trimmed = (coin ?? "").trim();
40
+ if (trimmed === "") return [];
41
+ const match = reSignCoin.exec(trimmed);
42
+ if (!match) throw new Error(`invalid coin format: ${coin}`);
43
+ const [, rawAmount, denom] = match;
44
+ const amount = BigInt(rawAmount);
45
+ if (amount > maxCoinAmount) throw new Error(`coin amount out of range: ${coin}`);
46
+ if (amount === 0n) return [];
47
+ return [{
48
+ denom,
49
+ amount: amount.toString(10)
50
+ }];
51
+ };
29
52
  /**
30
53
  * Generates a new Secp256k1 key-pair using
31
54
  * the provided English mnemonic and account index
@@ -77,6 +100,7 @@ exports.encodeCharacterSet = encodeCharacterSet;
77
100
  exports.generateEntropy = generateEntropy;
78
101
  exports.generateHDPath = generateHDPath;
79
102
  exports.generateKeyPair = generateKeyPair;
103
+ exports.parseSignCoin = parseSignCoin;
80
104
  exports.sortedJsonStringify = sortedJsonStringify;
81
105
  exports.stringToUTF8 = stringToUTF8;
82
106
 
@@ -1 +1 @@
1
- {"version":3,"file":"utility.cjs","names":["Slip10RawIndex","Bip39","EnglishMnemonic","Slip10","Slip10Curve","Secp256k1"],"sources":["../../../src/wallet/utility/utility.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n Bip39,\n EnglishMnemonic,\n HdPath,\n Secp256k1,\n Slip10,\n Slip10Curve,\n Slip10RawIndex,\n} from \"@cosmjs/crypto\";\nimport crypto from \"crypto\";\n\n/**\n * Generates the HD path, for the specified index, in the form 'm/44'/118'/0'/0/i',\n * where 'i' is the account index\n * @param {number} [index=0] the account index\n */\nexport const generateHDPath = (index?: number): HdPath => {\n return [Slip10RawIndex.hardened(44), Slip10RawIndex.hardened(118), Slip10RawIndex.hardened(0), Slip10RawIndex.normal(0), Slip10RawIndex.normal(index ? index : 0)];\n};\n\n/**\n * Generates random entropy of the specified size (in B)\n * @param {number} [size=32] the entropy size in bytes\n */\nexport const generateEntropy = (size?: number): Uint8Array => {\n const array = new Uint8Array(size ? size : 32);\n\n // Generate random data\n crypto.randomFillSync(array);\n\n return array;\n};\n\ninterface keyPair {\n privateKey: Uint8Array\n publicKey: Uint8Array\n}\n\n/**\n * Generates a new Secp256k1 key-pair using\n * the provided English mnemonic and account index\n * @param {string} mnemonic the English mnemonic\n * @param {number} [accountIndex=0] the account index\n */\nexport const generateKeyPair = async (\n mnemonic: string,\n accountIndex?: number,\n): Promise<keyPair> => {\n // Generate the seed\n const seed = await Bip39.mnemonicToSeed(new EnglishMnemonic(mnemonic));\n\n // Derive the private key\n const {\n privkey: privateKey,\n } = Slip10.derivePath(\n Slip10Curve.Secp256k1,\n seed,\n generateHDPath(accountIndex),\n );\n\n // Derive the public key\n const {\n pubkey: publicKey,\n } = await Secp256k1.makeKeypair(privateKey);\n\n return {\n publicKey: publicKey,\n privateKey: privateKey,\n };\n};\n\n// Address prefix for TM2 networks\nexport const defaultAddressPrefix = \"g\";\n\n/**\n * Encodes a string into a Uint8Array\n * @param {string} str the string to be encoded\n */\nexport const stringToUTF8 = (str: string): Uint8Array => {\n return new TextEncoder().encode(str);\n};\n\n/**\n * Escapes <,>,& in string.\n * Golang's json marshaller escapes <,>,& by default.\n * https://cs.opensource.google/go/go/+/refs/tags/go1.20.6:src/encoding/json/encode.go;l=46-53\n */\nexport function encodeCharacterSet(data: string) {\n return data\n .replace(/</g, \"\\\\u003c\")\n .replace(/>/g, \"\\\\u003e\")\n .replace(/&/g, \"\\\\u0026\");\n}\n\nfunction sortedObject(obj: any): any {\n if (typeof obj !== \"object\" || obj === null) {\n return obj;\n }\n if (Array.isArray(obj)) {\n return obj.map(sortedObject);\n }\n const sortedKeys = Object.keys(obj).sort();\n const result: Record<string, any> = {\n };\n // NOTE: Use forEach instead of reduce for performance with large objects eg Wasm code\n sortedKeys.forEach((key) => {\n result[key] = sortedObject(obj[key]);\n });\n return result;\n}\n\n/** Returns a JSON string with objects sorted by key */\n\nexport function sortedJsonStringify(obj: any): string {\n return JSON.stringify(sortedObject(obj));\n}\n"],"mappings":";;;;;;;;;;AAiBA,MAAa,kBAAkB,UAA2B;CACxD,OAAO;EAACA,eAAAA,eAAe,SAAS,EAAE;EAAGA,eAAAA,eAAe,SAAS,GAAG;EAAGA,eAAAA,eAAe,SAAS,CAAC;EAAGA,eAAAA,eAAe,OAAO,CAAC;EAAGA,eAAAA,eAAe,OAAO,QAAQ,QAAQ,CAAC;CAAC;AACnK;;;;;AAMA,MAAa,mBAAmB,SAA8B;CAC5D,MAAM,QAAQ,IAAI,WAAW,OAAO,OAAO,EAAE;CAG7C,OAAA,QAAO,eAAe,KAAK;CAE3B,OAAO;AACT;;;;;;;AAaA,MAAa,kBAAkB,OAC7B,UACA,iBACqB;CAErB,MAAM,OAAO,MAAMC,eAAAA,MAAM,eAAe,IAAIC,eAAAA,gBAAgB,QAAQ,CAAC;CAGrE,MAAM,EACJ,SAAS,eACPC,eAAAA,OAAO,WACTC,eAAAA,YAAY,WACZ,MACA,eAAe,YAAY,CAC7B;CAGA,MAAM,EACJ,QAAQ,cACN,MAAMC,eAAAA,UAAU,YAAY,UAAU;CAE1C,OAAO;EACM;EACC;CACd;AACF;AAGA,MAAa,uBAAuB;;;;;AAMpC,MAAa,gBAAgB,QAA4B;CACvD,OAAO,IAAI,YAAY,CAAC,CAAC,OAAO,GAAG;AACrC;;;;;;AAOA,SAAgB,mBAAmB,MAAc;CAC/C,OAAO,KACJ,QAAQ,MAAM,SAAS,CAAC,CACxB,QAAQ,MAAM,SAAS,CAAC,CACxB,QAAQ,MAAM,SAAS;AAC5B;AAEA,SAAS,aAAa,KAAe;CACnC,IAAI,OAAO,QAAQ,YAAY,QAAQ,MACrC,OAAO;CAET,IAAI,MAAM,QAAQ,GAAG,GACnB,OAAO,IAAI,IAAI,YAAY;CAE7B,MAAM,aAAa,OAAO,KAAK,GAAG,CAAC,CAAC,KAAK;CACzC,MAAM,SAA8B,CACpC;CAEA,WAAW,SAAS,QAAQ;EAC1B,OAAO,OAAO,aAAa,IAAI,IAAI;CACrC,CAAC;CACD,OAAO;AACT;;AAIA,SAAgB,oBAAoB,KAAkB;CACpD,OAAO,KAAK,UAAU,aAAa,GAAG,CAAC;AACzC"}
1
+ {"version":3,"file":"utility.cjs","names":["Slip10RawIndex","Bip39","EnglishMnemonic","Slip10","Slip10Curve","Secp256k1"],"sources":["../../../src/wallet/utility/utility.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n Bip39,\n EnglishMnemonic,\n HdPath,\n Secp256k1,\n Slip10,\n Slip10Curve,\n Slip10RawIndex,\n} from \"@cosmjs/crypto\";\nimport crypto from \"crypto\";\n\nimport {\n TxSignCoin,\n} from \"../types/index.js\";\n\n/**\n * Generates the HD path, for the specified index, in the form 'm/44'/118'/0'/0/i',\n * where 'i' is the account index\n * @param {number} [index=0] the account index\n */\nexport const generateHDPath = (index?: number): HdPath => {\n return [Slip10RawIndex.hardened(44), Slip10RawIndex.hardened(118), Slip10RawIndex.hardened(0), Slip10RawIndex.normal(0), Slip10RawIndex.normal(index ? index : 0)];\n};\n\n/**\n * Generates random entropy of the specified size (in B)\n * @param {number} [size=32] the entropy size in bytes\n */\nexport const generateEntropy = (size?: number): Uint8Array => {\n const array = new Uint8Array(size ? size : 32);\n\n // Generate random data\n crypto.randomFillSync(array);\n\n return array;\n};\n\n// Mirrors tm2/pkg/std/coin.go: reAmt, reSpc and reDnmString\nconst reSignCoin = /^(\\d+)\\s*([a-z/][a-z0-9_.:/-]{2,})$/;\n\n// std.Coin amounts are int64\nconst maxCoinAmount = 9223372036854775807n;\n\n/**\n * Parses a coin string in the format <amount (decimal)><denomination>\n * into the signature payload coin shape, following the same rules as\n * std.ParseCoin on the chain. A missing, empty or zero coin yields\n * an empty list\n * @param {string} [coin] the coin string, ex. 1000000ugnot\n */\nexport const parseSignCoin = (coin?: string): TxSignCoin[] => {\n const trimmed = (coin ?? \"\").trim();\n if (trimmed === \"\") {\n return [];\n }\n\n const match = reSignCoin.exec(trimmed);\n if (!match) {\n throw new Error(`invalid coin format: ${coin}`);\n }\n\n const [, rawAmount, denom] = match;\n const amount = BigInt(rawAmount);\n if (amount > maxCoinAmount) {\n throw new Error(`coin amount out of range: ${coin}`);\n }\n\n if (amount === 0n) {\n return [];\n }\n\n return [\n {\n denom,\n amount: amount.toString(10),\n },\n ];\n};\n\ninterface keyPair {\n privateKey: Uint8Array\n publicKey: Uint8Array\n}\n\n/**\n * Generates a new Secp256k1 key-pair using\n * the provided English mnemonic and account index\n * @param {string} mnemonic the English mnemonic\n * @param {number} [accountIndex=0] the account index\n */\nexport const generateKeyPair = async (\n mnemonic: string,\n accountIndex?: number,\n): Promise<keyPair> => {\n // Generate the seed\n const seed = await Bip39.mnemonicToSeed(new EnglishMnemonic(mnemonic));\n\n // Derive the private key\n const {\n privkey: privateKey,\n } = Slip10.derivePath(\n Slip10Curve.Secp256k1,\n seed,\n generateHDPath(accountIndex),\n );\n\n // Derive the public key\n const {\n pubkey: publicKey,\n } = await Secp256k1.makeKeypair(privateKey);\n\n return {\n publicKey: publicKey,\n privateKey: privateKey,\n };\n};\n\n// Address prefix for TM2 networks\nexport const defaultAddressPrefix = \"g\";\n\n/**\n * Encodes a string into a Uint8Array\n * @param {string} str the string to be encoded\n */\nexport const stringToUTF8 = (str: string): Uint8Array => {\n return new TextEncoder().encode(str);\n};\n\n/**\n * Escapes <,>,& in string.\n * Golang's json marshaller escapes <,>,& by default.\n * https://cs.opensource.google/go/go/+/refs/tags/go1.20.6:src/encoding/json/encode.go;l=46-53\n */\nexport function encodeCharacterSet(data: string) {\n return data\n .replace(/</g, \"\\\\u003c\")\n .replace(/>/g, \"\\\\u003e\")\n .replace(/&/g, \"\\\\u0026\");\n}\n\nfunction sortedObject(obj: any): any {\n if (typeof obj !== \"object\" || obj === null) {\n return obj;\n }\n if (Array.isArray(obj)) {\n return obj.map(sortedObject);\n }\n const sortedKeys = Object.keys(obj).sort();\n const result: Record<string, any> = {\n };\n // NOTE: Use forEach instead of reduce for performance with large objects eg Wasm code\n sortedKeys.forEach((key) => {\n result[key] = sortedObject(obj[key]);\n });\n return result;\n}\n\n/** Returns a JSON string with objects sorted by key */\n\nexport function sortedJsonStringify(obj: any): string {\n return JSON.stringify(sortedObject(obj));\n}\n"],"mappings":";;;;;;;;;;AAqBA,MAAa,kBAAkB,UAA2B;CACxD,OAAO;EAACA,eAAAA,eAAe,SAAS,EAAE;EAAGA,eAAAA,eAAe,SAAS,GAAG;EAAGA,eAAAA,eAAe,SAAS,CAAC;EAAGA,eAAAA,eAAe,OAAO,CAAC;EAAGA,eAAAA,eAAe,OAAO,QAAQ,QAAQ,CAAC;CAAC;A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AAQ,MACrC,OAAO;CAET,IAAI,MAAM,QAAQ,GAAG,GACnB,OAAO,IAAI,IAAI,YAAY;CAE7B,MAAM,aAAa,OAAO,KAAK,GAAG,CAAC,CAAC,KAAK;CACzC,MAAM,SAA8B,CACpC;CAEA,WAAW,SAAS,QAAQ;EAC1B,OAAO,OAAO,aAAa,IAAI,IAAI;CACrC,CAAC;CACD,OAAO;AACT;;AAIA,SAAgB,oBAAoB,KAAkB;CACpD,OAAO,KAAK,UAAU,aAAa,GAAG,CAAC;AACzC"}
@@ -1,3 +1,5 @@
1
+ import { TxSignCoin } from "../types/sign.cjs";
2
+ import "../types/index.cjs";
1
3
  import { HdPath } from "@cosmjs/crypto";
2
4
  //#region src/wallet/utility/utility.d.ts
3
5
  /**
@@ -11,6 +13,14 @@ declare const generateHDPath: (index?: number) => HdPath;
11
13
  * @param {number} [size=32] the entropy size in bytes
12
14
  */
13
15
  declare const generateEntropy: (size?: number) => Uint8Array;
16
+ /**
17
+ * Parses a coin string in the format <amount (decimal)><denomination>
18
+ * into the signature payload coin shape, following the same rules as
19
+ * std.ParseCoin on the chain. A missing, empty or zero coin yields
20
+ * an empty list
21
+ * @param {string} [coin] the coin string, ex. 1000000ugnot
22
+ */
23
+ declare const parseSignCoin: (coin?: string) => TxSignCoin[];
14
24
  interface keyPair {
15
25
  privateKey: Uint8Array;
16
26
  publicKey: Uint8Array;
@@ -37,5 +47,5 @@ declare function encodeCharacterSet(data: string): string;
37
47
  /** Returns a JSON string with objects sorted by key */
38
48
  declare function sortedJsonStringify(obj: any): string;
39
49
  //#endregion
40
- export { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 };
50
+ export { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, parseSignCoin, sortedJsonStringify, stringToUTF8 };
41
51
  //# sourceMappingURL=utility.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utility.d.cts","names":[],"sources":["../../../src/wallet/utility/utility.ts"],"mappings":";;;;;;;cAiBa,iBAAkB,mBAAiB;;;;;cAQnC,kBAAmB,kBAAgB;UAStC;EACR,YAAY;EACZ,WAAW;;;;;;;;cASA,kBACX,kBACA,0BACC,QAAQ;cAyBE;;;;;cAMA,eAAgB,gBAAc;;;;;;iBAS3B,mBAAmB;;iBA0BnB,oBAAoB"}
1
+ {"version":3,"file":"utility.d.cts","names":[],"sources":["../../../src/wallet/utility/utility.ts"],"mappings":";;;;;;;;;cAqBa,iBAAkB,mBAAiB;;;;;cAQnC,kBAAmB,kBAAgB;;;;;;;;cAsBnC,gBAAiB,kBAAgB;UA6BpC;EACR,YAAY;EACZ,WAAW;;;;;;;;cASA,kBACX,kBACA,0BACC,QAAQ;cAyBE;;;;;cAMA,eAAgB,gBAAc;;;;;;iBAS3B,mBAAmB;;iBA0BnB,oBAAoB"}
@@ -1,3 +1,5 @@
1
+ import { TxSignCoin } from "../types/sign.mjs";
2
+ import "../types/index.mjs";
1
3
  import { HdPath } from "@cosmjs/crypto";
2
4
  //#region src/wallet/utility/utility.d.ts
3
5
  /**
@@ -11,6 +13,14 @@ declare const generateHDPath: (index?: number) => HdPath;
11
13
  * @param {number} [size=32] the entropy size in bytes
12
14
  */
13
15
  declare const generateEntropy: (size?: number) => Uint8Array;
16
+ /**
17
+ * Parses a coin string in the format <amount (decimal)><denomination>
18
+ * into the signature payload coin shape, following the same rules as
19
+ * std.ParseCoin on the chain. A missing, empty or zero coin yields
20
+ * an empty list
21
+ * @param {string} [coin] the coin string, ex. 1000000ugnot
22
+ */
23
+ declare const parseSignCoin: (coin?: string) => TxSignCoin[];
14
24
  interface keyPair {
15
25
  privateKey: Uint8Array;
16
26
  publicKey: Uint8Array;
@@ -37,5 +47,5 @@ declare function encodeCharacterSet(data: string): string;
37
47
  /** Returns a JSON string with objects sorted by key */
38
48
  declare function sortedJsonStringify(obj: any): string;
39
49
  //#endregion
40
- export { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 };
50
+ export { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, parseSignCoin, sortedJsonStringify, stringToUTF8 };
41
51
  //# sourceMappingURL=utility.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utility.d.mts","names":[],"sources":["../../../src/wallet/utility/utility.ts"],"mappings":";;;;;;;cAiBa,iBAAkB,mBAAiB;;;;;cAQnC,kBAAmB,kBAAgB;UAStC;EACR,YAAY;EACZ,WAAW;;;;;;;;cASA,kBACX,kBACA,0BACC,QAAQ;cAyBE;;;;;cAMA,eAAgB,gBAAc;;;;;;iBAS3B,mBAAmB;;iBA0BnB,oBAAoB"}
1
+ {"version":3,"file":"utility.d.mts","names":[],"sources":["../../../src/wallet/utility/utility.ts"],"mappings":";;;;;;;;;cAqBa,iBAAkB,mBAAiB;;;;;cAQnC,kBAAmB,kBAAgB;;;;;;;;cAsBnC,gBAAiB,kBAAgB;UA6BpC;EACR,YAAY;EACZ,WAAW;;;;;;;;cASA,kBACX,kBACA,0BACC,QAAQ;cAyBE;;;;;cAMA,eAAgB,gBAAc;;;;;;iBAS3B,mBAAmB;;iBA0BnB,oBAAoB"}
@@ -24,6 +24,29 @@ const generateEntropy = (size) => {
24
24
  crypto.randomFillSync(array);
25
25
  return array;
26
26
  };
27
+ const reSignCoin = /^(\d+)\s*([a-z/][a-z0-9_.:/-]{2,})$/;
28
+ const maxCoinAmount = 9223372036854775807n;
29
+ /**
30
+ * Parses a coin string in the format <amount (decimal)><denomination>
31
+ * into the signature payload coin shape, following the same rules as
32
+ * std.ParseCoin on the chain. A missing, empty or zero coin yields
33
+ * an empty list
34
+ * @param {string} [coin] the coin string, ex. 1000000ugnot
35
+ */
36
+ const parseSignCoin = (coin) => {
37
+ const trimmed = (coin ?? "").trim();
38
+ if (trimmed === "") return [];
39
+ const match = reSignCoin.exec(trimmed);
40
+ if (!match) throw new Error(`invalid coin format: ${coin}`);
41
+ const [, rawAmount, denom] = match;
42
+ const amount = BigInt(rawAmount);
43
+ if (amount > maxCoinAmount) throw new Error(`coin amount out of range: ${coin}`);
44
+ if (amount === 0n) return [];
45
+ return [{
46
+ denom,
47
+ amount: amount.toString(10)
48
+ }];
49
+ };
27
50
  /**
28
51
  * Generates a new Secp256k1 key-pair using
29
52
  * the provided English mnemonic and account index
@@ -70,6 +93,6 @@ function sortedJsonStringify(obj) {
70
93
  return JSON.stringify(sortedObject(obj));
71
94
  }
72
95
  //#endregion
73
- export { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, sortedJsonStringify, stringToUTF8 };
96
+ export { defaultAddressPrefix, encodeCharacterSet, generateEntropy, generateHDPath, generateKeyPair, parseSignCoin, sortedJsonStringify, stringToUTF8 };
74
97
 
75
98
  //# sourceMappingURL=utility.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utility.mjs","names":[],"sources":["../../../src/wallet/utility/utility.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n Bip39,\n EnglishMnemonic,\n HdPath,\n Secp256k1,\n Slip10,\n Slip10Curve,\n Slip10RawIndex,\n} from \"@cosmjs/crypto\";\nimport crypto from \"crypto\";\n\n/**\n * Generates the HD path, for the specified index, in the form 'm/44'/118'/0'/0/i',\n * where 'i' is the account index\n * @param {number} [index=0] the account index\n */\nexport const generateHDPath = (index?: number): HdPath => {\n return [Slip10RawIndex.hardened(44), Slip10RawIndex.hardened(118), Slip10RawIndex.hardened(0), Slip10RawIndex.normal(0), Slip10RawIndex.normal(index ? index : 0)];\n};\n\n/**\n * Generates random entropy of the specified size (in B)\n * @param {number} [size=32] the entropy size in bytes\n */\nexport const generateEntropy = (size?: number): Uint8Array => {\n const array = new Uint8Array(size ? size : 32);\n\n // Generate random data\n crypto.randomFillSync(array);\n\n return array;\n};\n\ninterface keyPair {\n privateKey: Uint8Array\n publicKey: Uint8Array\n}\n\n/**\n * Generates a new Secp256k1 key-pair using\n * the provided English mnemonic and account index\n * @param {string} mnemonic the English mnemonic\n * @param {number} [accountIndex=0] the account index\n */\nexport const generateKeyPair = async (\n mnemonic: string,\n accountIndex?: number,\n): Promise<keyPair> => {\n // Generate the seed\n const seed = await Bip39.mnemonicToSeed(new EnglishMnemonic(mnemonic));\n\n // Derive the private key\n const {\n privkey: privateKey,\n } = Slip10.derivePath(\n Slip10Curve.Secp256k1,\n seed,\n generateHDPath(accountIndex),\n );\n\n // Derive the public key\n const {\n pubkey: publicKey,\n } = await Secp256k1.makeKeypair(privateKey);\n\n return {\n publicKey: publicKey,\n privateKey: privateKey,\n };\n};\n\n// Address prefix for TM2 networks\nexport const defaultAddressPrefix = \"g\";\n\n/**\n * Encodes a string into a Uint8Array\n * @param {string} str the string to be encoded\n */\nexport const stringToUTF8 = (str: string): Uint8Array => {\n return new TextEncoder().encode(str);\n};\n\n/**\n * Escapes <,>,& in string.\n * Golang's json marshaller escapes <,>,& by default.\n * https://cs.opensource.google/go/go/+/refs/tags/go1.20.6:src/encoding/json/encode.go;l=46-53\n */\nexport function encodeCharacterSet(data: string) {\n return data\n .replace(/</g, \"\\\\u003c\")\n .replace(/>/g, \"\\\\u003e\")\n .replace(/&/g, \"\\\\u0026\");\n}\n\nfunction sortedObject(obj: any): any {\n if (typeof obj !== \"object\" || obj === null) {\n return obj;\n }\n if (Array.isArray(obj)) {\n return obj.map(sortedObject);\n }\n const sortedKeys = Object.keys(obj).sort();\n const result: Record<string, any> = {\n };\n // NOTE: Use forEach instead of reduce for performance with large objects eg Wasm code\n sortedKeys.forEach((key) => {\n result[key] = sortedObject(obj[key]);\n });\n return result;\n}\n\n/** Returns a JSON string with objects sorted by key */\n\nexport function sortedJsonStringify(obj: any): string {\n return JSON.stringify(sortedObject(obj));\n}\n"],"mappings":";;;;;;;;AAiBA,MAAa,kBAAkB,UAA2B;CACxD,OAAO;EAAC,eAAe,SAAS,EAAE;EAAG,eAAe,SAAS,GAAG;EAAG,eAAe,SAAS,CAAC;EAAG,eAAe,OAAO,CAAC;EAAG,eAAe,OAAO,QAAQ,QAAQ,CAAC;CAAC;AACnK;;;;;AAMA,MAAa,mBAAmB,SAA8B;CAC5D,MAAM,QAAQ,IAAI,WAAW,OAAO,OAAO,EAAE;CAG7C,OAAO,eAAe,KAAK;CAE3B,OAAO;AACT;;;;;;;AAaA,MAAa,kBAAkB,OAC7B,UACA,iBACqB;CAErB,MAAM,OAAO,MAAM,MAAM,eAAe,IAAI,gBAAgB,QAAQ,CAAC;CAGrE,MAAM,EACJ,SAAS,eACP,OAAO,WACT,YAAY,WACZ,MACA,eAAe,YAAY,CAC7B;CAGA,MAAM,EACJ,QAAQ,cACN,MAAM,UAAU,YAAY,UAAU;CAE1C,OAAO;EACM;EACC;CACd;AACF;AAGA,MAAa,uBAAuB;;;;;AAMpC,MAAa,gBAAgB,QAA4B;CACvD,OAAO,IAAI,YAAY,CAAC,CAAC,OAAO,GAAG;AACrC;;;;;;AAOA,SAAgB,mBAAmB,MAAc;CAC/C,OAAO,KACJ,QAAQ,MAAM,SAAS,CAAC,CACxB,QAAQ,MAAM,SAAS,CAAC,CACxB,QAAQ,MAAM,SAAS;AAC5B;AAEA,SAAS,aAAa,KAAe;CACnC,IAAI,OAAO,QAAQ,YAAY,QAAQ,MACrC,OAAO;CAET,IAAI,MAAM,QAAQ,GAAG,GACnB,OAAO,IAAI,IAAI,YAAY;CAE7B,MAAM,aAAa,OAAO,KAAK,GAAG,CAAC,CAAC,KAAK;CACzC,MAAM,SAA8B,CACpC;CAEA,WAAW,SAAS,QAAQ;EAC1B,OAAO,OAAO,aAAa,IAAI,IAAI;CACrC,CAAC;CACD,OAAO;AACT;;AAIA,SAAgB,oBAAoB,KAAkB;CACpD,OAAO,KAAK,UAAU,aAAa,GAAG,CAAC;AACzC"}
1
+ {"version":3,"file":"utility.mjs","names":[],"sources":["../../../src/wallet/utility/utility.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n Bip39,\n EnglishMnemonic,\n HdPath,\n Secp256k1,\n Slip10,\n Slip10Curve,\n Slip10RawIndex,\n} from \"@cosmjs/crypto\";\nimport crypto from \"crypto\";\n\nimport {\n TxSignCoin,\n} from \"../types/index.js\";\n\n/**\n * Generates the HD path, for the specified index, in the form 'm/44'/118'/0'/0/i',\n * where 'i' is the account index\n * @param {number} [index=0] the account index\n */\nexport const generateHDPath = (index?: number): HdPath => {\n return [Slip10RawIndex.hardened(44), Slip10RawIndex.hardened(118), Slip10RawIndex.hardened(0), Slip10RawIndex.normal(0), Slip10RawIndex.normal(index ? index : 0)];\n};\n\n/**\n * Generates random entropy of the specified size (in B)\n * @param {number} [size=32] the entropy size in bytes\n */\nexport const generateEntropy = (size?: number): Uint8Array => {\n const array = new Uint8Array(size ? size : 32);\n\n // Generate random data\n crypto.randomFillSync(array);\n\n return array;\n};\n\n// Mirrors tm2/pkg/std/coin.go: reAmt, reSpc and reDnmString\nconst reSignCoin = /^(\\d+)\\s*([a-z/][a-z0-9_.:/-]{2,})$/;\n\n// std.Coin amounts are int64\nconst maxCoinAmount = 9223372036854775807n;\n\n/**\n * Parses a coin string in the format <amount (decimal)><denomination>\n * into the signature payload coin shape, following the same rules as\n * std.ParseCoin on the chain. A missing, empty or zero coin yields\n * an empty list\n * @param {string} [coin] the coin string, ex. 1000000ugnot\n */\nexport const parseSignCoin = (coin?: string): TxSignCoin[] => {\n const trimmed = (coin ?? \"\").trim();\n if (trimmed === \"\") {\n return [];\n }\n\n const match = reSignCoin.exec(trimmed);\n if (!match) {\n throw new Error(`invalid coin format: ${coin}`);\n }\n\n const [, rawAmount, denom] = match;\n const amount = BigInt(rawAmount);\n if (amount > maxCoinAmount) {\n throw new Error(`coin amount out of range: ${coin}`);\n }\n\n if (amount === 0n) {\n return [];\n }\n\n return [\n {\n denom,\n amount: amount.toString(10),\n },\n ];\n};\n\ninterface keyPair {\n privateKey: Uint8Array\n publicKey: Uint8Array\n}\n\n/**\n * Generates a new Secp256k1 key-pair using\n * the provided English mnemonic and account index\n * @param {string} mnemonic the English mnemonic\n * @param {number} [accountIndex=0] the account index\n */\nexport const generateKeyPair = async (\n mnemonic: string,\n accountIndex?: number,\n): Promise<keyPair> => {\n // Generate the seed\n const seed = await Bip39.mnemonicToSeed(new EnglishMnemonic(mnemonic));\n\n // Derive the private key\n const {\n privkey: privateKey,\n } = Slip10.derivePath(\n Slip10Curve.Secp256k1,\n seed,\n generateHDPath(accountIndex),\n );\n\n // Derive the public key\n const {\n pubkey: publicKey,\n } = await Secp256k1.makeKeypair(privateKey);\n\n return {\n publicKey: publicKey,\n privateKey: privateKey,\n };\n};\n\n// Address prefix for TM2 networks\nexport const defaultAddressPrefix = \"g\";\n\n/**\n * Encodes a string into a Uint8Array\n * @param {string} str the string to be encoded\n */\nexport const stringToUTF8 = (str: string): Uint8Array => {\n return new TextEncoder().encode(str);\n};\n\n/**\n * Escapes <,>,& in string.\n * Golang's json marshaller escapes <,>,& by default.\n * https://cs.opensource.google/go/go/+/refs/tags/go1.20.6:src/encoding/json/encode.go;l=46-53\n */\nexport function encodeCharacterSet(data: string) {\n return data\n .replace(/</g, \"\\\\u003c\")\n .replace(/>/g, \"\\\\u003e\")\n .replace(/&/g, \"\\\\u0026\");\n}\n\nfunction sortedObject(obj: any): any {\n if (typeof obj !== \"object\" || obj === null) {\n return obj;\n }\n if (Array.isArray(obj)) {\n return obj.map(sortedObject);\n }\n const sortedKeys = Object.keys(obj).sort();\n const result: Record<string, any> = {\n };\n // NOTE: Use forEach instead of reduce for performance with large objects eg Wasm code\n sortedKeys.forEach((key) => {\n result[key] = sortedObject(obj[key]);\n });\n return result;\n}\n\n/** Returns a JSON string with objects sorted by key */\n\nexport function sortedJsonStringify(obj: any): string {\n return JSON.stringify(sortedObject(obj));\n}\n"],"mappings":";;;;;;;;AAqBA,MAAa,kBAAkB,UAA2B;CACxD,OAAO;EAAC,eAAe,SAAS,EAAE;EAAG,eAAe,SAAS,GAAG;EAAG,eAAe,SAAS,CAAC;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,OAAO,QAAQ,YAAY,QAAQ,MACrC,OAAO;CAET,IAAI,MAAM,QAAQ,GAAG,GACnB,OAAO,IAAI,IAAI,YAAY;CAE7B,MAAM,aAAa,OAAO,KAAK,GAAG,CAAC,CAAC,KAAK;CACzC,MAAM,SAA8B,CACpC;CAEA,WAAW,SAAS,QAAQ;EAC1B,OAAO,OAAO,aAAa,IAAI,IAAI;CACrC,CAAC;CACD,OAAO;AACT;;AAIA,SAAgB,oBAAoB,KAAkB;CACpD,OAAO,KAAK,UAAU,aAAa,GAAG,CAAC;AACzC"}
@@ -143,8 +143,8 @@ var Wallet = class {
143
143
  account_number: accountNumber,
144
144
  sequence: accountSequence,
145
145
  fee: {
146
- gas_fee: tx.fee.gas_fee,
147
- gas_wanted: tx.fee.gas_wanted.toString(10)
146
+ amount: require_utility.parseSignCoin(tx.fee.gas_fee),
147
+ gas: tx.fee.gas_wanted.toString(10)
148
148
  },
149
149
  msgs: decodeTxMessages(tx.messages),
150
150
  memo: tx.memo
@@ -1 +1 @@
1
- {"version":3,"file":"wallet.cjs","names":["stringToUTF8","encodeCharacterSet","sortedJsonStringify","Secp256k1PubKeyType","PubKeySecp256k1","uint8ArrayToBase64","Tx","generateKeyPair","Bip39","generateEntropy","Wallet","KeySigner","Secp256k1","LedgerSigner"],"sources":["../../src/wallet/wallet.ts"],"sourcesContent":["import {\n Bip39, Secp256k1,\n} from \"@cosmjs/crypto\";\nimport {\n LedgerConnector,\n} from \"@cosmjs/ledger-amino\";\n\nimport {\n Any, PubKeySecp256k1, Tx, TxSignature,\n} from \"../proto/index.js\";\nimport {\n BroadcastTransactionMap,\n Provider,\n Status,\n uint8ArrayToBase64,\n} from \"../provider/index.js\";\nimport {\n KeySigner,\n} from \"./key/index.js\";\nimport {\n LedgerSigner,\n} from \"./ledger/index.js\";\nimport {\n Signer,\n} from \"./signer.js\";\nimport {\n AccountWalletOption,\n CreateWalletOptions,\n Secp256k1PubKeyType,\n TxSignPayload,\n} from \"./types/index.js\";\nimport {\n encodeCharacterSet,\n generateEntropy,\n generateKeyPair,\n stringToUTF8,\n} from \"./utility/index.js\";\nimport {\n sortedJsonStringify,\n} from \"./utility/index.js\";\nexport interface SignTransactionOptions {\n accountNumber?: string\n sequence?: string\n}\n\n/**\n * Wallet is a single account abstraction\n * that can interact with the blockchain\n */\nexport class Wallet {\n protected declare provider: Provider;\n protected declare signer: Signer;\n\n /**\n * Connects the wallet to the specified {@link Provider}\n * @param {Provider} provider the active {@link Provider}, if any\n */\n connect = (provider: Provider) => {\n this.provider = provider;\n };\n\n // Wallet initialization //\n\n /**\n * Generates a private key-based wallet, using a random seed\n * @param {AccountWalletOption} options the account options\n */\n static createRandom = async (\n options?: AccountWalletOption,\n ): Promise<Wallet> => {\n const {\n publicKey, privateKey,\n } = await generateKeyPair(\n Bip39.encode(generateEntropy()).toString(),\n 0,\n );\n\n // Initialize the wallet\n const wallet: Wallet = new Wallet();\n wallet.signer = new KeySigner(\n privateKey,\n Secp256k1.compressPubkey(publicKey),\n options?.addressPrefix,\n );\n\n return wallet;\n };\n\n /**\n * Generates a custom signer-based wallet\n * @param {Signer} signer the custom signer implementing the Signer interface\n * @param {CreateWalletOptions} options the wallet generation options\n */\n static fromSigner = async (signer: Signer): Promise<Wallet> => {\n // Initialize the wallet\n const wallet: Wallet = new Wallet();\n wallet.signer = signer;\n\n return wallet;\n };\n\n /**\n * Generates a bip39 mnemonic-based wallet\n * @param {string} mnemonic the bip39 mnemonic\n * @param {CreateWalletOptions} options the wallet generation options\n */\n static fromMnemonic = async (\n mnemonic: string,\n options?: CreateWalletOptions,\n ): Promise<Wallet> => {\n const {\n publicKey, privateKey,\n } = await generateKeyPair(\n mnemonic,\n options?.accountIndex,\n );\n\n // Initialize the wallet\n const wallet: Wallet = new Wallet();\n wallet.signer = new KeySigner(\n privateKey,\n Secp256k1.compressPubkey(publicKey),\n options?.addressPrefix,\n );\n\n return wallet;\n };\n\n /**\n * Generates a private key-based wallet\n * @param {string} privateKey the private key\n * @param {AccountWalletOption} options the account options\n */\n static fromPrivateKey = async (\n privateKey: Uint8Array,\n options?: AccountWalletOption,\n ): Promise<Wallet> => {\n // Derive the public key\n const {\n pubkey: publicKey,\n } = await Secp256k1.makeKeypair(privateKey);\n\n // Initialize the wallet\n const wallet: Wallet = new Wallet();\n wallet.signer = new KeySigner(\n privateKey,\n Secp256k1.compressPubkey(publicKey),\n options?.addressPrefix,\n );\n\n return wallet;\n };\n\n /**\n * Creates a Ledger-based wallet\n * @param {LedgerConnector} connector the Ledger device connector\n * @param {CreateWalletOptions} options the wallet generation options\n */\n static fromLedger = (\n connector: LedgerConnector,\n options?: CreateWalletOptions,\n ): Wallet => {\n const wallet: Wallet = new Wallet();\n\n wallet.signer = new LedgerSigner(\n connector,\n options?.accountIndex ?? 0,\n options?.addressPrefix,\n );\n\n return wallet;\n };\n\n // Account manipulation //\n\n /**\n * Fetches the address associated with the wallet\n */\n getAddress = (): Promise<string> => {\n return this.signer.getAddress();\n };\n\n /**\n * Fetches the account sequence for the wallet\n * @param {number} [height=latest] the block height\n */\n getAccountSequence = async (height?: number): Promise<number> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Get the address\n const address: string = await this.getAddress();\n\n return this.provider.getAccountSequence(address, height);\n };\n\n /**\n * Fetches the account number for the wallet. Errors out if the\n * account is not initialized\n * @param {number} [height=latest] the block height\n */\n getAccountNumber = async (height?: number): Promise<number> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Get the address\n const address: string = await this.getAddress();\n\n return this.provider.getAccountNumber(address, height);\n };\n\n /**\n * Fetches the account balance for the specific denomination\n * @param {string} [denomination=ugnot] the fund denomination\n */\n getBalance = async (denomination?: string): Promise<number> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Get the address\n const address: string = await this.getAddress();\n\n return this.provider.getBalance(\n address,\n denomination ? denomination : \"ugnot\",\n );\n };\n\n /**\n * Fetches the current (recommended) average gas price\n */\n getGasPrice = async (): Promise<number> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n return this.provider.getGasPrice();\n };\n\n /**\n * Estimates the gas limit for the transaction\n * @param {Tx} tx the transaction that needs estimating\n */\n estimateGas = async (tx: Tx): Promise<bigint> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n return this.provider.estimateGas(tx);\n };\n\n /**\n * Returns the connected provider, if any\n */\n getProvider = (): Provider => {\n return this.provider;\n };\n\n /**\n * Generates a transaction signature, and appends it to the transaction\n * @param {Tx} tx the transaction to be signed\n * @param {(messages: Any[]) => any[]} decodeTxMessages tx message decode callback\n * that should expand the concrete message fields into an object. Required because\n * the transaction sign bytes are generated using sorted JSON, which requires\n * encoded message values to be decoded for sorting\n */\n signTransaction = async (\n tx: Tx,\n decodeTxMessages: (messages: Any[]) => unknown[],\n opts?: SignTransactionOptions,\n ): Promise<Tx> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Make sure the tx fee is initialized\n if (!tx.fee) {\n throw new Error(\"invalid transaction fee provided\");\n }\n\n // Extract the relevant chain data\n const status: Status = await this.provider.getStatus();\n const chainID: string = status.node_info.network;\n\n // Extract the relevant account data\n let accountNumber = opts?.accountNumber;\n let accountSequence = opts?.sequence;\n if (accountNumber === undefined || accountSequence === undefined) {\n const address: string = await this.getAddress();\n const account = await this.provider.getAccount(address);\n if (accountNumber === undefined) {\n accountNumber = account.BaseAccount.account_number;\n }\n if (accountSequence === undefined) {\n accountSequence = account.BaseAccount.sequence;\n }\n }\n const publicKey: Uint8Array = await this.signer.getPublicKey();\n\n // Create the signature payload\n const signPayload: TxSignPayload = {\n chain_id: chainID,\n account_number: accountNumber,\n sequence: accountSequence,\n fee: {\n gas_fee: tx.fee.gas_fee,\n gas_wanted: tx.fee.gas_wanted.toString(10),\n },\n msgs: decodeTxMessages(tx.messages), // unrolled message objects\n memo: tx.memo,\n };\n\n // The TM2 node does signature verification using\n // a sorted JSON object, so the payload needs to be sorted\n // before signing\n const signBytes: Uint8Array = stringToUTF8(\n encodeCharacterSet(sortedJsonStringify(signPayload)),\n );\n\n // The public key needs to be encoded using protobuf for Amino\n const wrappedKey: PubKeySecp256k1 = {\n key: publicKey,\n };\n\n // Generate the signature\n const txSignature: TxSignature = {\n pub_key: {\n type_url: Secp256k1PubKeyType,\n value: PubKeySecp256k1.encode(wrappedKey).finish(),\n },\n signature: await this.getSigner().signData(signBytes),\n session_addr: \"\",\n };\n\n // Append the signature\n return {\n ...tx,\n signatures: [...tx.signatures, txSignature],\n };\n };\n\n /**\n * Encodes and sends the transaction. If the type of endpoint\n * is a broadcast commit, waits for the transaction to be committed to the chain.\n * The transaction needs to be signed beforehand.\n * Returns the transaction hash (base-64)\n * @param {Tx} tx the signed transaction\n * @param {BroadcastType} endpoint the transaction broadcast type (sync / commit)\n */\n async sendTransaction<K extends keyof BroadcastTransactionMap>(\n tx: Tx,\n endpoint: K,\n ): Promise<BroadcastTransactionMap[K][\"result\"]> {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Encode the transaction to base-64\n const encodedTx: string = uint8ArrayToBase64(Tx.encode(tx).finish());\n\n // Send the encoded transaction\n return this.provider.sendTransaction(encodedTx, endpoint);\n }\n\n /**\n * Returns the associated signer\n */\n getSigner = (): Signer => {\n return this.signer;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiDA,IAAa,SAAb,MAAoB;;;;;;;;GAQlB;IAAW,aAAuB;IAChC,KAAK,WAAW;GAClB;;;;;;;GAuHA;SAAoC;IAClC,OAAO,KAAK,OAAO,WAAW;GAChC;;;;;;;;GAMA;GAAqB,OAAO,WAAqC;IAC/D,IAAI,CAAC,KAAK,UACR,MAAM,IAAI,MAAM,wBAAwB;IAI1C,MAAM,UAAkB,MAAM,KAAK,WAAW;IAE9C,OAAO,KAAK,SAAS,mBAAmB,SAAS,MAAM;GACzD;;;;;;;;;GAOA;GAAmB,OAAO,WAAqC;IAC7D,IAAI,CAAC,KAAK,UAC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,CAAA;AAOO,uBAAA,QAAA,QAAA,gBAAe,OACpB,UACA,YACoB;CACpB,MAAM,EACJ,WAAW,eACT,MAAMH,gBAAAA,gBACR,UACA,SAAS,YACX;CAGA,MAAM,SAAiB,IAAIG,QAAO;CAClC,OAAO,SAAS,IAAIC,YAAAA,UAClB,YACAC,eAAAA,UAAU,eAAe,SAAS,GAClC,SAAS,aACX;CAEA,OAAO;AACT,CAAA;AAOO,uBAAA,QAAA,QAAA,kBAAiB,OACtB,YACA,YACoB;CAEpB,MAAM,EACJ,QAAQ,cACN,MAAMA,eAAAA,UAAU,YAAY,UAAU;CAG1C,MAAM,SAAiB,IAAIF,QAAO;CAClC,OAAO,SAAS,IAAIC,YAAAA,UAClB,YACAC,eAAAA,UAAU,eAAe,SAAS,GAClC,SAAS,aACX;CAEA,OAAO;AACT,CAAA;AAOO,uBAAA,QAAA,QAAA,eACL,WACA,YACW;CACX,MAAM,SAAiB,IAAIF,QAAO;CAElC,OAAO,SAAS,IAAIG,eAAAA,aAClB,WACA,SAAS,gBAAgB,GACzB,SAAS,aACX;CAEA,OAAO;AACT,CAAA"}
1
+ {"version":3,"file":"wallet.cjs","names":["parseSignCoin","stringToUTF8","encodeCharacterSet","sortedJsonStringify","Secp256k1PubKeyType","PubKeySecp256k1","uint8ArrayToBase64","Tx","generateKeyPair","Bip39","generateEntropy","Wallet","KeySigner","Secp256k1","LedgerSigner"],"sources":["../../src/wallet/wallet.ts"],"sourcesContent":["import {\n Bip39, Secp256k1,\n} from \"@cosmjs/crypto\";\nimport {\n LedgerConnector,\n} from \"@cosmjs/ledger-amino\";\n\nimport {\n Any, PubKeySecp256k1, Tx, TxSignature,\n} from \"../proto/index.js\";\nimport {\n BroadcastTransactionMap,\n Provider,\n Status,\n uint8ArrayToBase64,\n} from \"../provider/index.js\";\nimport {\n KeySigner,\n} from \"./key/index.js\";\nimport {\n LedgerSigner,\n} from \"./ledger/index.js\";\nimport {\n Signer,\n} from \"./signer.js\";\nimport {\n AccountWalletOption,\n CreateWalletOptions,\n Secp256k1PubKeyType,\n TxSignPayload,\n} from \"./types/index.js\";\nimport {\n encodeCharacterSet,\n generateEntropy,\n generateKeyPair,\n parseSignCoin,\n sortedJsonStringify,\n stringToUTF8,\n} from \"./utility/index.js\";\nexport interface SignTransactionOptions {\n accountNumber?: string\n sequence?: string\n}\n\n/**\n * Wallet is a single account abstraction\n * that can interact with the blockchain\n */\nexport class Wallet {\n protected declare provider: Provider;\n protected declare signer: Signer;\n\n /**\n * Connects the wallet to the specified {@link Provider}\n * @param {Provider} provider the active {@link Provider}, if any\n */\n connect = (provider: Provider) => {\n this.provider = provider;\n };\n\n // Wallet initialization //\n\n /**\n * Generates a private key-based wallet, using a random seed\n * @param {AccountWalletOption} options the account options\n */\n static createRandom = async (\n options?: AccountWalletOption,\n ): Promise<Wallet> => {\n const {\n publicKey, privateKey,\n } = await generateKeyPair(\n Bip39.encode(generateEntropy()).toString(),\n 0,\n );\n\n // Initialize the wallet\n const wallet: Wallet = new Wallet();\n wallet.signer = new KeySigner(\n privateKey,\n Secp256k1.compressPubkey(publicKey),\n options?.addressPrefix,\n );\n\n return wallet;\n };\n\n /**\n * Generates a custom signer-based wallet\n * @param {Signer} signer the custom signer implementing the Signer interface\n * @param {CreateWalletOptions} options the wallet generation options\n */\n static fromSigner = async (signer: Signer): Promise<Wallet> => {\n // Initialize the wallet\n const wallet: Wallet = new Wallet();\n wallet.signer = signer;\n\n return wallet;\n };\n\n /**\n * Generates a bip39 mnemonic-based wallet\n * @param {string} mnemonic the bip39 mnemonic\n * @param {CreateWalletOptions} options the wallet generation options\n */\n static fromMnemonic = async (\n mnemonic: string,\n options?: CreateWalletOptions,\n ): Promise<Wallet> => {\n const {\n publicKey, privateKey,\n } = await generateKeyPair(\n mnemonic,\n options?.accountIndex,\n );\n\n // Initialize the wallet\n const wallet: Wallet = new Wallet();\n wallet.signer = new KeySigner(\n privateKey,\n Secp256k1.compressPubkey(publicKey),\n options?.addressPrefix,\n );\n\n return wallet;\n };\n\n /**\n * Generates a private key-based wallet\n * @param {string} privateKey the private key\n * @param {AccountWalletOption} options the account options\n */\n static fromPrivateKey = async (\n privateKey: Uint8Array,\n options?: AccountWalletOption,\n ): Promise<Wallet> => {\n // Derive the public key\n const {\n pubkey: publicKey,\n } = await Secp256k1.makeKeypair(privateKey);\n\n // Initialize the wallet\n const wallet: Wallet = new Wallet();\n wallet.signer = new KeySigner(\n privateKey,\n Secp256k1.compressPubkey(publicKey),\n options?.addressPrefix,\n );\n\n return wallet;\n };\n\n /**\n * Creates a Ledger-based wallet\n * @param {LedgerConnector} connector the Ledger device connector\n * @param {CreateWalletOptions} options the wallet generation options\n */\n static fromLedger = (\n connector: LedgerConnector,\n options?: CreateWalletOptions,\n ): Wallet => {\n const wallet: Wallet = new Wallet();\n\n wallet.signer = new LedgerSigner(\n connector,\n options?.accountIndex ?? 0,\n options?.addressPrefix,\n );\n\n return wallet;\n };\n\n // Account manipulation //\n\n /**\n * Fetches the address associated with the wallet\n */\n getAddress = (): Promise<string> => {\n return this.signer.getAddress();\n };\n\n /**\n * Fetches the account sequence for the wallet\n * @param {number} [height=latest] the block height\n */\n getAccountSequence = async (height?: number): Promise<number> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Get the address\n const address: string = await this.getAddress();\n\n return this.provider.getAccountSequence(address, height);\n };\n\n /**\n * Fetches the account number for the wallet. Errors out if the\n * account is not initialized\n * @param {number} [height=latest] the block height\n */\n getAccountNumber = async (height?: number): Promise<number> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Get the address\n const address: string = await this.getAddress();\n\n return this.provider.getAccountNumber(address, height);\n };\n\n /**\n * Fetches the account balance for the specific denomination\n * @param {string} [denomination=ugnot] the fund denomination\n */\n getBalance = async (denomination?: string): Promise<number> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Get the address\n const address: string = await this.getAddress();\n\n return this.provider.getBalance(\n address,\n denomination ? denomination : \"ugnot\",\n );\n };\n\n /**\n * Fetches the current (recommended) average gas price\n */\n getGasPrice = async (): Promise<number> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n return this.provider.getGasPrice();\n };\n\n /**\n * Estimates the gas limit for the transaction\n * @param {Tx} tx the transaction that needs estimating\n */\n estimateGas = async (tx: Tx): Promise<bigint> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n return this.provider.estimateGas(tx);\n };\n\n /**\n * Returns the connected provider, if any\n */\n getProvider = (): Provider => {\n return this.provider;\n };\n\n /**\n * Generates a transaction signature, and appends it to the transaction\n * @param {Tx} tx the transaction to be signed\n * @param {(messages: Any[]) => any[]} decodeTxMessages tx message decode callback\n * that should expand the concrete message fields into an object. Required because\n * the transaction sign bytes are generated using sorted JSON, which requires\n * encoded message values to be decoded for sorting\n */\n signTransaction = async (\n tx: Tx,\n decodeTxMessages: (messages: Any[]) => unknown[],\n opts?: SignTransactionOptions,\n ): Promise<Tx> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Make sure the tx fee is initialized\n if (!tx.fee) {\n throw new Error(\"invalid transaction fee provided\");\n }\n\n // Extract the relevant chain data\n const status: Status = await this.provider.getStatus();\n const chainID: string = status.node_info.network;\n\n // Extract the relevant account data\n let accountNumber = opts?.accountNumber;\n let accountSequence = opts?.sequence;\n if (accountNumber === undefined || accountSequence === undefined) {\n const address: string = await this.getAddress();\n const account = await this.provider.getAccount(address);\n if (accountNumber === undefined) {\n accountNumber = account.BaseAccount.account_number;\n }\n if (accountSequence === undefined) {\n accountSequence = account.BaseAccount.sequence;\n }\n }\n const publicKey: Uint8Array = await this.signer.getPublicKey();\n\n // Create the signature payload\n const signPayload: TxSignPayload = {\n chain_id: chainID,\n account_number: accountNumber,\n sequence: accountSequence,\n fee: {\n amount: parseSignCoin(tx.fee.gas_fee),\n gas: tx.fee.gas_wanted.toString(10),\n },\n msgs: decodeTxMessages(tx.messages), // unrolled message objects\n memo: tx.memo,\n };\n\n // The TM2 node does signature verification using\n // a sorted JSON object, so the payload needs to be sorted\n // before signing\n const signBytes: Uint8Array = stringToUTF8(\n encodeCharacterSet(sortedJsonStringify(signPayload)),\n );\n\n // The public key needs to be encoded using protobuf for Amino\n const wrappedKey: PubKeySecp256k1 = {\n key: publicKey,\n };\n\n // Generate the signature\n const txSignature: TxSignature = {\n pub_key: {\n type_url: Secp256k1PubKeyType,\n value: PubKeySecp256k1.encode(wrappedKey).finish(),\n },\n signature: await this.getSigner().signData(signBytes),\n session_addr: \"\",\n };\n\n // Append the signature\n return {\n ...tx,\n signatures: [...tx.signatures, txSignature],\n };\n };\n\n /**\n * Encodes and sends the transaction. If the type of endpoint\n * is a broadcast commit, waits for the transaction to be committed to the chain.\n * The transaction needs to be signed beforehand.\n * Returns the transaction hash (base-64)\n * @param {Tx} tx the signed transaction\n * @param {BroadcastType} endpoint the transaction broadcast type (sync / commit)\n */\n async sendTransaction<K extends keyof BroadcastTransactionMap>(\n tx: Tx,\n endpoint: K,\n ): Promise<BroadcastTransactionMap[K][\"result\"]> {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Encode the transaction to base-64\n const encodedTx: string = uint8ArrayToBase64(Tx.encode(tx).finish());\n\n // Send the encoded transaction\n return this.provider.sendTransaction(encodedTx, endpoint);\n }\n\n /**\n * Returns the associated signer\n */\n getSigner = (): Signer => {\n return this.signer;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgDA,IAAa,SAAb,MAAoB;;;;;;;;GAQlB;IAAW,aAAuB;IAChC,KAAK,WAAW;GAClB;;;;;;;GAuHA;SAAoC;IAClC,OAAO,KAAK,OAAO,WAAW;GAChC;;;;;;;;GAMA;GAAqB,OAAO,WAAqC;IAC/D,IAAI,CAAC,KAAK,UACR,MAAM,IAAI,MAAM,wBAAwB;IAI1C,MAAM,UAAkB,MAAM,KAAK,WAAW;IAE9C,OAAO,KAAK,SAAS,mBAAmB,SAAS,MAAM;GACzD;;;;;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B;;;;;EAe5C,aAAoB,0BAAwB;;;;EAiB5C,mBAAwB;;;;;EAYxB,cAAqB,IAAI,OAAK;;;;EAW9B,mBAAkB;;;;;;;;;EAYlB,kBACE,IAAI,IACJ,mBAAmB,UAAU,qBAC7B,OAAO,2BACN,QAAQ;;;;;;;;;EA+EL,gBAAgB,gBAAgB,yBACpC,IAAI,IACJ,UAAU,IACT,QAAQ,wBAAwB;;;;EAenC,iBAAgB"}
1
+ {"version":3,"file":"wallet.d.cts","names":[],"sources":["../../src/wallet/wallet.ts"],"mappings":";;;;;;;;;;;UAuCiB;EACf;EACA;;;;;;cAOW;YACO,UAAU;YACV,QAAQ;;;;;EAM1B,UAAW,UAAU;;;;;SAUd,eACL,UAAU,wBACT,QAAQ;;;;;;SAwBJ,aAAoB,QAAQ,WAAS,QAAQ;;;;;;SAa7C,eACL,kBACA,UAAU,wBACT,QAAQ;;;;;;SAwBJ,iBACL,YAAY,YACZ,UAAU,wBACT,QAAQ;;;;;;SAsBJ,aACL,WAAW,iBACX,UAAU,wBACT;;;;EAiBH,kBAAiB;;;;;EAQjB,qBAA4B,oBAAkB;;;;;;EAgB9C,mBAA0B,oBAAkB;;;;;EAe5C,aAAoB,0BAAwB;;;;EAiB5C,mBAAwB;;;;;EAYxB,cAAqB,IAAI,OAAK;;;;EAW9B,mBAAkB;;;;;;;;;EAYlB,kBACE,IAAI,IACJ,mBAAmB,UAAU,qBAC7B,OAAO,2BACN,QAAQ;;;;;;;;;EA+EL,gBAAgB,gBAAgB,yBACpC,IAAI,IACJ,UAAU,IACT,QAAQ,wBAAwB;;;;EAenC,iBAAgB"}
@@ -1 +1 @@
1
- {"version":3,"file":"wallet.d.mts","names":[],"sources":["../../src/wallet/wallet.ts"],"mappings":";;;;;;;;;;;UAwCiB;EACf;EACA;;;;;;cAOW;YACO,UAAU;YACV,QAAQ;;;;;EAM1B,UAAW,UAAU;;;;;SAUd,eACL,UAAU,wBACT,QAAQ;;;;;;SAwBJ,aAAoB,QAAQ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@@ -3,7 +3,7 @@ import "../proto/index.mjs";
3
3
  import _defineProperty from "../_virtual/_@oxc-project_runtime@0.143.0/helpers/esm/defineProperty.mjs";
4
4
  import { uint8ArrayToBase64 } from "../provider/utility/requests.utility.mjs";
5
5
  import "../provider/index.mjs";
6
- import { encodeCharacterSet, generateEntropy, generateKeyPair, sortedJsonStringify, stringToUTF8 } from "./utility/utility.mjs";
6
+ import { encodeCharacterSet, generateEntropy, generateKeyPair, parseSignCoin, sortedJsonStringify, stringToUTF8 } from "./utility/utility.mjs";
7
7
  import "./utility/index.mjs";
8
8
  import { KeySigner } from "./key/key.mjs";
9
9
  import "./key/index.mjs";
@@ -143,8 +143,8 @@ var Wallet = class {
143
143
  account_number: accountNumber,
144
144
  sequence: accountSequence,
145
145
  fee: {
146
- gas_fee: tx.fee.gas_fee,
147
- gas_wanted: tx.fee.gas_wanted.toString(10)
146
+ amount: parseSignCoin(tx.fee.gas_fee),
147
+ gas: tx.fee.gas_wanted.toString(10)
148
148
  },
149
149
  msgs: decodeTxMessages(tx.messages),
150
150
  memo: tx.memo
@@ -1 +1 @@
1
- {"version":3,"file":"wallet.mjs","names":["Wallet"],"sources":["../../src/wallet/wallet.ts"],"sourcesContent":["import {\n Bip39, Secp256k1,\n} from \"@cosmjs/crypto\";\nimport {\n LedgerConnector,\n} from \"@cosmjs/ledger-amino\";\n\nimport {\n Any, PubKeySecp256k1, Tx, TxSignature,\n} from \"../proto/index.js\";\nimport {\n BroadcastTransactionMap,\n Provider,\n Status,\n uint8ArrayToBase64,\n} from \"../provider/index.js\";\nimport {\n KeySigner,\n} from \"./key/index.js\";\nimport {\n LedgerSigner,\n} from \"./ledger/index.js\";\nimport {\n Signer,\n} from \"./signer.js\";\nimport {\n AccountWalletOption,\n CreateWalletOptions,\n Secp256k1PubKeyType,\n TxSignPayload,\n} from \"./types/index.js\";\nimport {\n encodeCharacterSet,\n generateEntropy,\n generateKeyPair,\n stringToUTF8,\n} from \"./utility/index.js\";\nimport {\n sortedJsonStringify,\n} from \"./utility/index.js\";\nexport interface SignTransactionOptions {\n accountNumber?: string\n sequence?: string\n}\n\n/**\n * Wallet is a single account abstraction\n * that can interact with the blockchain\n */\nexport class Wallet {\n protected declare provider: Provider;\n protected declare signer: Signer;\n\n /**\n * Connects the wallet to the specified {@link Provider}\n * @param {Provider} provider the active {@link Provider}, if any\n */\n connect = (provider: Provider) => {\n this.provider = provider;\n };\n\n // Wallet initialization //\n\n /**\n * Generates a private key-based wallet, using a random seed\n * @param {AccountWalletOption} options the account options\n */\n static createRandom = async (\n options?: AccountWalletOption,\n ): Promise<Wallet> => {\n const {\n publicKey, privateKey,\n } = await generateKeyPair(\n Bip39.encode(generateEntropy()).toString(),\n 0,\n );\n\n // Initialize the wallet\n const wallet: Wallet = new Wallet();\n wallet.signer = new KeySigner(\n privateKey,\n Secp256k1.compressPubkey(publicKey),\n options?.addressPrefix,\n );\n\n return wallet;\n };\n\n /**\n * Generates a custom signer-based wallet\n * @param {Signer} signer the custom signer implementing the Signer interface\n * @param {CreateWalletOptions} options the wallet generation options\n */\n static fromSigner = async (signer: Signer): Promise<Wallet> => {\n // Initialize the wallet\n const wallet: Wallet = new Wallet();\n wallet.signer = signer;\n\n return wallet;\n };\n\n /**\n * Generates a bip39 mnemonic-based wallet\n * @param {string} mnemonic the bip39 mnemonic\n * @param {CreateWalletOptions} options the wallet generation options\n */\n static fromMnemonic = async (\n mnemonic: string,\n options?: CreateWalletOptions,\n ): Promise<Wallet> => {\n const {\n publicKey, privateKey,\n } = await generateKeyPair(\n mnemonic,\n options?.accountIndex,\n );\n\n // Initialize the wallet\n const wallet: Wallet = new Wallet();\n wallet.signer = new KeySigner(\n privateKey,\n Secp256k1.compressPubkey(publicKey),\n options?.addressPrefix,\n );\n\n return wallet;\n };\n\n /**\n * Generates a private key-based wallet\n * @param {string} privateKey the private key\n * @param {AccountWalletOption} options the account options\n */\n static fromPrivateKey = async (\n privateKey: Uint8Array,\n options?: AccountWalletOption,\n ): Promise<Wallet> => {\n // Derive the public key\n const {\n pubkey: publicKey,\n } = await Secp256k1.makeKeypair(privateKey);\n\n // Initialize the wallet\n const wallet: Wallet = new Wallet();\n wallet.signer = new KeySigner(\n privateKey,\n Secp256k1.compressPubkey(publicKey),\n options?.addressPrefix,\n );\n\n return wallet;\n };\n\n /**\n * Creates a Ledger-based wallet\n * @param {LedgerConnector} connector the Ledger device connector\n * @param {CreateWalletOptions} options the wallet generation options\n */\n static fromLedger = (\n connector: LedgerConnector,\n options?: CreateWalletOptions,\n ): Wallet => {\n const wallet: Wallet = new Wallet();\n\n wallet.signer = new LedgerSigner(\n connector,\n options?.accountIndex ?? 0,\n options?.addressPrefix,\n );\n\n return wallet;\n };\n\n // Account manipulation //\n\n /**\n * Fetches the address associated with the wallet\n */\n getAddress = (): Promise<string> => {\n return this.signer.getAddress();\n };\n\n /**\n * Fetches the account sequence for the wallet\n * @param {number} [height=latest] the block height\n */\n getAccountSequence = async (height?: number): Promise<number> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Get the address\n const address: string = await this.getAddress();\n\n return this.provider.getAccountSequence(address, height);\n };\n\n /**\n * Fetches the account number for the wallet. Errors out if the\n * account is not initialized\n * @param {number} [height=latest] the block height\n */\n getAccountNumber = async (height?: number): Promise<number> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Get the address\n const address: string = await this.getAddress();\n\n return this.provider.getAccountNumber(address, height);\n };\n\n /**\n * Fetches the account balance for the specific denomination\n * @param {string} [denomination=ugnot] the fund denomination\n */\n getBalance = async (denomination?: string): Promise<number> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Get the address\n const address: string = await this.getAddress();\n\n return this.provider.getBalance(\n address,\n denomination ? denomination : \"ugnot\",\n );\n };\n\n /**\n * Fetches the current (recommended) average gas price\n */\n getGasPrice = async (): Promise<number> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n return this.provider.getGasPrice();\n };\n\n /**\n * Estimates the gas limit for the transaction\n * @param {Tx} tx the transaction that needs estimating\n */\n estimateGas = async (tx: Tx): Promise<bigint> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n return this.provider.estimateGas(tx);\n };\n\n /**\n * Returns the connected provider, if any\n */\n getProvider = (): Provider => {\n return this.provider;\n };\n\n /**\n * Generates a transaction signature, and appends it to the transaction\n * @param {Tx} tx the transaction to be signed\n * @param {(messages: Any[]) => any[]} decodeTxMessages tx message decode callback\n * that should expand the concrete message fields into an object. Required because\n * the transaction sign bytes are generated using sorted JSON, which requires\n * encoded message values to be decoded for sorting\n */\n signTransaction = async (\n tx: Tx,\n decodeTxMessages: (messages: Any[]) => unknown[],\n opts?: SignTransactionOptions,\n ): Promise<Tx> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Make sure the tx fee is initialized\n if (!tx.fee) {\n throw new Error(\"invalid transaction fee provided\");\n }\n\n // Extract the relevant chain data\n const status: Status = await this.provider.getStatus();\n const chainID: string = status.node_info.network;\n\n // Extract the relevant account data\n let accountNumber = opts?.accountNumber;\n let accountSequence = opts?.sequence;\n if (accountNumber === undefined || accountSequence === undefined) {\n const address: string = await this.getAddress();\n const account = await this.provider.getAccount(address);\n if (accountNumber === undefined) {\n accountNumber = account.BaseAccount.account_number;\n }\n if (accountSequence === undefined) {\n accountSequence = account.BaseAccount.sequence;\n }\n }\n const publicKey: Uint8Array = await this.signer.getPublicKey();\n\n // Create the signature payload\n const signPayload: TxSignPayload = {\n chain_id: chainID,\n account_number: accountNumber,\n sequence: accountSequence,\n fee: {\n gas_fee: tx.fee.gas_fee,\n gas_wanted: tx.fee.gas_wanted.toString(10),\n },\n msgs: decodeTxMessages(tx.messages), // unrolled message objects\n memo: tx.memo,\n };\n\n // The TM2 node does signature verification using\n // a sorted JSON object, so the payload needs to be sorted\n // before signing\n const signBytes: Uint8Array = stringToUTF8(\n encodeCharacterSet(sortedJsonStringify(signPayload)),\n );\n\n // The public key needs to be encoded using protobuf for Amino\n const wrappedKey: PubKeySecp256k1 = {\n key: publicKey,\n };\n\n // Generate the signature\n const txSignature: TxSignature = {\n pub_key: {\n type_url: Secp256k1PubKeyType,\n value: PubKeySecp256k1.encode(wrappedKey).finish(),\n },\n signature: await this.getSigner().signData(signBytes),\n session_addr: \"\",\n };\n\n // Append the signature\n return {\n ...tx,\n signatures: [...tx.signatures, txSignature],\n };\n };\n\n /**\n * Encodes and sends the transaction. If the type of endpoint\n * is a broadcast commit, waits for the transaction to be committed to the chain.\n * The transaction needs to be signed beforehand.\n * Returns the transaction hash (base-64)\n * @param {Tx} tx the signed transaction\n * @param {BroadcastType} endpoint the transaction broadcast type (sync / commit)\n */\n async sendTransaction<K extends keyof BroadcastTransactionMap>(\n tx: Tx,\n endpoint: K,\n ): Promise<BroadcastTransactionMap[K][\"result\"]> {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Encode the transaction to base-64\n const encodedTx: string = uint8ArrayToBase64(Tx.encode(tx).finish());\n\n // Send the encoded transaction\n return this.provider.sendTransaction(encodedTx, endpoint);\n }\n\n /**\n * Returns the associated signer\n */\n getSigner = (): Signer => {\n return this.signer;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiDA,IAAa,SAAb,MAAoB;;;;;;;;GAQlB;IAAW,aAAuB;IAChC,KAAK,WAAW;GAClB;;;;;;;GAuHA;SAAoC;IAClC,OAAO,KAAK,OAAO,WAAW;GAChC;;;;;;;;GAMA;GAAqB,OAAO,WAAqC;IAC/D,IAAI,CAAC,KAAK,UACR,MAAM,IAAI,MAAM,wBAAwB;IAI1C,MAAM,UAAkB,MAAM,KAAK,WAAW;IAE9C,OAAO,KAAK,SAAS,mBAAmB,SAAS,MAAM;GACzD;;;;;;;;;GAOA;GAAmB,OAAO,WAAqC;IAC7D,IAAI,CAAC,KAAK,UACR,MAAM,IAAI,MAAM,wBAAwB;IAI1C,MAAM,UAAkB,MAAM,KAAK,WAAW;IAE9C,OAAO,K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S,aACX;CAEA,OAAO;AACT,CAAA;AAOO,gBAAA,QAAA,kBAAiB,OACtB,YACA,YACoB;CAEpB,MAAM,EACJ,QAAQ,cACN,MAAM,UAAU,YAAY,UAAU;CAG1C,MAAM,SAAiB,IAAIA,QAAO;CAClC,OAAO,SAAS,IAAI,UAClB,YACA,UAAU,eAAe,SAAS,GAClC,SAAS,aACX;CAEA,OAAO;AACT,CAAA;AAOO,gBAAA,QAAA,eACL,WACA,YACW;CACX,MAAM,SAAiB,IAAIA,QAAO;CAElC,OAAO,SAAS,IAAI,aAClB,WACA,SAAS,gBAAgB,GACzB,SAAS,aACX;CAEA,OAAO;AACT,CAAA"}
1
+ {"version":3,"file":"wallet.mjs","names":["Wallet"],"sources":["../../src/wallet/wallet.ts"],"sourcesContent":["import {\n Bip39, Secp256k1,\n} from \"@cosmjs/crypto\";\nimport {\n LedgerConnector,\n} from \"@cosmjs/ledger-amino\";\n\nimport {\n Any, PubKeySecp256k1, Tx, TxSignature,\n} from \"../proto/index.js\";\nimport {\n BroadcastTransactionMap,\n Provider,\n Status,\n uint8ArrayToBase64,\n} from \"../provider/index.js\";\nimport {\n KeySigner,\n} from \"./key/index.js\";\nimport {\n LedgerSigner,\n} from \"./ledger/index.js\";\nimport {\n Signer,\n} from \"./signer.js\";\nimport {\n AccountWalletOption,\n CreateWalletOptions,\n Secp256k1PubKeyType,\n TxSignPayload,\n} from \"./types/index.js\";\nimport {\n encodeCharacterSet,\n generateEntropy,\n generateKeyPair,\n parseSignCoin,\n sortedJsonStringify,\n stringToUTF8,\n} from \"./utility/index.js\";\nexport interface SignTransactionOptions {\n accountNumber?: string\n sequence?: string\n}\n\n/**\n * Wallet is a single account abstraction\n * that can interact with the blockchain\n */\nexport class Wallet {\n protected declare provider: Provider;\n protected declare signer: Signer;\n\n /**\n * Connects the wallet to the specified {@link Provider}\n * @param {Provider} provider the active {@link Provider}, if any\n */\n connect = (provider: Provider) => {\n this.provider = provider;\n };\n\n // Wallet initialization //\n\n /**\n * Generates a private key-based wallet, using a random seed\n * @param {AccountWalletOption} options the account options\n */\n static createRandom = async (\n options?: AccountWalletOption,\n ): Promise<Wallet> => {\n const {\n publicKey, privateKey,\n } = await generateKeyPair(\n Bip39.encode(generateEntropy()).toString(),\n 0,\n );\n\n // Initialize the wallet\n const wallet: Wallet = new Wallet();\n wallet.signer = new KeySigner(\n privateKey,\n Secp256k1.compressPubkey(publicKey),\n options?.addressPrefix,\n );\n\n return wallet;\n };\n\n /**\n * Generates a custom signer-based wallet\n * @param {Signer} signer the custom signer implementing the Signer interface\n * @param {CreateWalletOptions} options the wallet generation options\n */\n static fromSigner = async (signer: Signer): Promise<Wallet> => {\n // Initialize the wallet\n const wallet: Wallet = new Wallet();\n wallet.signer = signer;\n\n return wallet;\n };\n\n /**\n * Generates a bip39 mnemonic-based wallet\n * @param {string} mnemonic the bip39 mnemonic\n * @param {CreateWalletOptions} options the wallet generation options\n */\n static fromMnemonic = async (\n mnemonic: string,\n options?: CreateWalletOptions,\n ): Promise<Wallet> => {\n const {\n publicKey, privateKey,\n } = await generateKeyPair(\n mnemonic,\n options?.accountIndex,\n );\n\n // Initialize the wallet\n const wallet: Wallet = new Wallet();\n wallet.signer = new KeySigner(\n privateKey,\n Secp256k1.compressPubkey(publicKey),\n options?.addressPrefix,\n );\n\n return wallet;\n };\n\n /**\n * Generates a private key-based wallet\n * @param {string} privateKey the private key\n * @param {AccountWalletOption} options the account options\n */\n static fromPrivateKey = async (\n privateKey: Uint8Array,\n options?: AccountWalletOption,\n ): Promise<Wallet> => {\n // Derive the public key\n const {\n pubkey: publicKey,\n } = await Secp256k1.makeKeypair(privateKey);\n\n // Initialize the wallet\n const wallet: Wallet = new Wallet();\n wallet.signer = new KeySigner(\n privateKey,\n Secp256k1.compressPubkey(publicKey),\n options?.addressPrefix,\n );\n\n return wallet;\n };\n\n /**\n * Creates a Ledger-based wallet\n * @param {LedgerConnector} connector the Ledger device connector\n * @param {CreateWalletOptions} options the wallet generation options\n */\n static fromLedger = (\n connector: LedgerConnector,\n options?: CreateWalletOptions,\n ): Wallet => {\n const wallet: Wallet = new Wallet();\n\n wallet.signer = new LedgerSigner(\n connector,\n options?.accountIndex ?? 0,\n options?.addressPrefix,\n );\n\n return wallet;\n };\n\n // Account manipulation //\n\n /**\n * Fetches the address associated with the wallet\n */\n getAddress = (): Promise<string> => {\n return this.signer.getAddress();\n };\n\n /**\n * Fetches the account sequence for the wallet\n * @param {number} [height=latest] the block height\n */\n getAccountSequence = async (height?: number): Promise<number> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Get the address\n const address: string = await this.getAddress();\n\n return this.provider.getAccountSequence(address, height);\n };\n\n /**\n * Fetches the account number for the wallet. Errors out if the\n * account is not initialized\n * @param {number} [height=latest] the block height\n */\n getAccountNumber = async (height?: number): Promise<number> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Get the address\n const address: string = await this.getAddress();\n\n return this.provider.getAccountNumber(address, height);\n };\n\n /**\n * Fetches the account balance for the specific denomination\n * @param {string} [denomination=ugnot] the fund denomination\n */\n getBalance = async (denomination?: string): Promise<number> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Get the address\n const address: string = await this.getAddress();\n\n return this.provider.getBalance(\n address,\n denomination ? denomination : \"ugnot\",\n );\n };\n\n /**\n * Fetches the current (recommended) average gas price\n */\n getGasPrice = async (): Promise<number> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n return this.provider.getGasPrice();\n };\n\n /**\n * Estimates the gas limit for the transaction\n * @param {Tx} tx the transaction that needs estimating\n */\n estimateGas = async (tx: Tx): Promise<bigint> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n return this.provider.estimateGas(tx);\n };\n\n /**\n * Returns the connected provider, if any\n */\n getProvider = (): Provider => {\n return this.provider;\n };\n\n /**\n * Generates a transaction signature, and appends it to the transaction\n * @param {Tx} tx the transaction to be signed\n * @param {(messages: Any[]) => any[]} decodeTxMessages tx message decode callback\n * that should expand the concrete message fields into an object. Required because\n * the transaction sign bytes are generated using sorted JSON, which requires\n * encoded message values to be decoded for sorting\n */\n signTransaction = async (\n tx: Tx,\n decodeTxMessages: (messages: Any[]) => unknown[],\n opts?: SignTransactionOptions,\n ): Promise<Tx> => {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Make sure the tx fee is initialized\n if (!tx.fee) {\n throw new Error(\"invalid transaction fee provided\");\n }\n\n // Extract the relevant chain data\n const status: Status = await this.provider.getStatus();\n const chainID: string = status.node_info.network;\n\n // Extract the relevant account data\n let accountNumber = opts?.accountNumber;\n let accountSequence = opts?.sequence;\n if (accountNumber === undefined || accountSequence === undefined) {\n const address: string = await this.getAddress();\n const account = await this.provider.getAccount(address);\n if (accountNumber === undefined) {\n accountNumber = account.BaseAccount.account_number;\n }\n if (accountSequence === undefined) {\n accountSequence = account.BaseAccount.sequence;\n }\n }\n const publicKey: Uint8Array = await this.signer.getPublicKey();\n\n // Create the signature payload\n const signPayload: TxSignPayload = {\n chain_id: chainID,\n account_number: accountNumber,\n sequence: accountSequence,\n fee: {\n amount: parseSignCoin(tx.fee.gas_fee),\n gas: tx.fee.gas_wanted.toString(10),\n },\n msgs: decodeTxMessages(tx.messages), // unrolled message objects\n memo: tx.memo,\n };\n\n // The TM2 node does signature verification using\n // a sorted JSON object, so the payload needs to be sorted\n // before signing\n const signBytes: Uint8Array = stringToUTF8(\n encodeCharacterSet(sortedJsonStringify(signPayload)),\n );\n\n // The public key needs to be encoded using protobuf for Amino\n const wrappedKey: PubKeySecp256k1 = {\n key: publicKey,\n };\n\n // Generate the signature\n const txSignature: TxSignature = {\n pub_key: {\n type_url: Secp256k1PubKeyType,\n value: PubKeySecp256k1.encode(wrappedKey).finish(),\n },\n signature: await this.getSigner().signData(signBytes),\n session_addr: \"\",\n };\n\n // Append the signature\n return {\n ...tx,\n signatures: [...tx.signatures, txSignature],\n };\n };\n\n /**\n * Encodes and sends the transaction. If the type of endpoint\n * is a broadcast commit, waits for the transaction to be committed to the chain.\n * The transaction needs to be signed beforehand.\n * Returns the transaction hash (base-64)\n * @param {Tx} tx the signed transaction\n * @param {BroadcastType} endpoint the transaction broadcast type (sync / commit)\n */\n async sendTransaction<K extends keyof BroadcastTransactionMap>(\n tx: Tx,\n endpoint: K,\n ): Promise<BroadcastTransactionMap[K][\"result\"]> {\n if (!this.provider) {\n throw new Error(\"provider not connected\");\n }\n\n // Encode the transaction to base-64\n const encodedTx: string = uint8ArrayToBase64(Tx.encode(tx).finish());\n\n // Send the encoded transaction\n return this.provider.sendTransaction(encodedTx, endpoint);\n }\n\n /**\n * Returns the associated signer\n */\n getSigner = (): Signer => {\n return this.signer;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgDA,IAAa,SAAb,MAAoB;;;;;;;;GAQlB;IAAW,aAAuB;IAChC,KAAK,WAAW;GAClB;;;;;;;GAuHA;SAAoC;IAClC,OAAO,KAAK,OAAO,WAAW;GAChC;;;;;;;;GAMA;GAAqB,OAAO,WAAqC;IAC/D,IAAI,CAAC,KAAK,UACR,MAAM,IAAI,MAAM,wBAAwB;IAI1C,MAAM,UAAkB,MAAM,KAAK,WAAW;IAE9C,OAAO,KAAK,SAAS,mBAAmB,SAAS,MAAM;GACzD;;;;;;;;;GAOA;GAAmB,OAAO,WAAqC;IAC7D,IAAI,CAAC,KAAK,UACR,MAAM,IAAI,MAAM,wBAAwB;IAI1C,MAAM,UAAkB,MAAM,KAAK,WAAW;IAE9C,OAAO,KAAK,SAAS,iBAAiB,SAAS,MAAM;GACvD;;;;;;;;GAMA;GAAa,OAAO,iBAA2C;IAC7D,IAAI,CAAC,KAAK,UACR,MAAM,IAAI,MAAM,wBAAwB;IAI1C,MAAM,UAAkB,MAAM,KAAK,WAAW;IAE9C,OAAO,KAAK,SAAS,WACnB,SACA,eAAe,eAAe,OAChC;GACF;;;;;;;GAKA;GAAc,YAA6B;IACzC,IAAI,CAAC,KAAK,UACR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,QAAA,eACL,WACA,YACW;CACX,MAAM,SAAiB,IAAIA,QAAO;CAElC,OAAO,SAAS,IAAI,aAClB,WACA,SAAS,gBAAgB,GACzB,SAAS,aACX;CAEA,OAAO;AACT,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gnolang/tm2-js-client",
3
- "version": "2.1.0",
3
+ "version": "3.0.0",
4
4
  "description": "Tendermint2 JS / TS Client",
5
5
  "repository": {
6
6
  "type": "git",