@gnolang/tm2-js-client 1.2.2 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/proto/google/protobuf/any.d.ts +20 -14
- package/bin/proto/google/protobuf/any.js +29 -44
- package/bin/proto/tm2/abci.d.ts +37 -0
- package/bin/proto/tm2/abci.js +265 -0
- package/bin/proto/tm2/tx.d.ts +16 -36
- package/bin/proto/tm2/tx.js +79 -93
- package/bin/provider/jsonrpc/jsonrpc.d.ts +1 -1
- package/bin/provider/jsonrpc/jsonrpc.js +24 -3
- package/bin/provider/jsonrpc/jsonrpc.test.js +36 -4
- package/bin/provider/utility/provider.utility.d.ts +8 -1
- package/bin/provider/utility/provider.utility.js +32 -3
- package/bin/provider/utility/requests.utility.d.ts +2 -0
- package/bin/provider/utility/requests.utility.js +6 -1
- package/bin/provider/websocket/ws.d.ts +1 -1
- package/bin/provider/websocket/ws.js +27 -2
- package/bin/provider/websocket/ws.test.js +49 -4
- package/bin/wallet/wallet.d.ts +6 -0
- package/bin/wallet/wallet.js +13 -0
- package/package.json +4 -4
|
@@ -37,9 +37,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.WSProvider = void 0;
|
|
40
|
+
var proto_1 = require("../../proto");
|
|
41
|
+
var endpoints_1 = require("../endpoints");
|
|
40
42
|
var types_1 = require("../types");
|
|
41
43
|
var utility_1 = require("../utility");
|
|
42
|
-
var endpoints_1 = require("../endpoints");
|
|
43
44
|
var errors_utility_1 = require("../utility/errors.utility");
|
|
44
45
|
/**
|
|
45
46
|
* Provider based on WS JSON-RPC HTTP requests
|
|
@@ -144,7 +145,31 @@ var WSProvider = /** @class */ (function () {
|
|
|
144
145
|
return response.result;
|
|
145
146
|
};
|
|
146
147
|
WSProvider.prototype.estimateGas = function (tx) {
|
|
147
|
-
return
|
|
148
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
149
|
+
var encodedTx, response, abciResponse, simulateResult, resultErrorKey;
|
|
150
|
+
var _a, _b;
|
|
151
|
+
return __generator(this, function (_c) {
|
|
152
|
+
switch (_c.label) {
|
|
153
|
+
case 0:
|
|
154
|
+
encodedTx = (0, utility_1.uint8ArrayToBase64)(proto_1.Tx.encode(tx).finish());
|
|
155
|
+
return [4 /*yield*/, this.sendRequest((0, utility_1.newRequest)(endpoints_1.ABCIEndpoint.ABCI_QUERY, [
|
|
156
|
+
".app/simulate",
|
|
157
|
+
"".concat(encodedTx),
|
|
158
|
+
'0', // Height; not supported > 0 for now
|
|
159
|
+
false,
|
|
160
|
+
]))];
|
|
161
|
+
case 1:
|
|
162
|
+
response = _c.sent();
|
|
163
|
+
abciResponse = this.parseResponse(response);
|
|
164
|
+
simulateResult = (0, utility_1.extractSimulateFromResponse)(abciResponse);
|
|
165
|
+
resultErrorKey = (_b = (_a = simulateResult.responseBase) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.typeUrl;
|
|
166
|
+
if (resultErrorKey) {
|
|
167
|
+
throw (0, errors_utility_1.constructRequestError)(resultErrorKey);
|
|
168
|
+
}
|
|
169
|
+
return [2 /*return*/, simulateResult.gasUsed.toInt()];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
});
|
|
148
173
|
};
|
|
149
174
|
WSProvider.prototype.getBalance = function (address, denomination, height) {
|
|
150
175
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -39,14 +39,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
var
|
|
43
|
-
var utility_1 = require("../utility");
|
|
44
|
-
var ws_1 = require("./ws");
|
|
42
|
+
var crypto_1 = require("@cosmjs/crypto");
|
|
45
43
|
var jest_websocket_mock_1 = __importDefault(require("jest-websocket-mock"));
|
|
44
|
+
var long_1 = __importDefault(require("long"));
|
|
46
45
|
var proto_1 = require("../../proto");
|
|
47
|
-
var crypto_1 = require("@cosmjs/crypto");
|
|
48
46
|
var endpoints_1 = require("../endpoints");
|
|
49
47
|
var messages_1 = require("../errors/messages");
|
|
48
|
+
var types_1 = require("../types");
|
|
49
|
+
var utility_1 = require("../utility");
|
|
50
|
+
var ws_1 = require("./ws");
|
|
50
51
|
describe('WS Provider', function () {
|
|
51
52
|
var wsPort = 8545;
|
|
52
53
|
var wsHost = 'localhost';
|
|
@@ -102,6 +103,50 @@ describe('WS Provider', function () {
|
|
|
102
103
|
wsProvider.closeConnection();
|
|
103
104
|
jest_websocket_mock_1.default.clean();
|
|
104
105
|
});
|
|
106
|
+
test('estimateGas', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
107
|
+
var tx, expectedEstimation, mockSimulateResponseVale, mockABCIResponse, estimation;
|
|
108
|
+
return __generator(this, function (_a) {
|
|
109
|
+
switch (_a.label) {
|
|
110
|
+
case 0:
|
|
111
|
+
tx = proto_1.Tx.fromJSON({
|
|
112
|
+
signatures: [],
|
|
113
|
+
fee: {
|
|
114
|
+
gasFee: '',
|
|
115
|
+
gasWanted: new long_1.default(0),
|
|
116
|
+
},
|
|
117
|
+
messages: [],
|
|
118
|
+
memo: '',
|
|
119
|
+
});
|
|
120
|
+
expectedEstimation = 44900;
|
|
121
|
+
mockSimulateResponseVale = 'CiMiIW1zZzowLHN1Y2Nlc3M6dHJ1ZSxsb2c6LGV2ZW50czpbXRCAiXoYyL0F';
|
|
122
|
+
mockABCIResponse = {
|
|
123
|
+
response: {
|
|
124
|
+
Height: '',
|
|
125
|
+
Key: '',
|
|
126
|
+
Proof: null,
|
|
127
|
+
Value: mockSimulateResponseVale,
|
|
128
|
+
ResponseBase: {
|
|
129
|
+
Log: '',
|
|
130
|
+
Info: '',
|
|
131
|
+
Error: null,
|
|
132
|
+
Events: null,
|
|
133
|
+
Data: '',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
// Set the response
|
|
138
|
+
return [4 /*yield*/, setHandler(mockABCIResponse)];
|
|
139
|
+
case 1:
|
|
140
|
+
// Set the response
|
|
141
|
+
_a.sent();
|
|
142
|
+
return [4 /*yield*/, wsProvider.estimateGas(tx)];
|
|
143
|
+
case 2:
|
|
144
|
+
estimation = _a.sent();
|
|
145
|
+
expect(estimation).toEqual(expectedEstimation);
|
|
146
|
+
return [2 /*return*/];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}); });
|
|
105
150
|
test('getNetwork', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
106
151
|
var mockInfo, info;
|
|
107
152
|
return __generator(this, function (_a) {
|
package/bin/wallet/wallet.d.ts
CHANGED
|
@@ -20,6 +20,12 @@ export declare class Wallet {
|
|
|
20
20
|
* @param {AccountWalletOption} options the account options
|
|
21
21
|
*/
|
|
22
22
|
static createRandom: (options?: AccountWalletOption) => Promise<Wallet>;
|
|
23
|
+
/**
|
|
24
|
+
* Generates a custom signer-based wallet
|
|
25
|
+
* @param {Signer} signer the custom signer implementing the Signer interface
|
|
26
|
+
* @param {CreateWalletOptions} options the wallet generation options
|
|
27
|
+
*/
|
|
28
|
+
static fromSigner: (signer: Signer) => Promise<Wallet>;
|
|
23
29
|
/**
|
|
24
30
|
* Generates a bip39 mnemonic-based wallet
|
|
25
31
|
* @param {string} mnemonic the bip39 mnemonic
|
package/bin/wallet/wallet.js
CHANGED
|
@@ -289,6 +289,19 @@ var Wallet = /** @class */ (function () {
|
|
|
289
289
|
}
|
|
290
290
|
});
|
|
291
291
|
}); };
|
|
292
|
+
/**
|
|
293
|
+
* Generates a custom signer-based wallet
|
|
294
|
+
* @param {Signer} signer the custom signer implementing the Signer interface
|
|
295
|
+
* @param {CreateWalletOptions} options the wallet generation options
|
|
296
|
+
*/
|
|
297
|
+
Wallet.fromSigner = function (signer) { return __awaiter(void 0, void 0, void 0, function () {
|
|
298
|
+
var wallet;
|
|
299
|
+
return __generator(_a, function (_b) {
|
|
300
|
+
wallet = new _a();
|
|
301
|
+
wallet.signer = signer;
|
|
302
|
+
return [2 /*return*/, wallet];
|
|
303
|
+
});
|
|
304
|
+
}); };
|
|
292
305
|
/**
|
|
293
306
|
* Generates a bip39 mnemonic-based wallet
|
|
294
307
|
* @param {string} mnemonic the bip39 mnemonic
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gnolang/tm2-js-client",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "Tendermint2 JS / TS Client",
|
|
5
5
|
"main": "./bin/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"registry": "https://registry.npmjs.org/"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@eslint/js": "^9.
|
|
29
|
+
"@eslint/js": "^9.11.1",
|
|
30
30
|
"@types/jest": "^29.5.12",
|
|
31
31
|
"@types/long": "^5.0.0",
|
|
32
|
-
"@types/node": "^22.
|
|
32
|
+
"@types/node": "^22.7.4",
|
|
33
33
|
"@types/ws": "^8.5.11",
|
|
34
34
|
"@typescript-eslint/eslint-plugin": "^8.6.0",
|
|
35
35
|
"@typescript-eslint/parser": "^8.6.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"ts-jest": "^29.2.2",
|
|
46
46
|
"ts-proto": "^2.2.0",
|
|
47
47
|
"typescript": "^5.6.2",
|
|
48
|
-
"typescript-eslint": "^8.
|
|
48
|
+
"typescript-eslint": "^8.7.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@cosmjs/amino": "^0.32.4",
|