@gnolang/tm2-js-client 1.0.4 → 1.0.6

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.
@@ -0,0 +1,59 @@
1
+ declare class TM2Error extends Error {
2
+ log?: string;
3
+ constructor(message: string, log?: string);
4
+ }
5
+ declare class InternalError extends TM2Error {
6
+ constructor(log?: string);
7
+ }
8
+ declare class TxDecodeError extends TM2Error {
9
+ constructor(log?: string);
10
+ }
11
+ declare class InvalidSequenceError extends TM2Error {
12
+ constructor(log?: string);
13
+ }
14
+ declare class UnauthorizedError extends TM2Error {
15
+ constructor(log?: string);
16
+ }
17
+ declare class InsufficientFundsError extends TM2Error {
18
+ constructor(log?: string);
19
+ }
20
+ declare class UnknownRequestError extends TM2Error {
21
+ constructor(log?: string);
22
+ }
23
+ declare class InvalidAddressError extends TM2Error {
24
+ constructor(log?: string);
25
+ }
26
+ declare class UnknownAddressError extends TM2Error {
27
+ constructor(log?: string);
28
+ }
29
+ declare class InvalidPubKeyError extends TM2Error {
30
+ constructor(log?: string);
31
+ }
32
+ declare class InsufficientCoinsError extends TM2Error {
33
+ constructor(log?: string);
34
+ }
35
+ declare class InvalidCoinsError extends TM2Error {
36
+ constructor(log?: string);
37
+ }
38
+ declare class InvalidGasWantedError extends TM2Error {
39
+ constructor(log?: string);
40
+ }
41
+ declare class OutOfGasError extends TM2Error {
42
+ constructor(log?: string);
43
+ }
44
+ declare class MemoTooLargeError extends TM2Error {
45
+ constructor(log?: string);
46
+ }
47
+ declare class InsufficientFeeError extends TM2Error {
48
+ constructor(log?: string);
49
+ }
50
+ declare class TooManySignaturesError extends TM2Error {
51
+ constructor(log?: string);
52
+ }
53
+ declare class NoSignaturesError extends TM2Error {
54
+ constructor(log?: string);
55
+ }
56
+ declare class GasOverflowError extends TM2Error {
57
+ constructor(log?: string);
58
+ }
59
+ export { TM2Error, InternalError, TxDecodeError, InvalidSequenceError, UnauthorizedError, InsufficientFundsError, UnknownRequestError, InvalidAddressError, UnknownAddressError, InvalidPubKeyError, InsufficientCoinsError, InvalidCoinsError, InvalidGasWantedError, OutOfGasError, MemoTooLargeError, InsufficientFeeError, TooManySignaturesError, NoSignaturesError, GasOverflowError, };
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.GasOverflowError = exports.NoSignaturesError = exports.TooManySignaturesError = exports.InsufficientFeeError = exports.MemoTooLargeError = exports.OutOfGasError = exports.InvalidGasWantedError = exports.InvalidCoinsError = exports.InsufficientCoinsError = exports.InvalidPubKeyError = exports.UnknownAddressError = exports.InvalidAddressError = exports.UnknownRequestError = exports.InsufficientFundsError = exports.UnauthorizedError = exports.InvalidSequenceError = exports.TxDecodeError = exports.InternalError = exports.TM2Error = void 0;
19
+ var messages_1 = require("./messages");
20
+ var TM2Error = /** @class */ (function (_super) {
21
+ __extends(TM2Error, _super);
22
+ function TM2Error(message, log) {
23
+ var _this = _super.call(this, message) || this;
24
+ _this.log = log;
25
+ return _this;
26
+ }
27
+ return TM2Error;
28
+ }(Error));
29
+ exports.TM2Error = TM2Error;
30
+ var InternalError = /** @class */ (function (_super) {
31
+ __extends(InternalError, _super);
32
+ function InternalError(log) {
33
+ return _super.call(this, messages_1.InternalErrorMessage, log) || this;
34
+ }
35
+ return InternalError;
36
+ }(TM2Error));
37
+ exports.InternalError = InternalError;
38
+ var TxDecodeError = /** @class */ (function (_super) {
39
+ __extends(TxDecodeError, _super);
40
+ function TxDecodeError(log) {
41
+ return _super.call(this, messages_1.TxDecodeErrorMessage, log) || this;
42
+ }
43
+ return TxDecodeError;
44
+ }(TM2Error));
45
+ exports.TxDecodeError = TxDecodeError;
46
+ var InvalidSequenceError = /** @class */ (function (_super) {
47
+ __extends(InvalidSequenceError, _super);
48
+ function InvalidSequenceError(log) {
49
+ return _super.call(this, messages_1.InvalidSequenceErrorMessage, log) || this;
50
+ }
51
+ return InvalidSequenceError;
52
+ }(TM2Error));
53
+ exports.InvalidSequenceError = InvalidSequenceError;
54
+ var UnauthorizedError = /** @class */ (function (_super) {
55
+ __extends(UnauthorizedError, _super);
56
+ function UnauthorizedError(log) {
57
+ return _super.call(this, messages_1.UnauthorizedErrorMessage, log) || this;
58
+ }
59
+ return UnauthorizedError;
60
+ }(TM2Error));
61
+ exports.UnauthorizedError = UnauthorizedError;
62
+ var InsufficientFundsError = /** @class */ (function (_super) {
63
+ __extends(InsufficientFundsError, _super);
64
+ function InsufficientFundsError(log) {
65
+ return _super.call(this, messages_1.InsufficientFundsErrorMessage, log) || this;
66
+ }
67
+ return InsufficientFundsError;
68
+ }(TM2Error));
69
+ exports.InsufficientFundsError = InsufficientFundsError;
70
+ var UnknownRequestError = /** @class */ (function (_super) {
71
+ __extends(UnknownRequestError, _super);
72
+ function UnknownRequestError(log) {
73
+ return _super.call(this, messages_1.UnknownRequestErrorMessage, log) || this;
74
+ }
75
+ return UnknownRequestError;
76
+ }(TM2Error));
77
+ exports.UnknownRequestError = UnknownRequestError;
78
+ var InvalidAddressError = /** @class */ (function (_super) {
79
+ __extends(InvalidAddressError, _super);
80
+ function InvalidAddressError(log) {
81
+ return _super.call(this, messages_1.InvalidAddressErrorMessage, log) || this;
82
+ }
83
+ return InvalidAddressError;
84
+ }(TM2Error));
85
+ exports.InvalidAddressError = InvalidAddressError;
86
+ var UnknownAddressError = /** @class */ (function (_super) {
87
+ __extends(UnknownAddressError, _super);
88
+ function UnknownAddressError(log) {
89
+ return _super.call(this, messages_1.UnknownAddressErrorMessage, log) || this;
90
+ }
91
+ return UnknownAddressError;
92
+ }(TM2Error));
93
+ exports.UnknownAddressError = UnknownAddressError;
94
+ var InvalidPubKeyError = /** @class */ (function (_super) {
95
+ __extends(InvalidPubKeyError, _super);
96
+ function InvalidPubKeyError(log) {
97
+ return _super.call(this, messages_1.InvalidPubKeyErrorMessage, log) || this;
98
+ }
99
+ return InvalidPubKeyError;
100
+ }(TM2Error));
101
+ exports.InvalidPubKeyError = InvalidPubKeyError;
102
+ var InsufficientCoinsError = /** @class */ (function (_super) {
103
+ __extends(InsufficientCoinsError, _super);
104
+ function InsufficientCoinsError(log) {
105
+ return _super.call(this, messages_1.InsufficientCoinsErrorMessage, log) || this;
106
+ }
107
+ return InsufficientCoinsError;
108
+ }(TM2Error));
109
+ exports.InsufficientCoinsError = InsufficientCoinsError;
110
+ var InvalidCoinsError = /** @class */ (function (_super) {
111
+ __extends(InvalidCoinsError, _super);
112
+ function InvalidCoinsError(log) {
113
+ return _super.call(this, messages_1.InvalidCoinsErrorMessage, log) || this;
114
+ }
115
+ return InvalidCoinsError;
116
+ }(TM2Error));
117
+ exports.InvalidCoinsError = InvalidCoinsError;
118
+ var InvalidGasWantedError = /** @class */ (function (_super) {
119
+ __extends(InvalidGasWantedError, _super);
120
+ function InvalidGasWantedError(log) {
121
+ return _super.call(this, messages_1.InvalidGasWantedErrorMessage, log) || this;
122
+ }
123
+ return InvalidGasWantedError;
124
+ }(TM2Error));
125
+ exports.InvalidGasWantedError = InvalidGasWantedError;
126
+ var OutOfGasError = /** @class */ (function (_super) {
127
+ __extends(OutOfGasError, _super);
128
+ function OutOfGasError(log) {
129
+ return _super.call(this, messages_1.OutOfGasErrorMessage, log) || this;
130
+ }
131
+ return OutOfGasError;
132
+ }(TM2Error));
133
+ exports.OutOfGasError = OutOfGasError;
134
+ var MemoTooLargeError = /** @class */ (function (_super) {
135
+ __extends(MemoTooLargeError, _super);
136
+ function MemoTooLargeError(log) {
137
+ return _super.call(this, messages_1.MemoTooLargeErrorMessage, log) || this;
138
+ }
139
+ return MemoTooLargeError;
140
+ }(TM2Error));
141
+ exports.MemoTooLargeError = MemoTooLargeError;
142
+ var InsufficientFeeError = /** @class */ (function (_super) {
143
+ __extends(InsufficientFeeError, _super);
144
+ function InsufficientFeeError(log) {
145
+ return _super.call(this, messages_1.InsufficientFeeErrorMessage, log) || this;
146
+ }
147
+ return InsufficientFeeError;
148
+ }(TM2Error));
149
+ exports.InsufficientFeeError = InsufficientFeeError;
150
+ var TooManySignaturesError = /** @class */ (function (_super) {
151
+ __extends(TooManySignaturesError, _super);
152
+ function TooManySignaturesError(log) {
153
+ return _super.call(this, messages_1.TooManySignaturesErrorMessage, log) || this;
154
+ }
155
+ return TooManySignaturesError;
156
+ }(TM2Error));
157
+ exports.TooManySignaturesError = TooManySignaturesError;
158
+ var NoSignaturesError = /** @class */ (function (_super) {
159
+ __extends(NoSignaturesError, _super);
160
+ function NoSignaturesError(log) {
161
+ return _super.call(this, messages_1.NoSignaturesErrorMessage, log) || this;
162
+ }
163
+ return NoSignaturesError;
164
+ }(TM2Error));
165
+ exports.NoSignaturesError = NoSignaturesError;
166
+ var GasOverflowError = /** @class */ (function (_super) {
167
+ __extends(GasOverflowError, _super);
168
+ function GasOverflowError(log) {
169
+ return _super.call(this, messages_1.GasOverflowErrorMessage, log) || this;
170
+ }
171
+ return GasOverflowError;
172
+ }(TM2Error));
173
+ exports.GasOverflowError = GasOverflowError;
@@ -0,0 +1 @@
1
+ export * from './errors';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./errors"), exports);
@@ -0,0 +1,19 @@
1
+ declare const InternalErrorMessage = "internal error encountered";
2
+ declare const TxDecodeErrorMessage = "unable to decode tx";
3
+ declare const InvalidSequenceErrorMessage = "invalid sequence";
4
+ declare const UnauthorizedErrorMessage = "signature is unauthorized";
5
+ declare const InsufficientFundsErrorMessage = "insufficient funds";
6
+ declare const UnknownRequestErrorMessage = "unknown request";
7
+ declare const InvalidAddressErrorMessage = "invalid address";
8
+ declare const UnknownAddressErrorMessage = "unknown address";
9
+ declare const InvalidPubKeyErrorMessage = "invalid pubkey";
10
+ declare const InsufficientCoinsErrorMessage = "insufficient coins";
11
+ declare const InvalidCoinsErrorMessage = "invalid coins";
12
+ declare const InvalidGasWantedErrorMessage = "invalid gas wanted";
13
+ declare const OutOfGasErrorMessage = "out of gas";
14
+ declare const MemoTooLargeErrorMessage = "memo too large";
15
+ declare const InsufficientFeeErrorMessage = "insufficient fee";
16
+ declare const TooManySignaturesErrorMessage = "too many signatures";
17
+ declare const NoSignaturesErrorMessage = "no signatures";
18
+ declare const GasOverflowErrorMessage = "gas overflow";
19
+ export { InternalErrorMessage, TxDecodeErrorMessage, InvalidSequenceErrorMessage, UnauthorizedErrorMessage, InsufficientFundsErrorMessage, UnknownRequestErrorMessage, InvalidAddressErrorMessage, UnknownAddressErrorMessage, InvalidPubKeyErrorMessage, InsufficientCoinsErrorMessage, InvalidCoinsErrorMessage, InvalidGasWantedErrorMessage, OutOfGasErrorMessage, MemoTooLargeErrorMessage, InsufficientFeeErrorMessage, TooManySignaturesErrorMessage, NoSignaturesErrorMessage, GasOverflowErrorMessage, };
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ // Errors constructed from:
3
+ // https://github.com/gnolang/gno/blob/master/tm2/pkg/std/errors.go
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.GasOverflowErrorMessage = exports.NoSignaturesErrorMessage = exports.TooManySignaturesErrorMessage = exports.InsufficientFeeErrorMessage = exports.MemoTooLargeErrorMessage = exports.OutOfGasErrorMessage = exports.InvalidGasWantedErrorMessage = exports.InvalidCoinsErrorMessage = exports.InsufficientCoinsErrorMessage = exports.InvalidPubKeyErrorMessage = exports.UnknownAddressErrorMessage = exports.InvalidAddressErrorMessage = exports.UnknownRequestErrorMessage = exports.InsufficientFundsErrorMessage = exports.UnauthorizedErrorMessage = exports.InvalidSequenceErrorMessage = exports.TxDecodeErrorMessage = exports.InternalErrorMessage = void 0;
6
+ var InternalErrorMessage = 'internal error encountered';
7
+ exports.InternalErrorMessage = InternalErrorMessage;
8
+ var TxDecodeErrorMessage = 'unable to decode tx';
9
+ exports.TxDecodeErrorMessage = TxDecodeErrorMessage;
10
+ var InvalidSequenceErrorMessage = 'invalid sequence';
11
+ exports.InvalidSequenceErrorMessage = InvalidSequenceErrorMessage;
12
+ var UnauthorizedErrorMessage = 'signature is unauthorized';
13
+ exports.UnauthorizedErrorMessage = UnauthorizedErrorMessage;
14
+ var InsufficientFundsErrorMessage = 'insufficient funds';
15
+ exports.InsufficientFundsErrorMessage = InsufficientFundsErrorMessage;
16
+ var UnknownRequestErrorMessage = 'unknown request';
17
+ exports.UnknownRequestErrorMessage = UnknownRequestErrorMessage;
18
+ var InvalidAddressErrorMessage = 'invalid address';
19
+ exports.InvalidAddressErrorMessage = InvalidAddressErrorMessage;
20
+ var UnknownAddressErrorMessage = 'unknown address';
21
+ exports.UnknownAddressErrorMessage = UnknownAddressErrorMessage;
22
+ var InvalidPubKeyErrorMessage = 'invalid pubkey';
23
+ exports.InvalidPubKeyErrorMessage = InvalidPubKeyErrorMessage;
24
+ var InsufficientCoinsErrorMessage = 'insufficient coins';
25
+ exports.InsufficientCoinsErrorMessage = InsufficientCoinsErrorMessage;
26
+ var InvalidCoinsErrorMessage = 'invalid coins';
27
+ exports.InvalidCoinsErrorMessage = InvalidCoinsErrorMessage;
28
+ var InvalidGasWantedErrorMessage = 'invalid gas wanted';
29
+ exports.InvalidGasWantedErrorMessage = InvalidGasWantedErrorMessage;
30
+ var OutOfGasErrorMessage = 'out of gas';
31
+ exports.OutOfGasErrorMessage = OutOfGasErrorMessage;
32
+ var MemoTooLargeErrorMessage = 'memo too large';
33
+ exports.MemoTooLargeErrorMessage = MemoTooLargeErrorMessage;
34
+ var InsufficientFeeErrorMessage = 'insufficient fee';
35
+ exports.InsufficientFeeErrorMessage = InsufficientFeeErrorMessage;
36
+ var TooManySignaturesErrorMessage = 'too many signatures';
37
+ exports.TooManySignaturesErrorMessage = TooManySignaturesErrorMessage;
38
+ var NoSignaturesErrorMessage = 'no signatures';
39
+ exports.NoSignaturesErrorMessage = NoSignaturesErrorMessage;
40
+ var GasOverflowErrorMessage = 'gas overflow';
41
+ exports.GasOverflowErrorMessage = GasOverflowErrorMessage;
@@ -4,3 +4,4 @@ export * from './utility';
4
4
  export * from './websocket';
