Skip to content

Commit

Permalink
XCH support for btc address validation (flexpool#792)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSSD7 authored Sep 12, 2023
2 parents 686b96c + 7ead40f commit 1970260
Show file tree
Hide file tree
Showing 16 changed files with 358 additions and 46 deletions.
5 changes: 5 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ module.exports = withPWA(
destination: '/miner/iron/:address',
permanent: false,
},
{
source: '/get-started/xch/flexfarmer',
destination: 'https://farmer.flexpool.io/get-started',
permanent: false,
},
// Old Redirects from CRA app
// {
// source: '/:lang/blocks',
Expand Down
Binary file added public/nicehash-guide/nh_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/nicehash-guide/nh_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/nicehash-guide/nh_3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions src/locales/en-US/get-started.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,15 @@
"title": "FlexFarmer",
"key": "flexfarmer"
}
]
],
"btc_payout": {
"intro": "The following instructions guide you through how to change payout options for Chia.",
"paste_info": "First, grab the Launcher ID from <mono>chia plotnft show</mono> command and paste your Bitcoin wallet address into the box below:",
"run_cmd": "Run the following command to change your payout address:",
"gui_instruction": "Edit your payout instructions for your PlotNFT in the 'Pool' page.",
"gui_note": "<b>Note:</b> Your address must follow the format <mono>btc:BTC_WALLET</mono>",
"dashboard_format": "If you are using BTC AutoSwap, use your Bitcoin wallet address with the following format: <mono>btc:BTC_WALLET</mono>"
}
},
"detail_tiron": {
"title": "Iron Fish (Testnet) mining",
Expand Down Expand Up @@ -456,4 +464,4 @@
},
"terms": "Terms and conditions apply"
}
}
}
10 changes: 9 additions & 1 deletion src/locales/zh-CN/get-started.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,15 @@
"title": "FlexFarmer",
"key": "flexfarmer"
}
]
],
"btc_payout": {
"intro": "以下说明将指导您如何更改Chia的支付选项。",
"paste_info": "首先,从<mono>chia plotnft show</mono>命令中获取启动器ID,并将您的比特币钱包地址粘贴到下方的框中:",
"run_cmd": "运行以下命令以更改您的支付地址:",
"gui_instruction": "在“矿池”页面编辑您的PlotNFT的支付说明。",
"gui_note": "<b>注意:</b>您的地址必须遵循以下格式:<mono>btc:BTC_WALLET</mono>",
"dashboard_format": "如果您正在使用BTC AutoSwap,请使用以下格式的比特币钱包地址:<mono>btc:BTC_WALLET</mono>"
}
},
"detail_tiron": {
"title": "Iron Fish (Testnet) mining",
Expand Down
19 changes: 18 additions & 1 deletion src/pages/GetStarted/ChiaCli/Guide.page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { useRouter } from 'next/router';

import { useTranslation } from 'next-i18next';
import { Trans, useTranslation } from 'next-i18next';

import { Page } from 'src/components/layout/Page';
import { Spacer } from 'src/components/layout/Spacer';
Expand All @@ -21,6 +21,8 @@ import merge from 'lodash.merge';
import { NextSeo } from 'next-seo';

import { GuideForm, SectionWrapper } from '../common';
import { AutoSwapBTCToggleSection } from '../ChiaShared/AutoSwapBTCToggleSection';
import { CLI } from '../ChiaShared/AutoSwapBTCGuide';

export const ChiaCliGuidePage: React.FC = () => {
const isMounted = useIsMounted();
Expand Down Expand Up @@ -176,7 +178,13 @@ export const ChiaCliGuidePage: React.FC = () => {
</li>
</ul>
</p>

<Spacer />
<AutoSwapBTCToggleSection>
<CLI />
</AutoSwapBTCToggleSection>
<Spacer size="xl" />

{farmer_option === 'new-farmer' ? (
<>
<ButtonGroupField
Expand Down Expand Up @@ -210,6 +218,15 @@ export const ChiaCliGuidePage: React.FC = () => {
title={t('detail_xch.monitor_farm.title')}
>
<p>{t('detail_xch.monitor_farm.desc')}</p>
<p>
<Trans
t={t}
i18nKey={'detail_xch.btc_payout.dashboard_format'}
components={{
mono: <Mono />,
}}
/>
</p>
</SectionWrapper>

<Spacer size="xl" />
Expand Down
26 changes: 19 additions & 7 deletions src/pages/GetStarted/ChiaGui/Guide.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ import { ChiaGuiInput } from './Input';
import { ChiaGuiLink } from './Link';
import { FarmerOptionSelector } from '../ChiaShared/FarmerOptionSelector';
import { NextSeo } from 'next-seo';
import { AutoSwapBTCToggleSection } from '../ChiaShared/AutoSwapBTCToggleSection';
import { GUI } from '../ChiaShared/AutoSwapBTCGuide';

import { GuideForm, SectionWrapper } from '../common';
import { Mono } from '@/components/Typo/Typo';

export const ChiaGuiGuidePage: React.FC = () => {
const router = useRouter();
Expand Down Expand Up @@ -97,11 +100,8 @@ export const ChiaGuiGuidePage: React.FC = () => {
namePrimary="primary_server"
/>
</SectionWrapper>

<Spacer size="xl" />

<FarmerOptionSelector name="farmer_option" />

{farmer_option !== 'already-farmer' ? (
<SectionWrapper
position={2}
Expand Down Expand Up @@ -165,9 +165,7 @@ export const ChiaGuiGuidePage: React.FC = () => {
/>
</SectionWrapper>
)}

<Spacer size="xl" />

<SectionWrapper
position={3}
title={t('detail_xch.gather_payout_address_gui.title')}
Expand All @@ -182,6 +180,7 @@ export const ChiaGuiGuidePage: React.FC = () => {
/>
}
/>

<Spacer />
<p>
<b>{t('detail.note') + ' '}</b>
Expand All @@ -195,13 +194,26 @@ export const ChiaGuiGuidePage: React.FC = () => {
</p>
</SectionWrapper>

<Spacer size="xl" />
<Spacer />
<AutoSwapBTCToggleSection>
<GUI />
</AutoSwapBTCToggleSection>

<Spacer size="xl" />
<SectionWrapper
position={4}
title={t('detail_xch.monitor_farm.title')}
>
<p>{t('detail_xch.monitor_farm.desc_gui')}</p>
<p>
<Trans
t={t}
i18nKey={'detail_xch.btc_payout.dashboard_format'}
components={{
mono: <Mono />,
}}
/>
</p>
</SectionWrapper>
</>
);
Expand Down Expand Up @@ -735,7 +747,7 @@ type ChiaGuiMenuProps = {
highlightMenu?: boolean;
};

const ChiaGuiMenu = (props: ChiaGuiMenuProps) => {
export const ChiaGuiMenu = (props: ChiaGuiMenuProps) => {
const { selectedMenu, menuContent, highlightMenu } = props;

return (
Expand Down
179 changes: 179 additions & 0 deletions src/pages/GetStarted/ChiaShared/AutoSwapBTCGuide.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
import { TextField } from '@/components/Form/TextInput';
import { TerminalCommand } from '../ChiaCli/TerminalCommand';
import { GuideForm } from '../common';
import { Spacer } from '@/components/layout/Spacer';
import { Mono } from '@/components/Typo/Typo';
import { ChiaGuiMenu } from '../ChiaGui/Guide.page';
import styled, { keyframes } from 'styled-components';
import { FiMoreVertical } from 'react-icons/fi';
import { Code } from '@/components/Code/Code';
import { Trans, useTranslation } from 'next-i18next';

const CLI = () => {
const { t } = useTranslation('get-started');

return (
<GuideForm
initialValue={{
launcherId: '',
btc_address: '',
}}
>
{({ values }) => {
const cmdAddress = values.btc_address
? `btc:${values.btc_address}`
: `<btc:BTC_WALLET>`;

const cmdLauncherId = values.launcherId
? values.launcherId
: '<LAUNCHER_ID>';

return (
<div
style={{
maxWidth: 800,
}}
>
<p>{t('detail_xch.btc_payout.intro')}</p>

<Spacer />

<p>
<Trans
t={t}
i18nKey={'detail_xch.btc_payout.paste_info'}
components={{
mono: <Mono />,
}}
/>
</p>
<Spacer size="sm" />

<div
style={{
maxWidth: 500,
}}
>
<TextField
name="launcherId"
label={'Launcher ID'}
placeholder="4973f2b459881b08295dff931c26d..."
/>

<Spacer size="md" />

<TextField
name="btc_address"
label={'Bitcoin wallet address'}
placeholder="bc1q5zx6dqklmnjq9gffv70fsrz7uaulmr65vyf0hj"
/>
</div>

<Spacer size="lg" />

<p>{t('detail_xch.btc_payout.run_cmd')}</p>
<TerminalCommand
cmd={`chia plotnft change_payout_instructions -l ${cmdLauncherId} -a ${cmdAddress}`}
/>
</div>
);
}}
</GuideForm>
);
};

const ChiaGuiSidebarItemWrapperGlowAnimation = keyframes`
0% {
background-color: var(--bg-secondary);
}
50% {
background-color: var(--border-color);
}
100% {
background-color: var(--bg-secondary);
}
`;

const Highlight = styled.div`
animation: ${ChiaGuiSidebarItemWrapperGlowAnimation} 1s linear infinite;
`;

const MockDropdownMenuItem = styled.div`
padding: 8px 12px;
font-size: 14px;
color: var(--text-secondary);
`;

const MockDropdownMenu = () => {
return (
<div
style={{
maxWidth: '240px',
borderRadius: '4px',
backgroundColor: 'var(--bg-secondary)',
padding: '8px 0',
marginLeft: 'auto',
marginTop: '4px',
}}
>
<MockDropdownMenuItem>Add a plot</MockDropdownMenuItem>
<MockDropdownMenuItem>View pool login link</MockDropdownMenuItem>
<Highlight>
<MockDropdownMenuItem>Edit payout instructions</MockDropdownMenuItem>
</Highlight>
<MockDropdownMenuItem>
Delete unconfirmed transactions
</MockDropdownMenuItem>
</div>
);
};

const EditPayoutInstructions = () => {
return (
<div>
<div
style={{
backgroundColor: 'var(--bg-secondary)',
height: '32px',
width: '32px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
borderRadius: '4px',
marginLeft: 'auto',
}}
>
<FiMoreVertical />
</div>
<MockDropdownMenu />
</div>
);
};

const GUI = () => {
const { t } = useTranslation('get-started');
return (
<div>
<p>{t('detail_xch.btc_payout.intro')}</p>
<Spacer />
<p>{t('detail_xch.btc_payout.gui_instruction')}</p>
<Trans
t={t}
i18nKey={'detail_xch.btc_payout.paste_info'}
components={{
mono: <Mono />,
b: <b />,
}}
/>
<Spacer />
<ChiaGuiMenu
selectedMenu="Pool"
menuContent={<EditPayoutInstructions />}
/>
</div>
);
};

export { CLI, GUI };
24 changes: 24 additions & 0 deletions src/pages/GetStarted/ChiaShared/AutoSwapBTCToggleSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useState } from 'react';
import { MineBTCBox } from '../common/MineBTCBox';
import { Spacer } from '@/components/layout/Spacer';

export const AutoSwapBTCToggleSection = ({
children,
}: {
children: React.ReactNode;
}) => {
const [checked, setChecked] = useState(false);

return (
<div>
<MineBTCBox checked={checked} onClick={setChecked} />

{checked && (
<>
<Spacer size="sm" />
{children}
</>
)}
</div>
);
};
Loading

0 comments on commit 1970260

Please sign in to comment.