Skip to content

Commit

Permalink
feat: WT-1984 Rename xbridge to bridge (#1283)
Browse files Browse the repository at this point in the history
  • Loading branch information
sharonsheah authored Dec 14, 2023
1 parent 4ce828e commit 1802b18
Show file tree
Hide file tree
Showing 36 changed files with 207 additions and 207 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { ApproveBridgeResponse, BridgeTxResponse } from '@imtbl/bridge-sdk';
import { ViewType } from './ViewType';

export enum BridgeWidgetViews {
WALLET_NETWORK_SELECTION = 'WALLET_NETWORK_SELECTION',
BRIDGE_FORM = 'BRIDGE_FORM',
BRIDGE_REVIEW = 'BRIDGE_REVIEW',
IN_PROGRESS = 'IN_PROGRESS',
BRIDGE_FAILURE = 'BRIDGE_FAILURE',
APPROVE_TRANSACTION = 'APPROVE_TRANSACTION',
}

export type BridgeWidgetView =
| BridgeCrossWalletSelection
| BridgeForm
| BridgeReview
| BridgeInProgress
| BridgeFailure
| BridgeApproveTransaction;

interface BridgeCrossWalletSelection extends ViewType {
type: BridgeWidgetViews.WALLET_NETWORK_SELECTION,
}

interface BridgeForm extends ViewType {
type: BridgeWidgetViews.BRIDGE_FORM,
}

interface BridgeReview extends ViewType {
type: BridgeWidgetViews.BRIDGE_REVIEW,
}

interface BridgeInProgress extends ViewType {
type: BridgeWidgetViews.IN_PROGRESS,
transactionHash: string,
}

interface BridgeFailure extends ViewType {
type: BridgeWidgetViews.BRIDGE_FAILURE,
reason: string;
}

interface BridgeApproveTransaction extends ViewType {
type: BridgeWidgetViews.APPROVE_TRANSACTION,
approveTransaction: ApproveBridgeResponse;
transaction: BridgeTxResponse;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
UpdateViewPayload,
SharedViews,
} from './ViewContext';
import { XBridgeWidgetViews } from './XBridgeViewContextTypes';
import { BridgeWidgetViews } from './BridgeViewContextTypes';

describe('view-context', () => {
describe('UPDATE_VIEW', () => {
Expand Down Expand Up @@ -186,34 +186,34 @@ describe('view-context', () => {
const state = viewReducer(
{
view: {
type: XBridgeWidgetViews.BRIDGE_FAILURE,
type: BridgeWidgetViews.BRIDGE_FAILURE,
reason: 'Transaction failed',
},
history: [
{ type: XBridgeWidgetViews.WALLET_NETWORK_SELECTION },
{ type: XBridgeWidgetViews.BRIDGE_FORM },
{ type: XBridgeWidgetViews.BRIDGE_REVIEW },
{ type: BridgeWidgetViews.WALLET_NETWORK_SELECTION },
{ type: BridgeWidgetViews.BRIDGE_FORM },
{ type: BridgeWidgetViews.BRIDGE_REVIEW },
{
type: XBridgeWidgetViews.IN_PROGRESS,
type: BridgeWidgetViews.IN_PROGRESS,
transactionHash: '',
},
{
type: XBridgeWidgetViews.BRIDGE_FAILURE,
type: BridgeWidgetViews.BRIDGE_FAILURE,
reason: 'Transaction failed',
},
],
},
{ payload: { type: ViewActions.GO_BACK_TO, view: { type: XBridgeWidgetViews.BRIDGE_REVIEW } } },
{ payload: { type: ViewActions.GO_BACK_TO, view: { type: BridgeWidgetViews.BRIDGE_REVIEW } } },
);

expect(state).toEqual({
view: {
type: XBridgeWidgetViews.BRIDGE_REVIEW,
type: BridgeWidgetViews.BRIDGE_REVIEW,
},
history: [
{ type: XBridgeWidgetViews.WALLET_NETWORK_SELECTION },
{ type: XBridgeWidgetViews.BRIDGE_FORM },
{ type: XBridgeWidgetViews.BRIDGE_REVIEW },
{ type: BridgeWidgetViews.WALLET_NETWORK_SELECTION },
{ type: BridgeWidgetViews.BRIDGE_FORM },
{ type: BridgeWidgetViews.BRIDGE_REVIEW },
],
});
});
Expand All @@ -222,36 +222,36 @@ describe('view-context', () => {
const state = viewReducer(
{
view: {
type: XBridgeWidgetViews.BRIDGE_FAILURE,
type: BridgeWidgetViews.BRIDGE_FAILURE,
reason: 'Transaction failed',
},
history: [
{ type: XBridgeWidgetViews.WALLET_NETWORK_SELECTION },
{ type: XBridgeWidgetViews.BRIDGE_REVIEW },
{ type: XBridgeWidgetViews.BRIDGE_FORM },
{ type: XBridgeWidgetViews.BRIDGE_REVIEW },
{ type: BridgeWidgetViews.WALLET_NETWORK_SELECTION },
{ type: BridgeWidgetViews.BRIDGE_REVIEW },
{ type: BridgeWidgetViews.BRIDGE_FORM },
{ type: BridgeWidgetViews.BRIDGE_REVIEW },
{
type: XBridgeWidgetViews.IN_PROGRESS,
type: BridgeWidgetViews.IN_PROGRESS,
transactionHash: '',
},
{
type: XBridgeWidgetViews.BRIDGE_FAILURE,
type: BridgeWidgetViews.BRIDGE_FAILURE,
reason: 'Transaction failed',
},
],
},
{ payload: { type: ViewActions.GO_BACK_TO, view: { type: XBridgeWidgetViews.BRIDGE_REVIEW } } },
{ payload: { type: ViewActions.GO_BACK_TO, view: { type: BridgeWidgetViews.BRIDGE_REVIEW } } },
);

expect(state).toEqual({
view: {
type: XBridgeWidgetViews.BRIDGE_REVIEW,
type: BridgeWidgetViews.BRIDGE_REVIEW,
},
history: [
{ type: XBridgeWidgetViews.WALLET_NETWORK_SELECTION },
{ type: XBridgeWidgetViews.BRIDGE_REVIEW },
{ type: XBridgeWidgetViews.BRIDGE_FORM },
{ type: XBridgeWidgetViews.BRIDGE_REVIEW },
{ type: BridgeWidgetViews.WALLET_NETWORK_SELECTION },
{ type: BridgeWidgetViews.BRIDGE_REVIEW },
{ type: BridgeWidgetViews.BRIDGE_FORM },
{ type: BridgeWidgetViews.BRIDGE_REVIEW },
],
});
});
Expand All @@ -260,19 +260,19 @@ describe('view-context', () => {
const state = viewReducer(
{
view: {
type: XBridgeWidgetViews.BRIDGE_FAILURE,
type: BridgeWidgetViews.BRIDGE_FAILURE,
reason: 'Transaction failed',
},
history: [
{ type: XBridgeWidgetViews.WALLET_NETWORK_SELECTION },
{ type: XBridgeWidgetViews.BRIDGE_FORM },
{ type: XBridgeWidgetViews.BRIDGE_REVIEW },
{ type: BridgeWidgetViews.WALLET_NETWORK_SELECTION },
{ type: BridgeWidgetViews.BRIDGE_FORM },
{ type: BridgeWidgetViews.BRIDGE_REVIEW },
{
type: XBridgeWidgetViews.IN_PROGRESS,
type: BridgeWidgetViews.IN_PROGRESS,
transactionHash: '',
},
{
type: XBridgeWidgetViews.BRIDGE_FAILURE,
type: BridgeWidgetViews.BRIDGE_FAILURE,
reason: 'Transaction failed',
},
],
Expand All @@ -282,19 +282,19 @@ describe('view-context', () => {

expect(state).toEqual({
view: {
type: XBridgeWidgetViews.BRIDGE_FAILURE,
type: BridgeWidgetViews.BRIDGE_FAILURE,
reason: 'Transaction failed',
},
history: [
{ type: XBridgeWidgetViews.WALLET_NETWORK_SELECTION },
{ type: XBridgeWidgetViews.BRIDGE_FORM },
{ type: XBridgeWidgetViews.BRIDGE_REVIEW },
{ type: BridgeWidgetViews.WALLET_NETWORK_SELECTION },
{ type: BridgeWidgetViews.BRIDGE_FORM },
{ type: BridgeWidgetViews.BRIDGE_REVIEW },
{
type: XBridgeWidgetViews.IN_PROGRESS,
type: BridgeWidgetViews.IN_PROGRESS,
transactionHash: '',
},
{
type: XBridgeWidgetViews.BRIDGE_FAILURE,
type: BridgeWidgetViews.BRIDGE_FAILURE,
reason: 'Transaction failed',
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createContext } from 'react';
import { ConnectWidgetView } from './ConnectViewContextTypes';
import { WalletWidgetView } from './WalletViewContextTypes';
import { PrefilledSwapForm, SwapWidgetView } from './SwapViewContextTypes';
import { XBridgeWidgetView } from './XBridgeViewContextTypes';
import { BridgeWidgetView } from './BridgeViewContextTypes';
import { SaleWidgetView } from './SaleViewContextTypes';
import { ViewType } from './ViewType';
import { OnRampWidgetView } from './OnRampViewContextTypes';
Expand Down Expand Up @@ -47,7 +47,7 @@ export type View =
| SwapWidgetView
| OnRampWidgetView
| SaleWidgetView
| XBridgeWidgetView;
| BridgeWidgetView;

export interface ViewState {
view: View;
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions packages/checkout/widgets-lib/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { OnRamp } from 'widgets/on-ramp/OnRampWidgetRoot';
import { Wallet } from 'widgets/wallet/WalletWidgetRoot';
import { Sale } from 'widgets/sale/SaleWidgetRoot';
import { Web3Provider } from '@ethersproject/providers';
import { XBridge } from 'widgets/x-bridge/XBridgeWidgetRoot';
import { Bridge } from 'widgets/bridge/BridgeWidgetRoot';
import {
sendProviderUpdatedEvent,
addProviderListenersForWidgetRoot,
Expand Down Expand Up @@ -44,7 +44,7 @@ export class WidgetsFactory implements IWidgetsFactory {
}) as Widget<WidgetType.CONNECT> as Widget<T>;
}
case WidgetType.BRIDGE: {
return new XBridge(this.sdk, {
return new Bridge(this.sdk, {
config: { ...this.widgetConfig, ...(config) },
provider,
}) as Widget<WidgetType.BRIDGE> as Widget<T>;
Expand Down
14 changes: 7 additions & 7 deletions packages/checkout/widgets-lib/src/resources/text/textConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable max-len */
import { WalletProviderName } from '@imtbl/checkout-sdk';
import { XBridgeWidgetViews } from 'context/view-context/XBridgeViewContextTypes';
import { BridgeWidgetViews } from 'context/view-context/BridgeViewContextTypes';
import { ConnectWidgetViews } from '../../context/view-context/ConnectViewContextTypes';
import { SwapWidgetViews } from '../../context/view-context/SwapViewContextTypes';
import { SharedViews } from '../../context/view-context/ViewContext';
Expand Down Expand Up @@ -362,7 +362,7 @@ export const text = {
text: 'Order completed',
actionText: 'Continue',
},
[XBridgeWidgetViews.WALLET_NETWORK_SELECTION]: {
[BridgeWidgetViews.WALLET_NETWORK_SELECTION]: {
layoutHeading: 'Move',
heading: 'Where would you like to move funds between?',
fromFormInput: {
Expand All @@ -380,7 +380,7 @@ export const text = {
text: 'Next',
},
},
[XBridgeWidgetViews.BRIDGE_FORM]: {
[BridgeWidgetViews.BRIDGE_FORM]: {
header: {
title: 'Move coins',
},
Expand All @@ -406,7 +406,7 @@ export const text = {
noTokenSelected: 'Select a coin to move',
},
},
[XBridgeWidgetViews.BRIDGE_REVIEW]: {
[BridgeWidgetViews.BRIDGE_REVIEW]: {
layoutHeading: 'Move',
heading: 'Ok, how does this look?',
fromLabel: {
Expand All @@ -424,11 +424,11 @@ export const text = {
},
fiatPricePrefix: '~ USD $',
},
[XBridgeWidgetViews.BRIDGE_FAILURE]: {
[BridgeWidgetViews.BRIDGE_FAILURE]: {
statusText: 'Transaction failed',
actionText: 'Review & Try again',
},
[XBridgeWidgetViews.APPROVE_TRANSACTION]: {
[BridgeWidgetViews.APPROVE_TRANSACTION]: {
content: {
heading: 'Approve the transaction in your wallet',
body: 'Follow the prompts in your wallet popup to confirm.',
Expand All @@ -441,7 +441,7 @@ export const text = {
text: 'Initiating move',
},
},
[XBridgeWidgetViews.IN_PROGRESS]: {
[BridgeWidgetViews.IN_PROGRESS]: {
heading: 'Move in progress',
body1: (symbol: string) => `Less than 3 mins until your ${symbol} lands on zkEVM.`,
body2: 'You can close this window, the transaction will be reflected in your wallet once complete.',
Expand Down
4 changes: 2 additions & 2 deletions packages/checkout/widgets-lib/src/views/top-up/TopUpView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
IMTBLWidgetEvents,
} from '@imtbl/checkout-sdk';
import { DEFAULT_TOKEN_SYMBOLS } from 'context/crypto-fiat-context/CryptoFiatProvider';
import { XBridgeWidgetViews } from 'context/view-context/XBridgeViewContextTypes';
import { BridgeWidgetViews } from 'context/view-context/BridgeViewContextTypes';
import { FooterLogo } from '../../components/Footer/FooterLogo';
import { HeaderNavigation } from '../../components/Header/HeaderNavigation';
import { SimpleLayout } from '../../components/SimpleLayout/SimpleLayout';
Expand Down Expand Up @@ -181,7 +181,7 @@ export function TopUpView({
payload: {
type: ViewActions.UPDATE_VIEW,
view: {
type: XBridgeWidgetViews.WALLET_NETWORK_SELECTION,
type: BridgeWidgetViews.WALLET_NETWORK_SELECTION,
data,
},
},
Expand Down
Loading

0 comments on commit 1802b18

Please sign in to comment.