Skip to content

Commit

Permalink
GITBOOK-74: refactored: etherlinkProvider in unity
Browse files Browse the repository at this point in the history
  • Loading branch information
f.schoenknecht authored and gitbook-bot committed Dec 19, 2024
1 parent 9f651a0 commit 362d275
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions getting-started/implementation-guide/unity.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,18 @@ export const useUnityCommunicator = (
const [address, setAddress] = useState<string | undefined>();

// Get modal functionality and wallet providers from TConnect
const { openModal, evmProvider, tezosBeaconProvider, tezosWcProvider }
const { openModal, etherlinkProvider, tezosBeaconProvider, tezosWcProvider }
= useTConnectModal();

// Function to retrieve the user's Etherlink address
const getAddressEvm = useCallback(async () => {
if (!evmProvider) return;
const web3 = new Web3(evmProvider);
const getAddressEtherlink = useCallback(async () => {
if (!etherlinkProvider) return;
const web3 = new Web3(etherlinkProvider);
const accounts = await web3.eth.getAccounts();
const walletAddress = accounts.length > 0 ? accounts[0] : undefined;
setAddress(walletAddress);
return walletAddress;
}, [evmProvider]);
}, [etherlinkProvider]);

// Function to retrieve a Tezos wallet address (Beacon or WalletConnect)
const getAddress = useCallback(
Expand Down Expand Up @@ -140,9 +140,9 @@ export const useUnityCommunicator = (

try {
// Fetch the appropriate address based on the available provider
const data = evmProvider
const data = etherlinkProvider
? // If Etherlink provider is available, get the Ethereum address
await getAddressEvm()
await getAddressEtherlink()
: activeTezosProvider
? // Get the Tezos address
await getAddress(activeTezosProvider)
Expand All @@ -160,7 +160,7 @@ export const useUnityCommunicator = (
}
};
}, [openModal, getAddressEvm, getAddress, sendMessage,
evmProvider, tezosBeaconProvider, tezosWcProvider]);
etherlinkProvider, tezosBeaconProvider, tezosWcProvider]);

// Return the `setupUnityCommunication` function and the wallet address state
return {
Expand Down

0 comments on commit 362d275

Please sign in to comment.