@super-protocol/sdk-js 0.12.8-beta.0 → 0.12.8-beta.2
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.
|
@@ -79,7 +79,7 @@ var utils_1 = require("../utils");
|
|
|
79
79
|
var TxManager_1 = __importDefault(require("../utils/TxManager"));
|
|
80
80
|
var app_json_1 = __importDefault(require("../contracts/app.json"));
|
|
81
81
|
var ethers_1 = require("ethers");
|
|
82
|
-
var Jsonrpc = require(
|
|
82
|
+
var Jsonrpc = require("web3-core-requestmanager/src/jsonrpc");
|
|
83
83
|
// TODO: remove this dependencies
|
|
84
84
|
var store_1 = __importDefault(require("../store"));
|
|
85
85
|
var Superpro_1 = __importDefault(require("../staticModels/Superpro"));
|
|
@@ -110,17 +110,17 @@ var BlockchainConnector = /** @class */ (function (_super) {
|
|
|
110
110
|
* Needs to run this function before using blockchain connector
|
|
111
111
|
*/
|
|
112
112
|
BlockchainConnector.prototype.initialize = function (config) {
|
|
113
|
+
var _a;
|
|
113
114
|
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
-
var url,
|
|
115
|
-
return __generator(this, function (
|
|
116
|
-
switch (
|
|
115
|
+
var url, _b;
|
|
116
|
+
return __generator(this, function (_c) {
|
|
117
|
+
switch (_c.label) {
|
|
117
118
|
case 0:
|
|
118
119
|
this.logger.trace(config, "Initializing");
|
|
119
120
|
url = (config === null || config === void 0 ? void 0 : config.blockchainUrl) || constants_1.defaultBlockchainUrl;
|
|
120
121
|
this.provider = new web3_1.default.providers.HttpProvider(url);
|
|
121
122
|
store_1.default.web3Https = new web3_1.default(this.provider);
|
|
122
|
-
|
|
123
|
-
store_1.default.gasPrice = config.gasPrice;
|
|
123
|
+
store_1.default.gasPrice = (_a = config === null || config === void 0 ? void 0 : config.gasPrice) !== null && _a !== void 0 ? _a : constants_1.defaultGasPrice;
|
|
124
124
|
if (config === null || config === void 0 ? void 0 : config.gasLimit)
|
|
125
125
|
store_1.default.gasLimit = config.gasLimit;
|
|
126
126
|
if (config === null || config === void 0 ? void 0 : config.gasLimitMultiplier)
|
|
@@ -130,10 +130,10 @@ var BlockchainConnector = /** @class */ (function (_super) {
|
|
|
130
130
|
Superpro_1.default.address = config.contractAddress;
|
|
131
131
|
this.contract = new store_1.default.web3Https.eth.Contract(app_json_1.default.abi, Superpro_1.default.address);
|
|
132
132
|
TxManager_1.default.init(store_1.default.web3Https);
|
|
133
|
-
|
|
133
|
+
_b = SuperproToken_1.default;
|
|
134
134
|
return [4 /*yield*/, Superpro_1.default.getTokenAddress(this.contract)];
|
|
135
135
|
case 1:
|
|
136
|
-
|
|
136
|
+
_b.addressHttps = _c.sent();
|
|
137
137
|
Monitoring_1.Monitoring.getInstance().initializeLogging();
|
|
138
138
|
this.initialized = true;
|
|
139
139
|
this.logger.trace("Initialized");
|
package/build/constants.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const defaultBlockchainUrl = "http://127.0.0.1:8545";
|
|
2
2
|
export declare const defaultGasLimit = 7000000;
|
|
3
|
-
export declare const defaultGasPrice = "
|
|
3
|
+
export declare const defaultGasPrice = "3000000000";
|
|
4
4
|
export declare const defaultGasPriceMultiplier = 1;
|
|
5
5
|
export declare const defaultGasLimitMultiplier = 1.2;
|
|
6
6
|
export declare const ONE_DAY: number;
|
package/build/constants.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
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
|
-
exports.defaultGasPrice = "
|
|
6
|
+
exports.defaultGasPrice = "3000000000";
|
|
7
7
|
exports.defaultGasPriceMultiplier = 1;
|
|
8
8
|
exports.defaultGasLimitMultiplier = 1.2;
|
|
9
9
|
exports.ONE_DAY = 24 * 60 * 60;
|
package/build/utils/TxManager.js
CHANGED
|
@@ -142,9 +142,7 @@ 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
145
|
txData.gasPrice = Math.ceil(txData.gasPrice * store_1.default.gasPriceMultiplier);
|
|
147
|
-
TxManager.logger.debug({ price: txData.gasPrice }, "gasPrice after multipling");
|
|
148
146
|
_a.label = 6;
|
|
149
147
|
case 6:
|
|
150
148
|
if (!(!(0, utils_1.checkForUsingExternalTxManager)(transactionOptions) && this.nonceTrackers[options.from])) return [3 /*break*/, 8];
|
package/build/utils.js
CHANGED
|
@@ -74,7 +74,7 @@ exports.getGasPrice = getGasPrice;
|
|
|
74
74
|
* Used in all set methods
|
|
75
75
|
*/
|
|
76
76
|
var createTransactionOptions = function (options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
77
|
-
var web3, _a;
|
|
77
|
+
var web3, _a, e_1;
|
|
78
78
|
return __generator(this, function (_b) {
|
|
79
79
|
switch (_b.label) {
|
|
80
80
|
case 0:
|
|
@@ -86,21 +86,24 @@ var createTransactionOptions = function (options) { return __awaiter(void 0, voi
|
|
|
86
86
|
options.gas = store_1.default.gasLimit;
|
|
87
87
|
if (!options.gasPriceMultiplier)
|
|
88
88
|
options.gasPriceMultiplier = store_1.default.gasPriceMultiplier;
|
|
89
|
-
if (!!options.gasPrice) return [3 /*break*/,
|
|
90
|
-
if (!store_1.default.gasPrice) return [3 /*break*/, 1];
|
|
91
|
-
options.gasPrice = store_1.default.gasPrice;
|
|
92
|
-
return [3 /*break*/, 3];
|
|
93
|
-
case 1:
|
|
89
|
+
if (!!options.gasPrice) return [3 /*break*/, 6];
|
|
94
90
|
web3 = options.web3 || store_1.default.web3Https;
|
|
95
|
-
if (!web3)
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
if (!web3) return [3 /*break*/, 5];
|
|
92
|
+
_b.label = 1;
|
|
93
|
+
case 1:
|
|
94
|
+
_b.trys.push([1, 3, , 4]);
|
|
98
95
|
_a = options;
|
|
99
96
|
return [4 /*yield*/, (0, exports.getGasPrice)(web3)];
|
|
100
97
|
case 2:
|
|
101
98
|
_a.gasPrice = _b.sent();
|
|
102
|
-
|
|
99
|
+
return [3 /*break*/, 4];
|
|
103
100
|
case 3:
|
|
101
|
+
e_1 = _b.sent();
|
|
102
|
+
options.gasPrice = store_1.default.gasPrice;
|
|
103
|
+
return [3 /*break*/, 4];
|
|
104
|
+
case 4: return [3 /*break*/, 6];
|
|
105
|
+
case 5: throw Error("web3 is undefined, define it in transaction options or initialize BlockchainConnector with web3 instance.");
|
|
106
|
+
case 6:
|
|
104
107
|
delete options.web3;
|
|
105
108
|
return [2 /*return*/, options];
|
|
106
109
|
}
|