@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.
@@ -623,7 +623,10 @@ const initialState = {
623
623
  backendUrl: '',
624
624
  nodeProviderQuery: '',
625
625
  txId: -1,
626
- currencyOptions: COIN_LIST['USDK']
626
+ currencyOptions: COIN_LIST['USDK'],
627
+ compliantOption: true,
628
+ sourceCompliant: true,
629
+ targetCompliant: true
627
630
  };
628
631
  const optionSlice = createSlice({
629
632
  name: 'option',
@@ -637,6 +640,9 @@ const optionSlice = createSlice({
637
640
  state.serviceFee = -1;
638
641
  state.amount = 0;
639
642
  state.targetAddress = '';
643
+ state.compliantOption = true;
644
+ state.sourceCompliant = true;
645
+ state.targetCompliant = true;
640
646
  },
641
647
  setTheme: (state, action) => {
642
648
  state.theme = action.payload;
@@ -709,6 +715,15 @@ const optionSlice = createSlice({
709
715
  },
710
716
  setCurrencyOptions: (state, action) => {
711
717
  state.currencyOptions = action.payload;
718
+ },
719
+ setCompliantOption: (state, action) => {
720
+ state.compliantOption = action.payload;
721
+ },
722
+ setSourceCompliant: (state, action) => {
723
+ state.sourceCompliant = action.payload;
724
+ },
725
+ setTargetCompliant: (state, action) => {
726
+ state.targetCompliant = action.payload;
712
727
  }
713
728
  }
714
729
  });
@@ -737,7 +752,10 @@ const {
737
752
  setBackendUrl,
738
753
  setNodeProviderQuery,
739
754
  setTxId,
740
- setCurrencyOptions
755
+ setCurrencyOptions,
756
+ setCompliantOption,
757
+ setSourceCompliant,
758
+ setTargetCompliant
741
759
  } = optionSlice.actions;
742
760
  var optionReducer = optionSlice.reducer;
743
761
 
@@ -774,6 +792,9 @@ const selectBackendUrl = state => state.option.backendUrl;
774
792
  const selectNodeProviderQuery = state => state.option.nodeProviderQuery;
775
793
  const selectTxId = state => state.option.txId;
776
794
  const selectCurrencyOptions = state => state.option.currencyOptions;
795
+ const selectCompliantOption = state => state.option.compliantOption;
796
+ const selectSourceCompliant = state => state.option.sourceCompliant;
797
+ const selectTargetCompliant = state => state.option.targetCompliant;
777
798
 
778
799
  const EthereumProviderContext = React.createContext({
779
800
  connect: () => {},
@@ -1809,6 +1830,8 @@ const WalletButton = ({
1809
1830
  }) => {
1810
1831
  const dispatch = useDispatch();
1811
1832
  const theme = useSelector(selectTheme);
1833
+ const sourceCompliant = useSelector(selectSourceCompliant);
1834
+ const compliantOption = useSelector(selectCompliantOption);
1812
1835
  const selectedNetwork = useSelector(selectOriginNetwork);
1813
1836
  const {
1814
1837
  disconnect: disconnectSolana
@@ -1846,9 +1869,11 @@ const WalletButton = ({
1846
1869
  "data-testid": connectWalletBtn
1847
1870
  }, React.createElement(PrimaryButton, {
1848
1871
  clickHandler: handleClick
1849
- }, isReady ? `Disconnect ${getShortenedAddress(walletAddress || '')}` : 'Wallet'), !isReady && React.createElement("p", {
1872
+ }, isReady ? `Disconnect ${getShortenedAddress(walletAddress || '')}` : 'Wallet'), !isReady ? React.createElement("p", {
1850
1873
  className: 'provider-error'
1851
- }, statusMessage));
1874
+ }, statusMessage) : !sourceCompliant && compliantOption ? React.createElement("p", {
1875
+ className: 'provider-error'
1876
+ }, "Non-compliant address") : null);
1852
1877
  };
1853
1878
 
1854
1879
  const CoinDropdown = () => {
@@ -2345,6 +2370,8 @@ const SingleForm = ({
2345
2370
  const mode = useSelector(selectMode);
2346
2371
  const theme = useSelector(selectTheme);
2347
2372
  const amount = useSelector(selectAmount);
2373
+ const compliantOption = useSelector(selectCompliantOption);
2374
+ const targetCompliant = useSelector(selectTargetCompliant);
2348
2375
  const transactionOption = useSelector(selectTransactionOption);
2349
2376
  const selectedCoin = useSelector(selectCurrencyOptions);
2350
2377
  return React.createElement("div", {
@@ -2370,7 +2397,9 @@ const SingleForm = ({
2370
2397
  className: `form-item ${theme}`
2371
2398
  }, React.createElement("span", {
2372
2399
  className: 'label'
2373
- }, "Target Address:"), React.createElement(AddressInput, null)), mode === ModeOptions.bridge ? React.createElement("div", {
2400
+ }, "Target Address:"), React.createElement(AddressInput, null), compliantOption && !targetCompliant ? React.createElement("p", {
2401
+ className: 'error'
2402
+ }, "Non-compliant address") : null), mode === ModeOptions.bridge ? React.createElement("div", {
2374
2403
  className: `form-item ${theme}`
2375
2404
  }, React.createElement("span", {
2376
2405
  className: 'label'
@@ -6449,6 +6478,9 @@ const TransferWidget = ({
6449
6478
  const sourceChain = useSelector(selectOriginNetwork);
6450
6479
  const targetAddress = useSelector(selectTargetAddress);
6451
6480
  const targetNetwork = useSelector(selectTargetNetwork);
6481
+ const compliantOption = useSelector(selectCompliantOption);
6482
+ const sourceCompliant = useSelector(selectSourceCompliant);
6483
+ const targetCompliant = useSelector(selectTargetCompliant);
6452
6484
  const isApproving = useSelector(selectApproving);
6453
6485
  const errorHandler = useSelector(selectErrorHandler);
6454
6486
  const closeHandler = useSelector(selectCloseHandler);
@@ -6458,6 +6490,32 @@ const TransferWidget = ({
6458
6490
  } = useCurrencyOptions();
6459
6491
  const backendUrl = useSelector(selectBackendUrl);
6460
6492
  const nodeProviderQuery = useSelector(selectNodeProviderQuery);
6493
+ useEffect(() => {
6494
+ if (!walletAddress) return;
6495
+ (async function () {
6496
+ try {
6497
+ const res = await fetchWrapper.post(`${backendUrl}/compliant`, JSON.stringify({
6498
+ address: walletAddress
6499
+ }));
6500
+ dispatch(setSourceCompliant(res === 'ok'));
6501
+ } catch (e) {
6502
+ console.log('xplorisk check failed', e);
6503
+ }
6504
+ })();
6505
+ }, [walletAddress]);
6506
+ useEffect(() => {
6507
+ if (!targetAddress) return;
6508
+ (async function () {
6509
+ try {
6510
+ const res = await fetchWrapper.post(`${backendUrl}/compliant`, JSON.stringify({
6511
+ address: targetAddress
6512
+ }));
6513
+ dispatch(setTargetCompliant(res === 'ok'));
6514
+ } catch (e) {
6515
+ console.log('xplorisk check failed', e);
6516
+ }
6517
+ })();
6518
+ }, [targetAddress]);
6461
6519
  useEffect(() => {
6462
6520
  if (!nodeProviderQuery) return;
6463
6521
  (async function () {
@@ -6560,14 +6618,16 @@ const TransferWidget = ({
6560
6618
  }
6561
6619
  return;
6562
6620
  }
6563
- if (mode === ModeOptions.payment && wizardStep === 1 && fee >= 0) {
6621
+ if (mode === ModeOptions.payment && wizardStep === 1 && fee >= 0 && (!compliantOption || sourceCompliant && targetCompliant)) {
6564
6622
  dispatch(setConfirming(true));
6565
6623
  setWizardStep(5);
6566
6624
  } else setWizardStep(step => step + 1);
6567
6625
  }
6568
6626
  if (!isWizard && !formStep) {
6569
6627
  if (isReady) {
6570
- if (fee >= 0 && mode === ModeOptions.payment || fee >= 0 && targetAddress && amount > 0) {
6628
+ if (fee < 0) return;
6629
+ if (compliantOption && (!sourceCompliant || !targetCompliant)) return;
6630
+ if (mode === ModeOptions.payment || targetAddress && amount > 0) {
6571
6631
  dispatch(setConfirming(true));
6572
6632
  setFormStep(1);
6573
6633
  }
@@ -6662,6 +6722,7 @@ const KimaTransactionWidget = ({
6662
6722
  fontSize: _fontSize = FontSizeOptions.medium,
6663
6723
  titleOption,
6664
6724
  paymentTitleOption,
6725
+ compliantOption: _compliantOption = true,
6665
6726
  transactionOption,
6666
6727
  kimaBackendUrl,
6667
6728
  kimaNodeProviderQuery,
@@ -6674,6 +6735,7 @@ const KimaTransactionWidget = ({
6674
6735
  useEffect(() => {
6675
6736
  dispatch(setTheme(_theme));
6676
6737
  if (transactionOption) dispatch(setTransactionOption(transactionOption));
6738
+ dispatch(setCompliantOption(_compliantOption));
6677
6739
  dispatch(setErrorHandler(_errorHandler));
6678
6740
  dispatch(setCloseHandler(_closeHandler));
6679
6741
  dispatch(setSuccessHandler(_successHandler));
@@ -6689,6 +6751,16 @@ const KimaTransactionWidget = ({
6689
6751
  } catch (e) {
6690
6752
  console.log('rpc disconnected', e);
6691
6753
  }
6754
+ try {
6755
+ if (transactionOption !== null && transactionOption !== void 0 && transactionOption.targetAddress) {
6756
+ const compliantRes = await fetchWrapper.post(`${kimaBackendUrl}/compliant`, JSON.stringify({
6757
+ address: transactionOption === null || transactionOption === void 0 ? void 0 : transactionOption.targetAddress
6758
+ }));
6759
+ dispatch(setTargetCompliant(compliantRes === 'ok'));
6760
+ }
6761
+ } catch (e) {
6762
+ console.log('xplorisk check failed', e);
6763
+ }
6692
6764
  })();
6693
6765
  dispatch(setTargetAddress((transactionOption === null || transactionOption === void 0 ? void 0 : transactionOption.targetAddress) || ''));
6694
6766
  dispatch(setAmount((transactionOption === null || transactionOption === void 0 ? void 0 : transactionOption.amount) || 0));