-
-
-
-
-
-
Grant Permissions
-
- App.xyz is asking you to grant it the following
- permissions:
-
-
-
-
- -
- ✅Read your wallet address.
-
-
-
-
- -
- ⚠️Interact with all{" "}
- contracts on Base Sepolia
-
- -
- ⚠️Spend all your
- funds on Base Sepolia
-
- -
- 📆Granted until{" "}
- 02/02/2025
-
-
-
-
-
- {
- if (!account) {
- throw new Error("No account found");
- }
- if (!code) {
- throw new Error("No code found");
- }
- if (!redirect) {
- throw new Error("No redirect found");
- }
- const accountContract = getContract({
- address: account.address,
- // hard coded for now
- chain: baseSepolia,
- client,
- });
- let hasSessionKey = false;
- // check if already added
- const accountDeployed =
- await isContractDeployed(accountContract);
- if (accountDeployed) {
- hasSessionKey = await isActiveSigner({
- contract: accountContract,
- signer: sessionKeySignerAddress,
- });
- }
- // if not added, send tx to add the session key
- if (!hasSessionKey) {
- return addSessionKey({
- account,
- contract: accountContract,
- sessionKeyAddress: sessionKeySignerAddress,
- // hard coded for now
- permissions: { approvedTargets: "*" },
- });
- }
- throw "already-added";
- }}
- onError={async (e) => {
- if (!code) {
- throw new Error("No code found");
- }
- if (!redirect) {
- throw new Error("No redirect found");
- }
- if (typeof e === "string" && e === "already-added") {
- // sign jwt
- const jwt = await generateJWT({
- address: account.address,
- sessionKeySignerAddress,
- code,
- });
- // redirect
- window.location.href = `${redirect}?code=${code}#${jwt}`;
- } else {
- console.error(e);
- }
- }}
- onTransactionConfirmed={async () => {
- if (!code) {
- throw new Error("No code found");
- }
- if (!redirect) {
- throw new Error("No redirect found");
- }
- // sign jwt
- const jwt = await generateJWT({
- address: account.address,
- sessionKeySignerAddress,
- code,
- });
- // redirect
- window.location.href = `${redirect}?code=${code}#${jwt}`;
- }}
- >
- Approve
-
-
-