import { StandardRelayerAPIOrderProvider } from '@0x/asset-buyer'; import { getContractAddressesForNetworkOrThrow } from '@0x/contract-addresses'; import { assetDataUtils } from '@0x/order-utils'; import { ObjectMap } from '@0x/types'; import * as _ from 'lodash'; import * as React from 'react'; import { CheckMark } from 'ts/components/ui/check_mark'; import { Container } from 'ts/components/ui/container'; import { MultiSelect } from 'ts/components/ui/multi_select'; import { Select, SelectItemConfig } from 'ts/components/ui/select'; import { Spinner } from 'ts/components/ui/spinner'; import { Text } from 'ts/components/ui/text'; import { colors } from 'ts/style/colors'; import { WebsiteBackendTokenInfo } from 'ts/types'; import { backendClient } from 'ts/utils/backend_client'; import { constants } from 'ts/utils/constants'; import { ZeroExInstantBaseConfig } from '../../../../instant/src/types'; export interface ConfigGeneratorProps { value: ZeroExInstantBaseConfig; onConfigChange: (config: ZeroExInstantBaseConfig) => void; } export interface ConfigGeneratorState { isLoadingAvailableTokens: boolean; // Address to token info allKnownTokens: ObjectMap; availableTokens?: WebsiteBackendTokenInfo[]; } const SRA_ENDPOINTS = ['https://api.radarrelay.com/0x/v2/', 'https://api.openrelay.xyz/v2/']; export class ConfigGenerator extends React.Component { public state: ConfigGeneratorState = { isLoadingAvailableTokens: true, allKnownTokens: {}, }; public componentDidMount(): void { this._setAllKnownTokens(this._setAvailableAssetsFromOrderProvider); } public componentDidUpdate(prevProps: ConfigGeneratorProps): void { if (prevProps.value.orderSource !== this.props.value.orderSource) { this._setAvailableAssetsFromOrderProvider(); } } public render(): React.ReactNode { const { value } = this.props; if (!_.isString(value.orderSource)) { throw new Error('ConfigGenerator component only supports string values as an orderSource.'); } return (