5
5
  export * from './endpoints';
6
6
  export * from './provider';
7
+ export * from './errors';
@@ -20,3 +20,4 @@ __exportStar(require("./utility"), exports);
20
20
  __exportStar(require("./websocket"), exports);
21
21
  __exportStar(require("./endpoints"), exports);
22
22
  __exportStar(require("./provider"), exports);
23
+ __exportStar(require("./errors"), exports);
@@ -1,5 +1,6 @@
1
1
  import { Provider } from '../provider';
2
2
  import { BlockInfo, BlockResult, ConsensusParams, NetworkInfo, Status } from '../types';
3
+ import { TransactionEndpoint } from '../endpoints';
3
4
  import { Tx } from '../../proto';
4
5
  /**
5
6
  * Provider based on JSON-RPC HTTP requests
@@ -22,6 +23,8 @@ export declare class JSONRPCProvider implements Provider {
22
23
  getAccountSequence(address: string, height?: number): Promise<number>;
23
24
  getAccountNumber(address: string, height?: number): Promise<number>;
24
25
  getStatus(): Promise<Status>;
25
- sendTransaction(tx: string): Promise<string>;
26
+ sendTransaction(tx: string, endpoint?: TransactionEndpoint.BROADCAST_TX_SYNC | TransactionEndpoint.BROADCAST_TX_COMMIT): Promise<string>;
27
+ private broadcastTxSync;
28
+ private broadcastTxCommit;
26
29
  waitForTransaction(hash: string, fromHeight?: number, timeout?: number): Promise<Tx>;
27
30
  }
@@ -40,6 +40,7 @@ exports.JSONRPCProvider = void 0;
40
40
  var services_1 = require("../../services");
41
41
  var utility_1 = require("../utility");
42
42
  var endpoints_1 = require("../endpoints");
43
+ var errors_utility_1 = require("../utility/errors.utility");
43
44
  /**
44
45
  * Provider based on JSON-RPC HTTP requests
45
46
  */
