@kimafinance/kima-transaction-widget 1.2.22-beta.1 → 1.2.23-beta.1
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 +10 -106
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +8 -94
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2209,7 +2209,10 @@ function useIsWalletReady() {
|
|
|
2209
2209
|
var _useState = React.useState('loading'),
|
|
2210
2210
|
capabilityState = _useState[0],
|
|
2211
2211
|
setCapabilityState = _useState[1];
|
|
2212
|
-
var
|
|
2212
|
+
var _useState2 = React.useState(),
|
|
2213
|
+
capabilities = _useState2[0],
|
|
2214
|
+
setCapabilities = _useState2[1];
|
|
2215
|
+
var capabilityMessage = capabilityState === 'loading' ? 'Checking capabilities...' : capabilityState === 'cancelled' ? 'Capability check cancelled by wallet. Please refresh the page and try again.' : capabilityState === 'missing' ? 'Could not find an installed Sats Connect capable wallet. Please install a wallet and try again.' : !capabilities ? 'Something went wrong with getting capabilities' : undefined;
|
|
2213
2216
|
React.useEffect(function () {
|
|
2214
2217
|
var _events$data, _events$data2;
|
|
2215
2218
|
if (((_events$data = events.data) === null || _events$data === void 0 ? void 0 : _events$data.event) === 'SELECT_WALLET' || ((_events$data2 = events.data) === null || _events$data2 === void 0 ? void 0 : _events$data2.event) === 'CONNECT_SUCCESS') {
|
|
@@ -2218,7 +2221,6 @@ function useIsWalletReady() {
|
|
|
2218
2221
|
}
|
|
2219
2222
|
}, [events]);
|
|
2220
2223
|
React.useEffect(function () {
|
|
2221
|
-
if (sourceChain !== exports.SupportNetworks.BTC) return;
|
|
2222
2224
|
var runCapabilityCheck = function runCapabilityCheck() {
|
|
2223
2225
|
try {
|
|
2224
2226
|
var runs = 0;
|
|
@@ -2229,12 +2231,13 @@ function useIsWalletReady() {
|
|
|
2229
2231
|
}, void 0, function () {
|
|
2230
2232
|
function _temp2() {
|
|
2231
2233
|
return Promise.resolve(new Promise(function (resolve) {
|
|
2232
|
-
return setTimeout(resolve,
|
|
2234
|
+
return setTimeout(resolve, 100);
|
|
2233
2235
|
})).then(function () {});
|
|
2234
2236
|
}
|
|
2235
2237
|
var _temp = _catch(function () {
|
|
2236
2238
|
return Promise.resolve(satsConnect.getCapabilities({
|
|
2237
|
-
onFinish: function onFinish() {
|
|
2239
|
+
onFinish: function onFinish(response) {
|
|
2240
|
+
setCapabilities(new Set(response));
|
|
2238
2241
|
setCapabilityState('loaded');
|
|
2239
2242
|
},
|
|
2240
2243
|
onCancel: function onCancel() {
|
|
@@ -2260,7 +2263,7 @@ function useIsWalletReady() {
|
|
|
2260
2263
|
}
|
|
2261
2264
|
};
|
|
2262
2265
|
runCapabilityCheck();
|
|
2263
|
-
}, [
|
|
2266
|
+
}, []);
|
|
2264
2267
|
var connectBitcoinWallet = React.useCallback(function () {
|
|
2265
2268
|
try {
|
|
2266
2269
|
return Promise.resolve(satsConnect.getAddress({
|
|
@@ -2796,7 +2799,6 @@ function useBalance() {
|
|
|
2796
2799
|
var tokenOptions = reactRedux.useSelector(selectTokenOptions);
|
|
2797
2800
|
var tokenAddress = React.useMemo(function () {
|
|
2798
2801
|
if (isEmptyObject(tokenOptions) || sourceChain === exports.SupportNetworks.FIAT) return '';
|
|
2799
|
-
console.log(tokenOptions);
|
|
2800
2802
|
if (tokenOptions && typeof tokenOptions === 'object') {
|
|
2801
2803
|
var coinOptions = tokenOptions[selectedCoin];
|
|
2802
2804
|
if (coinOptions && typeof coinOptions === 'object') {
|
|
@@ -3366,24 +3368,6 @@ var BankInput = function BankInput() {
|
|
|
3366
3368
|
})));
|
|
3367
3369
|
};
|
|
3368
3370
|
|
|
3369
|
-
var TxButton = function TxButton(_ref) {
|
|
3370
|
-
var theme = _ref.theme,
|
|
3371
|
-
txCount = _ref.txCount;
|
|
3372
|
-
var dispatch = reactRedux.useDispatch();
|
|
3373
|
-
var handleClick = function handleClick() {
|
|
3374
|
-
dispatch(setPendingTxPopup(true));
|
|
3375
|
-
};
|
|
3376
|
-
return React__default.createElement("button", {
|
|
3377
|
-
className: "secondary-button tx-button " + theme.colorMode,
|
|
3378
|
-
onClick: handleClick,
|
|
3379
|
-
"data-tooltip-id": 'popup-tooltip'
|
|
3380
|
-
}, txCount, React__default.createElement(Loading180Ring, {
|
|
3381
|
-
height: 16,
|
|
3382
|
-
width: 16,
|
|
3383
|
-
fill: theme.colorMode === 'light' ? 'black' : 'white'
|
|
3384
|
-
}));
|
|
3385
|
-
};
|
|
3386
|
-
|
|
3387
3371
|
var HelpPopup = function HelpPopup() {
|
|
3388
3372
|
var dispatch = reactRedux.useDispatch();
|
|
3389
3373
|
var theme = reactRedux.useSelector(selectTheme);
|
|
@@ -8243,79 +8227,6 @@ var PendingTxPopup = function PendingTxPopup(_ref) {
|
|
|
8243
8227
|
}))))));
|
|
8244
8228
|
};
|
|
8245
8229
|
|
|
8246
|
-
function usePendingTx(_ref) {
|
|
8247
|
-
var walletAddress = _ref.walletAddress;
|
|
8248
|
-
var _useState = React.useState(0),
|
|
8249
|
-
pendingTxs = _useState[0],
|
|
8250
|
-
setPendingTxs = _useState[1];
|
|
8251
|
-
var _useState2 = React.useState([]),
|
|
8252
|
-
pendingTxData = _useState2[0],
|
|
8253
|
-
setPendingTxData = _useState2[1];
|
|
8254
|
-
var sourceChain = reactRedux.useSelector(selectSourceChain);
|
|
8255
|
-
var nodeProviderQuery = reactRedux.useSelector(selectNodeProviderQuery);
|
|
8256
|
-
React.useEffect(function () {
|
|
8257
|
-
console.log(nodeProviderQuery, sourceChain, walletAddress);
|
|
8258
|
-
if (!nodeProviderQuery || sourceChain !== exports.SupportNetworks.BTC || !walletAddress) return;
|
|
8259
|
-
var updatePendingTxs = function updatePendingTxs() {
|
|
8260
|
-
try {
|
|
8261
|
-
var _temp = _catch(function () {
|
|
8262
|
-
return Promise.resolve(fetchWrapper.get(nodeProviderQuery + "/kima-finance/kima-blockchain/transaction/get_htlc_transaction/" + walletAddress)).then(function (result) {
|
|
8263
|
-
var data = result === null || result === void 0 ? void 0 : result.htlcLockingTransaction;
|
|
8264
|
-
var txData = [];
|
|
8265
|
-
if (data.length > 0) {
|
|
8266
|
-
for (var _iterator = _createForOfIteratorHelperLoose(data), _step; !(_step = _iterator()).done;) {
|
|
8267
|
-
var tx = _step.value;
|
|
8268
|
-
var status = '';
|
|
8269
|
-
if (tx.status !== 'Completed') {
|
|
8270
|
-
status = 'Confirming';
|
|
8271
|
-
} else if (tx.pull_status === 'htlc_pull_available') {
|
|
8272
|
-
status = 'Pending';
|
|
8273
|
-
} else if (tx.pull_status === 'htlc_pull_in_progress') {
|
|
8274
|
-
status = 'In Progress';
|
|
8275
|
-
} else if (tx.pull_status === 'htlc_pull_succeed') {
|
|
8276
|
-
status = 'Completed';
|
|
8277
|
-
} else if (tx.pull_status === 'htlc_pull_failed') {
|
|
8278
|
-
status = 'Failed';
|
|
8279
|
-
}
|
|
8280
|
-
txData.push({
|
|
8281
|
-
hash: tx.txHash,
|
|
8282
|
-
amount: tx.amount,
|
|
8283
|
-
expireTime: tx.htlcTimestamp,
|
|
8284
|
-
status: status
|
|
8285
|
-
});
|
|
8286
|
-
}
|
|
8287
|
-
console.log(txData);
|
|
8288
|
-
setPendingTxData([].concat(txData));
|
|
8289
|
-
setPendingTxs(txData.filter(function (tx) {
|
|
8290
|
-
return tx.status === 'Pending' || tx.status === 'Confirming';
|
|
8291
|
-
}).length);
|
|
8292
|
-
}
|
|
8293
|
-
});
|
|
8294
|
-
}, function (e) {
|
|
8295
|
-
console.log(e);
|
|
8296
|
-
});
|
|
8297
|
-
return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
|
|
8298
|
-
} catch (e) {
|
|
8299
|
-
return Promise.reject(e);
|
|
8300
|
-
}
|
|
8301
|
-
};
|
|
8302
|
-
var timerId = setInterval(function () {
|
|
8303
|
-
updatePendingTxs();
|
|
8304
|
-
}, 10000);
|
|
8305
|
-
updatePendingTxs();
|
|
8306
|
-
return function () {
|
|
8307
|
-
console.log('clearInterval', timerId);
|
|
8308
|
-
clearInterval(timerId);
|
|
8309
|
-
};
|
|
8310
|
-
}, [sourceChain, nodeProviderQuery, walletAddress]);
|
|
8311
|
-
return React.useMemo(function () {
|
|
8312
|
-
return {
|
|
8313
|
-
pendingTxData: pendingTxData,
|
|
8314
|
-
pendingTxs: pendingTxs
|
|
8315
|
-
};
|
|
8316
|
-
}, [pendingTxs, pendingTxData]);
|
|
8317
|
-
}
|
|
8318
|
-
|
|
8319
8230
|
var TransferWidget = function TransferWidget(_ref) {
|
|
8320
8231
|
var _theme$backgroundColo;
|
|
8321
8232
|
var theme = _ref.theme,
|
|
@@ -8387,11 +8298,7 @@ var TransferWidget = function TransferWidget(_ref) {
|
|
|
8387
8298
|
var _useIsWalletReady = useIsWalletReady(),
|
|
8388
8299
|
isReady = _useIsWalletReady.isReady,
|
|
8389
8300
|
walletAddress = _useIsWalletReady.walletAddress;
|
|
8390
|
-
var
|
|
8391
|
-
walletAddress: walletAddress || ''
|
|
8392
|
-
}),
|
|
8393
|
-
pendingTxData = _usePendingTx.pendingTxData,
|
|
8394
|
-
pendingTxs = _usePendingTx.pendingTxs;
|
|
8301
|
+
var pendingTxData = [];
|
|
8395
8302
|
var _useAllowance = useAllowance({
|
|
8396
8303
|
setApproving: setApproving
|
|
8397
8304
|
}),
|
|
@@ -8875,10 +8782,7 @@ var TransferWidget = function TransferWidget(_ref) {
|
|
|
8875
8782
|
className: 'title'
|
|
8876
8783
|
}, React__default.createElement("h3", null, isWizard && wizardStep === 3 || !isWizard && formStep > 0 ? titleOption !== null && titleOption !== void 0 && titleOption.confirmTitle ? titleOption === null || titleOption === void 0 ? void 0 : titleOption.confirmTitle : 'Transfer Details' : titleOption !== null && titleOption !== void 0 && titleOption.initialTitle ? titleOption === null || titleOption === void 0 ? void 0 : titleOption.initialTitle : 'New Transfer')), React__default.createElement("div", {
|
|
8877
8784
|
className: 'control-buttons'
|
|
8878
|
-
},
|
|
8879
|
-
theme: theme,
|
|
8880
|
-
txCount: pendingTxs
|
|
8881
|
-
}) : null, React__default.createElement(ExternalLink, {
|
|
8785
|
+
}, null, React__default.createElement(ExternalLink, {
|
|
8882
8786
|
to: helpURL ? helpURL : 'https://docs.kima.finance/demo'
|
|
8883
8787
|
}, React__default.createElement("div", {
|
|
8884
8788
|
className: 'menu-button'
|