Skip to content

Commit

Permalink
Merge pull request #39 from base-org/lukas/support-callbacks
Browse files Browse the repository at this point in the history
[feat] support callbacks
  • Loading branch information
lukasrosario authored Nov 28, 2023
2 parents 5e9afb1 + f32a28f commit 3559dc9
Show file tree
Hide file tree
Showing 11 changed files with 421 additions and 103 deletions.
6 changes: 6 additions & 0 deletions .changeset/twenty-snakes-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@op-wagmi/docs": minor
"op-wagmi": minor
---

[feat] support writeContract callbacks
38 changes: 36 additions & 2 deletions docs/docs/hooks/L1/useWriteDepositERC20.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Config to use instead of retrieving from the from nearest WagmiProvider.

### writeDepositERC20

`(variables: WriteDepositERC20Parameters) => void`
`(variables: WriteDepositERC20Parameters, { onSuccess, onSettled, onError }) => void`

The mutation function you can call with variables to trigger the deposit.

Expand Down Expand Up @@ -79,9 +79,26 @@ The mutation function you can call with variables to trigger the deposit.

The chain ID of the chain you want to deposit to.

- #### options (optional)
- ##### onSuccess
`(data: WriteContractReturnType, variables: WriteDepositERC20Parameters, context: TContext) => void`

This function will fire when the mutation is successful and will be passed the mutation's result.

- ##### onError
`(error: WriteContractErrorType, variables: WriteDepositERC20Parameters, context: TContext | undefined) => void`

This function will fire if the mutation encounters an error and will be passed the error.

- ##### onSettled
`(data: WriteContractReturnType | undefined, error: WriteContractErrorType | null, variables: WriteDepositERC20Parameters, context: TContext | undefined) => void`

- This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error
- If you make multiple requests, onSuccess will fire only after the latest call you've made.

### writeDepositERC20Async

`(variables: WriteDepositERC20Parameters) => Promise<WriteContractReturnType>`
`(variables: WriteDepositERC20Parameters, { onSuccess, onSettled, onError }) => Promise<WriteContractReturnType>`

Similar to writeDepositERC20 but returns a promise which can be awaited.

Expand Down Expand Up @@ -123,4 +140,21 @@ Similar to writeDepositERC20 but returns a promise which can be awaited.

The chain ID of the chain you want to deposit to.

- #### options (optional)
- ##### onSuccess
`(data: WriteContractReturnType, variables: WriteDepositERC20Parameters, context: TContext) => void`

This function will fire when the mutation is successful and will be passed the mutation's result.

- ##### onError
`(error: WriteContractErrorType, variables: WriteDepositERC20Parameters, context: TContext | undefined) => void`

This function will fire if the mutation encounters an error and will be passed the error.

- ##### onSettled
`(data: WriteContractReturnType | undefined, error: WriteContractErrorType | null, variables: WriteDepositERC20Parameters, context: TContext | undefined) => void`

- This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error
- If you make multiple requests, onSuccess will fire only after the latest call you've made.

### The rest of wagmi's [useWriteContract return type](https://beta.wagmi.sh/react/api/hooks/useWrtieContract#return-type) (except `writeContract` and `writeContractAsync`).
38 changes: 36 additions & 2 deletions docs/docs/hooks/L1/useWriteDepositETH.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Config to use instead of retrieving from the from nearest WagmiProvider.

### writeDepositETH

`(variables: WriteDepositETHParameters) => void`
`(variables: WriteDepositETHParameters, { onSuccess, onSettled, onError }) => void`

The mutation function you can call with variables to trigger the ETH deposit.

Expand Down Expand Up @@ -67,9 +67,26 @@ The mutation function you can call with variables to trigger the ETH deposit.

The chain ID of the chain you want to deposit to.

- #### options (optional)
- ##### onSuccess
`(data: WriteContractReturnType, variables: WriteDepositETHParameters, context: TContext) => void`

This function will fire when the mutation is successful and will be passed the mutation's result.

- ##### onError
`(error: WriteContractErrorType, variables: WriteDepositETHParameters, context: TContext | undefined) => void`

This function will fire if the mutation encounters an error and will be passed the error.

- ##### onSettled
`(data: WriteContractReturnType | undefined, error: WriteContractErrorType | null, variables: WriteDepositETHParameters, context: TContext | undefined) => void`

- This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error
- If you make multiple requests, onSuccess will fire only after the latest call you've made.

### writeDepositETHAsync

`(variables: WriteDepositETHParameters) => Promise<WriteContractReturnType>`
`(variables: WriteDepositETHParameters, { onSuccess, onSettled, onError }) => Promise<WriteContractReturnType>`

Similar to writeDepositETH but returns a promise which can be awaited.

Expand Down Expand Up @@ -101,4 +118,21 @@ Similar to writeDepositETH but returns a promise which can be awaited.

The chain ID of the chain you want to deposit to.

- #### options (optional)
- ##### onSuccess
`(data: WriteContractReturnType, variables: WriteDepositETHParameters, context: TContext) => void`

This function will fire when the mutation is successful and will be passed the mutation's result.

- ##### onError
`(error: WriteContractErrorType, variables: WriteDepositETHParameters, context: TContext | undefined) => void`

This function will fire if the mutation encounters an error and will be passed the error.

- ##### onSettled
`(data: WriteContractReturnType | undefined, error: WriteContractErrorType | null, variables: WriteDepositETHParameters, context: TContext | undefined) => void`

- This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error
- If you make multiple requests, onSuccess will fire only after the latest call you've made.

### The rest of wagmi's [useWriteContract return type](https://beta.wagmi.sh/react/api/hooks/useWrtieContract#return-type) (except `writeContract` and `writeContractAsync`).
38 changes: 36 additions & 2 deletions docs/docs/hooks/L1/useWriteFinalizeWithdrawalTransaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Config to use instead of retrieving from the from nearest WagmiProvider.

### writeFinalizeWithdrawalTransaction

`(variables: WriteFinalizeWithdrawalTransactionParameters) => void`
`(variables: WriteFinalizeWithdrawalTransactionParameters, { onSuccess, onSettled, onError }) => void`

The mutation function you can call with variables to trigger finalizing the provided withdrawal.

Expand All @@ -53,9 +53,26 @@ The mutation function you can call with variables to trigger finalizing the prov

The chain ID of the chain you are withdrawing from.

- #### options (optional)
- ##### onSuccess
`(data: WriteContractReturnType, variables: WriteFinalizeWithdrawalTransactionParameters, context: TContext) => void`

This function will fire when the mutation is successful and will be passed the mutation's result.

- ##### onError
`(error: WriteContractErrorType, variables: WriteFinalizeWithdrawalTransactionParameters, context: TContext | undefined) => void`

This function will fire if the mutation encounters an error and will be passed the error.

- ##### onSettled
`(data: WriteContractReturnType | undefined, error: WriteContractErrorType | null, variables: WriteFinalizeWithdrawalTransactionParameters, context: TContext | undefined) => void`

- This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error
- If you make multiple requests, onSuccess will fire only after the latest call you've made.

### writeFinalizeWithdrawalTransactionAsync

`(variables: WriteFinalizeWithdrawalTransactionParameters) => Promise<WriteContractReturnType>`
`(variables: WriteFinalizeWithdrawalTransactionParameters, { onSuccess, onSettled, onError }) => Promise<WriteContractReturnType>`

Similar to writeFinalizeWithdrawalTransaction but returns a promise which can be awaited.

Expand All @@ -72,4 +89,21 @@ Similar to writeFinalizeWithdrawalTransaction but returns a promise which can be

The chain ID of the chain you are withdrawing from.

- #### options (optional)
- ##### onSuccess
`(data: WriteContractReturnType, variables: WriteFinalizeWithdrawalTransactionParameters, context: TContext) => void`

This function will fire when the mutation is successful and will be passed the mutation's result.

- ##### onError
`(error: WriteContractErrorType, variables: WriteFinalizeWithdrawalTransactionParameters, context: TContext | undefined) => void`

This function will fire if the mutation encounters an error and will be passed the error.

- ##### onSettled
`(data: WriteContractReturnType | undefined, error: WriteContractErrorType | null, variables: WriteFinalizeWithdrawalTransactionParameters, context: TContext | undefined) => void`

- This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error
- If you make multiple requests, onSuccess will fire only after the latest call you've made.

