-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
126 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { | ||
type ProcessStatus, | ||
type ProcessType, | ||
type StatusMessage, | ||
type Substatus, | ||
} from '@lifi/types' | ||
|
||
const processMessages: Record< | ||
ProcessType, | ||
Partial<Record<ProcessStatus, string>> | ||
> = { | ||
TOKEN_ALLOWANCE: { | ||
STARTED: 'Setting token allowance.', | ||
PENDING: 'Waiting for token allowance.', | ||
DONE: 'Token allowance set.', | ||
}, | ||
SWITCH_CHAIN: { | ||
PENDING: 'Chain switch required.', | ||
DONE: 'Chain switched successfully.', | ||
}, | ||
SWAP: { | ||
STARTED: 'Preparing swap transaction.', | ||
ACTION_REQUIRED: 'Please sign the transaction.', | ||
PENDING: 'Waiting for swap transaction.', | ||
DONE: 'Swap completed.', | ||
}, | ||
CROSS_CHAIN: { | ||
STARTED: 'Preparing bridge transaction.', | ||
ACTION_REQUIRED: 'Please sign the transaction.', | ||
PENDING: 'Waiting for bridge transaction.', | ||
DONE: 'Bridge transaction confirmed.', | ||
}, | ||
RECEIVING_CHAIN: { | ||
PENDING: 'Waiting for destination chain.', | ||
DONE: 'Bridge completed.', | ||
}, | ||
TRANSACTION: {}, | ||
} | ||
const substatusMessages: Record< | ||
StatusMessage, | ||
Partial<Record<Substatus, string>> | ||
> = { | ||
PENDING: { | ||
BRIDGE_NOT_AVAILABLE: 'Bridge communication is temporarily unavailable.', | ||
CHAIN_NOT_AVAILABLE: 'RPC communication is temporarily unavailable.', | ||
UNKNOWN_ERROR: | ||
'An unexpected error occurred. Please seek assistance in the LI.FI discord server.', | ||
WAIT_SOURCE_CONFIRMATIONS: | ||
'The bridge deposit has been received. The bridge is waiting for more confirmations to start the off-chain logic.', | ||
WAIT_DESTINATION_TRANSACTION: | ||
'The bridge off-chain logic is being executed. Wait for the transaction to appear on the destination chain.', | ||
}, | ||
DONE: { | ||
PARTIAL: | ||
'Some of the received tokens are not the requested destination tokens.', | ||
REFUNDED: 'The tokens were refunded to the sender address.', | ||
COMPLETED: 'The transfer is complete.', | ||
}, | ||
FAILED: {}, | ||
INVALID: {}, | ||
NOT_FOUND: {}, | ||
} | ||
|
||
export function getProcessMessage( | ||
type: ProcessType, | ||
status: ProcessStatus | ||
): string | undefined { | ||
const processMessage = processMessages[type][status] | ||
return processMessage | ||
} | ||
|
||
export function getSubstatusMessage( | ||
status: StatusMessage, | ||
substatus?: Substatus | ||
): string | undefined { | ||
if (!substatus) { | ||
return | ||
} | ||
const message = substatusMessages[status][substatus] | ||
return message | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters