@gnolang/tm2-js-client 2.0.5 → 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.
- package/CHANGELOG.md +12 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/proto/tm2/tx.cjs +11 -2
- package/dist/proto/tm2/tx.cjs.map +1 -1
- package/dist/proto/tm2/tx.d.cts +2 -0
- package/dist/proto/tm2/tx.d.cts.map +1 -1
- package/dist/proto/tm2/tx.d.mts +2 -0
- package/dist/proto/tm2/tx.d.mts.map +1 -1
- package/dist/proto/tm2/tx.mjs +11 -2
- package/dist/proto/tm2/tx.mjs.map +1 -1
- package/dist/wallet/index.cjs +1 -0
- package/dist/wallet/index.d.cts +3 -3
- package/dist/wallet/index.d.mts +3 -3
- package/dist/wallet/index.mjs +2 -2
- package/dist/wallet/types/index.d.cts +2 -2
- package/dist/wallet/types/index.d.mts +2 -2
- package/dist/wallet/types/sign.cjs.map +1 -1
- package/dist/wallet/types/sign.d.cts +10 -3
- package/dist/wallet/types/sign.d.cts.map +1 -1
- package/dist/wallet/types/sign.d.mts +10 -3
- package/dist/wallet/types/sign.d.mts.map +1 -1
- package/dist/wallet/types/sign.mjs.map +1 -1
- package/dist/wallet/utility/index.cjs +1 -0
- package/dist/wallet/utility/index.d.cts +2 -2
- package/dist/wallet/utility/index.d.mts +2 -2
- package/dist/wallet/utility/index.mjs +2 -2
- package/dist/wallet/utility/utility.cjs +24 -0
- package/dist/wallet/utility/utility.cjs.map +1 -1
- package/dist/wallet/utility/utility.d.cts +11 -1
- package/dist/wallet/utility/utility.d.cts.map +1 -1
- package/dist/wallet/utility/utility.d.mts +11 -1
- package/dist/wallet/utility/utility.d.mts.map +1 -1
- package/dist/wallet/utility/utility.mjs +24 -1
- package/dist/wallet/utility/utility.mjs.map +1 -1
- package/dist/wallet/wallet.cjs +4 -3
- package/dist/wallet/wallet.cjs.map +1 -1
- package/dist/wallet/wallet.d.cts.map +1 -1
- package/dist/wallet/wallet.d.mts.map +1 -1
- package/dist/wallet/wallet.mjs +5 -4
- package/dist/wallet/wallet.mjs.map +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
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
|
+
|
|
9
|
+
## 2.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#284](https://github.com/gnolang/tm2-js-client/pull/284) [`e518a06`](https://github.com/gnolang/tm2-js-client/commit/e518a06751eeb4246772b8e6613fe34731c3f50f) Thanks [@jinoosss](https://github.com/jinoosss)! - Sync `tm2/tx.proto` with upstream `std.Signature`: add the `session_addr` field (introduced by gno account sessions) to `TxSignature`, and regenerate the protobuf bindings. Master-key signatures keep an empty `session_addr`, so the wire encoding is unchanged for existing transactions.
|
|
14
|
+
|
|
3
15
|
## 2.0.5
|
|
4
16
|
|
|
5
17
|
### Patch 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 };
|
package/dist/proto/tm2/tx.cjs
CHANGED
|
@@ -136,13 +136,15 @@ const TxFee = {
|
|
|
136
136
|
function createBaseTxSignature() {
|
|
137
137
|
return {
|
|
138
138
|
pub_key: void 0,
|
|
139
|
-
signature: /* @__PURE__ */ new Uint8Array(0)
|
|
139
|
+
signature: /* @__PURE__ */ new Uint8Array(0),
|
|
140
|
+
session_addr: ""
|
|
140
141
|
};
|
|
141
142
|
}
|
|
142
143
|
const TxSignature = {
|
|
143
144
|
encode(message, writer = new _bufbuild_protobuf_wire.BinaryWriter()) {
|
|
144
145
|
if (message.pub_key !== void 0) require_any.Any.encode(message.pub_key, writer.uint32(10).fork()).join();
|
|
145
146
|
if (message.signature.length !== 0) writer.uint32(18).bytes(message.signature);
|
|
147
|
+
if (message.session_addr !== "") writer.uint32(26).string(message.session_addr);
|
|
146
148
|
return writer;
|
|
147
149
|
},
|
|
148
150
|
decode(input, length) {
|
|
@@ -160,6 +162,10 @@ const TxSignature = {
|
|
|
160
162
|
if (tag !== 18) break;
|
|
161
163
|
message.signature = reader.bytes();
|
|
162
164
|
continue;
|
|
165
|
+
case 3:
|
|
166
|
+
if (tag !== 26) break;
|
|
167
|
+
message.session_addr = reader.string();
|
|
168
|
+
continue;
|
|
163
169
|
}
|
|
164
170
|
if ((tag & 7) === 4 || tag === 0) break;
|
|
165
171
|
reader.skip(tag & 7);
|
|
@@ -169,13 +175,15 @@ const TxSignature = {
|
|
|
169
175
|
fromJSON(object) {
|
|
170
176
|
return {
|
|
171
177
|
pub_key: isSet(object.pub_key) ? require_any.Any.fromJSON(object.pub_key) : void 0,
|
|
172
|
-
signature: isSet(object.signature) ? bytesFromBase64(object.signature) : /* @__PURE__ */ new Uint8Array(0)
|
|
178
|
+
signature: isSet(object.signature) ? bytesFromBase64(object.signature) : /* @__PURE__ */ new Uint8Array(0),
|
|
179
|
+
session_addr: isSet(object.session_addr) ? globalThis.String(object.session_addr) : ""
|
|
173
180
|
};
|
|
174
181
|
},
|
|
175
182
|
toJSON(message) {
|
|
176
183
|
const obj = {};
|
|
177
184
|
if (message.pub_key !== void 0) obj.pub_key = require_any.Any.toJSON(message.pub_key);
|
|
178
185
|
if (message.signature !== void 0) obj.signature = base64FromBytes(message.signature);
|
|
186
|
+
if (message.session_addr !== void 0) obj.session_addr = message.session_addr;
|
|
179
187
|
return obj;
|
|
180
188
|
},
|
|
181
189
|
create(base) {
|
|
@@ -185,6 +193,7 @@ const TxSignature = {
|
|
|
185
193
|
const message = createBaseTxSignature();
|
|
186
194
|
message.pub_key = object.pub_key !== void 0 && object.pub_key !== null ? require_any.Any.fromPartial(object.pub_key) : void 0;
|
|
187
195
|
message.signature = object.signature ?? /* @__PURE__ */ new Uint8Array(0);
|
|
196
|
+
message.session_addr = object.session_addr ?? "";
|
|
188
197
|
return message;
|
|
189
198
|
}
|
|
190
199
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx.cjs","names":["BinaryWriter","BinaryReader","Any"],"sources":["../../../src/proto/tm2/tx.ts"],"sourcesContent":["// Code generated by protoc-gen-ts_proto. DO NOT EDIT.\n// versions:\n// protoc-gen-ts_proto v2.11.6\n// protoc v6.33.4\n// source: tm2/tx.proto\n\n/* eslint-disable */\nimport { BinaryReader, BinaryWriter } from \"@bufbuild/protobuf/wire\";\nimport { Any } from \"../google/protobuf/any.js\";\n\nexport const protobufPackage = \"tm2.tx\";\n\nexport interface Tx {\n /** specific message types */\n messages: Any[];\n /** transaction costs (fee) */\n fee?:\n | TxFee\n | undefined;\n /** the signatures for the transaction */\n signatures: TxSignature[];\n /** memo attached to the transaction */\n memo: string;\n}\n\nexport interface TxFee {\n /** gas limit */\n gas_wanted: bigint;\n /** gas fee details (<value><denomination>) */\n gas_fee: string;\n}\n\nexport interface TxSignature {\n /** public key associated with the signature */\n pub_key?:\n | Any\n | undefined;\n /** the signature */\n signature: Uint8Array;\n}\n\nexport interface PubKeySecp256k1 {\n key: Uint8Array;\n}\n\nfunction createBaseTx(): Tx {\n return { messages: [], fee: undefined, signatures: [], memo: \"\" };\n}\n\nexport const Tx: MessageFns<Tx> = {\n encode(message: Tx, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n for (const v of message.messages) {\n Any.encode(v!, writer.uint32(10).fork()).join();\n }\n if (message.fee !== undefined) {\n TxFee.encode(message.fee, writer.uint32(18).fork()).join();\n }\n for (const v of message.signatures) {\n TxSignature.encode(v!, writer.uint32(26).fork()).join();\n }\n if (message.memo !== \"\") {\n writer.uint32(34).string(message.memo);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): Tx {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseTx();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.messages.push(Any.decode(reader, reader.uint32()));\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.fee = TxFee.decode(reader, reader.uint32());\n continue;\n }\n case 3: {\n if (tag !== 26) {\n break;\n }\n\n message.signatures.push(TxSignature.decode(reader, reader.uint32()));\n continue;\n }\n case 4: {\n if (tag !== 34) {\n break;\n }\n\n message.memo = reader.string();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): Tx {\n return {\n messages: globalThis.Array.isArray(object?.messages) ? object.messages.map((e: any) => Any.fromJSON(e)) : [],\n fee: isSet(object.fee) ? TxFee.fromJSON(object.fee) : undefined,\n signatures: globalThis.Array.isArray(object?.signatures)\n ? object.signatures.map((e: any) => TxSignature.fromJSON(e))\n : [],\n memo: isSet(object.memo) ? globalThis.String(object.memo) : \"\",\n };\n },\n\n toJSON(message: Tx): unknown {\n const obj: any = {};\n if (message.messages?.length) {\n obj.messages = message.messages.map((e) => Any.toJSON(e));\n }\n if (message.fee !== undefined) {\n obj.fee = TxFee.toJSON(message.fee);\n }\n if (message.signatures?.length) {\n obj.signatures = message.signatures.map((e) => TxSignature.toJSON(e));\n }\n if (message.memo !== undefined) {\n obj.memo = message.memo;\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<Tx>, I>>(base?: I): Tx {\n return Tx.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<Tx>, I>>(object: I): Tx {\n const message = createBaseTx();\n message.messages = object.messages?.map((e) => Any.fromPartial(e)) || [];\n message.fee = (object.fee !== undefined && object.fee !== null) ? TxFee.fromPartial(object.fee) : undefined;\n message.signatures = object.signatures?.map((e) => TxSignature.fromPartial(e)) || [];\n message.memo = object.memo ?? \"\";\n return message;\n },\n};\n\nfunction createBaseTxFee(): TxFee {\n return { gas_wanted: 0n, gas_fee: \"\" };\n}\n\nexport const TxFee: MessageFns<TxFee> = {\n encode(message: TxFee, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.gas_wanted !== 0n) {\n if (BigInt.asIntN(64, message.gas_wanted) !== message.gas_wanted) {\n throw new globalThis.Error(\"value provided for field message.gas_wanted of type sint64 too large\");\n }\n writer.uint32(8).sint64(message.gas_wanted);\n }\n if (message.gas_fee !== \"\") {\n writer.uint32(18).string(message.gas_fee);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): TxFee {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseTxFee();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 8) {\n break;\n }\n\n message.gas_wanted = reader.sint64() as bigint;\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.gas_fee = reader.string();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): TxFee {\n return {\n gas_wanted: isSet(object.gas_wanted) ? BigInt(object.gas_wanted) : 0n,\n gas_fee: isSet(object.gas_fee) ? globalThis.String(object.gas_fee) : \"\",\n };\n },\n\n toJSON(message: TxFee): unknown {\n const obj: any = {};\n if (message.gas_wanted !== undefined) {\n obj.gas_wanted = message.gas_wanted.toString();\n }\n if (message.gas_fee !== undefined) {\n obj.gas_fee = message.gas_fee;\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<TxFee>, I>>(base?: I): TxFee {\n return TxFee.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<TxFee>, I>>(object: I): TxFee {\n const message = createBaseTxFee();\n message.gas_wanted = object.gas_wanted ?? 0n;\n message.gas_fee = object.gas_fee ?? \"\";\n return message;\n },\n};\n\nfunction createBaseTxSignature(): TxSignature {\n return { pub_key: undefined, signature: new Uint8Array(0) };\n}\n\nexport const TxSignature: MessageFns<TxSignature> = {\n encode(message: TxSignature, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.pub_key !== undefined) {\n Any.encode(message.pub_key, writer.uint32(10).fork()).join();\n }\n if (message.signature.length !== 0) {\n writer.uint32(18).bytes(message.signature);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): TxSignature {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseTxSignature();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.pub_key = Any.decode(reader, reader.uint32());\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.signature = reader.bytes();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): TxSignature {\n return {\n pub_key: isSet(object.pub_key) ? Any.fromJSON(object.pub_key) : undefined,\n signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(0),\n };\n },\n\n toJSON(message: TxSignature): unknown {\n const obj: any = {};\n if (message.pub_key !== undefined) {\n obj.pub_key = Any.toJSON(message.pub_key);\n }\n if (message.signature !== undefined) {\n obj.signature = base64FromBytes(message.signature);\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<TxSignature>, I>>(base?: I): TxSignature {\n return TxSignature.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<TxSignature>, I>>(object: I): TxSignature {\n const message = createBaseTxSignature();\n message.pub_key = (object.pub_key !== undefined && object.pub_key !== null)\n ? Any.fromPartial(object.pub_key)\n : undefined;\n message.signature = object.signature ?? new Uint8Array(0);\n return message;\n },\n};\n\nfunction createBasePubKeySecp256k1(): PubKeySecp256k1 {\n return { key: new Uint8Array(0) };\n}\n\nexport const PubKeySecp256k1: MessageFns<PubKeySecp256k1> = {\n encode(message: PubKeySecp256k1, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.key.length !== 0) {\n writer.uint32(10).bytes(message.key);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): PubKeySecp256k1 {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBasePubKeySecp256k1();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.key = reader.bytes();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): PubKeySecp256k1 {\n return { key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(0) };\n },\n\n toJSON(message: PubKeySecp256k1): unknown {\n const obj: any = {};\n if (message.key !== undefined) {\n obj.key = base64FromBytes(message.key);\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<PubKeySecp256k1>, I>>(base?: I): PubKeySecp256k1 {\n return PubKeySecp256k1.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<PubKeySecp256k1>, I>>(object: I): PubKeySecp256k1 {\n const message = createBasePubKeySecp256k1();\n message.key = object.key ?? new Uint8Array(0);\n return message;\n },\n};\n\nfunction bytesFromBase64(b64: string): Uint8Array {\n if ((globalThis as any).Buffer) {\n return Uint8Array.from((globalThis as any).Buffer.from(b64, \"base64\"));\n } else {\n const bin = globalThis.atob(b64);\n const arr = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; ++i) {\n arr[i] = bin.charCodeAt(i);\n }\n return arr;\n }\n}\n\nfunction base64FromBytes(arr: Uint8Array): string {\n if ((globalThis as any).Buffer) {\n return (globalThis as any).Buffer.from(arr).toString(\"base64\");\n } else {\n const bin: string[] = [];\n arr.forEach((byte) => {\n bin.push(globalThis.String.fromCharCode(byte));\n });\n return globalThis.btoa(bin.join(\"\"));\n }\n}\n\ntype Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;\n\nexport type DeepPartial<T> = T extends Builtin ? T\n : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>\n : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>\n : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }\n : Partial<T>;\n\ntype KeysOfUnion<T> = T extends T ? keyof T : never;\nexport type Exact<P, I extends P> = P extends Builtin ? P\n : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };\n\nfunction isSet(value: any): boolean {\n return value !== null && value !== undefined;\n}\n\nexport interface MessageFns<T> {\n encode(message: T, writer?: BinaryWriter): BinaryWriter;\n decode(input: BinaryReader | Uint8Array, length?: number): T;\n fromJSON(object: any): T;\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WAAmB,QACtB,OAAQ,WAAmB,OAAO,KAAK,GAAG,CAAC,CAAC,SAAS,QAAQ;MACxD;EACL,MAAM,MAAgB,CAAC;EACvB,IAAI,SAAS,SAAS;GACpB,IAAI,KAAK,WAAW,OAAO,aAAa,IAAI,CAAC;EAC/C,CAAC;EACD,OAAO,WAAW,KAAK,IAAI,KAAK,EAAE,CAAC;CACrC;AACF;AAcA,SAAS,MAAM,OAAqB;CAClC,OAAO,UAAU,QAAQ,UAAU;AACrC"}
|
|
1
|
+
{"version":3,"file":"tx.cjs","names":["BinaryWriter","BinaryReader","Any"],"sources":["../../../src/proto/tm2/tx.ts"],"sourcesContent":["// Code generated by protoc-gen-ts_proto. DO NOT EDIT.\n// versions:\n// protoc-gen-ts_proto v2.11.6\n// protoc v6.33.4\n// source: tm2/tx.proto\n\n/* eslint-disable */\nimport { BinaryReader, BinaryWriter } from \"@bufbuild/protobuf/wire\";\nimport { Any } from \"../google/protobuf/any.js\";\n\nexport const protobufPackage = \"tm2.tx\";\n\nexport interface Tx {\n /** specific message types */\n messages: Any[];\n /** transaction costs (fee) */\n fee?:\n | TxFee\n | undefined;\n /** the signatures for the transaction */\n signatures: TxSignature[];\n /** memo attached to the transaction */\n memo: string;\n}\n\nexport interface TxFee {\n /** gas limit */\n gas_wanted: bigint;\n /** gas fee details (<value><denomination>) */\n gas_fee: string;\n}\n\nexport interface TxSignature {\n /** public key associated with the signature */\n pub_key?:\n | Any\n | undefined;\n /** the signature */\n signature: Uint8Array;\n /** session account address (empty for master-key signatures) */\n session_addr: string;\n}\n\nexport interface PubKeySecp256k1 {\n key: Uint8Array;\n}\n\nfunction createBaseTx(): Tx {\n return { messages: [], fee: undefined, signatures: [], memo: \"\" };\n}\n\nexport const Tx: MessageFns<Tx> = {\n encode(message: Tx, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n for (const v of message.messages) {\n Any.encode(v!, writer.uint32(10).fork()).join();\n }\n if (message.fee !== undefined) {\n TxFee.encode(message.fee, writer.uint32(18).fork()).join();\n }\n for (const v of message.signatures) {\n TxSignature.encode(v!, writer.uint32(26).fork()).join();\n }\n if (message.memo !== \"\") {\n writer.uint32(34).string(message.memo);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): Tx {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseTx();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.messages.push(Any.decode(reader, reader.uint32()));\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.fee = TxFee.decode(reader, reader.uint32());\n continue;\n }\n case 3: {\n if (tag !== 26) {\n break;\n }\n\n message.signatures.push(TxSignature.decode(reader, reader.uint32()));\n continue;\n }\n case 4: {\n if (tag !== 34) {\n break;\n }\n\n message.memo = reader.string();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): Tx {\n return {\n messages: globalThis.Array.isArray(object?.messages) ? object.messages.map((e: any) => Any.fromJSON(e)) : [],\n fee: isSet(object.fee) ? TxFee.fromJSON(object.fee) : undefined,\n signatures: globalThis.Array.isArray(object?.signatures)\n ? object.signatures.map((e: any) => TxSignature.fromJSON(e))\n : [],\n memo: isSet(object.memo) ? globalThis.String(object.memo) : \"\",\n };\n },\n\n toJSON(message: Tx): unknown {\n const obj: any = {};\n if (message.messages?.length) {\n obj.messages = message.messages.map((e) => Any.toJSON(e));\n }\n if (message.fee !== undefined) {\n obj.fee = TxFee.toJSON(message.fee);\n }\n if (message.signatures?.length) {\n obj.signatures = message.signatures.map((e) => TxSignature.toJSON(e));\n }\n if (message.memo !== undefined) {\n obj.memo = message.memo;\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<Tx>, I>>(base?: I): Tx {\n return Tx.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<Tx>, I>>(object: I): Tx {\n const message = createBaseTx();\n message.messages = object.messages?.map((e) => Any.fromPartial(e)) || [];\n message.fee = (object.fee !== undefined && object.fee !== null) ? TxFee.fromPartial(object.fee) : undefined;\n message.signatures = object.signatures?.map((e) => TxSignature.fromPartial(e)) || [];\n message.memo = object.memo ?? \"\";\n return message;\n },\n};\n\nfunction createBaseTxFee(): TxFee {\n return { gas_wanted: 0n, gas_fee: \"\" };\n}\n\nexport const TxFee: MessageFns<TxFee> = {\n encode(message: TxFee, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.gas_wanted !== 0n) {\n if (BigInt.asIntN(64, message.gas_wanted) !== message.gas_wanted) {\n throw new globalThis.Error(\"value provided for field message.gas_wanted of type sint64 too large\");\n }\n writer.uint32(8).sint64(message.gas_wanted);\n }\n if (message.gas_fee !== \"\") {\n writer.uint32(18).string(message.gas_fee);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): TxFee {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseTxFee();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 8) {\n break;\n }\n\n message.gas_wanted = reader.sint64() as bigint;\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.gas_fee = reader.string();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): TxFee {\n return {\n gas_wanted: isSet(object.gas_wanted) ? BigInt(object.gas_wanted) : 0n,\n gas_fee: isSet(object.gas_fee) ? globalThis.String(object.gas_fee) : \"\",\n };\n },\n\n toJSON(message: TxFee): unknown {\n const obj: any = {};\n if (message.gas_wanted !== undefined) {\n obj.gas_wanted = message.gas_wanted.toString();\n }\n if (message.gas_fee !== undefined) {\n obj.gas_fee = message.gas_fee;\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<TxFee>, I>>(base?: I): TxFee {\n return TxFee.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<TxFee>, I>>(object: I): TxFee {\n const message = createBaseTxFee();\n message.gas_wanted = object.gas_wanted ?? 0n;\n message.gas_fee = object.gas_fee ?? \"\";\n return message;\n },\n};\n\nfunction createBaseTxSignature(): TxSignature {\n return { pub_key: undefined, signature: new Uint8Array(0), session_addr: \"\" };\n}\n\nexport const TxSignature: MessageFns<TxSignature> = {\n encode(message: TxSignature, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.pub_key !== undefined) {\n Any.encode(message.pub_key, writer.uint32(10).fork()).join();\n }\n if (message.signature.length !== 0) {\n writer.uint32(18).bytes(message.signature);\n }\n if (message.session_addr !== \"\") {\n writer.uint32(26).string(message.session_addr);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): TxSignature {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseTxSignature();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.pub_key = Any.decode(reader, reader.uint32());\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.signature = reader.bytes();\n continue;\n }\n case 3: {\n if (tag !== 26) {\n break;\n }\n\n message.session_addr = reader.string();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): TxSignature {\n return {\n pub_key: isSet(object.pub_key) ? Any.fromJSON(object.pub_key) : undefined,\n signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(0),\n session_addr: isSet(object.session_addr) ? globalThis.String(object.session_addr) : \"\",\n };\n },\n\n toJSON(message: TxSignature): unknown {\n const obj: any = {};\n if (message.pub_key !== undefined) {\n obj.pub_key = Any.toJSON(message.pub_key);\n }\n if (message.signature !== undefined) {\n obj.signature = base64FromBytes(message.signature);\n }\n if (message.session_addr !== undefined) {\n obj.session_addr = message.session_addr;\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<TxSignature>, I>>(base?: I): TxSignature {\n return TxSignature.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<TxSignature>, I>>(object: I): TxSignature {\n const message = createBaseTxSignature();\n message.pub_key = (object.pub_key !== undefined && object.pub_key !== null)\n ? Any.fromPartial(object.pub_key)\n : undefined;\n message.signature = object.signature ?? new Uint8Array(0);\n message.session_addr = object.session_addr ?? \"\";\n return message;\n },\n};\n\nfunction createBasePubKeySecp256k1(): PubKeySecp256k1 {\n return { key: new Uint8Array(0) };\n}\n\nexport const PubKeySecp256k1: MessageFns<PubKeySecp256k1> = {\n encode(message: PubKeySecp256k1, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.key.length !== 0) {\n writer.uint32(10).bytes(message.key);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): PubKeySecp256k1 {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBasePubKeySecp256k1();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.key = reader.bytes();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): PubKeySecp256k1 {\n return { key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(0) };\n },\n\n toJSON(message: PubKeySecp256k1): unknown {\n const obj: any = {};\n if (message.key !== undefined) {\n obj.key = base64FromBytes(message.key);\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<PubKeySecp256k1>, I>>(base?: I): PubKeySecp256k1 {\n return PubKeySecp256k1.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<PubKeySecp256k1>, I>>(object: I): PubKeySecp256k1 {\n const message = createBasePubKeySecp256k1();\n message.key = object.key ?? new Uint8Array(0);\n return message;\n },\n};\n\nfunction bytesFromBase64(b64: string): Uint8Array {\n if ((globalThis as any).Buffer) {\n return Uint8Array.from((globalThis as any).Buffer.from(b64, \"base64\"));\n } else {\n const bin = globalThis.atob(b64);\n const arr = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; ++i) {\n arr[i] = bin.charCodeAt(i);\n }\n return arr;\n }\n}\n\nfunction base64FromBytes(arr: Uint8Array): string {\n if ((globalThis as any).Buffer) {\n return (globalThis as any).Buffer.from(arr).toString(\"base64\");\n } else {\n const bin: string[] = [];\n arr.forEach((byte) => {\n bin.push(globalThis.String.fromCharCode(byte));\n });\n return globalThis.btoa(bin.join(\"\"));\n }\n}\n\ntype Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;\n\nexport type DeepPartial<T> = T extends Builtin ? T\n : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>\n : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>\n : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }\n : Partial<T>;\n\ntype KeysOfUnion<T> = T extends T ? keyof T : never;\nexport type Exact<P, I extends P> = P extends Builtin ? P\n : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };\n\nfunction isSet(value: any): boolean {\n return value !== null && value !== undefined;\n}\n\nexport interface MessageFns<T> {\n encode(message: T, writer?: BinaryWriter): BinaryWriter;\n decode(input: BinaryReader | Uint8Array, length?: number): T;\n fromJSON(object: any): T;\n toJSON(message: T): unknown;\n create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;\n fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;\n}\n"],"mappings":";;;AAUA,MAAa,kBAAkB;AAqC/B,S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,IAAI,WAAW,IAAI,MAAM;EACrC,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,QAAQ,EAAE,GAChC,IAAI,KAAK,IAAI,WAAW,CAAC;EAE3B,OAAO;CACT;AACF;AAEA,SAAS,gBAAgB,KAAyB;CAChD,IAAK,WAAmB,QACtB,OAAQ,WAAmB,OAAO,KAAK,GAAG,CAAC,CAAC,SAAS,QAAQ;MACxD;EACL,MAAM,MAAgB,CAAC;EACvB,IAAI,SAAS,SAAS;GACpB,IAAI,KAAK,WAAW,OAAO,aAAa,IAAI,CAAC;EAC/C,CAAC;EACD,OAAO,WAAW,KAAK,IAAI,KAAK,EAAE,CAAC;CACrC;AACF;AAcA,SAAS,MAAM,OAAqB;CAClC,OAAO,UAAU,QAAQ,UAAU;AACrC"}
|
package/dist/proto/tm2/tx.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx.d.cts","names":[],"sources":["../../../src/proto/tm2/tx.ts"],"mappings":";;;cAUa;UAEI;;EAEf,UAAU;;EAEV,MACI;;EAGJ,YAAY;;EAEZ;;UAGe;;EAEf;;EAEA;;UAGe;;EAEf,UACI;;EAGJ,WAAW;;
|
|
1
|
+
{"version":3,"file":"tx.d.cts","names":[],"sources":["../../../src/proto/tm2/tx.ts"],"mappings":";;;cAUa;UAEI;;EAEf,UAAU;;EAEV,MACI;;EAGJ,YAAY;;EAEZ;;UAGe;;EAEf;;EAEA;;UAGe;;EAEf,UACI;;EAGJ,WAAW;;EAEX;;UAGe;EACf,KAAK;;cAOM,IAAI,WAAW;cA8Gf,OAAO,WAAW;cA+ElB,aAAa,WAAW;cA8FxB,iBAAiB,WAAW;KA+EpC,UAAU,OAAO,WAAW;KAErB,YAAY,KAAK,UAAU,UAAU,IAC7C,UAAU,WAAW,YAAY,KAAK,WAAW,MAAM,YAAY,MACnE,UAAU,oBAAoB,KAAK,cAAc,YAAY,MAC7D,kBAAkB,WAAW,KAAK,YAAY,EAAE,SAChD,QAAQ;KAEP,YAAY,KAAK,UAAU,UAAU;KAC9B,MAAM,GAAG,UAAU,KAAK,UAAU,UAAU,IACpD,OAAO,WAAW,IAAI,MAAM,EAAE,IAAI,EAAE,YAAW,KAAK,cAAc,GAAG,YAAY;UAMpE,WAAW;EAC1B,OAAO,SAAS,GAAG,SAAS,eAAe;EAC3C,OAAO,OAAO,eAAe,YAAY,kBAAkB;EAC3D,SAAS,cAAc;EACvB,OAAO,SAAS;EAChB,OAAO,UAAU,MAAM,YAAY,IAAI,IAAI,OAAO,IAAI;EACtD,YAAY,UAAU,MAAM,YAAY,IAAI,IAAI,QAAQ,IAAI"}
|
package/dist/proto/tm2/tx.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx.d.mts","names":[],"sources":["../../../src/proto/tm2/tx.ts"],"mappings":";;;cAUa;UAEI;;EAEf,UAAU;;EAEV,MACI;;EAGJ,YAAY;;EAEZ;;UAGe;;EAEf;;EAEA;;UAGe;;EAEf,UACI;;EAGJ,WAAW;;
|
|
1
|
+
{"version":3,"file":"tx.d.mts","names":[],"sources":["../../../src/proto/tm2/tx.ts"],"mappings":";;;cAUa;UAEI;;EAEf,UAAU;;EAEV,MACI;;EAGJ,YAAY;;EAEZ;;UAGe;;EAEf;;EAEA;;UAGe;;EAEf,UACI;;EAGJ,WAAW;;EAEX;;UAGe;EACf,KAAK;;cAOM,IAAI,WAAW;cA8Gf,OAAO,WAAW;cA+ElB,aAAa,WAAW;cA8FxB,iBAAiB,WAAW;KA+EpC,UAAU,OAAO,WAAW;KAErB,YAAY,KAAK,UAAU,UAAU,IAC7C,UAAU,WAAW,YAAY,KAAK,WAAW,MAAM,YAAY,MACnE,UAAU,oBAAoB,KAAK,cAAc,YAAY,MAC7D,kBAAkB,WAAW,KAAK,YAAY,EAAE,SAChD,QAAQ;KAEP,YAAY,KAAK,UAAU,UAAU;KAC9B,MAAM,GAAG,UAAU,KAAK,UAAU,UAAU,IACpD,OAAO,WAAW,IAAI,MAAM,EAAE,IAAI,EAAE,YAAW,KAAK,cAAc,GAAG,YAAY;UAMpE,WAAW;EAC1B,OAAO,SAAS,GAAG,SAAS,eAAe;EAC3C,OAAO,OAAO,eAAe,YAAY,kBAAkB;EAC3D,SAAS,cAAc;EACvB,OAAO,SAAS;EAChB,OAAO,UAAU,MAAM,YAAY,IAAI,IAAI,OAAO,IAAI;EACtD,YAAY,UAAU,MAAM,YAAY,IAAI,IAAI,QAAQ,IAAI"}
|
package/dist/proto/tm2/tx.mjs
CHANGED
|
@@ -136,13 +136,15 @@ const TxFee = {
|
|
|
136
136
|
function createBaseTxSignature() {
|
|
137
137
|
return {
|
|
138
138
|
pub_key: void 0,
|
|
139
|
-
signature: /* @__PURE__ */ new Uint8Array(0)
|
|
139
|
+
signature: /* @__PURE__ */ new Uint8Array(0),
|
|
140
|
+
session_addr: ""
|
|
140
141
|
};
|
|
141
142
|
}
|
|
142
143
|
const TxSignature = {
|
|
143
144
|
encode(message, writer = new BinaryWriter()) {
|
|
144
145
|
if (message.pub_key !== void 0) Any.encode(message.pub_key, writer.uint32(10).fork()).join();
|
|
145
146
|
if (message.signature.length !== 0) writer.uint32(18).bytes(message.signature);
|
|
147
|
+
if (message.session_addr !== "") writer.uint32(26).string(message.session_addr);
|
|
146
148
|
return writer;
|
|
147
149
|
},
|
|
148
150
|
decode(input, length) {
|
|
@@ -160,6 +162,10 @@ const TxSignature = {
|
|
|
160
162
|
if (tag !== 18) break;
|
|
161
163
|
message.signature = reader.bytes();
|
|
162
164
|
continue;
|
|
165
|
+
case 3:
|
|
166
|
+
if (tag !== 26) break;
|
|
167
|
+
message.session_addr = reader.string();
|
|
168
|
+
continue;
|
|
163
169
|
}
|
|
164
170
|
if ((tag & 7) === 4 || tag === 0) break;
|
|
165
171
|
reader.skip(tag & 7);
|
|
@@ -169,13 +175,15 @@ const TxSignature = {
|
|
|
169
175
|
fromJSON(object) {
|
|
170
176
|
return {
|
|
171
177
|
pub_key: isSet(object.pub_key) ? Any.fromJSON(object.pub_key) : void 0,
|
|
172
|
-
signature: isSet(object.signature) ? bytesFromBase64(object.signature) : /* @__PURE__ */ new Uint8Array(0)
|
|
178
|
+
signature: isSet(object.signature) ? bytesFromBase64(object.signature) : /* @__PURE__ */ new Uint8Array(0),
|
|
179
|
+
session_addr: isSet(object.session_addr) ? globalThis.String(object.session_addr) : ""
|
|
173
180
|
};
|
|
174
181
|
},
|
|
175
182
|
toJSON(message) {
|
|
176
183
|
const obj = {};
|
|
177
184
|
if (message.pub_key !== void 0) obj.pub_key = Any.toJSON(message.pub_key);
|
|
178
185
|
if (message.signature !== void 0) obj.signature = base64FromBytes(message.signature);
|
|
186
|
+
if (message.session_addr !== void 0) obj.session_addr = message.session_addr;
|
|
179
187
|
return obj;
|
|
180
188
|
},
|
|
181
189
|
create(base) {
|
|
@@ -185,6 +193,7 @@ const TxSignature = {
|
|
|
185
193
|
const message = createBaseTxSignature();
|
|
186
194
|
message.pub_key = object.pub_key !== void 0 && object.pub_key !== null ? Any.fromPartial(object.pub_key) : void 0;
|
|
187
195
|
message.signature = object.signature ?? /* @__PURE__ */ new Uint8Array(0);
|
|
196
|
+
message.session_addr = object.session_addr ?? "";
|
|
188
197
|
return message;
|
|
189
198
|
}
|
|
190
199
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx.mjs","names":[],"sources":["../../../src/proto/tm2/tx.ts"],"sourcesContent":["// Code generated by protoc-gen-ts_proto. DO NOT EDIT.\n// versions:\n// protoc-gen-ts_proto v2.11.6\n// protoc v6.33.4\n// source: tm2/tx.proto\n\n/* eslint-disable */\nimport { BinaryReader, BinaryWriter } from \"@bufbuild/protobuf/wire\";\nimport { Any } from \"../google/protobuf/any.js\";\n\nexport const protobufPackage = \"tm2.tx\";\n\nexport interface Tx {\n /** specific message types */\n messages: Any[];\n /** transaction costs (fee) */\n fee?:\n | TxFee\n | undefined;\n /** the signatures for the transaction */\n signatures: TxSignature[];\n /** memo attached to the transaction */\n memo: string;\n}\n\nexport interface TxFee {\n /** gas limit */\n gas_wanted: bigint;\n /** gas fee details (<value><denomination>) */\n gas_fee: string;\n}\n\nexport interface TxSignature {\n /** public key associated with the signature */\n pub_key?:\n | Any\n | undefined;\n /** the signature */\n signature: Uint8Array;\n}\n\nexport interface PubKeySecp256k1 {\n key: Uint8Array;\n}\n\nfunction createBaseTx(): Tx {\n return { messages: [], fee: undefined, signatures: [], memo: \"\" };\n}\n\nexport const Tx: MessageFns<Tx> = {\n encode(message: Tx, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n for (const v of message.messages) {\n Any.encode(v!, writer.uint32(10).fork()).join();\n }\n if (message.fee !== undefined) {\n TxFee.encode(message.fee, writer.uint32(18).fork()).join();\n }\n for (const v of message.signatures) {\n TxSignature.encode(v!, writer.uint32(26).fork()).join();\n }\n if (message.memo !== \"\") {\n writer.uint32(34).string(message.memo);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): Tx {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseTx();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.messages.push(Any.decode(reader, reader.uint32()));\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.fee = TxFee.decode(reader, reader.uint32());\n continue;\n }\n case 3: {\n if (tag !== 26) {\n break;\n }\n\n message.signatures.push(TxSignature.decode(reader, reader.uint32()));\n continue;\n }\n case 4: {\n if (tag !== 34) {\n break;\n }\n\n message.memo = reader.string();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): Tx {\n return {\n messages: globalThis.Array.isArray(object?.messages) ? object.messages.map((e: any) => Any.fromJSON(e)) : [],\n fee: isSet(object.fee) ? TxFee.fromJSON(object.fee) : undefined,\n signatures: globalThis.Array.isArray(object?.signatures)\n ? object.signatures.map((e: any) => TxSignature.fromJSON(e))\n : [],\n memo: isSet(object.memo) ? globalThis.String(object.memo) : \"\",\n };\n },\n\n toJSON(message: Tx): unknown {\n const obj: any = {};\n if (message.messages?.length) {\n obj.messages = message.messages.map((e) => Any.toJSON(e));\n }\n if (message.fee !== undefined) {\n obj.fee = TxFee.toJSON(message.fee);\n }\n if (message.signatures?.length) {\n obj.signatures = message.signatures.map((e) => TxSignature.toJSON(e));\n }\n if (message.memo !== undefined) {\n obj.memo = message.memo;\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<Tx>, I>>(base?: I): Tx {\n return Tx.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<Tx>, I>>(object: I): Tx {\n const message = createBaseTx();\n message.messages = object.messages?.map((e) => Any.fromPartial(e)) || [];\n message.fee = (object.fee !== undefined && object.fee !== null) ? TxFee.fromPartial(object.fee) : undefined;\n message.signatures = object.signatures?.map((e) => TxSignature.fromPartial(e)) || [];\n message.memo = object.memo ?? \"\";\n return message;\n },\n};\n\nfunction createBaseTxFee(): TxFee {\n return { gas_wanted: 0n, gas_fee: \"\" };\n}\n\nexport const TxFee: MessageFns<TxFee> = {\n encode(message: TxFee, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.gas_wanted !== 0n) {\n if (BigInt.asIntN(64, message.gas_wanted) !== message.gas_wanted) {\n throw new globalThis.Error(\"value provided for field message.gas_wanted of type sint64 too large\");\n }\n writer.uint32(8).sint64(message.gas_wanted);\n }\n if (message.gas_fee !== \"\") {\n writer.uint32(18).string(message.gas_fee);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): TxFee {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseTxFee();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 8) {\n break;\n }\n\n message.gas_wanted = reader.sint64() as bigint;\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.gas_fee = reader.string();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): TxFee {\n return {\n gas_wanted: isSet(object.gas_wanted) ? BigInt(object.gas_wanted) : 0n,\n gas_fee: isSet(object.gas_fee) ? globalThis.String(object.gas_fee) : \"\",\n };\n },\n\n toJSON(message: TxFee): unknown {\n const obj: any = {};\n if (message.gas_wanted !== undefined) {\n obj.gas_wanted = message.gas_wanted.toString();\n }\n if (message.gas_fee !== undefined) {\n obj.gas_fee = message.gas_fee;\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<TxFee>, I>>(base?: I): TxFee {\n return TxFee.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<TxFee>, I>>(object: I): TxFee {\n const message = createBaseTxFee();\n message.gas_wanted = object.gas_wanted ?? 0n;\n message.gas_fee = object.gas_fee ?? \"\";\n return message;\n },\n};\n\nfunction createBaseTxSignature(): TxSignature {\n return { pub_key: undefined, signature: new Uint8Array(0) };\n}\n\nexport const TxSignature: MessageFns<TxSignature> = {\n encode(message: TxSignature, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.pub_key !== undefined) {\n Any.encode(message.pub_key, writer.uint32(10).fork()).join();\n }\n if (message.signature.length !== 0) {\n writer.uint32(18).bytes(message.signature);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): TxSignature {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseTxSignature();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.pub_key = Any.decode(reader, reader.uint32());\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.signature = reader.bytes();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): TxSignature {\n return {\n pub_key: isSet(object.pub_key) ? Any.fromJSON(object.pub_key) : undefined,\n signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(0),\n };\n },\n\n toJSON(message: TxSignature): unknown {\n const obj: any = {};\n if (message.pub_key !== undefined) {\n obj.pub_key = Any.toJSON(message.pub_key);\n }\n if (message.signature !== undefined) {\n obj.signature = base64FromBytes(message.signature);\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<TxSignature>, I>>(base?: I): TxSignature {\n return TxSignature.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<TxSignature>, I>>(object: I): TxSignature {\n const message = createBaseTxSignature();\n message.pub_key = (object.pub_key !== undefined && object.pub_key !== null)\n ? Any.fromPartial(object.pub_key)\n : undefined;\n message.signature = object.signature ?? new Uint8Array(0);\n return message;\n },\n};\n\nfunction createBasePubKeySecp256k1(): PubKeySecp256k1 {\n return { key: new Uint8Array(0) };\n}\n\nexport const PubKeySecp256k1: MessageFns<PubKeySecp256k1> = {\n encode(message: PubKeySecp256k1, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.key.length !== 0) {\n writer.uint32(10).bytes(message.key);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): PubKeySecp256k1 {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBasePubKeySecp256k1();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.key = reader.bytes();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): PubKeySecp256k1 {\n return { key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(0) };\n },\n\n toJSON(message: PubKeySecp256k1): unknown {\n const obj: any = {};\n if (message.key !== undefined) {\n obj.key = base64FromBytes(message.key);\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<PubKeySecp256k1>, I>>(base?: I): PubKeySecp256k1 {\n return PubKeySecp256k1.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<PubKeySecp256k1>, I>>(object: I): PubKeySecp256k1 {\n const message = createBasePubKeySecp256k1();\n message.key = object.key ?? new Uint8Array(0);\n return message;\n },\n};\n\nfunction bytesFromBase64(b64: string): Uint8Array {\n if ((globalThis as any).Buffer) {\n return Uint8Array.from((globalThis as any).Buffer.from(b64, \"base64\"));\n } else {\n const bin = globalThis.atob(b64);\n const arr = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; ++i) {\n arr[i] = bin.charCodeAt(i);\n }\n return arr;\n }\n}\n\nfunction base64FromBytes(arr: Uint8Array): string {\n if ((globalThis as any).Buffer) {\n return (globalThis as any).Buffer.from(arr).toString(\"base64\");\n } else {\n const bin: string[] = [];\n arr.forEach((byte) => {\n bin.push(globalThis.String.fromCharCode(byte));\n });\n return globalThis.btoa(bin.join(\"\"));\n }\n}\n\ntype Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;\n\nexport type DeepPartial<T> = T extends Builtin ? T\n : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>\n : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>\n : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }\n : Partial<T>;\n\ntype KeysOfUnion<T> = T extends T ? keyof T : never;\nexport type Exact<P, I extends P> = P extends Builtin ? P\n : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };\n\nfunction isSet(value: any): boolean {\n return value !== null && value !== undefined;\n}\n\nexport interface MessageFns<T> {\n encode(message: T, writer?: BinaryWriter): BinaryWriter;\n decode(input: BinaryReader | Uint8Array, length?: number): T;\n fromJSON(object: any): T;\n toJSON(message: T): unknown;\n create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;\n fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;\n}\n"],"mappings":";;;AAUA,MAAa,kBAAkB;AAmC/B,SAAS,eAAmB;CAC1B,OAAO;EAAE,UAAU,CAAC;EAAG,KAAK;EAAW,YAAY,CAAC;EAAG,MAAM;CAAG;AAClE;AAEA,MAAa,KAAqB;CAChC,OAAO,SAAa,SAAuB,IAAI,aAAa,GAAiB;EAC3E,KAAK,MAAM,KAAK,QAAQ,UACtB,IAAI,OAAO,GAAI,OAAO,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK;EAEhD,IAAI,QAAQ,QAAQ,QAClB,MAAM,OAAO,QAAQ,KAAK,OAAO,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK;EAE3D,KAAK,MAAM,KAAK,QAAQ,YACtB,YAAY,OAAO,GAAI,OAAO,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK;EAExD,IAAI,QAAQ,SAAS,IACnB,OAAO,OAAO,EAAE,CAAC,CAAC,OAAO,QAAQ,IAAI;EAEvC,OAAO;CACT;CAEA,OAAO,OAAkC,QAAqB;EAC5D,MAAM,SAAS,iBAAiB,eAAe,QAAQ,IAAI,aAAa,KAAK;EAC7E,MAAM,MAAM,WAAW,SAAY,OAAO,MAAM,OAAO,MAAM;EAC7D,MAAM,UAAU,aAAa;EAC7B,OAAO,OAAO,MAAM,KAAK;GACvB,MAAM,MAAM,OAAO,OAAO;GAC1B,QAAQ,QAAQ,GAAhB;IACE,KAAK;KACH,IAAI,QAAQ,IACV;KAGF,QAAQ,SAAS,KAAK,IAAI,OAAO,QAAQ,OAAO,OAAO,CAAC,CAAC;KACzD;IAEF,KAAK;KACH,IAAI,QAAQ,IACV;KAGF,QAAQ,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AAI,KAAK,WAAW,OAAO,aAAa,IAAI,CAAC;EAC/C,CAAC;EACD,OAAO,WAAW,KAAK,IAAI,KAAK,EAAE,CAAC;CACrC;AACF;AAcA,SAAS,MAAM,OAAqB;CAClC,OAAO,UAAU,QAAQ,UAAU;AACrC"}
|
|
1
|
+
{"version":3,"file":"tx.mjs","names":[],"sources":["../../../src/proto/tm2/tx.ts"],"sourcesContent":["// Code generated by protoc-gen-ts_proto. DO NOT EDIT.\n// versions:\n// protoc-gen-ts_proto v2.11.6\n// protoc v6.33.4\n// source: tm2/tx.proto\n\n/* eslint-disable */\nimport { BinaryReader, BinaryWriter } from \"@bufbuild/protobuf/wire\";\nimport { Any } from \"../google/protobuf/any.js\";\n\nexport const protobufPackage = \"tm2.tx\";\n\nexport interface Tx {\n /** specific message types */\n messages: Any[];\n /** transaction costs (fee) */\n fee?:\n | TxFee\n | undefined;\n /** the signatures for the transaction */\n signatures: TxSignature[];\n /** memo attached to the transaction */\n memo: string;\n}\n\nexport interface TxFee {\n /** gas limit */\n gas_wanted: bigint;\n /** gas fee details (<value><denomination>) */\n gas_fee: string;\n}\n\nexport interface TxSignature {\n /** public key associated with the signature */\n pub_key?:\n | Any\n | undefined;\n /** the signature */\n signature: Uint8Array;\n /** session account address (empty for master-key signatures) */\n session_addr: string;\n}\n\nexport interface PubKeySecp256k1 {\n key: Uint8Array;\n}\n\nfunction createBaseTx(): Tx {\n return { messages: [], fee: undefined, signatures: [], memo: \"\" };\n}\n\nexport const Tx: MessageFns<Tx> = {\n encode(message: Tx, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n for (const v of message.messages) {\n Any.encode(v!, writer.uint32(10).fork()).join();\n }\n if (message.fee !== undefined) {\n TxFee.encode(message.fee, writer.uint32(18).fork()).join();\n }\n for (const v of message.signatures) {\n TxSignature.encode(v!, writer.uint32(26).fork()).join();\n }\n if (message.memo !== \"\") {\n writer.uint32(34).string(message.memo);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): Tx {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseTx();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.messages.push(Any.decode(reader, reader.uint32()));\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.fee = TxFee.decode(reader, reader.uint32());\n continue;\n }\n case 3: {\n if (tag !== 26) {\n break;\n }\n\n message.signatures.push(TxSignature.decode(reader, reader.uint32()));\n continue;\n }\n case 4: {\n if (tag !== 34) {\n break;\n }\n\n message.memo = reader.string();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): Tx {\n return {\n messages: globalThis.Array.isArray(object?.messages) ? object.messages.map((e: any) => Any.fromJSON(e)) : [],\n fee: isSet(object.fee) ? TxFee.fromJSON(object.fee) : undefined,\n signatures: globalThis.Array.isArray(object?.signatures)\n ? object.signatures.map((e: any) => TxSignature.fromJSON(e))\n : [],\n memo: isSet(object.memo) ? globalThis.String(object.memo) : \"\",\n };\n },\n\n toJSON(message: Tx): unknown {\n const obj: any = {};\n if (message.messages?.length) {\n obj.messages = message.messages.map((e) => Any.toJSON(e));\n }\n if (message.fee !== undefined) {\n obj.fee = TxFee.toJSON(message.fee);\n }\n if (message.signatures?.length) {\n obj.signatures = message.signatures.map((e) => TxSignature.toJSON(e));\n }\n if (message.memo !== undefined) {\n obj.memo = message.memo;\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<Tx>, I>>(base?: I): Tx {\n return Tx.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<Tx>, I>>(object: I): Tx {\n const message = createBaseTx();\n message.messages = object.messages?.map((e) => Any.fromPartial(e)) || [];\n message.fee = (object.fee !== undefined && object.fee !== null) ? TxFee.fromPartial(object.fee) : undefined;\n message.signatures = object.signatures?.map((e) => TxSignature.fromPartial(e)) || [];\n message.memo = object.memo ?? \"\";\n return message;\n },\n};\n\nfunction createBaseTxFee(): TxFee {\n return { gas_wanted: 0n, gas_fee: \"\" };\n}\n\nexport const TxFee: MessageFns<TxFee> = {\n encode(message: TxFee, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.gas_wanted !== 0n) {\n if (BigInt.asIntN(64, message.gas_wanted) !== message.gas_wanted) {\n throw new globalThis.Error(\"value provided for field message.gas_wanted of type sint64 too large\");\n }\n writer.uint32(8).sint64(message.gas_wanted);\n }\n if (message.gas_fee !== \"\") {\n writer.uint32(18).string(message.gas_fee);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): TxFee {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseTxFee();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 8) {\n break;\n }\n\n message.gas_wanted = reader.sint64() as bigint;\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.gas_fee = reader.string();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): TxFee {\n return {\n gas_wanted: isSet(object.gas_wanted) ? BigInt(object.gas_wanted) : 0n,\n gas_fee: isSet(object.gas_fee) ? globalThis.String(object.gas_fee) : \"\",\n };\n },\n\n toJSON(message: TxFee): unknown {\n const obj: any = {};\n if (message.gas_wanted !== undefined) {\n obj.gas_wanted = message.gas_wanted.toString();\n }\n if (message.gas_fee !== undefined) {\n obj.gas_fee = message.gas_fee;\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<TxFee>, I>>(base?: I): TxFee {\n return TxFee.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<TxFee>, I>>(object: I): TxFee {\n const message = createBaseTxFee();\n message.gas_wanted = object.gas_wanted ?? 0n;\n message.gas_fee = object.gas_fee ?? \"\";\n return message;\n },\n};\n\nfunction createBaseTxSignature(): TxSignature {\n return { pub_key: undefined, signature: new Uint8Array(0), session_addr: \"\" };\n}\n\nexport const TxSignature: MessageFns<TxSignature> = {\n encode(message: TxSignature, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.pub_key !== undefined) {\n Any.encode(message.pub_key, writer.uint32(10).fork()).join();\n }\n if (message.signature.length !== 0) {\n writer.uint32(18).bytes(message.signature);\n }\n if (message.session_addr !== \"\") {\n writer.uint32(26).string(message.session_addr);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): TxSignature {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBaseTxSignature();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.pub_key = Any.decode(reader, reader.uint32());\n continue;\n }\n case 2: {\n if (tag !== 18) {\n break;\n }\n\n message.signature = reader.bytes();\n continue;\n }\n case 3: {\n if (tag !== 26) {\n break;\n }\n\n message.session_addr = reader.string();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): TxSignature {\n return {\n pub_key: isSet(object.pub_key) ? Any.fromJSON(object.pub_key) : undefined,\n signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(0),\n session_addr: isSet(object.session_addr) ? globalThis.String(object.session_addr) : \"\",\n };\n },\n\n toJSON(message: TxSignature): unknown {\n const obj: any = {};\n if (message.pub_key !== undefined) {\n obj.pub_key = Any.toJSON(message.pub_key);\n }\n if (message.signature !== undefined) {\n obj.signature = base64FromBytes(message.signature);\n }\n if (message.session_addr !== undefined) {\n obj.session_addr = message.session_addr;\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<TxSignature>, I>>(base?: I): TxSignature {\n return TxSignature.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<TxSignature>, I>>(object: I): TxSignature {\n const message = createBaseTxSignature();\n message.pub_key = (object.pub_key !== undefined && object.pub_key !== null)\n ? Any.fromPartial(object.pub_key)\n : undefined;\n message.signature = object.signature ?? new Uint8Array(0);\n message.session_addr = object.session_addr ?? \"\";\n return message;\n },\n};\n\nfunction createBasePubKeySecp256k1(): PubKeySecp256k1 {\n return { key: new Uint8Array(0) };\n}\n\nexport const PubKeySecp256k1: MessageFns<PubKeySecp256k1> = {\n encode(message: PubKeySecp256k1, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {\n if (message.key.length !== 0) {\n writer.uint32(10).bytes(message.key);\n }\n return writer;\n },\n\n decode(input: BinaryReader | Uint8Array, length?: number): PubKeySecp256k1 {\n const reader = input instanceof BinaryReader ? input : new BinaryReader(input);\n const end = length === undefined ? reader.len : reader.pos + length;\n const message = createBasePubKeySecp256k1();\n while (reader.pos < end) {\n const tag = reader.uint32();\n switch (tag >>> 3) {\n case 1: {\n if (tag !== 10) {\n break;\n }\n\n message.key = reader.bytes();\n continue;\n }\n }\n if ((tag & 7) === 4 || tag === 0) {\n break;\n }\n reader.skip(tag & 7);\n }\n return message;\n },\n\n fromJSON(object: any): PubKeySecp256k1 {\n return { key: isSet(object.key) ? bytesFromBase64(object.key) : new Uint8Array(0) };\n },\n\n toJSON(message: PubKeySecp256k1): unknown {\n const obj: any = {};\n if (message.key !== undefined) {\n obj.key = base64FromBytes(message.key);\n }\n return obj;\n },\n\n create<I extends Exact<DeepPartial<PubKeySecp256k1>, I>>(base?: I): PubKeySecp256k1 {\n return PubKeySecp256k1.fromPartial(base ?? ({} as any));\n },\n fromPartial<I extends Exact<DeepPartial<PubKeySecp256k1>, I>>(object: I): PubKeySecp256k1 {\n const message = createBasePubKeySecp256k1();\n message.key = object.key ?? new Uint8Array(0);\n return message;\n },\n};\n\nfunction bytesFromBase64(b64: string): Uint8Array {\n if ((globalThis as any).Buffer) {\n return Uint8Array.from((globalThis as any).Buffer.from(b64, \"base64\"));\n } else {\n const bin = globalThis.atob(b64);\n const arr = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; ++i) {\n arr[i] = bin.charCodeAt(i);\n }\n return arr;\n }\n}\n\nfunction base64FromBytes(arr: Uint8Array): string {\n if ((globalThis as any).Buffer) {\n return (globalThis as any).Buffer.from(arr).toString(\"base64\");\n } else {\n const bin: string[] = [];\n arr.forEach((byte) => {\n bin.push(globalThis.String.fromCharCode(byte));\n });\n return globalThis.btoa(bin.join(\"\"));\n }\n}\n\ntype Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;\n\nexport type DeepPartial<T> = T extends Builtin ? T\n : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>\n : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>\n : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }\n : Partial<T>;\n\ntype KeysOfUnion<T> = T extends T ? keyof T : never;\nexport type Exact<P, I extends P> = P extends Builtin ? P\n : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };\n\nfunction isSet(value: any): boolean {\n return value !== null && value !== undefined;\n}\n\nexport interface MessageFns<T> {\n encode(message: T, writer?: BinaryWriter): BinaryWriter;\n decode(input: BinaryReader | Uint8Array, length?: number): T;\n fromJSON(object: any): T;\n toJSON(message: T): unknown;\n create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;\n fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;\n}\n"],"mappings":";;;AAUA,MAAa,kBAAkB;AAqC/B,SAAS,eAAmB;CAC1B,OAAO;EAAE,UAAU,CAAC;EAAG,KAAK;EAAW,YAAY,CAAC;EAAG,MAAM;CAAG;AAClE;AAEA,MAAa,KAAqB;CAChC,OAAO,SAAa,SAAuB,IAAI,aAAa,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AAC;EAC/C,CAAC;EACD,OAAO,WAAW,KAAK,IAAI,KAAK,EAAE,CAAC;CACrC;AACF;AAcA,SAAS,MAAM,OAAqB;CAClC,OAAO,UAAU,QAAQ,UAAU;AACrC"}
|
package/dist/wallet/index.cjs
CHANGED
|
@@ -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;
|
package/dist/wallet/index.d.cts
CHANGED
|
@@ -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 };
|
package/dist/wallet/index.d.mts
CHANGED
|
@@ -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 };
|
package/dist/wallet/index.mjs
CHANGED
|
@@ -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
|
|
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
|
-
|
|
12
|
-
|
|
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;
|
|
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
|
-
|
|
12
|
-
|
|
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;
|
|
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
|
|
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":";;;;;;;;;;
|
|
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));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vD,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,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":"
|
|
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":"
|
|
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":";;;;;;;;
|
|
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;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;AAGA,MAAM,aAAa;AAGnB,MAAM,gBAAgB;;;;;;;;AAStB,MAAa,iBAAiB,SAAgC;CAC5D,MAAM,WAAW,QAAQ,GAAA,CAAI,KAAK;CAClC,IAAI,YAAY,IACd,OAAO,CAAC;CAGV,MAAM,QAAQ,WAAW,KAAK,OAAO;CACrC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,wBAAwB,MAAM;CAGhD,MAAM,GAAG,WAAW,SAAS;CAC7B,MAAM,SAAS,OAAO,SAAS;CAC/B,IAAI,SAAS,eACX,MAAM,IAAI,MAAM,6BAA6B,MAAM;CAGrD,IAAI,WAAW,IACb,OAAO,CAAC;CAGV,OAAO,CACL;EACE;EACA,QAAQ,OAAO,SAAS,EAAE;CAC5B,CACF;AACF;;;;;;;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"}
|
package/dist/wallet/wallet.cjs
CHANGED
|
@@ -143,8 +143,8 @@ var Wallet = class {
|
|
|
143
143
|
account_number: accountNumber,
|
|
144
144
|
sequence: accountSequence,
|
|
145
145
|
fee: {
|
|
146
|
-
|
|
147
|
-
|
|
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
|
|
@@ -156,7 +156,8 @@ var Wallet = class {
|
|
|
156
156
|
type_url: require_sign.Secp256k1PubKeyType,
|
|
157
157
|
value: require_tx.PubKeySecp256k1.encode(wrappedKey).finish()
|
|
158
158
|
},
|
|
159
|
-
signature: await this.getSigner().signData(signBytes)
|
|
159
|
+
signature: await this.getSigner().signData(signBytes),
|
|
160
|
+
session_addr: ""
|
|
160
161
|
};
|
|
161
162
|
return {
|
|
162
163
|
...tx,
|
|
@@ -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 };\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,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;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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;;;;;;;;;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,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AAA;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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.cts","names":[],"sources":["../../src/wallet/wallet.ts"],"mappings":";;;;;;;;;;;
|
|
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":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"wallet.d.mts","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"}
|
package/dist/wallet/wallet.mjs
CHANGED
|
@@ -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
|
-
|
|
147
|
-
|
|
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
|
|
@@ -156,7 +156,8 @@ var Wallet = class {
|
|
|
156
156
|
type_url: Secp256k1PubKeyType,
|
|
157
157
|
value: PubKeySecp256k1.encode(wrappedKey).finish()
|
|
158
158
|
},
|
|
159
|
-
signature: await this.getSigner().signData(signBytes)
|
|
159
|
+
signature: await this.getSigner().signData(signBytes),
|
|
160
|
+
session_addr: ""
|
|
160
161
|
};
|
|
161
162
|
return {
|
|
162
163
|
...tx,
|
|
@@ -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 };\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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SAAS,GAClC,SAAS,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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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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gnolang/tm2-js-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Tendermint2 JS / TS Client",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"type": "module",
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@arethetypeswrong/core": "^0.18.5",
|
|
32
|
+
"@changesets/changelog-github": "^1.0.1",
|
|
32
33
|
"@changesets/cli": "^2.31.1",
|
|
33
34
|
"@eslint/js": "^10.0.1",
|
|
34
35
|
"@stylistic/eslint-plugin": "^5.10.0",
|