diff --git a/packages/react-app/components/Header.tsx b/packages/react-app/components/Header.tsx index 30a3cfd..466d696 100644 --- a/packages/react-app/components/Header.tsx +++ b/packages/react-app/components/Header.tsx @@ -56,11 +56,17 @@ export default function Header() {
Send cUSD + + nonCUSD +
@@ -85,6 +91,13 @@ export default function Header() { > Send cUSD + + nonCUSD + {/* Add here your custom menu elements */}
diff --git a/packages/react-app/pages/api/socialconnect/lookup.ts b/packages/react-app/pages/api/socialconnect/lookup.ts index fe9b0cf..dce1fc0 100644 --- a/packages/react-app/pages/api/socialconnect/lookup.ts +++ b/packages/react-app/pages/api/socialconnect/lookup.ts @@ -65,7 +65,8 @@ export default async function lookup( * But SocialConnect allows looking up under other issuers just need their address. */ let issuerAddresses = [ - "0x7888612486844Bb9BE598668081c59A9f7367FBc", + // "0x7888612486844Bb9BE598668081c59A9f7367FBc", + "0xDF7d8B197EB130cF68809730b0D41999A830c4d7", ]; let lookupResponse: LookupResponse = await issuer.lookup( diff --git a/packages/react-app/pages/api/socialconnect/register.ts b/packages/react-app/pages/api/socialconnect/register.ts index cd37608..5606ebf 100644 --- a/packages/react-app/pages/api/socialconnect/register.ts +++ b/packages/react-app/pages/api/socialconnect/register.ts @@ -20,7 +20,7 @@ export default async function register( switch (req.method) { case "POST": try { - let { identifier, account } = JSON.parse(req.body); + let { identifier, account } = req.body; let wallet = new Wallet( process.env.ISSUER_PRIVATE_KEY as string, diff --git a/packages/react-app/pages/index.tsx b/packages/react-app/pages/index.tsx index a02b313..9451a39 100644 --- a/packages/react-app/pages/index.tsx +++ b/packages/react-app/pages/index.tsx @@ -1,7 +1,6 @@ import { useState } from "react"; import { encodeFunctionData, isAddress, parseEther } from "viem"; import { useAccount, usePublicClient, useWalletClient } from "wagmi"; -import FederatedAttestationsAbi from "../abi/FederatedAttestation"; import stableTokenAbi from "../abi/StableToken"; import toast from "react-hot-toast"; import type { LookupResponse } from "./api/socialconnect/lookup"; @@ -9,8 +8,8 @@ import { FA_PROXY_ADDRESS, STABLE_TOKEN_ADDRESS } from "@/utils/constants"; import { celo, celoAlfajores } from "viem/chains"; import Button from "@/components/Button"; -// const ISSUER_ADDRESS = "0xDF7d8B197EB130cF68809730b0D41999A830c4d7"; -const ISSUER_ADDRESS = "0x7888612486844Bb9BE598668081c59A9f7367FBc"; +const ISSUER_ADDRESS = "0xDF7d8B197EB130cF68809730b0D41999A830c4d7"; +// const ISSUER_ADDRESS = "0x7888612486844Bb9BE598668081c59A9f7367FBc"; export const E164_REGEX = /^\+[1-9][0-9]{1,14}$/; @@ -59,26 +58,16 @@ export default function Home() { id: resolvingToast, duration: 2000, }); - - console.error(lookupResponse.error); } else { - let { obfuscatedId } = lookupResponse; + let { accounts, obfuscatedId } = lookupResponse; try { - let resolvedAddress = (await publicClient.readContract({ - address: FA_PROXY_ADDRESS, - abi: FederatedAttestationsAbi, - functionName: "lookupAttestations", - args: [obfuscatedId, [ISSUER_ADDRESS]], - })) as string[][]; - - if (resolvedAddress[1].length) { + if (accounts.length) { toast.success("Address found", { id: resolvingToast }); + setResolvedReceiverAddress(accounts[0]); } else { toast.error("No address found", { id: resolvingToast }); } - - setResolvedReceiverAddress(resolvedAddress[1][0]); } catch (error: any) { if ("message" in error) { toast.error(error.message, { @@ -89,6 +78,7 @@ export default function Home() { } } finally { setResolvingAddress(false); + setIdentifier(""); } } } diff --git a/packages/react-app/pages/noncusd.tsx b/packages/react-app/pages/noncusd.tsx new file mode 100644 index 0000000..0702762 --- /dev/null +++ b/packages/react-app/pages/noncusd.tsx @@ -0,0 +1,55 @@ +import Button from "@/components/Button"; +import { useState } from "react"; +import toast from "react-hot-toast"; +import { parseEther } from "viem"; +import { useAccount, usePublicClient, useWalletClient } from "wagmi"; + +export default function nonCUSD() { + const publicClient = usePublicClient(); + const { isConnected } = useAccount(); + const { data: walletClient } = useWalletClient(); + const [transferValue, setTransferValue] = useState(""); + const [receiver, setReceiver] = useState(""); + + async function sendCelo() { + try { + await walletClient?.sendTransaction({ + to: receiver as `0x${string}`, + value: parseEther(transferValue), + }); + } catch (e) { + toast.error("Something went wrong!"); + } + } + + return ( +
+

Send non-CUSD assets

+ {isConnected ? ( + <> + + setTransferValue(target.value) + } + placeholder="0" + /> +

Celo

+
+ To: + setReceiver(target.value)} + className="text-[16px] w-[250px] bg-gypsum border-b-2 outline-none" + /> +
+
+ ); +} diff --git a/packages/react-app/utils/SocialConnect.ts b/packages/react-app/utils/SocialConnect.ts index 035119e..9e16378 100644 --- a/packages/react-app/utils/SocialConnect.ts +++ b/packages/react-app/utils/SocialConnect.ts @@ -73,12 +73,16 @@ export class SocialConnectIssuer { ) ).wait(); + console.log(approvalTxReceipt); + const odisPaymentTxReceipt = ( await this.odisPaymentsContract.payInCUSD( this.wallet.address, ONE_CENT_CUSD // TODO we should increase by more ) ).wait(); + + console.log(odisPaymentTxReceipt); } } @@ -152,12 +156,13 @@ export class SocialConnectIssuer { plaintextId, identifierType ); + console.log(obfuscatedId); const attestations = await this.federatedAttestationsContract.lookupAttestations( obfuscatedId, issuerAddresses ); - + console.log(attestations); return { accounts: attestations.accounts as string[], // TODO typesafety obfuscatedId,