Skip to content

Commit

Permalink
Merge branch 'main' into add-tokens/tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
jiyounglee authored Dec 4, 2024
2 parents c0c99f6 + f8623bc commit 013e09f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export function DeliverToWalletDrawer({
getShouldRequestWalletPermissions={
selectedSameFromWalletType
}
shouldIdentifyUser={false}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export function PayWithWalletDrawer({
disabledOptions={disabledOptions}
bottomSlot={payWithCardItem}
onConnect={handleOnConnect}
shouldIdentifyUser={false}
/>
);
}
4 changes: 2 additions & 2 deletions packages/checkout/widgets-lib/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@
"from":{
"label": "Send from",
"caption": "Choose a wallet to bridge or swap from"
},
},
"to": {
"label": "Deliver to",
"caption": "Choose where you want your tokens to go"
Expand Down Expand Up @@ -839,7 +839,7 @@
},
"screen2": {
"title": "You can deliver tokens to Passport\n& pay from any wallet",
"caption": "whats evolved",
"caption": "what's evolved",
"buttonText": "Next"
},
"screen3": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import { checkSanctionedAddresses } from '../functions/checkSanctionedAddresses'
import { getFormattedAmounts } from '../functions/getFormattedNumber';
import { RouteData } from '../../../lib/squid/types';
import { SQUID_NATIVE_TOKEN } from '../../../lib/squid/config';
import { identifyUser } from '../../../lib/analytics/identifyUser';

interface AddTokensProps {
checkout: Checkout;
Expand Down Expand Up @@ -119,8 +120,13 @@ export function AddTokens({
isSwapAvailable,
} = addTokensState;

const {
track,
page,
identify,
user,
} = useAnalytics();
const { viewDispatch } = useContext(ViewContext);
const { track, page } = useAnalytics();
const { t } = useTranslation();

const {
Expand Down Expand Up @@ -259,6 +265,17 @@ export function AddTokens({
[providers],
);

useEffect(() => {
if (!lockedToProvider) { return; }

(async () => {
const userData = user ? await user() : undefined;
const anonymousId = userData?.anonymousId();

await identifyUser(identify, toProvider!, { anonymousId });
})();
}, [toProvider, lockedToProvider]);

const toChain = useMemo(
() => chains?.find((chain) => chain.id === ChainId.IMTBL_ZKEVM_MAINNET.toString()),
[chains],
Expand Down Expand Up @@ -638,7 +655,7 @@ export function AddTokens({
/>

<HeroFormControl.Caption>
{`${t('views.ADD_TOKENS.fees.fiatPricePrefix')}
{`${t('views.ADD_TOKENS.fees.fiatPricePrefix')}
$${getFormattedAmounts(selectedAmountUsd)}`}
</HeroFormControl.Caption>
</HeroFormControl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ export function OnRampMain({
screen: 'OrderInProgress',
control: 'PaymentProcessing',
controlType: 'IframeEvent',
extras: { ...miscProps },
extras: {
...miscProps,
transactionHash: event.data.transactionHash,
},
}); // checkoutOnRampOrderInProgress_PaymentProcessingIframeEvent
}
if (event.data.status === TransakStatuses.COMPLETED) {
Expand All @@ -117,7 +120,10 @@ export function OnRampMain({
screen: 'Success',
control: 'PaymentCompleted',
controlType: 'IframeEvent',
extras: { ...miscProps },
extras: {
...miscProps,
transactionHash: event.data.transactionHash,
},
}); // checkoutOnRampSuccess_PaymentCompletedIframeEvent
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ function AddTokensUI() {
[checkout]
);

const [presetToProvider, setPresetToProvider] = useState<boolean>(false);
const getPersistedToPresetProvider = () => localStorage.getItem('imtbl/addtokens_presetToProvider') === 'true';
const [presetToProvider, setPresetToProvider] = useState<boolean>(getPersistedToPresetProvider());
const [toProvider, setToProvider] = useState<Web3Provider | undefined>(undefined);

const [toTokenAddress, setToTokenAddress] = useState<string | undefined>(undefined);
Expand Down Expand Up @@ -81,6 +82,12 @@ function AddTokensUI() {
}, []);

useEffect(() => {
const presetToProviderValue = getPersistedToPresetProvider();

if (presetToProviderValue !== presetToProvider) {
localStorage.setItem('imtbl/addtokens_presetToProvider', presetToProvider.toString());
}

if (!checkout || !factory) return;
if (!presetToProvider) {
toProvider && addTokens.unmount();
Expand Down

0 comments on commit 013e09f

Please sign in to comment.