@@ -192,16 +193,68 @@ var JSONRPCProvider = /** @class */ (function () {
192
193
  });
193
194
  });
194
195
  };
195
- JSONRPCProvider.prototype.sendTransaction = function (tx) {
196
+ JSONRPCProvider.prototype.sendTransaction = function (tx, endpoint) {
196
197
  return __awaiter(this, void 0, void 0, function () {
197
- var response;
198
+ var queryEndpoint, request;
199
+ return __generator(this, function (_a) {
200
+ queryEndpoint = endpoint
201
+ ? endpoint
202
+ : endpoints_1.TransactionEndpoint.BROADCAST_TX_SYNC;
203
+ request = (0, utility_1.newRequest)(queryEndpoint, [tx]);
204
+ if (queryEndpoint == endpoints_1.TransactionEndpoint.BROADCAST_TX_SYNC) {
205
+ return [2 /*return*/, this.broadcastTxSync(request)];
206
+ }
207
+ // The endpoint is a commit broadcast
208
+ // (it waits for the transaction to be committed) to the chain before returning
209
+ return [2 /*return*/, this.broadcastTxCommit(request)];
210
+ });
211
+ });
212
+ };
213
+ JSONRPCProvider.prototype.broadcastTxSync = function (request) {
214
+ return __awaiter(this, void 0, void 0, function () {
215
+ var response, errType, log;
216
+ return __generator(this, function (_a) {
217
+ switch (_a.label) {
218
+ case 0: return [4 /*yield*/, services_1.RestService.post(this.baseURL, {
219
+ request: request,
220
+ })];
221
+ case 1:
222
+ response = _a.sent();
223
+ // Check if there is an immediate tx-broadcast error
224
+ // (originating from basic transaction checks like CheckTx)
225
+ if (response.error) {
226
+ errType = response.error.ABCIErrorKey;
227
+ log = response.Log;
228
+ throw (0, errors_utility_1.constructRequestError)(errType, log);
229
+ }
230
+ return [2 /*return*/, response.hash];
231
+ }
232
+ });
233
+ });
234
+ };
235
+ JSONRPCProvider.prototype.broadcastTxCommit = function (request) {
236
+ return __awaiter(this, void 0, void 0, function () {
237
+ var response, check_tx, deliver_tx, errType, log, errType, log;
198
238
  return __generator(this, function (_a) {
199
239
  switch (_a.label) {
200
240
  case 0: return [4 /*yield*/, services_1.RestService.post(this.baseURL, {
201
- request: (0, utility_1.newRequest)(endpoints_1.TransactionEndpoint.BROADCAST_TX_SYNC, [tx]),
241
+ request: request,
202
242
  })];
203
243
  case 1:
204
244
  response = _a.sent();
245
+ check_tx = response.check_tx, deliver_tx = response.deliver_tx;
246
+ // Check if there is an immediate tx-broadcast error (in CheckTx)
247
+ if (check_tx.ResponseBase.Error) {
248
+ errType = check_tx.ResponseBase.Error.ABCIErrorKey;
249
+ log = check_tx.ResponseBase.Log;
250
+ throw (0, errors_utility_1.constructRequestError)(errType, log);
251
+ }
252
+ // Check if there is a parsing error with the transaction (in DeliverTx)
253
+ if (deliver_tx.ResponseBase.Error) {
254
+ errType = deliver_tx.ResponseBase.Error.ABCIErrorKey;
255
+ log = deliver_tx.ResponseBase.Log;
256
+ throw (0, errors_utility_1.constructRequestError)(errType, log);
257
+ }
205
258
  return [2 /*return*/, response.hash];
206
259
  }
207
260
  });
@@ -46,6 +46,7 @@ var jest_mock_extended_1 = require("jest-mock-extended");
46
46
  var proto_1 = require("../../proto");
47
47
  var crypto_1 = require("@cosmjs/crypto");
48
48
  var endpoints_1 = require("../endpoints");
49
+ var messages_1 = require("../errors/messages");
49
50
  jest.mock('axios');
50
51
  var mockedAxios = axios_1.default;
51
52
  var mockURL = '127.0.0.1:26657';
@@ -108,26 +109,57 @@ describe('JSON-RPC Provider', function () {
108
109
  }
109
110
  });
110
111
  }); });
