diff --git a/packages/gui/src/components/offers/OfferShareDialog.tsx b/packages/gui/src/components/offers/OfferShareDialog.tsx index ce0158266d..6e5c07a763 100644 --- a/packages/gui/src/components/offers/OfferShareDialog.tsx +++ b/packages/gui/src/components/offers/OfferShareDialog.tsx @@ -38,7 +38,6 @@ const log = debug('chia-gui:offers'); enum OfferSharingService { Dexie = 'Dexie', - Hashgreen = 'Hashgreen', MintGarden = 'MintGarden', Offerpool = 'Offerpool', Spacescan = 'Spacescan', @@ -92,11 +91,6 @@ const OfferSharingProviders: { name: 'Dexie', capabilities: [OfferSharingCapability.Token, OfferSharingCapability.NFT], }, - [OfferSharingService.Hashgreen]: { - service: OfferSharingService.Hashgreen, - name: 'Hashgreen DEX', - capabilities: [OfferSharingCapability.Token], - }, [OfferSharingService.MintGarden]: { service: OfferSharingService.MintGarden, name: 'MintGarden', @@ -193,78 +187,6 @@ async function postToMintGarden(offerData: string, testnet: boolean): Promise { - const { ipcRenderer } = window as any; - const requestOptions = { - method: 'POST', - protocol: 'https:', - hostname: testnet ? testnetDummyHost : 'hash.green', - port: 443, - path: testnet ? '/hashgreen' : '/api/v1/orders', - }; - const requestHeaders = { - accept: 'application/json', - 'Content-Type': 'application/x-www-form-urlencoded', - }; - const requestData = `offer=${offerData}`; - const { err, statusCode, statusMessage, responseBody } = await ipcRenderer.invoke( - 'fetchTextResponse', - requestOptions, - requestHeaders, - requestData, - ); - - if (err) { - const error = new Error( - `Failed to post offer to hash.green: ${err}, statusCode=${statusCode}, statusMessage=${statusMessage}`, - ); - throw error; - } - - if (statusCode === 200) { - log('Hashgreen upload completed'); - - if (testnet) { - return 'https://www.chia.net/offers'; - } - - const jsonObj = JSON.parse(responseBody); - const { data } = jsonObj; - const id = data?.id; - - if (id) { - return `https://hash.green/dex?order=${id}`; - } - const error = new Error(`Hashgreen response missing data.id: ${responseBody}`); - throw error; - } else { - const jsonObj = JSON.parse(responseBody); - const { code, msg, data } = jsonObj; - - if (code === HashgreenErrorCodes.OFFER_FILE_EXISTS && data) { - return `https://hash.green/dex?order=${data}`; - } - log(`Upload failure response: ${responseBody}`); - switch (code) { - case HashgreenErrorCodes.MARKET_NOT_FOUND: - throw new Error(`Hashgreen upload rejected. Pairing is not supported: ${msg}`); - case HashgreenErrorCodes.COINS_ALREADY_COMMITTED: - throw new Error(`Hashgreen upload rejected. Offer contains coins that are in use by another offer: ${msg}`); - case HashgreenErrorCodes.OFFERED_AMOUNT_TOO_SMALL: - throw new Error(`Hashgreen upload rejected. Offer amount is too small: ${msg}`); - default: - throw new Error(`Hashgreen upload rejected: code=${code} msg=${msg} data=${data}`); - } - } -} - type PostToSpacescanResponse = { success: boolean; offer: { @@ -543,79 +465,6 @@ function OfferShareMintGardenDialog(props: OfferShareServiceDialogProps) { ); } -function OfferShareHashgreenDialog(props: OfferShareServiceDialogProps) { - const { offerRecord, offerData, testnet = false, onClose = () => {}, open = false } = props; - const openExternal = useOpenExternal(); - const [sharedURL, setSharedURL] = React.useState(''); - - function handleClose() { - onClose(false); - } - - async function handleConfirm() { - const url = await postToHashgreen(offerData, testnet); - log(`Hashgreen URL: ${url}`); - setSharedURL(url); - } - - if (sharedURL) { - return ( - - - Offer Shared - - - - Hashgreen DEX URL} - value={sharedURL} - variant="filled" - InputProps={{ - readOnly: true, - endAdornment: ( - - - - ), - }} - fullWidth - /> - - - - - - - - - - ); - } - - return ( - Share on Hashgreen DEX} - onConfirm={handleConfirm} - open={open} - onClose={onClose} - /> - ); -} - function OfferShareSpacescanDialog(props: OfferShareServiceDialogProps) { const { offerRecord, @@ -994,10 +843,6 @@ export default function OfferShareDialog(props: OfferShareDialogProps) { component: OfferShareDexieDialog, props: commonDialogProps, }, - [OfferSharingService.Hashgreen]: { - component: OfferShareHashgreenDialog, - props: commonDialogProps, - }, [OfferSharingService.MintGarden]: { component: OfferShareMintGardenDialog, props: commonDialogProps, diff --git a/packages/gui/src/constants/OfferServices.ts b/packages/gui/src/constants/OfferServices.ts index 5bfef89f11..d7ef4c2f36 100644 --- a/packages/gui/src/constants/OfferServices.ts +++ b/packages/gui/src/constants/OfferServices.ts @@ -3,10 +3,6 @@ export default [ label: 'Dexie', domains: ['dexie.space'], }, - { - label: 'Hashgreen', - domains: ['hash.green'], - }, { label: 'Mint Garden', domains: ['mintgarden.io'],