@kimafinance/kima-transaction-widget 1.1.6 → 1.1.7
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/components/KimaTransactionWidget.d.ts +2 -1
- package/dist/helpers/xplorisk.d.ts +17 -0
- package/dist/index.css +1169 -929
- package/dist/index.js +106 -9
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +79 -7
- package/dist/index.modern.js.map +1 -1
- package/dist/interface.d.ts +5 -0
- package/dist/store/optionSlice.d.ts +7 -1
- package/dist/store/selectors.d.ts +5 -2
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -694,7 +694,10 @@ var initialState = {
|
|
|
694
694
|
backendUrl: '',
|
|
695
695
|
nodeProviderQuery: '',
|
|
696
696
|
txId: -1,
|
|
697
|
-
currencyOptions: COIN_LIST['USDK']
|
|
697
|
+
currencyOptions: COIN_LIST['USDK'],
|
|
698
|
+
compliantOption: true,
|
|
699
|
+
sourceCompliant: true,
|
|
700
|
+
targetCompliant: true
|
|
698
701
|
};
|
|
699
702
|
var optionSlice = toolkit.createSlice({
|
|
700
703
|
name: 'option',
|
|
@@ -708,6 +711,9 @@ var optionSlice = toolkit.createSlice({
|
|
|
708
711
|
state.serviceFee = -1;
|
|
709
712
|
state.amount = 0;
|
|
710
713
|
state.targetAddress = '';
|
|
714
|
+
state.compliantOption = true;
|
|
715
|
+
state.sourceCompliant = true;
|
|
716
|
+
state.targetCompliant = true;
|
|
711
717
|
},
|
|
712
718
|
setTheme: function setTheme(state, action) {
|
|
713
719
|
state.theme = action.payload;
|
|
@@ -780,6 +786,15 @@ var optionSlice = toolkit.createSlice({
|
|
|
780
786
|
},
|
|
781
787
|
setCurrencyOptions: function setCurrencyOptions(state, action) {
|
|
782
788
|
state.currencyOptions = action.payload;
|
|
789
|
+
},
|
|
790
|
+
setCompliantOption: function setCompliantOption(state, action) {
|
|
791
|
+
state.compliantOption = action.payload;
|
|
792
|
+
},
|
|
793
|
+
setSourceCompliant: function setSourceCompliant(state, action) {
|
|
794
|
+
state.sourceCompliant = action.payload;
|
|
795
|
+
},
|
|
796
|
+
setTargetCompliant: function setTargetCompliant(state, action) {
|
|
797
|
+
state.targetCompliant = action.payload;
|
|
783
798
|
}
|
|
784
799
|
}
|
|
785
800
|
});
|
|
@@ -807,7 +822,10 @@ var _optionSlice$actions = optionSlice.actions,
|
|
|
807
822
|
setBackendUrl = _optionSlice$actions.setBackendUrl,
|
|
808
823
|
setNodeProviderQuery = _optionSlice$actions.setNodeProviderQuery,
|
|
809
824
|
setTxId = _optionSlice$actions.setTxId,
|
|
810
|
-
setCurrencyOptions = _optionSlice$actions.setCurrencyOptions
|
|
825
|
+
setCurrencyOptions = _optionSlice$actions.setCurrencyOptions,
|
|
826
|
+
setCompliantOption = _optionSlice$actions.setCompliantOption,
|
|
827
|
+
setSourceCompliant = _optionSlice$actions.setSourceCompliant,
|
|
828
|
+
setTargetCompliant = _optionSlice$actions.setTargetCompliant;
|
|
811
829
|
var optionReducer = optionSlice.reducer;
|
|
812
830
|
|
|
813
831
|
var store = toolkit.configureStore({
|
|
@@ -893,6 +911,15 @@ var selectTxId = function selectTxId(state) {
|
|
|
893
911
|
var selectCurrencyOptions = function selectCurrencyOptions(state) {
|
|
894
912
|
return state.option.currencyOptions;
|
|
895
913
|
};
|
|
914
|
+
var selectCompliantOption = function selectCompliantOption(state) {
|
|
915
|
+
return state.option.compliantOption;
|
|
916
|
+
};
|
|
917
|
+
var selectSourceCompliant = function selectSourceCompliant(state) {
|
|
918
|
+
return state.option.sourceCompliant;
|
|
919
|
+
};
|
|
920
|
+
var selectTargetCompliant = function selectTargetCompliant(state) {
|
|
921
|
+
return state.option.targetCompliant;
|
|
922
|
+
};
|
|
896
923
|
|
|
897
924
|
var EthereumProviderContext = React__default.createContext({
|
|
898
925
|
connect: function connect() {},
|
|
@@ -2013,6 +2040,8 @@ var WalletButton = function WalletButton(_ref) {
|
|
|
2013
2040
|
errorBelow = _ref$errorBelow === void 0 ? false : _ref$errorBelow;
|
|
2014
2041
|
var dispatch = reactRedux.useDispatch();
|
|
2015
2042
|
var theme = reactRedux.useSelector(selectTheme);
|
|
2043
|
+
var sourceCompliant = reactRedux.useSelector(selectSourceCompliant);
|
|
2044
|
+
var compliantOption = reactRedux.useSelector(selectCompliantOption);
|
|
2016
2045
|
var selectedNetwork = reactRedux.useSelector(selectOriginNetwork);
|
|
2017
2046
|
var _useWallet = walletAdapterReact.useWallet(),
|
|
2018
2047
|
disconnectSolana = _useWallet.disconnect;
|
|
@@ -2047,9 +2076,11 @@ var WalletButton = function WalletButton(_ref) {
|
|
|
2047
2076
|
"data-testid": connectWalletBtn
|
|
2048
2077
|
}, React__default.createElement(PrimaryButton, {
|
|
2049
2078
|
clickHandler: handleClick
|
|
2050
|
-
}, isReady ? "Disconnect " + getShortenedAddress(walletAddress || '') : 'Wallet'), !isReady
|
|
2079
|
+
}, isReady ? "Disconnect " + getShortenedAddress(walletAddress || '') : 'Wallet'), !isReady ? React__default.createElement("p", {
|
|
2080
|
+
className: 'provider-error'
|
|
2081
|
+
}, statusMessage) : !sourceCompliant && compliantOption ? React__default.createElement("p", {
|
|
2051
2082
|
className: 'provider-error'
|
|
2052
|
-
},
|
|
2083
|
+
}, "Non-compliant address") : null);
|
|
2053
2084
|
};
|
|
2054
2085
|
|
|
2055
2086
|
var CoinDropdown = function CoinDropdown() {
|
|
@@ -2623,6 +2654,8 @@ var SingleForm = function SingleForm(_ref) {
|
|
|
2623
2654
|
var mode = reactRedux.useSelector(selectMode);
|
|
2624
2655
|
var theme = reactRedux.useSelector(selectTheme);
|
|
2625
2656
|
var amount = reactRedux.useSelector(selectAmount);
|
|
2657
|
+
var compliantOption = reactRedux.useSelector(selectCompliantOption);
|
|
2658
|
+
var targetCompliant = reactRedux.useSelector(selectTargetCompliant);
|
|
2626
2659
|
var transactionOption = reactRedux.useSelector(selectTransactionOption);
|
|
2627
2660
|
var selectedCoin = reactRedux.useSelector(selectCurrencyOptions);
|
|
2628
2661
|
return React__default.createElement("div", {
|
|
@@ -2648,7 +2681,9 @@ var SingleForm = function SingleForm(_ref) {
|
|
|
2648
2681
|
className: "form-item " + theme
|
|
2649
2682
|
}, React__default.createElement("span", {
|
|
2650
2683
|
className: 'label'
|
|
2651
|
-
}, "Target Address:"), React__default.createElement(AddressInput, null)
|
|
2684
|
+
}, "Target Address:"), React__default.createElement(AddressInput, null), compliantOption && !targetCompliant ? React__default.createElement("p", {
|
|
2685
|
+
className: 'error'
|
|
2686
|
+
}, "Non-compliant address") : null), mode === exports.ModeOptions.bridge ? React__default.createElement("div", {
|
|
2652
2687
|
className: "form-item " + theme
|
|
2653
2688
|
}, React__default.createElement("span", {
|
|
2654
2689
|
className: 'label'
|
|
@@ -6908,6 +6943,9 @@ var TransferWidget = function TransferWidget(_ref) {
|
|
|
6908
6943
|
var sourceChain = reactRedux.useSelector(selectOriginNetwork);
|
|
6909
6944
|
var targetAddress = reactRedux.useSelector(selectTargetAddress);
|
|
6910
6945
|
var targetNetwork = reactRedux.useSelector(selectTargetNetwork);
|
|
6946
|
+
var compliantOption = reactRedux.useSelector(selectCompliantOption);
|
|
6947
|
+
var sourceCompliant = reactRedux.useSelector(selectSourceCompliant);
|
|
6948
|
+
var targetCompliant = reactRedux.useSelector(selectTargetCompliant);
|
|
6911
6949
|
var isApproving = reactRedux.useSelector(selectApproving);
|
|
6912
6950
|
var errorHandler = reactRedux.useSelector(selectErrorHandler);
|
|
6913
6951
|
var closeHandler = reactRedux.useSelector(selectCloseHandler);
|
|
@@ -6916,6 +6954,44 @@ var TransferWidget = function TransferWidget(_ref) {
|
|
|
6916
6954
|
selectedCoin = _useCurrencyOptions.options;
|
|
6917
6955
|
var backendUrl = reactRedux.useSelector(selectBackendUrl);
|
|
6918
6956
|
var nodeProviderQuery = reactRedux.useSelector(selectNodeProviderQuery);
|
|
6957
|
+
React.useEffect(function () {
|
|
6958
|
+
if (!walletAddress) return;
|
|
6959
|
+
(function () {
|
|
6960
|
+
try {
|
|
6961
|
+
var _temp2 = _catch(function () {
|
|
6962
|
+
return Promise.resolve(fetchWrapper.post(backendUrl + "/compliant", JSON.stringify({
|
|
6963
|
+
address: walletAddress
|
|
6964
|
+
}))).then(function (res) {
|
|
6965
|
+
dispatch(setSourceCompliant(res === 'ok'));
|
|
6966
|
+
});
|
|
6967
|
+
}, function (e) {
|
|
6968
|
+
console.log('xplorisk check failed', e);
|
|
6969
|
+
});
|
|
6970
|
+
return _temp2 && _temp2.then ? _temp2.then(function () {}) : void 0;
|
|
6971
|
+
} catch (e) {
|
|
6972
|
+
Promise.reject(e);
|
|
6973
|
+
}
|
|
6974
|
+
})();
|
|
6975
|
+
}, [walletAddress]);
|
|
6976
|
+
React.useEffect(function () {
|
|
6977
|
+
if (!targetAddress) return;
|
|
6978
|
+
(function () {
|
|
6979
|
+
try {
|
|
6980
|
+
var _temp4 = _catch(function () {
|
|
6981
|
+
return Promise.resolve(fetchWrapper.post(backendUrl + "/compliant", JSON.stringify({
|
|
6982
|
+
address: targetAddress
|
|
6983
|
+
}))).then(function (res) {
|
|
6984
|
+
dispatch(setTargetCompliant(res === 'ok'));
|
|
6985
|
+
});
|
|
6986
|
+
}, function (e) {
|
|
6987
|
+
console.log('xplorisk check failed', e);
|
|
6988
|
+
});
|
|
6989
|
+
return _temp4 && _temp4.then ? _temp4.then(function () {}) : void 0;
|
|
6990
|
+
} catch (e) {
|
|
6991
|
+
Promise.reject(e);
|
|
6992
|
+
}
|
|
6993
|
+
})();
|
|
6994
|
+
}, [targetAddress]);
|
|
6919
6995
|
React.useEffect(function () {
|
|
6920
6996
|
if (!nodeProviderQuery) return;
|
|
6921
6997
|
try {
|
|
@@ -7041,7 +7117,7 @@ var TransferWidget = function TransferWidget(_ref) {
|
|
|
7041
7117
|
}
|
|
7042
7118
|
return;
|
|
7043
7119
|
}
|
|
7044
|
-
if (mode === exports.ModeOptions.payment && wizardStep === 1 && fee >= 0) {
|
|
7120
|
+
if (mode === exports.ModeOptions.payment && wizardStep === 1 && fee >= 0 && (!compliantOption || sourceCompliant && targetCompliant)) {
|
|
7045
7121
|
dispatch(setConfirming(true));
|
|
7046
7122
|
setWizardStep(5);
|
|
7047
7123
|
} else setWizardStep(function (step) {
|
|
@@ -7050,7 +7126,9 @@ var TransferWidget = function TransferWidget(_ref) {
|
|
|
7050
7126
|
}
|
|
7051
7127
|
if (!isWizard && !formStep) {
|
|
7052
7128
|
if (isReady) {
|
|
7053
|
-
if (fee
|
|
7129
|
+
if (fee < 0) return;
|
|
7130
|
+
if (compliantOption && (!sourceCompliant || !targetCompliant)) return;
|
|
7131
|
+
if (mode === exports.ModeOptions.payment || targetAddress && amount > 0) {
|
|
7054
7132
|
dispatch(setConfirming(true));
|
|
7055
7133
|
setFormStep(1);
|
|
7056
7134
|
}
|
|
@@ -7151,6 +7229,8 @@ var KimaTransactionWidget = function KimaTransactionWidget(_ref) {
|
|
|
7151
7229
|
fontSize = _ref$fontSize === void 0 ? exports.FontSizeOptions.medium : _ref$fontSize,
|
|
7152
7230
|
titleOption = _ref.titleOption,
|
|
7153
7231
|
paymentTitleOption = _ref.paymentTitleOption,
|
|
7232
|
+
_ref$compliantOption = _ref.compliantOption,
|
|
7233
|
+
compliantOption = _ref$compliantOption === void 0 ? true : _ref$compliantOption,
|
|
7154
7234
|
transactionOption = _ref.transactionOption,
|
|
7155
7235
|
kimaBackendUrl = _ref.kimaBackendUrl,
|
|
7156
7236
|
kimaNodeProviderQuery = _ref.kimaNodeProviderQuery,
|
|
@@ -7171,6 +7251,7 @@ var KimaTransactionWidget = function KimaTransactionWidget(_ref) {
|
|
|
7171
7251
|
React.useEffect(function () {
|
|
7172
7252
|
dispatch(setTheme(theme));
|
|
7173
7253
|
if (transactionOption) dispatch(setTransactionOption(transactionOption));
|
|
7254
|
+
dispatch(setCompliantOption(compliantOption));
|
|
7174
7255
|
dispatch(setErrorHandler(errorHandler));
|
|
7175
7256
|
dispatch(setCloseHandler(closeHandler));
|
|
7176
7257
|
dispatch(setSuccessHandler(successHandler));
|
|
@@ -7181,14 +7262,30 @@ var KimaTransactionWidget = function KimaTransactionWidget(_ref) {
|
|
|
7181
7262
|
dispatch(setTargetNetwork((transactionOption === null || transactionOption === void 0 ? void 0 : transactionOption.targetChain) || exports.SupportNetworks.ETHEREUM));
|
|
7182
7263
|
(function () {
|
|
7183
7264
|
try {
|
|
7184
|
-
var
|
|
7265
|
+
var _temp4 = function _temp4() {
|
|
7266
|
+
return _catch(function () {
|
|
7267
|
+
var _temp = function () {
|
|
7268
|
+
if (transactionOption !== null && transactionOption !== void 0 && transactionOption.targetAddress) {
|
|
7269
|
+
return Promise.resolve(fetchWrapper.post(kimaBackendUrl + "/compliant", JSON.stringify({
|
|
7270
|
+
address: transactionOption === null || transactionOption === void 0 ? void 0 : transactionOption.targetAddress
|
|
7271
|
+
}))).then(function (compliantRes) {
|
|
7272
|
+
dispatch(setTargetCompliant(compliantRes === 'ok'));
|
|
7273
|
+
});
|
|
7274
|
+
}
|
|
7275
|
+
}();
|
|
7276
|
+
if (_temp && _temp.then) return _temp.then(function () {});
|
|
7277
|
+
}, function (e) {
|
|
7278
|
+
console.log('xplorisk check failed', e);
|
|
7279
|
+
});
|
|
7280
|
+
};
|
|
7281
|
+
var _temp5 = _catch(function () {
|
|
7185
7282
|
return Promise.resolve(fetchWrapper.get(kimaNodeProviderQuery + "/kima-finance/kima/kima/get_available_chains/" + ((transactionOption === null || transactionOption === void 0 ? void 0 : transactionOption.targetChain) || exports.SupportNetworks.ETHEREUM))).then(function (networks) {
|
|
7186
7283
|
dispatch(setOriginNetwork(networks.Chains[0]));
|
|
7187
7284
|
});
|
|
7188
7285
|
}, function (e) {
|
|
7189
7286
|
console.log('rpc disconnected', e);
|
|
7190
7287
|
});
|
|
7191
|
-
return
|
|
7288
|
+
return _temp5 && _temp5.then ? _temp5.then(_temp4) : _temp4(_temp5);
|
|
7192
7289
|
} catch (e) {
|
|
7193
7290
|
Promise.reject(e);
|
|
7194
7291
|
}
|