Technically, an interface can't be used in a non typescript react project, but type definitions can be done.
Through the react inbuilt propTypes property, component prop types can be explicitly defined, as well as the required
status of the prop.
By specifying that a prop is required
, the dev would receive an error in the console during run-time when an expected prop is missing.
Example:
import propTypes from "prop-types";
export const Component = ({prop1, prop2}) => {
// rest of component logic
return <button> ... </button>
}
Component.propTypes = {
prop1: propTypes.string.required,
prop2: propTypes.string
}
To make known which props are optional, entering a default value to the prop within the component creates a fallback for the prop except dev enters a desired value for a prop with default value.
Example:
export const Component = ({prop1 = "hello1", prop2 = "hello2"}) => {
// rest of component logic
return <button> ... </button>
In conclusion, getting missing prop errors during run-time isn't the best as such errors can be received during development if it were a typescript project with compulsory prop interfaces.
- User selects sending and destination chain.
- Check tokens that can be bridged based on step1.
- Populate the
from-token-list
andto-token-list
components with supported tokens for bridging. - User selects token to be sent and received.
- Fetch and display available routes between selected chains using the
quote
endpoint. - User selects a route.
- Check if selected token is an ERC-20 token.
- Request allowance of spending sending token from user using the
check-allowance
endpoint. - If selected token isn't ERC-20, skip step7 and continue.
- Fetch the
callData
for the route from/server/build-tx
endpoint to get transaction data. - Initiate a contract call to send
callData
to Socket contracts. - Socket contract bridges and swaps.
- Track transaction status using Socket Bridge Status APIs.