### The rest of wagmi's [useWriteContract return type](https://beta.wagmi.sh/react/api/hooks/useWrtieContract#return-type) (except `writeContract` and `writeContractAsync`).
38 changes: 36 additions & 2 deletions docs/docs/hooks/L1/useWriteProveWithdrawalTransaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Config to use instead of retrieving from the from nearest WagmiProvider.

### writeProveWithdrawalTransaction

`(variables: WriteProveWithdrawalTransactionParameters) => void`
`(variables: WriteProveWithdrawalTransactionParameters, { onSuccess, onSettled, onError }) => void`

The mutation function you can call with variables to trigger proving the provided withdrawal.

Expand All @@ -52,9 +52,26 @@ The mutation function you can call with variables to trigger proving the provide

The chain ID of the chain you are withdrawing from.

- #### options (optional)
- ##### onSuccess
`(data: WriteContractReturnType, variables: WriteProveWithdrawalTransactionParameters, context: TContext) => void`

This function will fire when the mutation is successful and will be passed the mutation's result.

- ##### onError
`(error: WriteContractErrorType, variables: WriteProveWithdrawalTransactionParameters, context: TContext | undefined) => void`

This function will fire if the mutation encounters an error and will be passed the error.

- ##### onSettled
`(data: WriteContractReturnType | undefined, error: WriteContractErrorType | null, variables: WriteProveWithdrawalTransactionParameters, context: TContext | undefined) => void`

- This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error
- If you make multiple requests, onSuccess will fire only after the latest call you've made.

### writeProveWithdrawalTransactionAsync

`(variables: WriteProveWithdrawalTransactionParameters) => Promise<WriteContractReturnType>`
`(variables: WriteProveWithdrawalTransactionParameters, { onSuccess, onSettled, onError }) => Promise<WriteContractReturnType>`

Similar to writeProveWithdrawalTransaction but returns a promise which can be awaited.

Expand All @@ -71,4 +88,21 @@ Similar to writeProveWithdrawalTransaction but returns a promise which can be aw

The chain ID of the chain you are withdrawing from.

- #### options (optional)
- ##### onSuccess
`(data: WriteContractReturnType, variables: WriteProveWithdrawalTransactionParameters, context: TContext) => void`

This function will fire when the mutation is successful and will be passed the mutation's result.

- ##### onError
`(error: WriteContractErrorType, variables: WriteProveWithdrawalTransactionParameters, context: TContext | undefined) => void`

This function will fire if the mutation encounters an error and will be passed the error.

- ##### onSettled
`(data: WriteContractReturnType | undefined, error: WriteContractErrorType | null, variables: WriteProveWithdrawalTransactionParameters, context: TContext | undefined) => void`

- This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error
- If you make multiple requests, onSuccess will fire only after the latest call you've made.

### The rest of wagmi's [useWriteContract return type](https://beta.wagmi.sh/react/api/hooks/useWrtieContract#return-type) (except `writeContract` and `writeContractAsync`).
38 changes: 36 additions & 2 deletions docs/docs/hooks/L2/useWriteWithdrawERC20.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Config to use instead of retrieving from the from nearest WagmiProvider.

### writeWithdrawERC20

`(variables: WriteWithdrawERC20Parameters) => void`
`(variables: WriteWithdrawERC20Parameters, { onSuccess, onSettled, onError }) => void`

The mutation function you can call with variables to trigger initiating the ERC20 withdrawal.

Expand Down Expand Up @@ -73,9 +73,26 @@ The mutation function you can call with variables to trigger initiating the ERC2

The chain ID of the chain you want to withdraw from.

- #### options (optional)
- ##### onSuccess
`(data: WriteContractReturnType, variables: WriteWithdrawERC20Parameters, context: TContext) => void`

This function will fire when the mutation is successful and will be passed the mutation's result.

- ##### onError
`(error: WriteContractErrorType, variables: WriteWithdrawERC20Parameters, context: TContext | undefined) => void`

This function will fire if the mutation encounters an error and will be passed the error.

- ##### onSettled
`(data: WriteContractReturnType | undefined, error: WriteContractErrorType | null, variables: WriteWithdrawERC20Parameters, context: TContext | undefined) => void`

