@ututrust/web-components 1.1.23 → 1.1.24
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/dist/index.js +32 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -34245,8 +34245,13 @@
|
|
|
34245
34245
|
chainId: 5
|
|
34246
34246
|
}
|
|
34247
34247
|
};
|
|
34248
|
+
var DEFAULT_NETWORK = "mumbai";
|
|
34248
34249
|
var getDefaultNetwork = function getDefaultNetwork() {
|
|
34249
|
-
return networks[config.production ?
|
|
34250
|
+
return networks[config.production ? "matic" : "mumbai"];
|
|
34251
|
+
};
|
|
34252
|
+
var getUTTContractAddress = function getUTTContractAddress(chain) {
|
|
34253
|
+
if (chain !== "matic") return UTT_CONTRACT_ADDRESS_TEST;
|
|
34254
|
+
return UTT_CONTRACT_ADDRESS_PRODUCTION;
|
|
34250
34255
|
};
|
|
34251
34256
|
|
|
34252
34257
|
function EndorsementForm(props) {
|
|
@@ -34339,9 +34344,11 @@
|
|
|
34339
34344
|
};
|
|
34340
34345
|
}();
|
|
34341
34346
|
|
|
34347
|
+
var CURRENT_NETWORK = String(props[ATTR_ENDORSEMENT_NETWORK]).toLowerCase().trim();
|
|
34348
|
+
|
|
34342
34349
|
var switchNetwork = /*#__PURE__*/function () {
|
|
34343
34350
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
34344
|
-
var provider,
|
|
34351
|
+
var provider, selectedNetwork;
|
|
34345
34352
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
34346
34353
|
while (1) {
|
|
34347
34354
|
switch (_context3.prev = _context3.next) {
|
|
@@ -34349,39 +34356,38 @@
|
|
|
34349
34356
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
34350
34357
|
// @ts-ignore
|
|
34351
34358
|
provider = getProvider();
|
|
34352
|
-
|
|
34353
|
-
|
|
34354
|
-
_context3.
|
|
34355
|
-
_context3.next = 6;
|
|
34359
|
+
selectedNetwork = networks[CURRENT_NETWORK] || getDefaultNetwork();
|
|
34360
|
+
_context3.prev = 2;
|
|
34361
|
+
_context3.next = 5;
|
|
34356
34362
|
return requestNetworkChange(provider, selectedNetwork);
|
|
34357
34363
|
|
|
34358
|
-
case
|
|
34359
|
-
_context3.next =
|
|
34364
|
+
case 5:
|
|
34365
|
+
_context3.next = 15;
|
|
34360
34366
|
break;
|
|
34361
34367
|
|
|
34362
|
-
case
|
|
34363
|
-
_context3.prev =
|
|
34364
|
-
_context3.t0 = _context3["catch"](
|
|
34368
|
+
case 7:
|
|
34369
|
+
_context3.prev = 7;
|
|
34370
|
+
_context3.t0 = _context3["catch"](2);
|
|
34365
34371
|
console.log(_context3.t0, _context3.t0.message);
|
|
34366
34372
|
|
|
34367
34373
|
if (!(_context3.t0.code === 4902 || _context3.t0.message.toLowerCase().includes("unrecognized"))) {
|
|
34368
|
-
_context3.next =
|
|
34374
|
+
_context3.next = 15;
|
|
34369
34375
|
break;
|
|
34370
34376
|
}
|
|
34371
34377
|
|
|
34372
|
-
_context3.next =
|
|
34378
|
+
_context3.next = 13;
|
|
34373
34379
|
return addNetwork(provider, selectedNetwork);
|
|
34374
34380
|
|
|
34375
|
-
case
|
|
34376
|
-
_context3.next =
|
|
34381
|
+
case 13:
|
|
34382
|
+
_context3.next = 15;
|
|
34377
34383
|
return requestNetworkChange(provider, selectedNetwork);
|
|
34378
34384
|
|
|
34379
|
-
case
|
|
34385
|
+
case 15:
|
|
34380
34386
|
case "end":
|
|
34381
34387
|
return _context3.stop();
|
|
34382
34388
|
}
|
|
34383
34389
|
}
|
|
34384
|
-
}, _callee3, null, [[
|
|
34390
|
+
}, _callee3, null, [[2, 7]]);
|
|
34385
34391
|
}));
|
|
34386
34392
|
|
|
34387
34393
|
return function switchNetwork() {
|
|
@@ -34389,11 +34395,9 @@
|
|
|
34389
34395
|
};
|
|
34390
34396
|
}();
|
|
34391
34397
|
|
|
34392
|
-
var UTT_CONTRACT_ADDRESS = config.production ? UTT_CONTRACT_ADDRESS_PRODUCTION : UTT_CONTRACT_ADDRESS_TEST;
|
|
34393
|
-
|
|
34394
34398
|
var sendTransaction = /*#__PURE__*/function () {
|
|
34395
34399
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(address, amount, transactionId) {
|
|
34396
|
-
var web3Provider, signer, contract, transaction;
|
|
34400
|
+
var UTT_CONTRACT_ADDRESS, web3Provider, signer, contract, transaction;
|
|
34397
34401
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
34398
34402
|
while (1) {
|
|
34399
34403
|
switch (_context4.prev = _context4.next) {
|
|
@@ -34402,25 +34406,26 @@
|
|
|
34402
34406
|
return switchNetwork();
|
|
34403
34407
|
|
|
34404
34408
|
case 2:
|
|
34405
|
-
|
|
34409
|
+
UTT_CONTRACT_ADDRESS = getUTTContractAddress(CURRENT_NETWORK || DEFAULT_NETWORK);
|
|
34410
|
+
_context4.next = 5;
|
|
34406
34411
|
return new Web3Provider(getProvider());
|
|
34407
34412
|
|
|
34408
|
-
case
|
|
34413
|
+
case 5:
|
|
34409
34414
|
web3Provider = _context4.sent;
|
|
34410
34415
|
signer = web3Provider.getSigner();
|
|
34411
34416
|
contract = new Contract(UTT_CONTRACT_ADDRESS, abi, signer);
|
|
34412
|
-
_context4.next =
|
|
34417
|
+
_context4.next = 10;
|
|
34413
34418
|
return contract.endorse(address, String(amount), transactionId);
|
|
34414
34419
|
|
|
34415
|
-
case
|
|
34420
|
+
case 10:
|
|
34416
34421
|
transaction = _context4.sent;
|
|
34417
|
-
_context4.next =
|
|
34422
|
+
_context4.next = 13;
|
|
34418
34423
|
return transaction.wait();
|
|
34419
34424
|
|
|
34420
|
-
case
|
|
34425
|
+
case 13:
|
|
34421
34426
|
return _context4.abrupt("return", transaction);
|
|
34422
34427
|
|
|
34423
|
-
case
|
|
34428
|
+
case 14:
|
|
34424
34429
|
case "end":
|
|
34425
34430
|
return _context4.stop();
|
|
34426
34431
|
}
|