Skip to content

Commit

Permalink
[NO CHANGELOG] [Add Tokens Widget] Rename to add tokens widget (#2357)
Browse files Browse the repository at this point in the history
  • Loading branch information
mimi-imtbl authored Oct 31, 2024
1 parent f81584e commit 556e4df
Show file tree
Hide file tree
Showing 92 changed files with 496 additions and 497 deletions.
2 changes: 1 addition & 1 deletion packages/checkout/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export type {
EIP1193Provider,
EIP6963ProviderInfo,
EIP6963ProviderDetail,
AddFundsConfig,
AddTokensConfig,
} from './types';

export type {
Expand Down
10 changes: 5 additions & 5 deletions packages/checkout/sdk/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export type RemoteConfiguration = {
onramp: OnRampConfig;
/** The config used for the Bridge. */
bridge: BridgeConfig;
/** The config used for Add Funds */
addfunds: AddFundsConfig;
/** The config used for Add Tokens */
addTokens: AddTokensConfig;
/** An array representing the allowed networks. */
allowedNetworks: AllowedNetworkConfig[];
/** The config for the tokens used to estimate gas. */
Expand All @@ -88,11 +88,11 @@ export type RemoteConfiguration = {
};

/**
* A type representing the configuration for the Add Funds.
* A type representing the configuration for the Add Tokens.
* @property {TokenInfo[] | undefined} tokens
*/
export type AddFundsConfig = {
/** A boolean value for enabling/disabling Add Funds */
export type AddTokensConfig = {
/** A boolean value for enabling/disabling Add Tokens */
enabled: boolean;
};

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { WidgetConfiguration } from './widget';

/**
* Add Tokens Widget Configuration represents the configuration options for the Add Tokens Widget.
*/
export type AddTokensWidgetConfiguration = {
} & WidgetConfiguration;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BridgeWidgetConfiguration } from './bridge';
import { SwapWidgetConfiguration } from './swap';
import { OnrampWidgetConfiguration } from './onramp';
import { SaleWidgetConfiguration } from './sale';
import { AddFundsWidgetConfiguration } from './addFunds';
import { AddTokensWidgetConfiguration } from './addTokens';

import { WidgetConfiguration } from './widget';

Expand All @@ -16,5 +16,5 @@ export type CommerceWidgetConfiguration = {
BRIDGE?: Omit<BridgeWidgetConfiguration, keyof WidgetConfiguration>;
ONRAMP?: Omit<OnrampWidgetConfiguration, keyof WidgetConfiguration>;
SALE?: Omit<SaleWidgetConfiguration, keyof WidgetConfiguration>;
ADD_FUNDS?: Omit<AddFundsWidgetConfiguration, keyof WidgetConfiguration>;
ADD_TOKENS?: Omit<AddTokensWidgetConfiguration, keyof WidgetConfiguration>;
} & Omit<WidgetConfiguration, 'walletConnect'>;
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export * from './onramp';
export * from './sale';
export * from './theme';
export * from './widget';
export * from './addFunds';
export * from './addTokens';
export * from './commerce';
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Web3Provider } from '@ethersproject/providers';
import { EIP6963ProviderInfo } from '../../../types';

/**
* Enum of possible Add Funds Widget event types.
* Enum of possible Add Tokens Widget event types.
*/
export enum AddFundsEventType {
export enum AddTokensEventType {
CLOSE_WIDGET = 'close-widget',
LANGUAGE_CHANGED = 'language-changed',
CONNECT_SUCCESS = 'connect-success',
Expand All @@ -13,20 +13,20 @@ export enum AddFundsEventType {
}

/**
* Represents a successful add funds transaction.
* Represents a successful add tokens transaction.
* @property {string} transactionHash
*/
export type AddFundsSuccess = {
export type AddTokensSuccess = {
/** The transaction hash of the successful transaction. */
transactionHash: string;
};

/**
* Type representing a add funds failure
* Type representing a add tokens failure
* @property {string} reason
* @property {number} timestamp
*/
export type AddFundsFailed = {
export type AddTokensFailed = {
/** The reason why it failed. */
reason: string;
/** The timestamp of the failed transaction. */
Expand All @@ -39,7 +39,7 @@ export type AddFundsFailed = {
* @property {EIP6963ProviderInfo} providerInfo
* @property {'from' | 'to'} providerType
*/
export type AddFundsConnectSuccess = {
export type AddTokensConnectSuccess = {
provider: Web3Provider;
providerInfo: EIP6963ProviderInfo;
providerType: 'from' | 'to';
Expand Down
28 changes: 14 additions & 14 deletions packages/checkout/sdk/src/widgets/definitions/events/commerce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from './bridge';
import { SwapFailed, SwapRejected, SwapSuccess } from './swap';
import { WalletNetworkSwitch } from './wallet';
import { AddFundsFailed, AddFundsSuccess, AddFundsConnectSuccess } from './addFunds';
import { AddTokensFailed, AddTokensSuccess, AddTokensConnectSuccess } from './addTokens';

export enum CommerceEventType {
INITIALISED = 'INITIALISED',
Expand All @@ -37,7 +37,7 @@ export enum CommerceSuccessEventType {
SALE_TRANSACTION_SUCCESS = 'SALE_TRANSACTION_SUCCESS',
BRIDGE_SUCCESS = 'BRIDGE_SUCCESS',
BRIDGE_CLAIM_WITHDRAWAL_SUCCESS = 'BRIDGE_CLAIM_WITHDRAWAL_SUCCESS',
ADD_FUNDS_SUCCESS = 'ADD_FUNDS_SUCCESS',
ADD_TOKENS_SUCCESS = 'ADD_TOKENS_SUCCESS',
}

export enum CommerceFailureEventType {
Expand All @@ -48,7 +48,7 @@ export enum CommerceFailureEventType {
CONNECT_FAILED = 'CONNECT_FAILED',
SALE_FAILED = 'SALE_FAILED',
ONRAMP_FAILED = 'ONRAMP_FAILED',
ADD_FUNDS_FAILED = 'ADD_FUNDS_FAILED',
ADD_TOKENS_FAILED = 'ADD_TOKENS_FAILED',
}

export enum CommerceUserActionEventType {
Expand Down Expand Up @@ -101,19 +101,19 @@ export type CommerceConnectSuccessEvent = {
data: ConnectionSuccess;
};

export type CommerceAddFundsSuccessEvent = {
type: CommerceSuccessEventType.ADD_FUNDS_SUCCESS;
data: AddFundsSuccess;
export type CommerceAddTokensSuccessEvent = {
type: CommerceSuccessEventType.ADD_TOKENS_SUCCESS;
data: AddTokensSuccess;
};

export type CommerceAddFundsConnectSuccessEvent = {
export type CommerceAddTokensConnectSuccessEvent = {
type: CommerceSuccessEventType.CONNECT_SUCCESS;
data: AddFundsConnectSuccess;
data: AddTokensConnectSuccess;
};

export type CommerceSuccessEvent =
| CommerceAddFundsSuccessEvent
| CommerceAddFundsConnectSuccessEvent
| CommerceAddTokensSuccessEvent
| CommerceAddTokensConnectSuccessEvent
| CommerceConnectSuccessEvent
| CommerceBridgeSuccessEvent
| CommerceBridgeClaimWithdrawalSuccessEvent
Expand Down Expand Up @@ -157,13 +157,13 @@ export type CommerceSaleFailureEvent = {
data: SaleFailed;
};

export type CommerceAddFundsFailureEvent = {
type: CommerceFailureEventType.ADD_FUNDS_FAILED;
data: AddFundsFailed;
export type CommerceAddTokensFailureEvent = {
type: CommerceFailureEventType.ADD_TOKENS_FAILED;
data: AddTokensFailed;
};

export type CommerceFailureEvent =
| CommerceAddFundsFailureEvent
| CommerceAddTokensFailureEvent
| CommerceBridgeFailureEvent
| CommerceBridgeClaimWithdrawalFailedEvent
| CommerceConnectFailureEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export * from './bridge';
export * from './orchestration';
export * from './onramp';
export * from './commerce';
export * from './addFunds';
export * from './addTokens';
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export enum OrchestrationEventType {
REQUEST_SWAP = 'request-swap',
REQUEST_BRIDGE = 'request-bridge',
REQUEST_ONRAMP = 'request-onramp',
REQUEST_ADD_FUNDS = 'request-add-funds',
REQUEST_ADD_TOKENS = 'request-add-tokens',
REQUEST_GO_BACK = 'request-go-back',
}

Expand Down Expand Up @@ -69,9 +69,9 @@ export type RequestOnrampEvent = {
};

/**
* Represents the add funds event object when the add funds widget is requested.
* Represents the add tokens event object when the add tokens widget is requested.
*/
export type RequestAddFundsEvent = {
export type RequestAddTokensEvent = {
/** Token address of the fund to be added */
toTokenAddress?: string;

Expand All @@ -98,4 +98,4 @@ export type OrchestrationEventData =
| RequestBridgeEvent
| RequestOnrampEvent
| RequestGoBackEvent
| RequestAddFundsEvent;
| RequestAddTokensEvent;
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export enum IMTBLWidgetEvents {
IMTBL_ONRAMP_WIDGET_EVENT = 'imtbl-onramp-widget',
IMTBL_SALE_WIDGET_EVENT = 'imtbl-sale-widget',
IMTBL_COMMERCE_WIDGET_EVENT = 'imtbl-commerce-widget',
IMTBL_ADD_FUNDS_WIDGET_EVENT = 'imtbl-add-funds-widget',
IMTBL_ADD_TOKENS_WIDGET_EVENT = 'imtbl-add-tokens-widget',
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Web3Provider } from '@ethersproject/providers';
import { WidgetLanguage } from '../configurations';

export type AddFundsWidgetParams = {
/** The language to use for the Add Funds widget */
export type AddTokensWidgetParams = {
/** The language to use for the Add Tokens widget */
language?: WidgetLanguage;

/** Configure to show on-ramp option */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { WalletWidgetParams } from './wallet';
import { SwapWidgetParams } from './swap';
import { OnRampWidgetParams } from './onramp';
import { SaleWidgetParams } from './sale';
import { AddFundsWidgetParams } from './addFunds';
import { AddTokensWidgetParams } from './addTokens';

export enum CommerceFlowType {
CONNECT = 'CONNECT',
Expand All @@ -15,7 +15,7 @@ export enum CommerceFlowType {
SWAP = 'SWAP',
BRIDGE = 'BRIDGE',
ONRAMP = 'ONRAMP',
ADD_FUNDS = 'ADD_FUNDS',
ADD_TOKENS = 'ADD_TOKENS',
}

export type CommerceWidgetConnectFlowParams = {
Expand All @@ -42,9 +42,9 @@ export type CommerceWidgetSaleFlowParams = {
flow: CommerceFlowType.SALE;
} & SaleWidgetParams;

export type CommerceWidgetAddFundsFlowParams = {
flow: CommerceFlowType.ADD_FUNDS;
} & AddFundsWidgetParams;
export type CommerceWidgetAddTokensFlowParams = {
flow: CommerceFlowType.ADD_TOKENS;
} & AddTokensWidgetParams;

export type CommerceWidgetFlowParams =
| CommerceWidgetConnectFlowParams
Expand All @@ -53,7 +53,7 @@ export type CommerceWidgetFlowParams =
| CommerceWidgetBridgeFlowParams
| CommerceWidgetOnRampFlowParams
| CommerceWidgetSaleFlowParams
| CommerceWidgetAddFundsFlowParams;
| CommerceWidgetAddTokensFlowParams;

export type CommerceWidgetParams = {
/** The language to use for the Commerce Widget */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type { AddFundsWidgetParams } from './addFunds';
export type { AddTokensWidgetParams } from './addTokens';

export * from './connect';
export * from './bridge';
Expand Down
34 changes: 17 additions & 17 deletions packages/checkout/sdk/src/widgets/definitions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ import {
CommerceSuccessEvent,
CommerceFailureEvent,
CommerceUserActionEvent,
RequestAddFundsEvent,
RequestAddTokensEvent,
RequestGoBackEvent,
AddFundsEventType,
AddFundsConnectSuccess,
AddFundsSuccess,
AddFundsFailed,
AddTokensEventType,
AddTokensConnectSuccess,
AddTokensSuccess,
AddTokensFailed,
} from './events';
import {
BridgeWidgetParams,
Expand All @@ -53,7 +53,7 @@ import {
WalletWidgetParams,
OnRampWidgetParams,
CommerceWidgetParams,
AddFundsWidgetParams,
AddTokensWidgetParams,
} from './parameters';
import { SaleWidgetParams } from './parameters/sale';
import {
Expand All @@ -64,7 +64,7 @@ import {
SwapWidgetConfiguration,
WalletWidgetConfiguration,
CommerceWidgetConfiguration,
AddFundsWidgetConfiguration,
AddTokensWidgetConfiguration,
} from './configurations';
import { WidgetTheme } from './configurations/theme';

Expand All @@ -79,7 +79,7 @@ export enum WidgetType {
ONRAMP = 'onramp',
SALE = 'sale',
IMMUTABLE_COMMERCE = 'immutableCommerce',
ADD_FUNDS = 'addFunds',
ADD_TOKENS = 'addTokens',
}

/**
Expand All @@ -97,7 +97,7 @@ export type WidgetConfigurations = {
[WidgetType.BRIDGE]: BridgeWidgetConfiguration;
[WidgetType.ONRAMP]: OnrampWidgetConfiguration;
[WidgetType.SALE]: SaleWidgetConfiguration;
[WidgetType.ADD_FUNDS]: AddFundsWidgetConfiguration;
[WidgetType.ADD_TOKENS]: AddTokensWidgetConfiguration;
[WidgetType.IMMUTABLE_COMMERCE]: CommerceWidgetConfiguration;
};

Expand All @@ -109,7 +109,7 @@ export type WidgetParameters = {
[WidgetType.BRIDGE]: BridgeWidgetParams;
[WidgetType.ONRAMP]: OnRampWidgetParams;
[WidgetType.SALE]: SaleWidgetParams;
[WidgetType.ADD_FUNDS]: AddFundsWidgetParams;
[WidgetType.ADD_TOKENS]: AddTokensWidgetParams;
[WidgetType.IMMUTABLE_COMMERCE]: CommerceWidgetParams;
};

Expand All @@ -124,7 +124,7 @@ export type WidgetEventTypes = {
[WidgetType.ONRAMP]: OnRampEventType | OrchestrationEventType;
[WidgetType.SALE]: SaleEventType | OrchestrationEventType;
[WidgetType.IMMUTABLE_COMMERCE]: CommerceEventType | OrchestrationEventType;
[WidgetType.ADD_FUNDS]: AddFundsEventType | OrchestrationEventType;
[WidgetType.ADD_TOKENS]: AddTokensEventType | OrchestrationEventType;
};

// Mapping of Orchestration events to their payloads
Expand All @@ -134,7 +134,7 @@ type OrchestrationMapping = {
[OrchestrationEventType.REQUEST_SWAP]: RequestSwapEvent;
[OrchestrationEventType.REQUEST_BRIDGE]: RequestBridgeEvent;
[OrchestrationEventType.REQUEST_ONRAMP]: RequestOnrampEvent;
[OrchestrationEventType.REQUEST_ADD_FUNDS]: RequestAddFundsEvent;
[OrchestrationEventType.REQUEST_ADD_TOKENS]: RequestAddTokensEvent;
[OrchestrationEventType.REQUEST_GO_BACK]: RequestGoBackEvent;
};

Expand Down Expand Up @@ -211,11 +211,11 @@ export type WidgetEventData = {
[CommerceEventType.USER_ACTION]: CommerceUserActionEvent;
};

[WidgetType.ADD_FUNDS]: {
[AddFundsEventType.CLOSE_WIDGET]: {};
[AddFundsEventType.CONNECT_SUCCESS]: AddFundsConnectSuccess;
[AddFundsEventType.SUCCESS]: AddFundsSuccess;
[AddFundsEventType.FAILURE]: AddFundsFailed;
[WidgetType.ADD_TOKENS]: {
[AddTokensEventType.CLOSE_WIDGET]: {};
[AddTokensEventType.CONNECT_SUCCESS]: AddTokensConnectSuccess;
[AddTokensEventType.SUCCESS]: AddTokensSuccess;
[AddTokensEventType.FAILURE]: AddTokensFailed;
} & OrchestrationMapping &
ProviderEventMapping;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export enum UserJourney {
SWAP = 'Swap',
BRIDGE = 'Bridge',
SALE = 'PrimarySale',
ADD_FUNDS = 'AddFunds',
ADD_TOKENS = 'AddTokens',
}

export type AnalyticsControlTypes =
Expand Down
Loading

0 comments on commit 556e4df

Please sign in to comment.