Bridge methods events
This page documents the events emitted by the following methods:
-
bridge() -
bridgeAndTransfer() -
bridgeAndExecute() -
These methods emit
NEXUS_EVENTS.STEPS_LISTwhen the intent for the bridge operation is created. It emits an array ofBridgeStepTypeobjects. -
Use a callback function to listen to the
NEXUS_EVENTS.STEPS_LISTevent to get the steps list for the bridge operation. -
NEXUS_EVENTS.STEP_COMPLETEis emitted for each completed step of the intent’s fulfillment, contains a singleBridgeStepTypeobject per emission.
- The
bridgeAndTransfer()method emits event steps corresponding to the execution of the transfer operation on the destination chain, in addition to the steps for the bridge operation. - The
bridge()method just emits the steps for the bridge operation. - In case
bridgeAndTransfer()orbridgeAndExecute()don’t need to bridge to complete the intent on the destination chain, they will just emit the steps for the transfer or execute operation respectively.
Signature
Typescript
type EventUnion =
| { name: 'STEPS_LIST'; args: BridgeStepType[] }
| { name: 'SWAP_STEP_COMPLETE'; args: SwapStepType } // Only emitted by `swapWithExactIn()` and `swapWithExactOut()`
| { name: 'STEP_COMPLETE'; args: BridgeStepType };
export type OnEventParam = {
onEvent?: (event: EventUnion) => void;
};
type BridgeStepType =
// Event types for bridge operations
| ReturnType<typeof ALLOWANCE_APPROVAL_REQUEST>
| ReturnType<typeof ALLOWANCE_APPROVAL_MINED>
| ReturnType<typeof INTENT_DEPOSIT_REQUEST>
| ReturnType<typeof INTENT_SUBMITTED>
| ReturnType<typeof INTENT_COLLECTION>
| typeof INTENT_ACCEPTED
| typeof INTENT_HASH_SIGNED
| typeof INTENT_DEPOSITS_CONFIRMED
| typeof INTENT_COLLECTION_COMPLETE
| typeof INTENT_FULFILLED
| typeof ALLOWANCE_COMPLETE
// Event types for execute operations
| typeof EXECUTE_APPROVAL_STEP
| typeof EXECUTE_TRANSACTION_CONFIRMED
| typeof EXECUTE_TRANSACTION_SENT;You can check out the type definitions for each step type here:
Usage Example
Typescript
sdk.bridge({...}, {
onEvent: (event) => {
if(event.name === NEXUS_EVENTS.STEPS_LIST) {
// Store list of steps
} else if(event.name === NEXUS_EVENTS.STEP_COMPLETE) {
// Mark step as done
}
}
});Last updated on