Bridge & Chain configs
Rhino has one bridge configuration that lists all the chains and tokens that are available for bridging. Additionally there is a configuration that lists all tokens that are available for bridge and swap. You can get those configs through the following SDK calls:Bridge config
BridgeConfig type that is exported by the SDK.
Each key will be a chain while the value will represent the chain config (ChainConfig type). Each value in the tokens field of a chain config represents a TokenConfig.
A lot of functions in the SDK will have the BridgeConfig or a specific ChainConfig/TokenConfig as parameters. So for most advanced use cases you will most likely want to fetch the bridge config first.
Chain Adapters
The SDK follows a modular approach where all blockchain interactions are encapsulated in chain adapters. When using one of the provided bridge functions, you always need to explicitly pass in a chain adapter that matches the origin chain.Chain adapters handle the following:
- Fetching balances
- Checking and setting token allowances
- Making a deposit to a bridge contract
- Estimating the gas fees for a bridge transaction (optional)
Resources
Supported chains and tokens
Since the bridge functions will often take chains or tokens asstring parameters, the SDK provides a list of supported chains and tokens to avoid the usage of magic strings. You can use them like this:
SupportedTokens does not include swap tokens as those are too dynamic to be included in a static list like this.Error handling
A lot of functions in the SDK will return an object with nullabledata and error fields instead of throwing. Checking one for being defined will automatically narrow down the type of the other to non-nullable in the opposite code path. Errors are always a discriminated union type with a _tag or type field as discriminator. Some error types will also contain some additional fields with specific information about the error.For example, an error that could occur when generating a user quote could be: