React
Getting started
This package provides binding for omniston-sdk to the React ecosystem. Using this package, you can access all Omniston methods as hooks powered by TanStack react query (out-of-box loading states, retries, error handling, and match more)
You can find all supported methods in our docs or take a look onto our demo app that use NextJs and omniston-sdk-react
package
Installation
via NPM
via YARN
via PNPM
Wrap you app in Omniston provider
You can pass custom queryClient
if you want to apply shared behaviour to all of the queries
The provider takes the following parameters:
Get list of supported assets
An AssetsResponse
has the following properties:
An AssetInfo
has the following properties:
An Address
has the following properties:
Send a quote request
Send a request for quote to swap an asset to another asset.
A QuoteRequest
has the following properties:
The server returns Observable<Quote | null>
, which is a stream of quotes. Learn more about Observable types in the official RxJS documentation.
A Quote
has the following properties:
Build a transaction
Now that we have a quote, we should request a server to build a transaction to initiate the trade that the user can verify and sign.
The buildTransfer
method takes a TransactionRequest
object as a parameter, having the following properties:
Sign the transaction
You can found the instruction on how to send transaction using the @tonconnect/ui-react
package here.
Listen for trade status updates
After the user has signed and initiated the transaction, we can track the trade status.
The trackTrade
method has the following parameters:
It returns Observable<TrackTradeStatus>
. For the different trade status values, see the source code. We are interested in the trade result enum which can be read from status.tradeSettled?.result?
field. The enum has the following values:
Last updated