111
- test('sendTransaction', function () { return __awaiter(void 0, void 0, void 0, function () {
112
- var mockResult, provider, hash;
113
- return __generator(this, function (_a) {
114
- switch (_a.label) {
115
- case 0:
116
- mockResult = (0, jest_mock_extended_1.mock)();
117
- mockResult.hash = 'hash123';
118
- mockedAxios.post.mockResolvedValue({
119
- data: (0, utility_1.newResponse)(mockResult),
120
- });
121
- provider = new jsonrpc_1.JSONRPCProvider(mockURL);
122
- return [4 /*yield*/, provider.sendTransaction('encoded tx')];
123
- case 1:
124
- hash = _a.sent();
125
- expect(axios_1.default.post).toHaveBeenCalled();
126
- expect(hash).toEqual(mockResult.hash);
127
- return [2 /*return*/];
128
- }
129
- });
130
- }); });
112
+ describe('sendTransaction', function () {
113
+ var validResult = {
114
+ error: null,
115
+ data: null,
116
+ Log: '',
117
+ hash: 'hash123',
118
+ };
119
+ var mockError = '/std.UnauthorizedError';
120
+ var mockLog = 'random error message';
121
+ var invalidResult = {
122
+ error: {
123
+ ABCIErrorKey: mockError,
124
+ },
125
+ data: null,
126
+ Log: mockLog,
127
+ hash: '',
128
+ };
129
+ test.each([
130
+ [validResult, validResult.hash, '', ''],
131
+ [invalidResult, invalidResult.hash, messages_1.UnauthorizedErrorMessage, mockLog], // error out
132
+ ])('case %#', function (response, expectedHash, expectedErr, expectedLog) { return __awaiter(void 0, void 0, void 0, function () {
133
+ var provider, hash, e_1;
134
+ return __generator(this, function (_a) {
135
+ switch (_a.label) {
136
+ case 0:
137
+ mockedAxios.post.mockResolvedValue({
138
+ data: (0, utility_1.newResponse)(response),
139
+ });
140
+ _a.label = 1;
141
+ case 1:
142
+ _a.trys.push([1, 3, , 4]);
143
+ provider = new jsonrpc_1.JSONRPCProvider(mockURL);
144
+ return [4 /*yield*/, provider.sendTransaction('encoded tx')];
145
+ case 2:
146
+ hash = _a.sent();
147
+ expect(axios_1.default.post).toHaveBeenCalled();
148
+ expect(hash).toEqual(expectedHash);
149
+ if (expectedErr != '') {
150
+ fail('expected error');
151
+ }
152
+ return [3 /*break*/, 4];
153
+ case 3:
154
+ e_1 = _a.sent();
155
+ expect(e_1.message).toBe(expectedErr);
156
+ expect(e_1.log).toBe(expectedLog);
157
+ return [3 /*break*/, 4];
158
+ case 4: return [2 /*return*/];
159
+ }
160
+ });
161
+ }); });
162
+ });
131
163
  test('waitForTransaction', function () { return __awaiter(void 0, void 0, void 0, function () {
132
164
  var emptyBlock, tx, encodedTx, txHash, filledBlock, latestBlock, startBlock, mockStatus, responseMap, provider, receivedTx;
133
165
  return __generator(this, function (_a) {
@@ -337,7 +369,7 @@ describe('JSON-RPC Provider', function () {
337
369
  ],
338
370
  ['null', 0], // account doesn't exist
339
371
  ])('case %#', function (response, expected) { return __awaiter(void 0, void 0, void 0, function () {
340
- var mockABCIResponse, provider, accountNumber, e_1;
372
+ var mockABCIResponse, provider, accountNumber, e_2;
341
373
  return __generator(this, function (_a) {
342
374
  switch (_a.label) {
343
375
  case 0:
@@ -363,8 +395,8 @@ describe('JSON-RPC Provider', function () {
363
395
  expect(accountNumber).toBe(expected);
364
396
  return [3 /*break*/, 4];
365
397
  case 3:
366
- e_1 = _a.sent();
367
- expect(e_1.message).toContain('account is not initialized');
398
+ e_2 = _a.sent();
399
+ expect(e_2.message).toContain('account is not initialized');
368
400
  return [3 /*break*/, 4];
369
401
  case 4: return [2 /*return*/];
370
402
  }
@@ -1,5 +1,6 @@
1
1
  import { BlockInfo, BlockResult, ConsensusParams, NetworkInfo, Status } from './types';
2
2
  import { Tx } from '../proto';
3
+ import { TransactionEndpoint } from './endpoints';
3
4
  /**
4
5
  * Read-only abstraction for accessing blockchain data
5
6
  */
@@ -68,8 +69,10 @@ export interface Provider {
68
69
  * The transaction needs to be signed beforehand.
69
70
  * Returns the transaction hash
70
71
  * @param {string} tx the base64-encoded signed transaction
72
+ * @param {TransactionEndpoint} endpoint the transaction broadcast type (sync / commit).
73
+ * Defaults to broadcast_sync
71
74
  */
72
- sendTransaction(tx: string): Promise<string>;
75
+ sendTransaction(tx: string, endpoint?: TransactionEndpoint.BROADCAST_TX_SYNC | TransactionEndpoint.BROADCAST_TX_COMMIT): Promise<string>;
73
76
  /**
74
77
  * Waits for the transaction to be committed on the chain.
75
78
  * NOTE: This method will not take in the fromHeight parameter once
@@ -143,7 +143,7 @@ export interface EndBlock {
143
143
  export interface BeginBlock {
144
144
  ResponseBase: ABCIResponseBase;
145
145
  }
146
- export interface BroadcastTxResult {
146
+ export interface BroadcastTxSyncResult {
147
147
  error: {
148
148
  [key: string]: string;
149
149
  } | null;
@@ -151,4 +151,10 @@ export interface BroadcastTxResult {
151
151
  Log: string;
152
152
  hash: string;
153
153
  }
154
+ export interface BroadcastTxCommitResult {
155
+ check_tx: DeliverTx;
156
+ deliver_tx: DeliverTx;
157
+ hash: string;
158
+ height: string;
159
+ }
154
160
  export {};
@@ -0,0 +1,11 @@
1
+ import { TM2Error } from '../errors';
2
+ /**
3
+ * Constructs the appropriate Tendermint2
4
+ * error based on the error ID.
5
+ * Error IDs retrieved from:
6
+ * https://github.com/gnolang/gno/blob/64f0fd0fa44021a076e1453b1767fbc914ed3b66/tm2/pkg/std/package.go#L20C1-L38
7
+ * @param {string} errorID the proto ID of the error
8
+ * @param {string} [log] the log associated with the error, if any
9
+ * @returns {TM2Error}
10
+ */
11
+ export declare const constructRequestError: (errorID: string, log?: string) => TM2Error;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.constructRequestError = void 0;
4
+ var errors_1 = require("../errors");
5
+ /**
6
+ * Constructs the appropriate Tendermint2
7
+ * error based on the error ID.
8
+ * Error IDs retrieved from:
9
+ * https://github.com/gnolang/gno/blob/64f0fd0fa44021a076e1453b1767fbc914ed3b66/tm2/pkg/std/package.go#L20C1-L38
10
+ * @param {string} errorID the proto ID of the error
11
+ * @param {string} [log] the log associated with the error, if any
12
+ * @returns {TM2Error}
13
+ */
14
+ var constructRequestError = function (errorID, log) {
15
+ switch (errorID) {
16
+ case '/std.InternalError':
17
+ return new errors_1.InternalError(log);
18
+ case '/std.TxDecodeError':
19
+ return new errors_1.TxDecodeError(log);
20
+ case '/std.InvalidSequenceError':
21
+ return new errors_1.InvalidSequenceError(log);
22
+ case '/std.UnauthorizedError':
23
+ return new errors_1.UnauthorizedError(log);
24
+ case '/std.InsufficientFundsError':
25
+ return new errors_1.InsufficientFundsError(log);
26
+ case '/std.UnknownRequestError':
27
+ return new errors_1.UnknownRequestError(log);
28
+ case '/std.InvalidAddressError':
29
+ return new errors_1.InvalidAddressError(log);
30
+ case '/std.UnknownAddressError':
31
+ return new errors_1.UnknownAddressError(log);
32
+ case '/std.InvalidPubKeyError':
33
+ return new errors_1.InvalidPubKeyError(log);
34
+ case '/std.InsufficientCoinsError':
35
+ return new errors_1.InsufficientCoinsError(log);
36
+ case '/std.InvalidCoinsError':
37
+ return new errors_1.InvalidCoinsError(log);
38
+ case '/std.InvalidGasWantedError':
39
+ return new errors_1.InvalidGasWantedError(log);
40
+ case '/std.OutOfGasError':
41
+ return new errors_1.OutOfGasError(log);
42
+ case '/std.MemoTooLargeError':
43
+ return new errors_1.MemoTooLargeError(log);
44
+ case '/std.InsufficientFeeError':
45
+ return new errors_1.InsufficientFeeError(log);
46
+ case '/std.TooManySignaturesError':
47
+ return new errors_1.TooManySignaturesError(log);
48
+ case '/std.NoSignaturesError':
49
+ return new errors_1.NoSignaturesError(log);
50
+ case '/std.GasOverflowError':
51
+ return new errors_1.GasOverflowError(log);
52
+ default:
53
+ return new errors_1.TM2Error("unknown error: ".concat(errorID), log);
54
+ }
55
+ };
56
+ exports.constructRequestError = constructRequestError;
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { Provider } from '../provider';
3
3
  import { BlockInfo, BlockResult, ConsensusParams, NetworkInfo, RPCRequest, RPCResponse, Status } from '../types';
4
+ import { TransactionEndpoint } from '../endpoints';
4
5
  import { Tx } from '../../proto';
5
6
  /**
6
7
  * Provider based on WS JSON-RPC HTTP requests
@@ -50,6 +51,8 @@ export declare class WSProvider implements Provider {
50
51
  getAccountSequence(address: string, height?: number): Promise<number>;
51
52
  getAccountNumber(address: string, height?: number): Promise<number>;
52
53
  getStatus(): Promise<Status>;
53
- sendTransaction(tx: string): Promise<string>;
54
+ sendTransaction(tx: string, endpoint?: TransactionEndpoint.BROADCAST_TX_SYNC | TransactionEndpoint.BROADCAST_TX_COMMIT): Promise<string>;
55
+ private broadcastTxSync;
56
+ private broadcastTxCommit;
54
57
  waitForTransaction(hash: string, fromHeight?: number, timeout?: number): Promise<Tx>;
55
58
  }
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.WSProvider = void 0;
40
40
  var utility_1 = require("../utility");
41
41
  var endpoints_1 = require("../endpoints");
42
+ var errors_utility_1 = require("../utility/errors.utility");
42
43
  /**
43
44
  * Provider based on WS JSON-RPC HTTP requests
44
45
  */
@@ -282,15 +283,67 @@ var WSProvider = /** @class */ (function () {
282
283
  });
283
284
  });
284
285
  };
285
- WSProvider.prototype.sendTransaction = function (tx) {
286
+ WSProvider.prototype.sendTransaction = function (tx, endpoint) {
286
287
  return __awaiter(this, void 0, void 0, function () {
287
- var response;
288
+ var queryEndpoint, request;
289
+ return __generator(this, function (_a) {
290
+ queryEndpoint = endpoint
291
+ ? endpoint
292
+ : endpoints_1.TransactionEndpoint.BROADCAST_TX_SYNC;
293
+ request = (0, utility_1.newRequest)(queryEndpoint, [tx]);
294
+ if (queryEndpoint == endpoints_1.TransactionEndpoint.BROADCAST_TX_SYNC) {
295
+ return [2 /*return*/, this.broadcastTxSync(request)];
296
+ }
297
+ // The endpoint is a commit broadcast
298
+ // (it waits for the transaction to be committed) to the chain before returning
299
+ return [2 /*return*/, this.broadcastTxCommit(request)];
300
+ });
301
+ });
302
+ };
303
+ WSProvider.prototype.broadcastTxSync = function (request) {
304
+ return __awaiter(this, void 0, void 0, function () {
305
+ var response, broadcastResponse, errType, log;
306
+ return __generator(this, function (_a) {
307
+ switch (_a.label) {
308
+ case 0: return [4 /*yield*/, this.sendRequest(request)];
309
+ case 1:
310
+ response = _a.sent();
311
+ broadcastResponse = this.parseResponse(response);
312
+ // Check if there is an immediate tx-broadcast error
313
+ // (originating from basic transaction checks like CheckTx)
314
+ if (broadcastResponse.error) {
315
+ errType = broadcastResponse.error.ABCIErrorKey;
316
+ log = broadcastResponse.Log;
317
+ throw (0, errors_utility_1.constructRequestError)(errType, log);
318
+ }
319
+ return [2 /*return*/, broadcastResponse.hash];
320
+ }
321
+ });
322
+ });
323
+ };
324
+ WSProvider.prototype.broadcastTxCommit = function (request) {
325
+ return __awaiter(this, void 0, void 0, function () {
326
+ var response, broadcastResponse, check_tx, deliver_tx, errType, log, errType, log;
288
327
  return __generator(this, function (_a) {
289
328
  switch (_a.label) {
290
- case 0: return [4 /*yield*/, this.sendRequest((0, utility_1.newRequest)(endpoints_1.TransactionEndpoint.BROADCAST_TX_SYNC, [tx]))];
329
+ case 0: return [4 /*yield*/, this.sendRequest(request)];
291
330
  case 1:
292
331
  response = _a.sent();
293
- return [2 /*return*/, this.parseResponse(response).hash];
332
+ broadcastResponse = this.parseResponse(response);
333
+ check_tx = broadcastResponse.check_tx, deliver_tx = broadcastResponse.deliver_tx;
334
+ // Check if there is an immediate tx-broadcast error (in CheckTx)
335
+ if (check_tx.ResponseBase.Error) {
336
+ errType = check_tx.ResponseBase.Error.ABCIErrorKey;
337
+ log = check_tx.ResponseBase.Log;
338
+ throw (0, errors_utility_1.constructRequestError)(errType, log);
339
+ }
340
+ // Check if there is a parsing error with the transaction (in DeliverTx)
341
+ if (deliver_tx.ResponseBase.Error) {
342
+ errType = deliver_tx.ResponseBase.Error.ABCIErrorKey;
343
+ log = deliver_tx.ResponseBase.Log;
344
+ throw (0, errors_utility_1.constructRequestError)(errType, log);
345
+ }
346
+ return [2 /*return*/, broadcastResponse.hash];
294
347
  }
295
348
  });
296
349
  });
@@ -45,6 +45,7 @@ var jest_websocket_mock_1 = __importDefault(require("jest-websocket-mock"));
45
45
  var proto_1 = require("../../proto");
46
46
  var crypto_1 = require("@cosmjs/crypto");
47
47
  var endpoints_1 = require("../endpoints");
48
+ var messages_1 = require("../errors/messages");
48
49
  describe('WS Provider', function () {
49
50
  var wsPort = 8545;
50
51
  var wsHost = 'localhost';
@@ -336,30 +337,54 @@ describe('WS Provider', function () {
336
337
  }
337
338
  });
338
339
  }); });
339
- test('sendTransaction', function () { return __awaiter(void 0, void 0, void 0, function () {
340
- var mockResult, hash;
341
- return __generator(this, function (_a) {
342
- switch (_a.label) {
343
- case 0:
344
- mockResult = {
345
- error: null,
346
- data: null,
347
- Log: '',
348
- hash: 'hash123',
349
- };
350
- // Set the response
351
- return [4 /*yield*/, setHandler(mockResult)];
352
- case 1:
353
- // Set the response
354
- _a.sent();
355
- return [4 /*yield*/, wsProvider.sendTransaction('encoded tx')];
356
- case 2:
357
- hash = _a.sent();
358
- expect(hash).toBe(mockResult.hash);
359
- return [2 /*return*/];
360
- }
361
- });
362
- }); });
340
+ describe('sendTransaction', function () {
341
+ var validResult = {
342
+ error: null,
343
+ data: null,
344
+ Log: '',
345
+ hash: 'hash123',
346
+ };
347
+ var mockError = '/std.UnauthorizedError';
348
+ var mockLog = 'random error message';
349
+ var invalidResult = {
350
+ error: {
351
+ ABCIErrorKey: mockError,
352
+ },
353
+ data: null,
354
+ Log: mockLog,
355
+ hash: '',
356
+ };
357
+ test.each([
358
+ [validResult, validResult.hash, '', ''],
359
+ [invalidResult, invalidResult.hash, messages_1.UnauthorizedErrorMessage, mockLog], // error out
360
+ ])('case %#', function (response, expectedHash, expectedErr, expectedLog) { return __awaiter(void 0, void 0, void 0, function () {
361
+ var hash, e_2;
362
+ return __generator(this, function (_a) {
363
+ switch (_a.label) {
364
+ case 0: return [4 /*yield*/, setHandler(response)];
365
+ case 1:
366
+ _a.sent();
367
+ _a.label = 2;
368
+ case 2:
369
+ _a.trys.push([2, 4, , 5]);
370
+ return [4 /*yield*/, wsProvider.sendTransaction('encoded tx')];
371
+ case 3:
372
+ hash = _a.sent();
373
+ expect(hash).toEqual(expectedHash);
374
+ if (expectedErr != '') {
375
+ fail('expected error');
376
+ }
377
+ return [3 /*break*/, 5];
378
+ case 4:
379
+ e_2 = _a.sent();
380
+ expect(e_2.message).toBe(expectedErr);
381
+ expect(e_2.log).toBe(expectedLog);
382
+ return [3 /*break*/, 5];
383
+ case 5: return [2 /*return*/];
384
+ }
385
+ });
386
+ }); });
387
+ });
363
388
  var getEmptyBlockInfo = function () {
364
389
  var emptyHeader = {
365
390
  version: '',
@@ -60,8 +60,8 @@ var KeySigner = /** @class */ (function () {
60
60
  * @param {string} addressPrefix the address prefix
61
61
  */
62
62
  function KeySigner(privateKey, publicKey, addressPrefix) {
63
- if (addressPrefix === void 0) { addressPrefix = utility_1.defaultAddressPrefix; }
64
63
  var _this = this;
64
+ if (addressPrefix === void 0) { addressPrefix = utility_1.defaultAddressPrefix; }
65
65
  this.getAddress = function () { return __awaiter(_this, void 0, void 0, function () {
66
66
  return __generator(this, function (_a) {
67
67
  return [2 /*return*/, (0, amino_1.pubkeyToAddress)((0, amino_1.encodeSecp256k1Pubkey)(crypto_1.Secp256k1.compressPubkey(this.publicKey)), this.addressPrefix)];
@@ -51,8 +51,8 @@ var LedgerSigner = /** @class */ (function () {
51
51
  * @param {string} addressPrefix the address prefix
52
52
  */
53
53
  function LedgerSigner(connector, accountIndex, addressPrefix) {
54
- if (addressPrefix === void 0) { addressPrefix = utility_1.defaultAddressPrefix; }
55
54
  var _this = this;
55
+ if (addressPrefix === void 0) { addressPrefix = utility_1.defaultAddressPrefix; }
56
56
  this.getAddress = function () { return __awaiter(_this, void 0, void 0, function () {
57
57
  var compressedPubKey;
58
58
  return __generator(this, function (_a) {
@@ -1,4 +1,4 @@
1
- import { Provider } from '../provider';
1
+ import { Provider, TransactionEndpoint } from '../provider';
2
2
  import { Signer } from './signer';
3
3
  import { LedgerConnector } from '@cosmjs/ledger-amino';
4
4
  import { Any, Tx } from '../proto';
@@ -85,8 +85,10 @@ export declare class Wallet {
85
85
  * The transaction needs to be signed beforehand.
86
86
  * Returns the transaction hash (base-64)
87
87
  * @param {Tx} tx the signed transaction
88
+ * @param {TransactionEndpoint} endpoint the transaction broadcast type (sync / commit).
89
+ * Defaults to broadcast_sync
88
90
  */
89
- sendTransaction: (tx: Tx) => Promise<string>;
91
+ sendTransaction: (tx: Tx, endpoint?: TransactionEndpoint.BROADCAST_TX_SYNC | TransactionEndpoint.BROADCAST_TX_COMMIT) => Promise<string>;
90
92
  /**
91
93
  * Returns the associated signer
92
94
  */
@@ -70,7 +70,7 @@ var signdoc_1 = require("@cosmjs/amino/build/signdoc");
70
70
  * Wallet is a single account abstraction
71
71
  * that can interact with the blockchain
72
72
  */
73
- var Wallet = exports.Wallet = /** @class */ (function () {
73
+ var Wallet = /** @class */ (function () {
74
74
  function Wallet() {
75
75
  var _this = this;
76
76
  /**
@@ -248,8 +248,10 @@ var Wallet = exports.Wallet = /** @class */ (function () {
248
248
  * The transaction needs to be signed beforehand.
249
249
  * Returns the transaction hash (base-64)
250
250
  * @param {Tx} tx the signed transaction
251
+ * @param {TransactionEndpoint} endpoint the transaction broadcast type (sync / commit).
252
+ * Defaults to broadcast_sync
251
253
  */
252
- this.sendTransaction = function (tx) { return __awaiter(_this, void 0, void 0, function () {
254
+ this.sendTransaction = function (tx, endpoint) { return __awaiter(_this, void 0, void 0, function () {
253
255
  var encodedTx;
254
256
  return __generator(this, function (_b) {
255
257
  if (!this.provider) {
@@ -257,7 +259,7 @@ var Wallet = exports.Wallet = /** @class */ (function () {
257
259
  }
258
260
  encodedTx = (0, provider_1.uint8ArrayToBase64)(proto_1.Tx.encode(tx).finish());
259
261
  // Send the encoded transaction
260
- return [2 /*return*/, this.provider.sendTransaction(encodedTx)];
262
+ return [2 /*return*/, this.provider.sendTransaction(encodedTx, endpoint)];
261
263
  });
262
264
  }); };
263
265
  /**
@@ -275,14 +277,13 @@ var Wallet = exports.Wallet = /** @class */ (function () {
275
277
  * @param {AccountWalletOption} options the account options
276
278
  */
277
279
  Wallet.createRandom = function (options) { return __awaiter(void 0, void 0, void 0, function () {
278
- var publicKey, privateKey, wallet;
279
- var _b;
280
+ var _b, publicKey, privateKey, wallet;
280
281
  return __generator(_a, function (_c) {
281
282
  switch (_c.label) {
282
283
  case 0: return [4 /*yield*/, (0, utility_1.generateKeyPair)((0, bip39_1.entropyToMnemonic)((0, utility_1.generateEntropy)()), 0)];
283
284
  case 1:
284
- publicKey = (_b = _c.sent(), _b.publicKey), privateKey = _b.privateKey;
285
- wallet = new Wallet();
285
+ _b = _c.sent(), publicKey = _b.publicKey, privateKey = _b.privateKey;
286
+ wallet = new _a();
286
287
  wallet.signer = new key_1.KeySigner(privateKey, crypto_1.Secp256k1.compressPubkey(publicKey), options === null || options === void 0 ? void 0 : options.addressPrefix);
287
288
  return [2 /*return*/, wallet];
288
289
  }
@@ -294,14 +295,13 @@ var Wallet = exports.Wallet = /** @class */ (function () {
294
295
  * @param {CreateWalletOptions} options the wallet generation options
295
296
  */
296
297
  Wallet.fromMnemonic = function (mnemonic, options) { return __awaiter(void 0, void 0, void 0, function () {
297
- var publicKey, privateKey, wallet;
298
- var _b;
298
+ var _b, publicKey, privateKey, wallet;
299
299
  return __generator(_a, function (_c) {
300
300
  switch (_c.label) {
301
301
  case 0: return [4 /*yield*/, (0, utility_1.generateKeyPair)(mnemonic, options === null || options === void 0 ? void 0 : options.accountIndex)];
302
302
  case 1:
303
- publicKey = (_b = _c.sent(), _b.publicKey), privateKey = _b.privateKey;
304
- wallet = new Wallet();
303
+ _b = _c.sent(), publicKey = _b.publicKey, privateKey = _b.privateKey;
304
+ wallet = new _a();
305
305
  wallet.signer = new key_1.KeySigner(privateKey, crypto_1.Secp256k1.compressPubkey(publicKey), options === null || options === void 0 ? void 0 : options.addressPrefix);
306
306
  return [2 /*return*/, wallet];
307
307
  }
@@ -319,7 +319,7 @@ var Wallet = exports.Wallet = /** @class */ (function () {
319
319
  case 0: return [4 /*yield*/, crypto_1.Secp256k1.makeKeypair(privateKey)];
320
320
  case 1:
321
321
  publicKey = (_b.sent()).pubkey;
322
- wallet = new Wallet();
322
+ wallet = new _a();
323
323
  wallet.signer = new key_1.KeySigner(privateKey, crypto_1.Secp256k1.compressPubkey(publicKey), options === null || options === void 0 ? void 0 : options.addressPrefix);
324
324
  return [2 /*return*/, wallet];
325
325
  }
@@ -332,9 +332,10 @@ var Wallet = exports.Wallet = /** @class */ (function () {
332
332
  */
333
333
  Wallet.fromLedger = function (connector, options) {
334
334
  var _b;
335
- var wallet = new Wallet();
335
+ var wallet = new _a();
336
336
  wallet.signer = new ledger_1.LedgerSigner(connector, (_b = options === null || options === void 0 ? void 0 : options.accountIndex) !== null && _b !== void 0 ? _b : 0, options === null || options === void 0 ? void 0 : options.addressPrefix);
337
337
  return wallet;
338
338
  };
339
339
  return Wallet;
340
340
  }());
341
+ exports.Wallet = Wallet;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gnolang/tm2-js-client",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Tendermint2 JS / TS Client",
5
5
  "main": "./bin/index.js",
6
6
  "repository": {
@@ -33,12 +33,12 @@
33
33
  "@typescript-eslint/eslint-plugin": "^5.59.5",
34
34
  "@typescript-eslint/parser": "^5.59.5",
35
35
  "eslint": "^8.40.0",
36
- "eslint-config-prettier": "^8.8.0",
37
- "eslint-plugin-prettier": "^4.2.1",
36
+ "eslint-config-prettier": "^9.0.0",
37
+ "eslint-plugin-prettier": "5.0.0",
38
38
  "jest": "^29.5.0",
39
39
  "jest-mock-extended": "^3.0.4",
40
40
  "jest-websocket-mock": "^2.4.0",
41
- "prettier": "^2.8.8",
41
+ "prettier": "^3.0.0",
42
42
  "ts-jest": "^29.1.0",
43
43
  "ts-proto": "^1.147.2",
44
44
  "typescript": "^5.0.4"