diff --git a/README.md b/README.md index 97dd2784e..ee3640cb6 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,13 @@ Catalogue of various wallet and dapp examples implementing WalletConnect's **SDK **Wallets:** -- [React Wallet (Sign v1 + v2)](https://github.com/WalletConnect/web-examples/tree/main/advanced/wallets/react-wallet-v2) ([Demo](https://react-wallet.walletconnect.com/)) **dApps:** - [React dApp (with standalone client) - v2](https://github.com/WalletConnect/web-examples/tree/main/advanced/dapps/react-dapp-v2) ([Demo](https://react-app.walletconnect.com/)) - [React dApp (with EthereumProvider + Ethers.js) - v2](https://github.com/WalletConnect/web-examples/tree/main/advanced/dapps/react-dapp-v2-with-ethers) ([Demo](https://react-dapp-v2-with-ethers.vercel.app/)) - [React dApp (with EthereumProvider + web3.js) - v2](https://github.com/WalletConnect/web-examples/tree/main/advanced/dapps/react-dapp-v2-with-web3js) ([Demo](https://react-dapp-v2-with-web3js.vercel.app/)) +- [React dApp (with TezosProvider) - v2](https://github.com/WalletConnect/web-examples/tree/main/dapps/tezos-provider) ### Auth API diff --git a/dapps/tezos-provider/src/App.tsx b/dapps/tezos-provider/src/App.tsx index eb46fbc8b..5b93dd340 100644 --- a/dapps/tezos-provider/src/App.tsx +++ b/dapps/tezos-provider/src/App.tsx @@ -30,33 +30,43 @@ const App = () => { const [contractAddress, setContractAddress] = useState(""); const [balance, setBalance] = useState(""); - console.log("Provider", provider); - // 3. handle display_uri event and open modal - if (provider.signer) { - provider.signer.on("display_uri", async (uri: string) => { - console.log("event display_uri", uri); - await modal.openModal({ - uri, + const subscribe = async () => { + if (provider.signer) { + console.log("Subscribing to events..."); + provider.signer.on("display_uri", async (uri: string) => { + console.log("event display_uri", uri); + await modal.openModal({ + uri, + }); }); - }); - provider.signer.on("session_ping", ({ id, topic }: { id: string; topic: string }) => { - console.log("Event session_ping:", id, topic); - }); + provider.signer.on("session_ping", ({ id, topic }: { id: string; topic: string }) => { + console.log("Event session_ping:", id, topic); + }); - provider.signer.on("session_event", ({ event, chainId }: { event: any; chainId: string }) => { - console.log("Event session_event:", event, chainId); - }); + provider.signer.on("session_event", ({ event, chainId }: { event: any; chainId: string }) => { + console.log("Event session_event:", event, chainId); + }); - provider.signer.on("session_update", ({ topic, params }: { topic: string; params: any }) => { - console.log("Event session_update:", topic, params); - }); + provider.signer.on("session_update", ({ topic, params }: { topic: string; params: any }) => { + console.log("Event session_update:", topic, params); + }); - provider.signer.on("session_delete", ({ id, topic }: { id: string; topic: string }) => { - console.log("Event session_delete:", id, topic); - }); - } + provider.signer.on("session_delete", ({ id, topic }: { id: string; topic: string }) => { + console.log("Event session_delete:", id, topic); + }); + + provider.signer.on("connect", ({ id, topic }: { id: string; topic: string }) => { + console.log("Event connect:", id, topic); + }); + + provider.signer.on("disconnect", ({ id, topic }: { id: string; topic: string }) => { + console.log("Event disconnect:", id, topic); + setIsConnected(false); + }); + } + }; const getBalance = async () => { if (provider) { @@ -68,7 +78,9 @@ const App = () => { // 4. handle connect event const connect = async () => { window.localStorage.removeItem('walletconnect'); + console.log("Connecting..."); try { + await subscribe(); await provider.connect({chains: [TezosChainDataTestnet, TezosChainDataMainnet]}); setIsConnected(true); console.log("Connected successfully. Provider", provider); @@ -83,6 +95,7 @@ const App = () => { // 5. handle disconnect event const disconnect = async () => { + console.log("Disconnecting..."); if (provider.signer) { await provider.signer.disconnect(); } diff --git a/dapps/tezos-provider/src/utils/tezos-provider.ts b/dapps/tezos-provider/src/utils/tezos-provider.ts index e4f4d560f..b6ed18aed 100644 --- a/dapps/tezos-provider/src/utils/tezos-provider.ts +++ b/dapps/tezos-provider/src/utils/tezos-provider.ts @@ -35,14 +35,13 @@ import { TezosEndorsementWithSlotOperation, TezosFailingNoopOperation, TezosOperationType, - TezosPreAttestationOperation, + TezosPreAttestationOperation, TezosProposalOperation, TezosSeedNonceRevelationOperation, TezosVdfRevelationOperation } from "@airgap/beacon-types"; import { ScriptedContracts } from "@taquito/rpc"; -import { TezosPreEndorsementOperation } from "@airgap/beacon-types/dist/esm/types/tezos/operations/PreEndorsement"; interface PartialTezosOriginationOperation extends Omit { script: ScriptedContracts; @@ -538,10 +537,6 @@ class TezosProvider { return this.tezosSend(op); } - public async tezosSendPreEndorsement(op: TezosPreEndorsementOperation): Promise { - return this.tezosSend(op); - } - public async tezosSendProposal(op: TezosProposalOperation): Promise { return this.tezosSend(op); }