@super-protocol/sdk-js 0.12.7-beta.2 → 0.12.8-beta.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.
@@ -6,6 +6,7 @@ export type Config = {
6
6
  gasPrice?: string;
7
7
  gasLimit?: number;
8
8
  gasLimitMultiplier?: number;
9
+ gasPriceMultiplier?: number;
9
10
  reconnect?: {
10
11
  auto?: boolean;
11
12
  delay?: number;
@@ -125,6 +125,8 @@ var BlockchainConnector = /** @class */ (function (_super) {
125
125
  store_1.default.gasLimit = config.gasLimit;
126
126
  if (config === null || config === void 0 ? void 0 : config.gasLimitMultiplier)
127
127
  store_1.default.gasLimitMultiplier = config.gasLimitMultiplier;
128
+ if (config === null || config === void 0 ? void 0 : config.gasPriceMultiplier)
129
+ store_1.default.gasPriceMultiplier = config.gasPriceMultiplier;
128
130
  Superpro_1.default.address = config.contractAddress;
129
131
  this.contract = new store_1.default.web3Https.eth.Contract(app_json_1.default.abi, Superpro_1.default.address);
130
132
  TxManager_1.default.init(store_1.default.web3Https);
@@ -1,6 +1,7 @@
1
1
  export declare const defaultBlockchainUrl = "http://127.0.0.1:8545";
2
2
  export declare const defaultGasLimit = 7000000;
3
3
  export declare const defaultGasPrice = "30000000000";
4
+ export declare const defaultGasPriceMultiplier = 1;
4
5
  export declare const defaultGasLimitMultiplier = 1.2;
5
6
  export declare const ONE_DAY: number;
6
7
  export declare const BLOCK_SIZE_TO_FETCH_TRANSACTION = 500;
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.POLYGON_MATIC_EVENT_PATH = exports.BLOCK_SIZE_TO_FETCH_TRANSACTION = exports.ONE_DAY = exports.defaultGasLimitMultiplier = exports.defaultGasPrice = exports.defaultGasLimit = exports.defaultBlockchainUrl = void 0;
3
+ exports.POLYGON_MATIC_EVENT_PATH = exports.BLOCK_SIZE_TO_FETCH_TRANSACTION = exports.ONE_DAY = exports.defaultGasLimitMultiplier = exports.defaultGasPriceMultiplier = exports.defaultGasPrice = exports.defaultGasLimit = exports.defaultBlockchainUrl = void 0;
4
4
  exports.defaultBlockchainUrl = "http://127.0.0.1:8545";
5
5
  exports.defaultGasLimit = 7000000;
6
6
  exports.defaultGasPrice = "30000000000";
7
+ exports.defaultGasPriceMultiplier = 1;
7
8
  exports.defaultGasLimitMultiplier = 1.2;
8
9
  exports.ONE_DAY = 24 * 60 * 60;
9
10
  exports.BLOCK_SIZE_TO_FETCH_TRANSACTION = 500;
package/build/store.d.ts CHANGED
@@ -5,6 +5,7 @@ export type Store = {
5
5
  actionAccount?: string;
6
6
  gasLimit: number;
7
7
  gasLimitMultiplier: number;
8
+ gasPriceMultiplier: number;
8
9
  gasPrice?: string;
9
10
  keys: Record<string, string>;
10
11
  };
package/build/store.js CHANGED
@@ -7,6 +7,7 @@ var store = {
7
7
  actionAccount: undefined,
8
8
  gasLimit: constants_1.defaultGasLimit,
9
9
  gasLimitMultiplier: constants_1.defaultGasLimitMultiplier,
10
+ gasPriceMultiplier: constants_1.defaultGasPriceMultiplier,
10
11
  gasPrice: undefined,
11
12
  keys: {},
12
13
  };
@@ -19,6 +19,7 @@ export type TransactionOptions = {
19
19
  from?: string;
20
20
  gas?: number;
21
21
  gasPrice?: string;
22
+ gasPriceMultiplier?: number;
22
23
  web3?: Web3;
23
24
  };
24
25
  export type Transaction = {
@@ -142,6 +142,9 @@ var TxManager = /** @class */ (function () {
142
142
  }
143
143
  txData.gas = options.gas;
144
144
  }
145
+ TxManager.logger.debug({ price: txData.gasPrice }, "gasPrice before multipling");
146
+ txData.gasPrice = Math.ceil(txData.gasPrice * store_1.default.gasPriceMultiplier);
147
+ TxManager.logger.debug({ price: txData.gasPrice }, "gasPrice after multipling");
145
148
  _a.label = 6;
146
149
  case 6:
147
150
  if (!(!(0, utils_1.checkForUsingExternalTxManager)(transactionOptions) && this.nonceTrackers[options.from])) return [3 /*break*/, 8];
package/build/utils.js CHANGED
@@ -84,6 +84,8 @@ var createTransactionOptions = function (options) { return __awaiter(void 0, voi
84
84
  options.from = store_1.default.actionAccount;
85
85
  if (!options.gas)
86
86
  options.gas = store_1.default.gasLimit;
87
+ if (!options.gasPriceMultiplier)
88
+ options.gasPriceMultiplier = store_1.default.gasPriceMultiplier;
87
89
  if (!!options.gasPrice) return [3 /*break*/, 3];
88
90
  if (!store_1.default.gasPrice) return [3 /*break*/, 1];
89
91
  options.gasPrice = store_1.default.gasPrice;
@@ -205,6 +207,7 @@ function unpackDeviceId(bytes32) {
205
207
  if (bytes32.length !== 66) {
206
208
  throw new Error("DeviceId bytes must be equal 66 symbols");
207
209
  }
208
- return bytes32.slice(0, 64);
210
+ // removes '0x'
211
+ return bytes32.slice(2, 66);
209
212
  }
210
213
  exports.unpackDeviceId = unpackDeviceId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@super-protocol/sdk-js",
3
- "version": "0.12.7-beta.2",
3
+ "version": "0.12.8-beta.0",
4
4
  "main": "build/index.js",
5
5
  "license": "MIT",
6
6
  "files": [