Time to read: 1 min
Flyover SDK - Advanced Operations
Note
If you wish to suggest changes on this document, please open a PR on the Liquidity Provider Server Repository
To configure custom networks, see Configuration section.
Captcha token handling
The tokenResolver asynchronously fetches a token from the state managed by a store.
const tokenResolver = function () {
return import('./store/store').then(
(mod) => mod.store.getState().flyover.captchaToken,
);
};
Info
A Liquidity Provider can choose to enable captcha in the service to ensure only human-generated quotes.
- The function above uses the dynamic import statement to import the module located at
./store/store. Once the module is imported, it accesses the store object from it using mod.store. Then, it retrieves theflyover.captchaTokenfrom the state usingstore.getState().flyover.captchaToken. The import statement returns a promise, and the .then block is used to specify what should happen after the import is successful. In this case, it returns the captchaToken.- The same principle applies to any approach taken by the developer to manage the state of its application. Flyover SDK only expects a string resulting from the promise, regardless of the origin. It’s important to mention that the type of captcha expected by the Flyover SDK is a Invisible reCAPTCHA v2. The site key to use the captcha is included in the LiquidityProvider object retrieved by getLiquidityProviders() function.
Assigning Resolver in the Flyover Instance
Add the captchaTokenResolver: tokenResolver in the Flyover instance.
const flyover = new Flyover({
network: 'Mainnet',
captchaTokenResolver: tokenResolver,
allowInsecureConnections: true,
});
This will assign the
tokenResolverfunction as the captcha token resolver for the Flyover instance. This means that when the Flyover instance needs a captcha token, it will use the logic defined intokenResolverto obtain it asynchronously.