- This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error
- If you make multiple requests, onSuccess will fire only after the latest call you've made.

### writeWithdrawERC20Async

`(variables: WriteWithdrawERC20Parameters) => Promise<WriteContractReturnType>`
`(variables: WriteWithdrawERC20Parameters, { onSuccess, onSettled, onError }) => Promise<WriteContractReturnType>`

Similar to writeWithdrawERC20 but returns a promise which can be awaited.

Expand Down Expand Up @@ -112,4 +129,21 @@ Similar to writeWithdrawERC20 but returns a promise which can be awaited.

The chain ID of the chain you want to withdraw from.

- #### options (optional)
- ##### onSuccess
`(data: WriteContractReturnType, variables: WriteWithdrawERC20Parameters, context: TContext) => void`

This function will fire when the mutation is successful and will be passed the mutation's result.

- ##### onError
`(error: WriteContractErrorType, variables: WriteWithdrawERC20Parameters, context: TContext | undefined) => void`

This function will fire if the mutation encounters an error and will be passed the error.

- ##### onSettled
`(data: WriteContractReturnType | undefined, error: WriteContractErrorType | null, variables: WriteWithdrawERC20Parameters, context: TContext | undefined) => void`

- This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error
- If you make multiple requests, onSuccess will fire only after the latest call you've made.

### The rest of wagmi's [useWriteContract return type](https://beta.wagmi.sh/react/api/hooks/useWrtieContract#return-type) (except `writeContract` and `writeContractAsync`).
38 changes: 36 additions & 2 deletions docs/docs/hooks/L2/useWriteWithdrawETH.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Config to use instead of retrieving from the from nearest WagmiProvider.

### writeWithdrawETH

`(variables: WriteWithdrawETHParameters) => void`
`(variables: WriteWithdrawETHParameters, { onSuccess, onSettled, onError }) => void`

The mutation function you can call with variables to trigger initiating the ETH withdrawal.

Expand Down Expand Up @@ -67,9 +67,26 @@ The mutation function you can call with variables to trigger initiating the ETH

The chain ID of the chain you want to withdraw from.

- #### options (optional)
- ##### onSuccess
`(data: WriteContractReturnType, variables: WriteWithdrawETHParameters, context: TContext) => void`

This function will fire when the mutation is successful and will be passed the mutation's result.

- ##### onError
`(error: WriteContractErrorType, variables: WriteWithdrawETHParameters, context: TContext | undefined) => void`

This function will fire if the mutation encounters an error and will be passed the error.

- ##### onSettled
`(data: WriteContractReturnType | undefined, error: WriteContractErrorType | null, variables: WriteWithdrawETHParameters, context: TContext | undefined) => void`

- This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error
- If you make multiple requests, onSuccess will fire only after the latest call you've made.

### writeWithdrawETHAsync

`(variables: WriteWithdrawETHParameters) => Promise<WriteContractReturnType>`
`(variables: WriteWithdrawETHParameters, { onSuccess, onSettled, onError }) => Promise<WriteContractReturnType>`

Similar to writeWithdrawETH but returns a promise which can be awaited.

Expand Down Expand Up @@ -101,4 +118,21 @@ Similar to writeWithdrawETH but returns a promise which can be awaited.

The chain ID of the chain you want to withdraw from.

- #### options (optional)
- ##### onSuccess
`(data: WriteContractReturnType, variables: WriteWithdrawETHParameters, context: TContext) => void`

This function will fire when the mutation is successful and will be passed the mutation's result.

- ##### onError
`(error: WriteContractErrorType, variables: WriteWithdrawETHParameters, context: TContext | undefined) => void`

This function will fire if the mutation encounters an error and will be passed the error.

- ##### onSettled
`(data: WriteContractReturnType | undefined, error: WriteContractErrorType | null, variables: WriteWithdrawETHParameters, context: TContext | undefined) => void`

- This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error
- If you make multiple requests, onSuccess will fire only after the latest call you've made.

### The rest of wagmi's [useWriteContract return type](https://beta.wagmi.sh/react/api/hooks/useWrtieContract#return-type) (except `writeContract` and `writeContractAsync`).
Loading

0 comments on commit 3559dc9

Please sign in to comment.