From 7f4014a799145bad104d4e326851a91d70289074 Mon Sep 17 00:00:00 2001 From: Juan Olmedo Date: Thu, 28 Nov 2024 13:30:11 -0500 Subject: [PATCH] feature [SGW-751] L1 data endpoint on token creation (#469) * Added: L1 data endpoint input on token creation * Added: migration to add dL1 endpoints on DOR and PACA * Updated: wallet_watchAsset RPC method (#471) --- .../scenes/external/WatchAsset/constants.ts | 3 +- .../external/WatchAsset/index.module.scss | 2 + source/scenes/external/WatchAsset/index.tsx | 45 +++++-- .../AddCustomAsset.container.tsx | 62 ++++++--- .../AddCustomAsset/AddCustomAsset.native.tsx | 97 ++++++++------ .../Asset/AddCustomAsset/AddCustomAsset.scss | 24 +++- .../Asset/AddCustomAsset/AddCustomAsset.tsx | 120 +++++++++++------- .../home/Asset/AddCustomAsset/styles.ts | 12 ++ .../scenes/home/Asset/AddCustomAsset/types.ts | 6 +- .../controllers/AssetsController.ts | 5 +- .../controllers/MigrationController.ts | 9 ++ source/scripts/Background/migration/v5_1_3.ts | 76 +++++++++++ .../methods/wallet_watchAsset.ts | 3 +- .../Provider/constellation/utils/index.ts | 32 ++++- source/state/assets/index.ts | 2 + source/state/erc20assets/index.ts | 2 + source/state/erc20assets/types.ts | 3 +- source/state/vault/index.ts | 2 +- 18 files changed, 381 insertions(+), 124 deletions(-) create mode 100644 source/scripts/Background/migration/v5_1_3.ts diff --git a/source/scenes/external/WatchAsset/constants.ts b/source/scenes/external/WatchAsset/constants.ts index 0c6b6b5ed..45d75cc7d 100644 --- a/source/scenes/external/WatchAsset/constants.ts +++ b/source/scenes/external/WatchAsset/constants.ts @@ -6,6 +6,7 @@ export const TOKEN = 'Token'; export const BALANCE = 'Balance'; export const METAGRAPH_ADDRESS = 'Metagraph Address'; export const L0_ENDPOINT = 'L0 Endpoint'; -export const L1_ENDPOINT = 'L1 Endpoint'; +export const cL1_ENDPOINT = 'L1 Currency Endpoint'; +export const dL1_ENDPOINT = 'L1 Data Endpoint'; export const CANCEL = 'Cancel'; export const ADD_TOKEN = 'Add token'; diff --git a/source/scenes/external/WatchAsset/index.module.scss b/source/scenes/external/WatchAsset/index.module.scss index eee78eb23..e16a40e01 100644 --- a/source/scenes/external/WatchAsset/index.module.scss +++ b/source/scenes/external/WatchAsset/index.module.scss @@ -97,6 +97,8 @@ width: 100%; justify-content: center; flex-direction: row; + padding-top: 16px; + padding-bottom: 16px; .button { margin-left: 4px; diff --git a/source/scenes/external/WatchAsset/index.tsx b/source/scenes/external/WatchAsset/index.tsx index 40f37fe6b..e41271137 100644 --- a/source/scenes/external/WatchAsset/index.tsx +++ b/source/scenes/external/WatchAsset/index.tsx @@ -26,7 +26,8 @@ import { BALANCE, CANCEL, L0_ENDPOINT, - L1_ENDPOINT, + cL1_ENDPOINT, + dL1_ENDPOINT, METAGRAPH_ADDRESS, NETWORK, TOKEN, @@ -45,7 +46,7 @@ const WatchAsset = () => { const { type, options, balance } = data; - const { address, chainId, l0, l1, logo, symbol, name } = options; + const { address, chainId, l0, cl1, dl1, logo, symbol, name } = options; const wallet = getWalletController(); const current = useSelector(dappSelectors.getCurrent); @@ -66,15 +67,22 @@ const WatchAsset = () => { (network) => network.chainId === chainId ); - await wallet.account.assetsController.addCustomL0Token( - l0, - l1, - address, - name, - symbol, - selectedNetwork.id, - logo - ); + try { + await wallet.account.assetsController.addCustomL0Token( + l0, + cl1, + dl1, + address, + name, + symbol, + selectedNetwork.id, + logo + ); + } catch (err) { + StargazerExternalPopups.addResolvedParam(location.href); + StargazerWSMessageBroker.sendResponseResult(false, message); + window.close(); + } StargazerExternalPopups.addResolvedParam(location.href); StargazerWSMessageBroker.sendResponseResult(true, message); @@ -159,10 +167,21 @@ const WatchAsset = () => { color={COLORS_ENUMS.SECONDARY_TEXT} extraStyles={styles.itemTitle} > - {L1_ENDPOINT} + {cL1_ENDPOINT} + + + {cl1} + + +
+ + {dL1_ENDPOINT} - {l1} + {dl1}
diff --git a/source/scenes/home/Asset/AddCustomAsset/AddCustomAsset.container.tsx b/source/scenes/home/Asset/AddCustomAsset/AddCustomAsset.container.tsx index 88b3a4186..384046d04 100644 --- a/source/scenes/home/Asset/AddCustomAsset/AddCustomAsset.container.tsx +++ b/source/scenes/home/Asset/AddCustomAsset/AddCustomAsset.container.tsx @@ -53,7 +53,8 @@ const AddCustomAssetContainer: FC<{ navigation: any }> = ({ navigation }) => { const [networkType, setNetworkType] = useState('main2'); const [tokenAddress, setTokenAddress] = useState(''); const [l0endpoint, setL0endpoint] = useState(''); - const [l1endpoint, setL1endpoint] = useState(''); + const [cl1endpoint, setcL1endpoint] = useState(''); + const [dl1endpoint, setdL1endpoint] = useState(''); const [tokenName, setTokenName] = useState(''); const [tokenSymbol, setTokenSymbol] = useState(''); const [tokenDecimals, setTokenDecimals] = useState(''); @@ -128,20 +129,34 @@ const AddCustomAssetContainer: FC<{ navigation: any }> = ({ navigation }) => { return true; }) .required('L0 endpoint is required'), - l1endpoint: yup + cl1endpoint: yup .string() .test('validURL', 'Please enter a valid URL', (val) => { const regex = new RegExp(URL_REGEX_PATTERN); return regex.test(val); }) - .test('validNode', 'L1 endpoint not found', (val) => { + .test('validNode', 'L1 currency endpoint not found', (val) => { if (!!val) { return accountController.isValidNode(val); } return true; }) - .required('L1 endpoint is required'), + .required('L1 currency endpoint is required'), + dl1endpoint: yup + .string() + .test('validURL', 'Please enter a valid URL', (val) => { + const regex = new RegExp(URL_REGEX_PATTERN); + return regex.test(val); + }) + .test('validNode', 'L1 data endpoint not found', (val) => { + if (!!val) { + return accountController.isValidNode(val); + } + + return true; + }) + .required('L1 data endpoint is required'), tokenName: yup.string().required('Token name is required'), tokenSymbol: yup .string() @@ -186,7 +201,7 @@ const AddCustomAssetContainer: FC<{ navigation: any }> = ({ navigation }) => { useEffect(() => { const hasErrors = !!Object.keys(errors)?.length; const otherChecks = isL0Token - ? l0endpoint === '' || l1endpoint === '' + ? l0endpoint === '' || cl1endpoint === '' || dl1endpoint === '' : tokenDecimals === ''; const disabled = hasErrors || @@ -199,7 +214,8 @@ const AddCustomAssetContainer: FC<{ navigation: any }> = ({ navigation }) => { Object.keys(errors), tokenAddress, l0endpoint, - l1endpoint, + cl1endpoint, + dl1endpoint, tokenName, tokenSymbol, tokenDecimals, @@ -220,10 +236,16 @@ const AddCustomAssetContainer: FC<{ navigation: any }> = ({ navigation }) => { triggerValidation('l0endpoint'); }; - const handleL1endpointChange = (value: string) => { - setValue('l1endpoint', value); - setL1endpoint(value); - triggerValidation('l1endpoint'); + const handlecL1endpointChange = (value: string) => { + setValue('cl1endpoint', value); + setcL1endpoint(value); + triggerValidation('cl1endpoint'); + }; + + const handledL1endpointChange = (value: string) => { + setValue('dl1endpoint', value); + setdL1endpoint(value); + triggerValidation('dl1endpoint'); }; const handleNameChange = (value: string) => { @@ -256,7 +278,8 @@ const AddCustomAssetContainer: FC<{ navigation: any }> = ({ navigation }) => { tokenSymbol, tokenDecimals, l0endpoint, - l1endpoint, + cl1endpoint, + dl1endpoint, } = asset; setButtonLoading(true); @@ -292,7 +315,8 @@ const AddCustomAssetContainer: FC<{ navigation: any }> = ({ navigation }) => { await accountController.assetsController.addCustomL0Token( l0endpoint, - l1endpoint, + cl1endpoint, + dl1endpoint, tokenAddress, tokenName, tokenSymbol @@ -308,14 +332,16 @@ const AddCustomAssetContainer: FC<{ navigation: any }> = ({ navigation }) => { setNetworkType(value); setValue('tokenAddress', ''); setValue('l0endpoint', ''); - setValue('l1endpoint', ''); + setValue('cl1endpoint', ''); + setValue('dl1endpoint', ''); setValue('tokenName', ''); setValue('tokenSymbol', ''); setValue('tokenDecimals', ''); setTokenAddress(''); setTokenName(''); setL0endpoint(''); - setL1endpoint(''); + setcL1endpoint(''); + setdL1endpoint(''); setTokenSymbol(''); setTokenDecimals(''); } @@ -331,7 +357,7 @@ const AddCustomAssetContainer: FC<{ navigation: any }> = ({ navigation }) => { }; const networkTypeOptions = { - title: 'Network type', + title: 'Network Type', value: networkType, items: [ // 349: New network should be added here. @@ -355,7 +381,8 @@ const AddCustomAssetContainer: FC<{ navigation: any }> = ({ navigation }) => { register={register} tokenAddress={tokenAddress} l0endpoint={l0endpoint} - l1endpoint={l1endpoint} + cl1endpoint={cl1endpoint} + dl1endpoint={dl1endpoint} tokenName={tokenName} tokenSymbol={tokenSymbol} tokenDecimals={tokenDecimals} @@ -364,7 +391,8 @@ const AddCustomAssetContainer: FC<{ navigation: any }> = ({ navigation }) => { handleAddressScan={handleAddressScan} handleAddressChange={handleAddressChange} handleL0endpointChange={handleL0endpointChange} - handleL1endpointChange={handleL1endpointChange} + handlecL1endpointChange={handlecL1endpointChange} + handledL1endpointChange={handledL1endpointChange} handleNameChange={handleNameChange} handleSymbolChange={handleSymbolChange} handleDecimalsChange={handleDecimalsChange} diff --git a/source/scenes/home/Asset/AddCustomAsset/AddCustomAsset.native.tsx b/source/scenes/home/Asset/AddCustomAsset/AddCustomAsset.native.tsx index a1db79bca..f3d2e519c 100644 --- a/source/scenes/home/Asset/AddCustomAsset/AddCustomAsset.native.tsx +++ b/source/scenes/home/Asset/AddCustomAsset/AddCustomAsset.native.tsx @@ -42,7 +42,8 @@ const AddCustomAsset: FC = ({ control, tokenAddress, l0endpoint, - l1endpoint, + cl1endpoint, + dl1endpoint, tokenName, tokenSymbol, tokenDecimals, @@ -51,7 +52,8 @@ const AddCustomAsset: FC = ({ handleAddressScan, handleAddressChange, handleL0endpointChange, - handleL1endpointChange, + handlecL1endpointChange, + handledL1endpointChange, handleNameChange, handleSymbolChange, handleDecimalsChange, @@ -76,7 +78,7 @@ const AddCustomAsset: FC = ({ ); }; - const tokenAddressLabel = isL0Token ? 'Metagraph address' : 'Token address'; + const tokenAddressLabel = isL0Token ? 'Metagraph Address' : 'Token Address'; const tokenAddressPlaceholder = isL0Token ? 'DAG...' : '0x...'; const tokenNamePlaceholder = isL0Token ? 'Enter token name' : 'Ethereum'; const tokenSymbolPlaceholder = isL0Token ? 'Enter token symbol' : 'ETH'; @@ -109,45 +111,66 @@ const AddCustomAsset: FC = ({ {isL0Token && ( <> - { - handleL0endpointChange(text); - }} - /> - - {!!errors?.l0endpoint ? errors?.l0endpoint?.message : ' '} - - { - handleL1endpointChange(text); - }} - /> - - {!!errors?.l1endpoint ? errors?.l1endpoint?.message : ' '} - + + Endpoints + + + { + handleL0endpointChange(text); + }} + /> + + {!!errors?.l0endpoint ? errors?.l0endpoint?.message : ' '} + + { + handlecL1endpointChange(text); + }} + /> + + {!!errors?.cl1endpoint ? errors?.cl1endpoint?.message : ' '} + + { + handledL1endpointChange(text); + }} + /> + + {!!errors?.dl1endpoint ? errors?.dl1endpoint?.message : ' '} + + )} = ({ name="tokenSymbol" defaultValue={tokenSymbol} placeholder={tokenSymbolPlaceholder} - label="Token symbol" + label="Token Symbol" control={control} labelStyle={styles.label} returnKeyType="done" diff --git a/source/scenes/home/Asset/AddCustomAsset/AddCustomAsset.scss b/source/scenes/home/Asset/AddCustomAsset/AddCustomAsset.scss index 1eb587eb0..e83e62501 100644 --- a/source/scenes/home/Asset/AddCustomAsset/AddCustomAsset.scss +++ b/source/scenes/home/Asset/AddCustomAsset/AddCustomAsset.scss @@ -59,6 +59,23 @@ ul.form { border-radius: 10px; background-color: $gray-light; + .endpoints { + font-weight: 500; + font-size: 14px; + line-height: 20px; + font-family: $inter; + color: $black; + } + + .endpointsContainer { + background-color: $white; + padding: 12px 12px 0px 12px; + border: 1px solid rgba(0, 0, 0, 0.16); + border-radius: 8px; + margin-bottom: 20px; + margin-top: 8px; + } + li { position: relative; box-sizing: border-box; @@ -75,10 +92,15 @@ ul.form { font-weight: 500; font-size: 14px; line-height: 20px; - margin-bottom: 2px; + margin-bottom: 8px; font-family: $inter; color: $black; } + + .labelSmall { + font-size: 12px; + line-height: 18px; + } } } diff --git a/source/scenes/home/Asset/AddCustomAsset/AddCustomAsset.tsx b/source/scenes/home/Asset/AddCustomAsset/AddCustomAsset.tsx index 290241590..9d8b74318 100644 --- a/source/scenes/home/Asset/AddCustomAsset/AddCustomAsset.tsx +++ b/source/scenes/home/Asset/AddCustomAsset/AddCustomAsset.tsx @@ -32,7 +32,8 @@ const AddCustomAsset: FC = ({ register, tokenAddress, l0endpoint, - l1endpoint, + cl1endpoint, + dl1endpoint, tokenName, tokenSymbol, tokenDecimals, @@ -40,7 +41,8 @@ const AddCustomAsset: FC = ({ isL0Token, handleAddressChange, handleL0endpointChange, - handleL1endpointChange, + handlecL1endpointChange, + handledL1endpointChange, handleNameChange, handleSymbolChange, handleDecimalsChange, @@ -52,7 +54,7 @@ const AddCustomAsset: FC = ({ }) => { const inputClass = clsx(styles.input, styles.address); - const tokenAddressLabel = isL0Token ? 'Metagraph address' : 'Token address'; + const tokenAddressLabel = isL0Token ? 'Metagraph Address' : 'Token Address'; const tokenAddressPlaceholder = isL0Token ? 'DAG...' : '0x...'; const tokenNamePlaceholder = isL0Token ? 'Enter token name' : 'Ethereum'; const tokenSymbolPlaceholder = isL0Token ? 'Enter token symbol' : 'ETH'; @@ -88,52 +90,76 @@ const AddCustomAsset: FC = ({ {isL0Token && ( <> -
  • - - handleL0endpointChange(ev.target.value)} - disabled={false} - error={!!errors?.l0endpoint} - variant={inputClass} - /> - - {!!errors?.l0endpoint ? errors?.l0endpoint?.message : ' '} - -
  • -
  • - - handleL1endpointChange(ev.target.value)} - disabled={false} - error={!!errors?.l1endpoint} - variant={inputClass} - /> - - {!!errors?.l1endpoint ? errors?.l1endpoint?.message : ' '} - -
  • + +
    +
  • + + handleL0endpointChange(ev.target.value)} + disabled={false} + error={!!errors?.l0endpoint} + variant={inputClass} + /> + + {!!errors?.l0endpoint ? errors?.l0endpoint?.message : ' '} + +
  • +
  • + + handlecL1endpointChange(ev.target.value)} + disabled={false} + error={!!errors?.cl1endpoint} + variant={inputClass} + /> + + {!!errors?.cl1endpoint ? errors?.cl1endpoint?.message : ' '} + +
  • +
  • + + handledL1endpointChange(ev.target.value)} + disabled={false} + error={!!errors?.dl1endpoint} + variant={inputClass} + /> + + {!!errors?.dl1endpoint ? errors?.dl1endpoint?.message : ' '} + +
  • +
    )}
  • - + = ({
  • - + Promise; handleAddressChange: (value: string) => Promise; handleL0endpointChange: (value: string) => void; - handleL1endpointChange: (value: string) => void; + handlecL1endpointChange: (value: string) => void; + handledL1endpointChange: (value: string) => void; handleNameChange: (value: string) => void; handleSymbolChange: (value: string) => void; handleDecimalsChange: (value: string) => void; diff --git a/source/scripts/Background/controllers/AssetsController.ts b/source/scripts/Background/controllers/AssetsController.ts index 788368e0e..26063fcd4 100644 --- a/source/scripts/Background/controllers/AssetsController.ts +++ b/source/scripts/Background/controllers/AssetsController.ts @@ -79,7 +79,8 @@ export interface IAssetsController { ) => Promise; addCustomL0Token: ( l0endpoint: string, - l1endpoint: string, + cl1endpoint: string, + dl1endpoint: string, address: string, name: string, symbol: string, @@ -133,6 +134,7 @@ const AssetsController = (): IAssetsController => { const addCustomL0Token = async ( l0endpoint: string, l1endpoint: string, + dl1endpoint: string, address: string, name: string, symbol: string, @@ -157,6 +159,7 @@ const AssetsController = (): IAssetsController => { network, l0endpoint, l1endpoint, + dl1endpoint, custom: true, }; diff --git a/source/scripts/Background/controllers/MigrationController.ts b/source/scripts/Background/controllers/MigrationController.ts index a3243b662..53645eb25 100644 --- a/source/scripts/Background/controllers/MigrationController.ts +++ b/source/scripts/Background/controllers/MigrationController.ts @@ -165,6 +165,15 @@ const MigrationController = async () => { const v5_0_0 = require('../migration/v5_0_0'); await v5_0_0.default(state); } + + /** + * version < 5_1_3 + * Description: Adds dL1 endpoints on DOR and PACA + */ + if (compareVersions(state.vault.version, '5.1.3') < 0) { + const v5_1_3 = require('../migration/v5_1_3'); + await v5_1_3.default(state); + } }; export default MigrationController; diff --git a/source/scripts/Background/migration/v5_1_3.ts b/source/scripts/Background/migration/v5_1_3.ts new file mode 100644 index 000000000..9dcef526a --- /dev/null +++ b/source/scripts/Background/migration/v5_1_3.ts @@ -0,0 +1,76 @@ +import { reload } from 'utils/browser'; +import IAssetListState from 'state/assets/types'; +import IContactBookState from 'state/contacts/types'; +import IPriceState from 'state/price/types'; +import IVaultState from 'state/vault/types'; +import { saveState } from 'state/localStorage'; +import { IBiometricsState } from 'state/biometrics/types'; +import { IDAppState } from 'state/dapp/types'; + +type V5_1_3_State = { + vault: IVaultState; + price: IPriceState; + contacts: IContactBookState; + assets: IAssetListState; + dapp: IDAppState; + swap: { + txIds: string[]; + }; + biometrics: IBiometricsState; +}; + +const VERSION = '5.1.3'; + +function updateAssets(assets: IAssetListState, updates: { [key: string]: any }) { + // Create a copy of the assets to avoid modifying the original object + const updatedAssets: any = { ...assets }; + + // Iterate over the keys in the updates object + Object.keys(updates).forEach((key) => { + if (updatedAssets[key]) { + // Iterate over each property in the updates for the current key + Object.keys(updates[key]).forEach((property: any) => { + // Update the property for the asset + updatedAssets[key][property] = updates[key][property]; + }); + } + }); + + return updatedAssets; +} + +const MigrateRunner = async (oldState: any) => { + const DOR_ASSET_KEY = 'DAG0CyySf35ftDQDQBnd1bdQ9aPyUdacMghpnCuM-main2'; + const PACA_ASSET_KEY = 'DAG7ChnhUF7uKgn8tXy45aj4zn9AFuhaZr8VXY43-main2'; + const DOR_dL1_ENDPOINT = 'http://dl1-lb-mainnet.getdor.com:9000'; + const PACA_dL1_ENDPOINT = + 'http://elpaca-dl1-550039959.us-west-1.elb.amazonaws.com:9300'; + + const assetsUpdated = updateAssets(oldState.assets, { + [DOR_ASSET_KEY]: { + dl1endpoint: DOR_dL1_ENDPOINT, + }, + [PACA_ASSET_KEY]: { + dl1endpoint: PACA_dL1_ENDPOINT, + }, + }); + + try { + const newState: V5_1_3_State = { + ...oldState, + assets: assetsUpdated, + vault: { + ...oldState.vault, + version: VERSION, + }, + }; + await saveState(newState); + console.log(`Migrate to successfully!`); + reload(); + } catch (error) { + console.log(` Migration Error`); + console.log(error); + } +}; + +export default MigrateRunner; diff --git a/source/scripts/Provider/constellation/methods/wallet_watchAsset.ts b/source/scripts/Provider/constellation/methods/wallet_watchAsset.ts index b47cae1df..1cdc7dfbc 100644 --- a/source/scripts/Provider/constellation/methods/wallet_watchAsset.ts +++ b/source/scripts/Provider/constellation/methods/wallet_watchAsset.ts @@ -12,7 +12,8 @@ export type WatchAssetOptions = { chainId: number; // The chain ID of the asset. 1 (mainnet), 3 (testnet), 4 (integrationnet) address: string; // Metagraph address l0: string; // L0 endpoint - l1: string; // L1 endpoint + cl1: string; // L1 currency endpoint + dl1: string; // L1 data endpoint name: string; // Name of the asset symbol: string; // Symbol of the asset logo: string; // Logo of the token diff --git a/source/scripts/Provider/constellation/utils/index.ts b/source/scripts/Provider/constellation/utils/index.ts index 8912b236b..cea602e9b 100644 --- a/source/scripts/Provider/constellation/utils/index.ts +++ b/source/scripts/Provider/constellation/utils/index.ts @@ -6,6 +6,7 @@ import { dag4 } from '@stardust-collective/dag4'; import { decodeFromBase64, encodeToBase64 } from 'utils/encoding'; import { WatchAssetParameters } from '../methods/wallet_watchAsset'; import { toDag } from 'utils/number'; +import { getAccountController } from 'utils/controllersUtils'; const LEDGER_URL = '/ledger.html'; const BITFI_URL = '/bitfi.html'; @@ -216,11 +217,35 @@ export const isValidMetagraphAddress = async ( return !!response?.data?.hash; }; +export const validateNodes = async ( + l0: string, + cl1: string, + dl1: string +): Promise => { + const accountController = getAccountController(); + + const isValidL0 = await accountController.isValidNode(l0); + const isValidcL1 = await accountController.isValidNode(cl1); + const isValiddL1 = await accountController.isValidNode(dl1); + + if (!isValidL0) { + throw new Error('Argument "l0" is invalid -> node not found'); + } + + if (!isValidcL1) { + throw new Error('Argument "cl1" is invalid -> node not found'); + } + + if (!isValiddL1) { + throw new Error('Argument "dl1" is invalid -> node not found'); + } +}; + export const checkWatchAssetParams = async ({ type, options, }: WatchAssetParameters): Promise => { - const { chainId, address, l0, l1, name, symbol, logo } = options; + const { chainId, address, l0, cl1, dl1, name, symbol, logo } = options; const SUPPORTED_TYPES = ['L0']; const SUPPORTED_CHAINS = Object.values(DAG_NETWORK).map((network) => network.chainId); const args = [ @@ -228,7 +253,8 @@ export const checkWatchAssetParams = async ({ { type: 'number', value: chainId, name: 'chainId' }, { type: 'string', value: address, name: 'address' }, { type: 'string', value: l0, name: 'l0' }, - { type: 'string', value: l1, name: 'l1' }, + { type: 'string', value: cl1, name: 'cl1' }, + { type: 'string', value: dl1, name: 'dl1' }, { type: 'string', value: name, name: 'name' }, { type: 'string', value: symbol, name: 'symbol' }, { type: 'string', value: logo, name: 'logo' }, @@ -260,4 +286,6 @@ export const checkWatchAssetParams = async ({ if (!isValidMetagraph) { throw new Error('Argument "address" or "chainId" are invalid -> metagraph not found'); } + + await validateNodes(l0, cl1, dl1); }; diff --git a/source/state/assets/index.ts b/source/state/assets/index.ts index 327c66ca2..6e4767a48 100644 --- a/source/state/assets/index.ts +++ b/source/state/assets/index.ts @@ -52,6 +52,7 @@ export const initialState: IAssetListState = { network: 'main2', l0endpoint: 'http://l0-lb-mainnet.getdor.com:7000', l1endpoint: 'http://cl1-lb-mainnet.getdor.com:8000', + dl1endpoint: 'http://dl1-lb-mainnet.getdor.com:9000', priceId: 'dor', }, 'DAG7ChnhUF7uKgn8tXy45aj4zn9AFuhaZr8VXY43-main2': { @@ -65,6 +66,7 @@ export const initialState: IAssetListState = { network: 'main2', l0endpoint: 'http://elpaca-l0-2006678808.us-west-1.elb.amazonaws.com:9100', l1endpoint: 'http://elpaca-cl1-1512652691.us-west-1.elb.amazonaws.com:9200', + dl1endpoint: 'http://elpaca-dl1-550039959.us-west-1.elb.amazonaws.com:9300', }, // 349: New network should be added here. [AssetType.Avalanche]: { diff --git a/source/state/erc20assets/index.ts b/source/state/erc20assets/index.ts index fa78b6d68..1b6a2cf7a 100644 --- a/source/state/erc20assets/index.ts +++ b/source/state/erc20assets/index.ts @@ -56,6 +56,7 @@ export const constellationInitialValues: IAssetInfoState[] = [ network: 'main2', l0endpoint: 'http://l0-lb-mainnet.getdor.com:7000', l1endpoint: 'http://cl1-lb-mainnet.getdor.com:8000', + dl1endpoint: 'http://dl1-lb-mainnet.getdor.com:9000', priceId: 'dor', }, { @@ -69,6 +70,7 @@ export const constellationInitialValues: IAssetInfoState[] = [ network: 'main2', l0endpoint: 'http://elpaca-l0-2006678808.us-west-1.elb.amazonaws.com:9100', l1endpoint: 'http://elpaca-cl1-1512652691.us-west-1.elb.amazonaws.com:9200', + dl1endpoint: 'http://elpaca-dl1-550039959.us-west-1.elb.amazonaws.com:9300', }, { id: '0xa393473d64d2F9F026B60b6Df7859A689715d092-mainnet', diff --git a/source/state/erc20assets/types.ts b/source/state/erc20assets/types.ts index afac8fcae..587d8d991 100644 --- a/source/state/erc20assets/types.ts +++ b/source/state/erc20assets/types.ts @@ -46,7 +46,8 @@ export interface SearchAsset { } export interface ICustomAssetForm { l0endpoint?: string; - l1endpoint?: string; + cl1endpoint?: string; + dl1endpoint?: string; tokenAddress: string; tokenName: string; tokenSymbol: string; diff --git a/source/state/vault/index.ts b/source/state/vault/index.ts index 642176117..6a365d6a9 100644 --- a/source/state/vault/index.ts +++ b/source/state/vault/index.ts @@ -60,7 +60,7 @@ const initialState: IVaultState = { ethereum: {}, }, customAssets: [], - version: '5.0.0', + version: '5.1.3', }; export const getHasEncryptedVault = createAsyncThunk(