@firmachain/firma-js 0.2.35 → 0.2.36
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.
|
@@ -27,5 +27,6 @@ export declare class ContractService {
|
|
|
27
27
|
private getSignedTxAddContractLog;
|
|
28
28
|
addContractLog(wallet: FirmaWalletService, contractHash: string, timeStamp: number, eventName: string, ownerAddress: string, jsonString: string, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
29
29
|
getUnsignedTxAddContractLog(wallet: FirmaWalletService, contractHash: string, timeStamp: number, eventName: string, ownerAddress: string, jsonString: string): Promise<EncodeObject>;
|
|
30
|
+
getGasEstimationSignAndBroadcast(wallet: FirmaWalletService, msgList: EncodeObject[], txMisc?: TxMisc): Promise<number>;
|
|
30
31
|
signAndBroadcast(wallet: FirmaWalletService, msgList: EncodeObject[], txMisc?: TxMisc): Promise<BroadcastTxResponse>;
|
|
31
32
|
}
|
|
@@ -386,10 +386,33 @@ var ContractService = /** @class */ (function () {
|
|
|
386
386
|
});
|
|
387
387
|
});
|
|
388
388
|
};
|
|
389
|
+
ContractService.prototype.getGasEstimationSignAndBroadcast = function (wallet, msgList, txMisc) {
|
|
390
|
+
if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
|
|
391
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
392
|
+
var contractTxClient, txRaw, error_16;
|
|
393
|
+
return __generator(this, function (_a) {
|
|
394
|
+
switch (_a.label) {
|
|
395
|
+
case 0:
|
|
396
|
+
_a.trys.push([0, 3, , 4]);
|
|
397
|
+
contractTxClient = new contract_1.ContractTxClient(wallet, this.config.rpcAddress);
|
|
398
|
+
return [4 /*yield*/, contractTxClient.sign(msgList, (0, FirmaUtil_1.getSignAndBroadcastOption)(this.config.denom, txMisc))];
|
|
399
|
+
case 1:
|
|
400
|
+
txRaw = _a.sent();
|
|
401
|
+
return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
|
|
402
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
403
|
+
case 3:
|
|
404
|
+
error_16 = _a.sent();
|
|
405
|
+
FirmaUtil_1.FirmaUtil.printLog(error_16);
|
|
406
|
+
throw error_16;
|
|
407
|
+
case 4: return [2 /*return*/];
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
};
|
|
389
412
|
ContractService.prototype.signAndBroadcast = function (wallet, msgList, txMisc) {
|
|
390
413
|
if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
|
|
391
414
|
return __awaiter(this, void 0, void 0, function () {
|
|
392
|
-
var contractTxClient,
|
|
415
|
+
var contractTxClient, error_17;
|
|
393
416
|
return __generator(this, function (_a) {
|
|
394
417
|
switch (_a.label) {
|
|
395
418
|
case 0:
|
|
@@ -398,9 +421,9 @@ var ContractService = /** @class */ (function () {
|
|
|
398
421
|
return [4 /*yield*/, contractTxClient.signAndBroadcast(msgList, (0, FirmaUtil_1.getSignAndBroadcastOption)(this.config.denom, txMisc))];
|
|
399
422
|
case 1: return [2 /*return*/, _a.sent()];
|
|
400
423
|
case 2:
|
|
401
|
-
|
|
402
|
-
FirmaUtil_1.FirmaUtil.printLog(
|
|
403
|
-
throw
|
|
424
|
+
error_17 = _a.sent();
|
|
425
|
+
FirmaUtil_1.FirmaUtil.printLog(error_17);
|
|
426
|
+
throw error_17;
|
|
404
427
|
case 3: return [2 /*return*/];
|
|
405
428
|
}
|
|
406
429
|
});
|
|
@@ -43,6 +43,7 @@ exports.FirmaCosmWasmService = void 0;
|
|
|
43
43
|
var cosmwasm_1 = require("./firmachain/cosmwasm");
|
|
44
44
|
var encoding_1 = require("@cosmjs/encoding");
|
|
45
45
|
var FirmaUtil_1 = require("./FirmaUtil");
|
|
46
|
+
var pako_1 = __importDefault(require("pako"));
|
|
46
47
|
var long_1 = __importDefault(require("long"));
|
|
47
48
|
var FirmaCosmWasmService = /** @class */ (function () {
|
|
48
49
|
function FirmaCosmWasmService(config) {
|
|
@@ -449,7 +450,7 @@ var FirmaCosmWasmService = /** @class */ (function () {
|
|
|
449
450
|
FirmaCosmWasmService.prototype.getSignedTxStoreCode = function (wallet, wasmCode, accessConfig, txMisc) {
|
|
450
451
|
if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
|
|
451
452
|
return __awaiter(this, void 0, void 0, function () {
|
|
452
|
-
var address, message, txClient, error_18;
|
|
453
|
+
var address, compressed, message, txClient, error_18;
|
|
453
454
|
return __generator(this, function (_a) {
|
|
454
455
|
switch (_a.label) {
|
|
455
456
|
case 0:
|
|
@@ -457,7 +458,8 @@ var FirmaCosmWasmService = /** @class */ (function () {
|
|
|
457
458
|
return [4 /*yield*/, wallet.getAddress()];
|
|
458
459
|
case 1:
|
|
459
460
|
address = _a.sent();
|
|
460
|
-
|
|
461
|
+
compressed = pako_1.default.gzip(wasmCode, { level: 9 });
|
|
462
|
+
message = cosmwasm_1.CosmWasmTxClient.msgStoreCode({ sender: address, wasmByteCode: compressed, instantiatePermission: accessConfig });
|
|
461
463
|
txClient = new cosmwasm_1.CosmWasmTxClient(wallet, this.config.rpcAddress);
|
|
462
464
|
return [4 /*yield*/, txClient.sign([message], (0, FirmaUtil_1.getSignAndBroadcastOption)(this.config.denom, txMisc))];
|
|
463
465
|
case 2: return [2 /*return*/, _a.sent()];
|
package/dist/sdk/FirmaUtil.js
CHANGED
|
@@ -230,7 +230,7 @@ var FirmaUtil = /** @class */ (function () {
|
|
|
230
230
|
return [4 /*yield*/, queryClient.queryEstimateGas(hexTx)];
|
|
231
231
|
case 1:
|
|
232
232
|
gas = _a.sent();
|
|
233
|
-
multiplier = 1.
|
|
233
|
+
multiplier = 1.15;
|
|
234
234
|
return [2 /*return*/, Math.ceil(gas * multiplier)];
|
|
235
235
|
case 2:
|
|
236
236
|
error_2 = _a.sent();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firmachain/firma-js",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.36",
|
|
4
4
|
"description": "The Official FirmaChain Javascript SDK written in Typescript",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -36,10 +36,12 @@
|
|
|
36
36
|
"@cosmjs/math": "^0.26.0",
|
|
37
37
|
"@cosmjs/proto-signing": "^0.25.6",
|
|
38
38
|
"@cosmjs/tendermint-rpc": "^0.26.0",
|
|
39
|
+
"@types/pako": "^2.0.0",
|
|
39
40
|
"axios": "^0.21.4",
|
|
40
41
|
"cosmjs-types": "^0.2.0",
|
|
41
42
|
"crypto-js": "^4.1.1",
|
|
42
43
|
"ipfs-http-client": "^52.0.5",
|
|
44
|
+
"pako": "^2.0.2",
|
|
43
45
|
"protobufjs": "^6.10.2",
|
|
44
46
|
"readline-sync": "^1.4.10"
|
|
45
47
|
},
|