Skip to content

Commit

Permalink
change sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
shineli1984 committed Dec 10, 2024
1 parent a60b8c0 commit 07e30f8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import { usePassportProvider } from '@/context/PassportProvider';
import CardStack from '@/components/CardStack';
import WorkflowButton from '@/components/WorkflowButton';
import LinkWallet from '@/components/LinkWallet';
import { useImmutableProvider } from '@/context/ImmutableProvider';

function PassportMethods() {
const [showLinkWallet, setShowLinkWallet] = useState<boolean>(false);
const { isLoading } = useStatusProvider();
const { clientId } = useImmutableProvider();
const {
logout,
login,
Expand All @@ -19,7 +17,6 @@ function PassportMethods() {
getUserInfo,
getLinkedAddresses,
linkWallet,
zkEvmProvider,
} = usePassportProvider();

const handleLinkWalletClick = async () => {
Expand All @@ -31,14 +28,6 @@ function PassportMethods() {
}
};

const handleCheckIn = () => {
if (!zkEvmProvider) {
console.error('zkEvmProvider not found');
return;
}
zkEvmProvider.request({ method: 'im_addSessionActivity', params: [clientId] });
};

const handleLinkWalletSubmit = useCallback(async (
type: string,
walletAddress: string,
Expand Down Expand Up @@ -96,12 +85,6 @@ function PassportMethods() {
>
Link Wallet
</WorkflowButton>
<WorkflowButton
disabled={isLoading}
onClick={handleCheckIn}
>
Check In
</WorkflowButton>
</Stack>
{showLinkWallet && (
<LinkWallet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ const EthereumMethods: EthereumMethod[] = [
{ name: 'blockNumber/tag', default: 'latest' },
],
},
{
name: 'im_addSessionActivity',
params: [
{ name: 'clientId' },
],
}
];

function Request({ showModal, setShowModal }: ModalProps) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,12 @@ const ImmutableContext = createContext<{
blockchainData: BlockchainData,
environment: EnvironmentNames,
setEnvironment?:(environment: EnvironmentNames) => void;
clientId: string;
}>({
sdkClient: new ImmutableX(getSdkConfig(EnvironmentNames.DEV)),
orderbookClient: new Orderbook(getOrderbookConfig(EnvironmentNames.DEV)),
passportClient: new Passport(getPassportConfig(EnvironmentNames.DEV)),
environment: EnvironmentNames.DEV,
blockchainData: new BlockchainData(getBlockchainDataConfig(EnvironmentNames.DEV)),
clientId: '',
});

export function ImmutableProvider({
Expand Down Expand Up @@ -231,17 +229,14 @@ export function ImmutableProvider({
setBlockchainData(new BlockchainData(getBlockchainDataConfig(environment)));
}, [environment]);

const { clientId } = getPassportConfig(environment);

const providerValues = useMemo(() => ({
sdkClient,
orderbookClient,
passportClient,
blockchainData,
environment,
setEnvironment,
clientId: getPassportConfig(environment).clientId,
}), [sdkClient, orderbookClient, passportClient, blockchainData, environment, setEnvironment, clientId]);
}), [sdkClient, orderbookClient, passportClient, blockchainData, environment, setEnvironment]);

return (
<ImmutableContext.Provider value={providerValues}>
Expand All @@ -258,7 +253,6 @@ export function useImmutableProvider() {
blockchainData,
environment,
setEnvironment,
clientId,
} = useContext(ImmutableContext);
return {
sdkClient,
Expand All @@ -267,6 +261,5 @@ export function useImmutableProvider() {
blockchainData,
environment,
setEnvironment,
clientId,
};
}

0 comments on commit 07e30f8

Please sign in to comment.