@firmachain/firma-js 0.2.35 → 0.2.38

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.
@@ -14,8 +14,8 @@ export declare class FirmaAuthzService {
14
14
  private getSignedTxExecuteAllowance;
15
15
  getGasEstimationGrantSendAuthorization(wallet: FirmaWalletService, granteeAddress: string, expirationDate: Date, maxTokens: number, txMisc?: TxMisc): Promise<number>;
16
16
  grantSendAuthorization(wallet: FirmaWalletService, granteeAddress: string, expirationDate: Date, maxTokens: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
17
- getGasEstimationGrantStakeAuthorization(wallet: FirmaWalletService, granteeAddress: string, validatorAddress: string, type: AuthorizationType, expirationDate: Date, maxTokens?: number, txMisc?: TxMisc): Promise<number>;
18
- grantStakeAuthorization(wallet: FirmaWalletService, granteeAddress: string, validatorAddress: string, type: AuthorizationType, expirationDate: Date, maxTokens?: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
17
+ getGasEstimationGrantStakeAuthorization(wallet: FirmaWalletService, granteeAddress: string, validatorAddressList: string[], type: AuthorizationType, expirationDate: Date, maxTokens?: number, txMisc?: TxMisc): Promise<number>;
18
+ grantStakeAuthorization(wallet: FirmaWalletService, granteeAddress: string, validatorAddressList: string[], type: AuthorizationType, expirationDate: Date, maxTokens?: number, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
19
19
  getGasEstimationGrantGenericAuthorization(wallet: FirmaWalletService, granteeAddress: string, msg: string, expirationDate: Date, txMisc?: TxMisc): Promise<number>;
20
20
  grantGenericAuthorization(wallet: FirmaWalletService, granteeAddress: string, msg: string, expirationDate: Date, txMisc?: TxMisc): Promise<BroadcastTxResponse>;
21
21
  getGasEstimationRevokeGenericAuthorization(wallet: FirmaWalletService, granteeAddress: string, msgType: string, txMisc?: TxMisc): Promise<number>;
@@ -84,7 +84,7 @@ var FirmaAuthzService = /** @class */ (function () {
84
84
  });
85
85
  });
86
86
  };
87
- FirmaAuthzService.prototype.getSignedTxGrantStakeAutorization = function (wallet, granteeAddress, validatorAddress, type, maxTokens, expirationDate, txMisc) {
87
+ FirmaAuthzService.prototype.getSignedTxGrantStakeAutorization = function (wallet, granteeAddress, validatorAddressList, type, maxTokens, expirationDate, txMisc) {
88
88
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
89
89
  return __awaiter(this, void 0, void 0, function () {
90
90
  var address, authorization, timestamp, message, authzTxClient, error_2;
@@ -98,7 +98,7 @@ var FirmaAuthzService = /** @class */ (function () {
98
98
  authorization = any_1.Any.fromPartial({
99
99
  typeUrl: "/cosmos.staking.v1beta1.StakeAuthorization",
100
100
  value: Uint8Array.from(AuthzTxTypes_1.StakeAuthorization.encode(AuthzTxTypes_1.StakeAuthorization.fromPartial({
101
- allowList: { address: [validatorAddress] },
101
+ allowList: { address: validatorAddressList },
102
102
  maxTokens: (maxTokens === "0") ? undefined : { denom: this.config.denom, amount: maxTokens },
103
103
  authorizationType: type
104
104
  })).finish()),
@@ -263,7 +263,7 @@ var FirmaAuthzService = /** @class */ (function () {
263
263
  });
264
264
  });
265
265
  };
266
- FirmaAuthzService.prototype.getGasEstimationGrantStakeAuthorization = function (wallet, granteeAddress, validatorAddress, type, expirationDate, maxTokens, txMisc) {
266
+ FirmaAuthzService.prototype.getGasEstimationGrantStakeAuthorization = function (wallet, granteeAddress, validatorAddressList, type, expirationDate, maxTokens, txMisc) {
267
267
  if (maxTokens === void 0) { maxTokens = 0; }
268
268
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
269
269
  return __awaiter(this, void 0, void 0, function () {
@@ -272,7 +272,7 @@ var FirmaAuthzService = /** @class */ (function () {
272
272
  switch (_a.label) {
273
273
  case 0:
274
274
  _a.trys.push([0, 3, , 4]);
275
- return [4 /*yield*/, this.getSignedTxGrantStakeAutorization(wallet, granteeAddress, validatorAddress, type, FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(maxTokens), expirationDate, txMisc)];
275
+ return [4 /*yield*/, this.getSignedTxGrantStakeAutorization(wallet, granteeAddress, validatorAddressList, type, FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(maxTokens), expirationDate, txMisc)];
276
276
  case 1:
277
277
  txRaw = _a.sent();
278
278
  return [4 /*yield*/, FirmaUtil_1.FirmaUtil.estimateGas(txRaw)];
@@ -286,7 +286,7 @@ var FirmaAuthzService = /** @class */ (function () {
286
286
  });
287
287
  });
288
288
  };
289
- FirmaAuthzService.prototype.grantStakeAuthorization = function (wallet, granteeAddress, validatorAddress, type, expirationDate, maxTokens, txMisc) {
289
+ FirmaAuthzService.prototype.grantStakeAuthorization = function (wallet, granteeAddress, validatorAddressList, type, expirationDate, maxTokens, txMisc) {
290
290
  if (maxTokens === void 0) { maxTokens = 0; }
291
291
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
292
292
  return __awaiter(this, void 0, void 0, function () {
@@ -295,7 +295,7 @@ var FirmaAuthzService = /** @class */ (function () {
295
295
  switch (_a.label) {
296
296
  case 0:
297
297
  _a.trys.push([0, 3, , 4]);
298
- return [4 /*yield*/, this.getSignedTxGrantStakeAutorization(wallet, granteeAddress, validatorAddress, type, FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(maxTokens), expirationDate, txMisc)];
298
+ return [4 /*yield*/, this.getSignedTxGrantStakeAutorization(wallet, granteeAddress, validatorAddressList, type, FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(maxTokens), expirationDate, txMisc)];
299
299
  case 1:
300
300
  txRaw = _a.sent();
301
301
  authzTxClient = new authz_1.AuthzTxClient(wallet, this.config.rpcAddress);
@@ -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, error_16;
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
- error_16 = _a.sent();
402
- FirmaUtil_1.FirmaUtil.printLog(error_16);
403
- throw error_16;
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
- message = cosmwasm_1.CosmWasmTxClient.msgStoreCode({ sender: address, wasmByteCode: wasmCode, instantiatePermission: accessConfig });
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()];
@@ -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.25;
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.35",
3
+ "version": "0.2.38",
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,16 @@
36
36
  "@cosmjs/math": "^0.26.0",
37
37
  "@cosmjs/proto-signing": "^0.25.6",
38
38
  "@cosmjs/tendermint-rpc": "^0.26.0",
39
+ "@nftstorage/ipfs-cluster": "^5.0.1",
40
+ "@types/pako": "^2.0.0",
39
41
  "axios": "^0.21.4",
40
42
  "cosmjs-types": "^0.2.0",
41
43
  "crypto-js": "^4.1.1",
44
+ "ipfs-cluster-api": "^0.0.9",
42
45
  "ipfs-http-client": "^52.0.5",
46
+ "is-stream": "^3.0.0",
47
+ "node-ipfs-cluster-api": "^0.0.1",
48
+ "pako": "^2.0.2",
43
49
  "protobufjs": "^6.10.2",
44
50
  "readline-sync": "^1.4.10"
45
51
  },