Skip to content

Instantly share code, notes, and snippets.

@nenadjaja
Last active January 26, 2022 22:41
Show Gist options
  • Save nenadjaja/94389ea38964106d851507798b7f0eec to your computer and use it in GitHub Desktop.
Save nenadjaja/94389ea38964106d851507798b7f0eec to your computer and use it in GitHub Desktop.
Approval in components
Components
-----------
1. Check for allowance (ethereum address, contract)
3. Compare with amount in input field
2. Approval buttons - render correct states
3. Approval logic (contract address, amount)
4. Step 2 button as well
type Props = {
ethereumAddress,
amount,
contractGRT,
otherContract,
button2Copy # step 2 button copy
}
// allowance
otherContract.allowance(ethereumAddress)
// approval
contractGRT(amount, otherContract)
// handleSubmit - passed from props
props.handleSubmit()
// States
1. Enabled: infinite + partial
2. Pending: 3 dots
3. Success: infinite + partial (amount)
4. Failed: red button
useEffeect(() => {
}, [amount])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment