@imtbl/checkout-widgets 2.4.14-alpha.0 → 2.4.14-alpha.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/browser/{AddTokensWidget-CF1YN2qr.js → AddTokensWidget-ShqEH0bA.js} +3 -3
- package/dist/browser/{BridgeWidget-D1iYISBu.js → BridgeWidget-DJLZDZAJ.js} +6 -6
- package/dist/browser/{CommerceWidget-0xlC0qeb.js → CommerceWidget-nbdP_6Ip.js} +13 -13
- package/dist/browser/{FeesBreakdown-9FvnOOCN.js → FeesBreakdown-DvFl9V2q.js} +1 -1
- package/dist/browser/{OnRampWidget-Db0Ma0JP.js → OnRampWidget-cqzl_-aK.js} +3 -3
- package/dist/browser/{SaleWidget-BiU-JU_Y.js → SaleWidget-iKKGkvvk.js} +10 -10
- package/dist/browser/{SpendingCapHero-DoDWVXeM.js → SpendingCapHero-Daz_5xcg.js} +1 -1
- package/dist/browser/{SwapWidget-0b44o7OG.js → SwapWidget-Y6Xo5WSo.js} +43 -54
- package/dist/browser/{TokenImage-ON5CsElS.js → TokenImage-DW2XzMbU.js} +1 -1
- package/dist/browser/{TopUpView-BSsm_pag.js → TopUpView-BORiBYNf.js} +1 -1
- package/dist/browser/{WalletApproveHero-BpQET2Ry.js → WalletApproveHero-4jx0GgAA.js} +2 -2
- package/dist/browser/{WalletWidget-DPtHMDzk.js → WalletWidget-BwFVpnAI.js} +3 -3
- package/dist/browser/{auto-track-YB97xHhP.js → auto-track-DZymc0UC.js} +1 -1
- package/dist/browser/{index-CYSUCb_r.js → index-B6p10_zD.js} +102 -69
- package/dist/browser/{index-B6LlGDqn.js → index-BQ53A9R_.js} +2 -2
- package/dist/browser/{index-CxVwwdjo.js → index-Bhny47VI.js} +1 -1
- package/dist/browser/{index-DhJhrEPT.js → index-BjxyO_sP.js} +1 -1
- package/dist/browser/{index-DfqbSiW-.js → index-CGpeUDFk.js} +1 -1
- package/dist/browser/{index-_E9_8iXP.js → index-CZhAFfYE.js} +1 -1
- package/dist/browser/{index-BGfRODL9.js → index-DQSmVvsC.js} +1 -1
- package/dist/browser/{index-DkUaawBA.js → index-bhVqRauZ.js} +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/{index.umd-C_C0lXQh.js → index.umd-DQuNDZ-6.js} +1 -1
- package/dist/browser/{useInterval-BjJWflew.js → useInterval-BPf23nxq.js} +1 -1
- package/dist/types/widgets/swap/context/SwapContext.d.ts +3 -9
- package/package.json +7 -7
- package/src/widgets/swap/SwapWidget.tsx +0 -23
- package/src/widgets/swap/components/SwapForm.tsx +45 -21
- package/src/widgets/swap/context/SwapContext.ts +1 -16
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { e7 as __awaiter, e8 as __generator } from './index-B6p10_zD.js';
|
|
2
2
|
|
|
3
3
|
function loadLegacyVideoPlugins(analytics) {
|
|
4
4
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -7,7 +7,7 @@ function loadLegacyVideoPlugins(analytics) {
|
|
|
7
7
|
switch (_a.label) {
|
|
8
8
|
case 0: return [4 /*yield*/, import(
|
|
9
9
|
// @ts-expect-error
|
|
10
|
-
'./index.umd-
|
|
10
|
+
'./index.umd-DQuNDZ-6.js').then(function (n) { return n.i; })
|
|
11
11
|
// This is super gross, but we need to support the `window.analytics.plugins` namespace
|
|
12
12
|
// that is linked in the segment docs in order to be backwards compatible with ajs-classic
|
|
13
13
|
// @ts-expect-error
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { e7 as __awaiter, e8 as __generator, e9 as loadScript, ea as getNextIntegrationsURL, eb as unloadScript, ec as __spreadArray, ed as isOffline, ee as __assign, ef as ContextCancelation, eg as applyDestinationMiddleware, eh as dist, ei as isServer, ej as mergedOptions, ek as isPlainObject, el as pWhile, em as PriorityQueue, en as PersistedPriorityQueue, eo as attempt, ep as isOnline, eq as Context } from './index-B6p10_zD.js';
|
|
2
2
|
import { i as isPlanEventEnabled } from './is-plan-event-enabled-mXX0dwl-.js';
|
|
3
3
|
|
|
4
4
|
function normalizeName(name) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dZ as se$1, d_ as T$2, d$ as oe$1, e0 as R$1, e1 as a$2, e2 as te$1, e3 as p$1, e4 as ne$1, e5 as y$1 } from './index-B6p10_zD.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { e7 as __awaiter, e8 as __generator, ei as isServer, ea as getNextIntegrationsURL, e9 as loadScript } from './index-B6p10_zD.js';
|
|
2
2
|
|
|
3
3
|
function remoteMiddlewares(ctx, settings, obfuscate) {
|
|
4
4
|
var _a;
|
package/dist/browser/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { et as WidgetsFactory } from './index-B6p10_zD.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as reactExports,
|
|
1
|
+
import { r as reactExports, dY as useBrowserLayoutEffect } from './index-B6p10_zD.js';
|
|
2
2
|
|
|
3
3
|
// Inspired by https://usehooks-ts.com/react-hook/use-interval
|
|
4
4
|
function useInterval(callback, delay) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WalletProviderName, GetBalanceResult, NetworkInfo, TokenInfo, SwapDirection
|
|
1
|
+
import { WalletProviderName, GetBalanceResult, NetworkInfo, TokenInfo, SwapDirection } from '@imtbl/checkout-sdk';
|
|
2
2
|
import { Exchange } from '@imtbl/dex-sdk';
|
|
3
3
|
export interface SwapState {
|
|
4
4
|
exchange: Exchange | null;
|
|
@@ -8,7 +8,6 @@ export interface SwapState {
|
|
|
8
8
|
supportedTopUps: TopUpFeature | null;
|
|
9
9
|
allowedTokens: TokenInfo[];
|
|
10
10
|
autoProceed: boolean;
|
|
11
|
-
riskAssessment: AssessmentResult | undefined;
|
|
12
11
|
}
|
|
13
12
|
export interface TopUpFeature {
|
|
14
13
|
isOnRampEnabled?: boolean;
|
|
@@ -23,7 +22,7 @@ export interface SwapContextState {
|
|
|
23
22
|
export interface SwapAction {
|
|
24
23
|
payload: ActionPayload;
|
|
25
24
|
}
|
|
26
|
-
type ActionPayload = SetExchangePayload | SetWalletProviderNamePayload | SetNetworkPayload | SetSupportedTopUpPayload | SetTokenBalancesPayload | SetAllowedTokensPayload | SetAutoProceedPayload
|
|
25
|
+
type ActionPayload = SetExchangePayload | SetWalletProviderNamePayload | SetNetworkPayload | SetSupportedTopUpPayload | SetTokenBalancesPayload | SetAllowedTokensPayload | SetAutoProceedPayload;
|
|
27
26
|
export declare enum SwapActions {
|
|
28
27
|
SET_EXCHANGE = "SET_EXCHANGE",
|
|
29
28
|
SET_WALLET_PROVIDER_NAME = "SET_WALLET_PROVIDER_NAME",
|
|
@@ -31,8 +30,7 @@ export declare enum SwapActions {
|
|
|
31
30
|
SET_SUPPORTED_TOP_UPS = "SET_SUPPORTED_TOP_UPS",
|
|
32
31
|
SET_TOKEN_BALANCES = "SET_TOKEN_BALANCES",
|
|
33
32
|
SET_ALLOWED_TOKENS = "SET_ALLOWED_TOKENS",
|
|
34
|
-
SET_AUTO_PROCEED = "SET_AUTO_PROCEED"
|
|
35
|
-
SET_RISK_ASSESSMENT = "SET_RISK_ASSESSMENT"
|
|
33
|
+
SET_AUTO_PROCEED = "SET_AUTO_PROCEED"
|
|
36
34
|
}
|
|
37
35
|
export interface SetExchangePayload {
|
|
38
36
|
type: SwapActions.SET_EXCHANGE;
|
|
@@ -63,10 +61,6 @@ export interface SetAutoProceedPayload {
|
|
|
63
61
|
autoProceed: boolean;
|
|
64
62
|
direction: SwapDirection;
|
|
65
63
|
}
|
|
66
|
-
export interface SetRiskAssessmentPayload {
|
|
67
|
-
type: SwapActions.SET_RISK_ASSESSMENT;
|
|
68
|
-
riskAssessment: AssessmentResult;
|
|
69
|
-
}
|
|
70
64
|
export declare const SwapContext: import("react").Context<SwapContextState>;
|
|
71
65
|
export type Reducer<S, A> = (prevState: S, action: A) => S;
|
|
72
66
|
export declare const swapReducer: Reducer<SwapState, SwapAction>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imtbl/checkout-widgets",
|
|
3
|
-
"version": "2.4.14-alpha.
|
|
3
|
+
"version": "2.4.14-alpha.1",
|
|
4
4
|
"browserslist": {
|
|
5
5
|
"production": [
|
|
6
6
|
">0.2%",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
"@biom3/design-tokens": "^0.4.5",
|
|
19
19
|
"@biom3/react": "^0.29.4",
|
|
20
20
|
"@emotion/react": "^11.11.3",
|
|
21
|
-
"@imtbl/bridge-sdk": "2.4.14-alpha.
|
|
22
|
-
"@imtbl/checkout-sdk": "2.4.14-alpha.
|
|
23
|
-
"@imtbl/config": "2.4.14-alpha.
|
|
24
|
-
"@imtbl/cryptofiat": "2.4.14-alpha.
|
|
25
|
-
"@imtbl/dex-sdk": "2.4.14-alpha.
|
|
26
|
-
"@imtbl/passport": "2.4.14-alpha.
|
|
21
|
+
"@imtbl/bridge-sdk": "2.4.14-alpha.1",
|
|
22
|
+
"@imtbl/checkout-sdk": "2.4.14-alpha.1",
|
|
23
|
+
"@imtbl/config": "2.4.14-alpha.1",
|
|
24
|
+
"@imtbl/cryptofiat": "2.4.14-alpha.1",
|
|
25
|
+
"@imtbl/dex-sdk": "2.4.14-alpha.1",
|
|
26
|
+
"@imtbl/passport": "2.4.14-alpha.1",
|
|
27
27
|
"@imtbl/react-analytics": "0.3.2-alpha",
|
|
28
28
|
"@rive-app/react-canvas-lite": "^4.9.0",
|
|
29
29
|
"@walletconnect/ethereum-provider": "^2.11.1",
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
TokenFilterTypes, IMTBLWidgetEvents, SwapWidgetParams,
|
|
11
11
|
SwapDirection,
|
|
12
|
-
fetchRiskAssessment,
|
|
13
12
|
WalletProviderName,
|
|
14
13
|
} from '@imtbl/checkout-sdk';
|
|
15
14
|
import { useTranslation } from 'react-i18next';
|
|
@@ -193,28 +192,6 @@ export default function SwapWidget({
|
|
|
193
192
|
})();
|
|
194
193
|
}, [checkout, provider]);
|
|
195
194
|
|
|
196
|
-
useEffect(() => {
|
|
197
|
-
if (!checkout || swapState.riskAssessment) {
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
(async () => {
|
|
202
|
-
const address = await (await provider?.getSigner())?.getAddress();
|
|
203
|
-
|
|
204
|
-
if (!address) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const assessment = await fetchRiskAssessment([address], checkout.config);
|
|
209
|
-
swapDispatch({
|
|
210
|
-
payload: {
|
|
211
|
-
type: SwapActions.SET_RISK_ASSESSMENT,
|
|
212
|
-
riskAssessment: assessment,
|
|
213
|
-
},
|
|
214
|
-
});
|
|
215
|
-
})();
|
|
216
|
-
}, [checkout, provider]);
|
|
217
|
-
|
|
218
195
|
useEffect(() => {
|
|
219
196
|
swapDispatch({
|
|
220
197
|
payload: {
|
|
@@ -5,8 +5,12 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
Box, ButtCon, Heading, Icon, OptionKey, Tooltip, Body,
|
|
7
7
|
} from '@biom3/react';
|
|
8
|
-
import {
|
|
9
|
-
|
|
8
|
+
import {
|
|
9
|
+
fetchRiskAssessmentV2,
|
|
10
|
+
isSingleAddressSanctioned,
|
|
11
|
+
TokenInfo,
|
|
12
|
+
WidgetTheme,
|
|
13
|
+
} from '@imtbl/checkout-sdk';
|
|
10
14
|
import { TransactionResponse } from '@imtbl/dex-sdk';
|
|
11
15
|
import { useTranslation } from 'react-i18next';
|
|
12
16
|
import { Environment } from '@imtbl/config';
|
|
@@ -92,7 +96,6 @@ export function SwapForm({ data, theme, cancelAutoProceed }: SwapFromProps) {
|
|
|
92
96
|
tokenBalances,
|
|
93
97
|
network,
|
|
94
98
|
autoProceed,
|
|
95
|
-
riskAssessment,
|
|
96
99
|
},
|
|
97
100
|
} = useContext(SwapContext);
|
|
98
101
|
|
|
@@ -815,18 +818,7 @@ export function SwapForm({ data, theme, cancelAutoProceed }: SwapFromProps) {
|
|
|
815
818
|
|
|
816
819
|
const sendTransaction = async () => {
|
|
817
820
|
if (!quote) return;
|
|
818
|
-
if (riskAssessment && isAddressSanctioned(riskAssessment)) {
|
|
819
|
-
viewDispatch({
|
|
820
|
-
payload: {
|
|
821
|
-
type: ViewActions.UPDATE_VIEW,
|
|
822
|
-
view: {
|
|
823
|
-
type: SwapWidgetViews.SERVICE_UNAVAILABLE,
|
|
824
|
-
},
|
|
825
|
-
},
|
|
826
|
-
});
|
|
827
821
|
|
|
828
|
-
return;
|
|
829
|
-
}
|
|
830
822
|
const transaction = quote;
|
|
831
823
|
const isValid = SwapFormValidator();
|
|
832
824
|
// Tracking swap from data here and is valid or not to understand behaviour
|
|
@@ -836,12 +828,12 @@ export function SwapForm({ data, theme, cancelAutoProceed }: SwapFromProps) {
|
|
|
836
828
|
control: 'Swap',
|
|
837
829
|
controlType: 'Button',
|
|
838
830
|
extras: {
|
|
839
|
-
swapFromAddress:
|
|
840
|
-
swapFromAmount:
|
|
841
|
-
swapFromTokenSymbol:
|
|
842
|
-
swapToAddress:
|
|
843
|
-
swapToAmount:
|
|
844
|
-
swapToTokenSymbol:
|
|
831
|
+
swapFromAddress: fromToken?.address,
|
|
832
|
+
swapFromAmount: fromAmount,
|
|
833
|
+
swapFromTokenSymbol: fromToken?.symbol,
|
|
834
|
+
swapToAddress: toToken?.address,
|
|
835
|
+
swapToAmount: toAmount,
|
|
836
|
+
swapToTokenSymbol: toToken?.symbol,
|
|
845
837
|
isSwapFormValid: isValid,
|
|
846
838
|
hasFundsForGas: !insufficientFundsForGas,
|
|
847
839
|
autoProceed,
|
|
@@ -855,6 +847,38 @@ export function SwapForm({ data, theme, cancelAutoProceed }: SwapFromProps) {
|
|
|
855
847
|
return;
|
|
856
848
|
}
|
|
857
849
|
|
|
850
|
+
// Perform sanctions check once we have valid asset and amount data
|
|
851
|
+
const address = await (await provider?.getSigner())?.getAddress();
|
|
852
|
+
|
|
853
|
+
if (!address) {
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
if (!fromToken?.address || !fromAmount) {
|
|
858
|
+
throw new Error('Invalid form data: fromToken.Address or fromAmount is missing');
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
const riskAssessmentData = [{
|
|
862
|
+
address,
|
|
863
|
+
tokenAddr: fromToken.address,
|
|
864
|
+
amount: parseUnits(fromAmount, fromToken.decimals),
|
|
865
|
+
}];
|
|
866
|
+
|
|
867
|
+
const riskAssessment = await fetchRiskAssessmentV2(riskAssessmentData, checkout.config);
|
|
868
|
+
|
|
869
|
+
if (riskAssessment && isSingleAddressSanctioned(riskAssessment, address)) {
|
|
870
|
+
viewDispatch({
|
|
871
|
+
payload: {
|
|
872
|
+
type: ViewActions.UPDATE_VIEW,
|
|
873
|
+
view: {
|
|
874
|
+
type: SwapWidgetViews.SERVICE_UNAVAILABLE,
|
|
875
|
+
},
|
|
876
|
+
},
|
|
877
|
+
});
|
|
878
|
+
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
|
|
858
882
|
try {
|
|
859
883
|
// check for switch network here
|
|
860
884
|
const currentChainId = await (provider.provider as any).send('eth_chainId', []);
|
|
@@ -959,7 +983,7 @@ export function SwapForm({ data, theme, cancelAutoProceed }: SwapFromProps) {
|
|
|
959
983
|
testInputMode="decimal"
|
|
960
984
|
textInputValue={fromAmount}
|
|
961
985
|
textInputPlaceholder={t('views.SWAP.swapForm.from.inputPlaceholder')}
|
|
962
|
-
textInputSubtext={`${t('views.SWAP.content.fiatPricePrefix')}
|
|
986
|
+
textInputSubtext={`${t('views.SWAP.content.fiatPricePrefix')}
|
|
963
987
|
$${formatZeroAmount(
|
|
964
988
|
fromFiatValue,
|
|
965
989
|
true,
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
NetworkInfo,
|
|
5
5
|
TokenInfo,
|
|
6
6
|
SwapDirection,
|
|
7
|
-
AssessmentResult,
|
|
8
7
|
} from '@imtbl/checkout-sdk';
|
|
9
8
|
import { Exchange } from '@imtbl/dex-sdk';
|
|
10
9
|
import { createContext } from 'react';
|
|
@@ -17,7 +16,6 @@ export interface SwapState {
|
|
|
17
16
|
supportedTopUps: TopUpFeature | null;
|
|
18
17
|
allowedTokens: TokenInfo[];
|
|
19
18
|
autoProceed: boolean;
|
|
20
|
-
riskAssessment: AssessmentResult | undefined;
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
export interface TopUpFeature {
|
|
@@ -34,7 +32,6 @@ export const initialSwapState: SwapState = {
|
|
|
34
32
|
supportedTopUps: null,
|
|
35
33
|
allowedTokens: [],
|
|
36
34
|
autoProceed: false,
|
|
37
|
-
riskAssessment: undefined,
|
|
38
35
|
};
|
|
39
36
|
|
|
40
37
|
export interface SwapContextState {
|
|
@@ -53,8 +50,7 @@ type ActionPayload =
|
|
|
53
50
|
| SetSupportedTopUpPayload
|
|
54
51
|
| SetTokenBalancesPayload
|
|
55
52
|
| SetAllowedTokensPayload
|
|
56
|
-
| SetAutoProceedPayload
|
|
57
|
-
| SetRiskAssessmentPayload;
|
|
53
|
+
| SetAutoProceedPayload;
|
|
58
54
|
|
|
59
55
|
export enum SwapActions {
|
|
60
56
|
SET_EXCHANGE = 'SET_EXCHANGE',
|
|
@@ -64,7 +60,6 @@ export enum SwapActions {
|
|
|
64
60
|
SET_TOKEN_BALANCES = 'SET_TOKEN_BALANCES',
|
|
65
61
|
SET_ALLOWED_TOKENS = 'SET_ALLOWED_TOKENS',
|
|
66
62
|
SET_AUTO_PROCEED = 'SET_AUTO_PROCEED',
|
|
67
|
-
SET_RISK_ASSESSMENT = 'SET_RISK_ASSESSMENT',
|
|
68
63
|
}
|
|
69
64
|
|
|
70
65
|
export interface SetExchangePayload {
|
|
@@ -103,11 +98,6 @@ export interface SetAutoProceedPayload {
|
|
|
103
98
|
direction: SwapDirection;
|
|
104
99
|
}
|
|
105
100
|
|
|
106
|
-
export interface SetRiskAssessmentPayload {
|
|
107
|
-
type: SwapActions.SET_RISK_ASSESSMENT;
|
|
108
|
-
riskAssessment: AssessmentResult;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
101
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
112
102
|
export const SwapContext = createContext<SwapContextState>({
|
|
113
103
|
swapState: initialSwapState,
|
|
@@ -165,11 +155,6 @@ export const swapReducer: Reducer<SwapState, SwapAction> = (
|
|
|
165
155
|
autoProceed: action.payload.autoProceed,
|
|
166
156
|
direction: action.payload.direction,
|
|
167
157
|
};
|
|
168
|
-
case SwapActions.SET_RISK_ASSESSMENT:
|
|
169
|
-
return {
|
|
170
|
-
...state,
|
|
171
|
-
riskAssessment: action.payload.riskAssessment,
|
|
172
|
-
};
|
|
173
158
|
default:
|
|
174
159
|
return state;
|
|
175
160
|
}
|