-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add an approval/funding UI #30
base: development
Are you sure you want to change the base?
Conversation
Unused dependencies (4)
Unused devDependencies (2)
|
There should be a separate input for a token. When mainnet or gnosis is selected the UUSD should be set in the input token field by default but user should have the ability to change the token address.
Check this comment. Overall github auth is not necessary as a part of the current github issue and can be solved in another PR. |
@zugdev, this task has been idle for a while. Please provide an update. |
I wonder if it makes sense for us to bridge over to as many chains as we can. I suppose anybody can do this and we just need to aggregate the addresses.
This is actually determined by the partner project currently. So in theory we could have partner A, B, and C and each pays with their own preferred token on their own preferred chain. This is because they need to fund their wallets with whatever asset they want.
|
I think aside from providers that's it. I need to find a smart way to use providers in all 10+ chains, why don't we use Alchemy or some service like that? |
@rndquu can you move this review forward? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rndquu fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Just a few small improvements and we are good to go.
Co-authored-by: EresDev <[email protected]>
@zugdev, this task has been idle for a while. Please provide an update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you get it working with Anvil or did you test it on testnet? I tried with Anvil fork of mainnet but got Internal JSON-RPC error
when trying to approve
if (appState.getIsConnectedState() && window.ethereum) { | ||
const ethereum = window.ethereum as ethers.providers.ExternalProvider; | ||
if (ethereum.request) { | ||
await ethereum.request({ method: "eth_requestAccounts" }); | ||
} | ||
|
||
// Create a Web3Provider from window.ethereum | ||
web3Provider = new ethers.providers.Web3Provider(window.ethereum); | ||
|
||
// web3Provider signer will handle transaction signing | ||
userSigner = web3Provider.getSigner(appState.getAddress()); | ||
|
||
console.log("User address:", await userSigner.getAddress()); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will only work for browser extension wallets but Reown also supports mobile wallets, so why not just use appState.getWalletProvider()
and appState.subscribeProvider(handleChange)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that, but reown doesnt offer a signer so we would need to externally manage it anyway. also this is the standar for other UIs in ubiquity too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand. appState.getWalletProvider()
returns a provider and then you call provider.getSigner()
and you get the signer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
appState.getWalletProvider() returns undefined, you can try it for urself :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reown was previously wallet connect, but there are still distinctions like that from a new product
console.error("Provider is not initialized"); | ||
return; | ||
} | ||
|
||
const tokenAddress = addressInput.value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you might wanna check if the address is ERC20 because if put a random address then it throws a revert error and it can be confusing to the users
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
managed that, thanks
@@ -1,6 +1,8 @@ | |||
import { appState, explorersUrl } from "./main"; | |||
|
|||
export function renderErrorInModal(error: Error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for common errors like ACTION_REJECTED
you can display a more user-friendly error message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we already display action rejected in a pretty way, also we try to avoid all errors instead of better displaying them. insufficient funds, missing new, numeric fault .. are handled. we could handle nonce id if user waits tooooo long to sign tho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be pretty enough for a developer but it's not really pretty a normal user though
@@ -26,22 +21,32 @@ const metadata = { | |||
url: "https://onboard.ubq.fi", | |||
icons: ["https://avatars.githubusercontent.com/u/76412717"], | |||
}; | |||
export const providersUrl: { [key: string]: string } = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add anvil network to providers and permit2 addresses otherwise it doesn't work when testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you dont need to actually sign the transaction to see if it works, if the transaction to approve x amount pops up in ur wallet u know it works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but btw I just checked and I've included anvil already, u can pick from te drop down
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I can select the network but it doesn't work because it's not in providersUrl
. I wanted to try to see the success message and I can't get there
static/index.html
Outdated
<div class="current-allowance"> | ||
<span>current allowance:</span> | ||
<span>Current allowance:</span> | ||
<span class="current-allowance-amount">-</span> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's not too much work can you also display balance, I think it's beneficial for the user to know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it too, but allowance is not tied to balance, so I figured its not necessary, lmk what you think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allowance is not tied to balance
Normally, I've seen that the default requested allowance would be the user's balance amount.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah but that's usually in a flow like swapping.
- user MUST allow 100 UUSD to swap 100 UUSD into 100 DAI.
- it's not a problem if he allows 119238129319203, its actually common for max allowances to happen (which is not good, opsec wise)
in our case having a balance is not mandatory, I can allow 10k UUSD even if I dont have that quantity in balance. but I can add if you guys want it
approveButton.disabled = true; | ||
revokeButton.disabled = true; | ||
|
||
if (isAddressValid && isConnected) { | ||
void getCurrentAllowance(); | ||
const isSuccess = await getCurrentAllowance(); | ||
if (isSuccess) { | ||
approveButton.disabled = !isAmountValid; | ||
revokeButton.disabled = false; | ||
addressInput.style.border = green; | ||
} else { | ||
addressInput.style.border = red; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now every time I click out of the amount input, the buttons get disabled until allowance is fetched and it's a weird UX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but thats what you meant by checking if its an erc20 token, should I add a spinner to indicate loading perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought you will do the check when approve button is clicked and then it would show the error modal.
Resolves #29
I like the word funding better than approval, allowance or permit2, as it is better aligned with the "ubiquity banking" concept. Don't worry bout the text, it still needs rephrasing.
Current UI:
I have a couple questions:
Should I force UUSD or should I offer an input field for token. If I should force, what about chains where UUSD is not at currently? I've included all permit2 chains I could, for now.
I don't want to have user authenticate with GitHub, it's an unnecessary step, but if I did I could read what chain he has payments setup in. Is there a way to read what token he is using as reward too? If that was the case I should consider adding GitHub auth.
I am waiting on the above to integrate ethers.