Validator is a smart contract used to check for failures prior to attempting a swap.
Add the @airswap/protocols
package to your application.
$ yarn add @airswap/protocols
Import the Validator client.
import { Validator } from '@airswap/protocols'
Create a new Validator
client.
public constructor(chainId = chainIds.RINKEBY,walletOrProvider?: ethers.Wallet | ethers.providers.Provider)
Create a client for the Rinkeby Validator using the default provider.
const validator = new Validator()
Create a client for the Mainnet Validator using an INFURA provider.
import { chainIds } from '@airswap/constants'const provider = new ethers.providers.InfuraProvider(...)const validator = new Validator(chainIds.MAINNET, provider);
See a list of available providers on the ethers.js documentation.
Get a plain language reason for a swap failure.
public static getReason(reason: string): string
Param | Type | Optionality | Description |
|
|
| The error text emitted by a |
Check swap given an order.
public async checkSwap(order: Order): Promise<Array<string>>
Param | Type | Optionality | Description |
|
|
| The order that would be swapped. |
Check swap through a Wrapper given an order.
public async checkWrappedSwap(order: Order,fromAddress: string,wrapperAddress: string): Promise<Array<string>>
Param | Type | Optionality | Description |
|
|
| Order that would be swapped. |
|
|
| Wallet address that would send the transaction. |
|
|
| Address of the wrapper contract to use. |
Check swap through a Delegate given an order.
public async checkDelegate(order: Order,delegateAddress: string): Promise<Array<string>>
Param | Type | Optionality | Description |
|
|
| Order that would be swapped. |
|
|
| Address of the delegate contract to use. |
Check swap through a Wrapper and Delegate given an order.
public async checkWrappedDelegate(order: Order,delegateAddress: string,wrapperAddress: string): Promise<Array<string>>
Param | Type | Optionality | Description |
|
|
| Order that would be swapped. |
|
|
| Address of the delegate contract to use. |
|
|
| Address of the wrapper contract to use. |