You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DynamicHookComponent does use the connected wallet #6
The dynamic hook is hardcoded to use eternl and does not show how to hook to a connected wallet.
Reproduction Steps
If there is no eternl wallet w/ approved Dapp it is easy to overlook in the developer console. The reproduction steps could be much shorter, but to demonstrate fully I have described the testing environment I used which made this quite apparent.
Create 2 testing wallets, 1 in lace and 1 in eternl.
Enable Dapp for wallet in eternl
run npm run dev for next-app-route.
Open Localhost:3000
Connect Lace, approve Dapp (, and disconnect
Connect Eternel, approve Dapp and disconnect
Fund the lace wallet with 10,000 tADA from the faucet.
Send 1000 tADA to the eternl wallet.
Open localhost:3000, open the developer console
Connect Lace wallet (with 10k tADA balance)
Observe dynamic hoook print the balance of 1000 tADA from the eternl wallet, instead of the 8999 tADA of the connected Lace wallets balance.
Expected Behavior
The DynamicHook should access the connected wallet, regardless of which wallet the user connected.
The balance displayed should be for the connected wallet and not potentially access a different wallet that also approved a Dapp connection.
I am unsure if this is the best way to handle this so I'm skipping a PR at the moment in favor of discussion. I did work around using a hardcoded wallet and showing a balance before the wallet is connected by delaying access until after useCustomHook is not null
Unsure what the preferred example would be, but I think demonstrating how to interact with useWallet() and useCustomHook() in the example makes the most sense to help a new developer learn how to leverage MeshJS.
Activity
chaincrucial commentedon Oct 28, 2024
Also, when an eternl wallet is already Dapp approved, the balance of eternl is displayed prior to the user connecting any wallet.
chaincrucial commentedon Oct 28, 2024
I am unsure if this is the best way to handle this so I'm skipping a PR at the moment in favor of discussion. I did work around using a hardcoded wallet and showing a balance before the wallet is connected by delaying access until after useCustomHook is not null
examples/next-app-route/app/_components/dinamycHook.tsx
Lines 27 to 32 in 314fab5
Then creating a new async function and calling it:
Which could instead be:
Unsure what the preferred example would be, but I think demonstrating how to interact with
useWallet()anduseCustomHook()in the example makes the most sense to help a new developer learn how to leverage MeshJS.jinglescode commentedon Oct 31, 2024
for
examples/next-app-routeexample, its really just an example, and because its nextjsapproute, requires all these hacky workaround to use hooks.