It can be used exactly the same as how it functioned in @wharfkit/antelope, developers exclusively using the antelope library will now just need to include this new dependency and update their imports.
import {APIClient} from '@wharfkit/apiclient-leap'
const client = new APIClient({url: 'https://jungle4.greymass.com'})
const info = await client.v1.chain.get_info()
Some new syntax is also available as part of this change, where you can import specific named APIs:
import {ChainAPI} from '@wharfkit/apiclient-leap'
const client = new ChainAPI({url: 'https://jungle4.greymass.com'})
const info = await client.get_info()
As mentioned before, the point of this is to offer chain specific implementations, which you'll now be able to do with packages that extend the leap package. I created one for WAX and called it @wharfkit/apiclient-wax.
It again can be used exactly in the same way, just required using the specific import and package.
import {ChainAPI} from '@wharfkit/apiclient-wax'
const client = new ChainAPI({url: 'https://jungle4.greymass.com'})
const info = await client.get_info()
What this new wax specific package does is overrides the get_account call:
Otherwise anything not defined falls back to @wharfkit/apiclient-leap.
This pattern that I'm establishing is what I want to use for things like a "Robo" API client, or a "Hyperion" or "AtomicAssets" client - where we can define additional calls that returned typed data.
I'm not entirely happy with how this turned out. I'm considering rewriting the entire APIClient class to make it aware of what chain its accessing and also allowing "plugins" of some sort that'll override the response types for specific chains.
The goal of this PR is to:
Looking at the commits, it's basically just deleting the API calls, types, and tests.
This code has moved to a generic APIClient implementation for leap named
@wharfkit/apiclient-leap
.https://github.com/wharfkit/apiclient-leap/tree/master/src
It can be used exactly the same as how it functioned in
@wharfkit/antelope
, developers exclusively using the antelope library will now just need to include this new dependency and update their imports.Some new syntax is also available as part of this change, where you can import specific named APIs:
As mentioned before, the point of this is to offer chain specific implementations, which you'll now be able to do with packages that extend the leap package. I created one for WAX and called it
@wharfkit/apiclient-wax
.https://github.com/wharfkit/apiclient-wax/tree/master/src
It again can be used exactly in the same way, just required using the specific import and package.
What this new wax specific package does is overrides the
get_account
call:https://github.com/wharfkit/apiclient-wax/blob/master/src/chain.ts
In order to return new types:
https://github.com/wharfkit/apiclient-wax/blob/master/src/types.ts
Otherwise anything not defined falls back to
@wharfkit/apiclient-leap
.This pattern that I'm establishing is what I want to use for things like a "Robo" API client, or a "Hyperion" or "AtomicAssets" client - where we can define additional calls that returned typed data.
I'm not entirely happy with how this turned out. I'm considering rewriting the entire
APIClient
class to make it aware of what chain its accessing and also allowing "plugins" of some sort that'll override the response types for specific chains.Definitely need some input here.