Skip to content

Commit

Permalink
Feat/395 redeem origin sov (#408)
Browse files Browse the repository at this point in the history
* Disable Claim CSOV option when none available. Closes #392 (#393)

* Master to dev (#403)

* Table for vested SOV asset. Closes #391

* Reduces table width #391

* Fix/401 double claiming (#402)

* Disable Claim CSOV option when none available. Closes #392 (#393)

* Fixes #401 - prevents multiple txs being sent when claiming tokens

Co-authored-by: soulBit <[email protected]>

Co-authored-by: soulBit <[email protected]>

* #395 banner and dialog for claiming origin SOV tokens

* Feat/395 redeem origin sov (#406)

* Fixes claiming bug

* #395 banner and dialog for claiming origin SOV tokens

* Revert "Feat/395 redeem origin sov (#406)" (#407)

This reverts commit d97d228.

* changed contract signatures for claiming origin sov tokens #395

* reworked how origin claiming works #395

* New strings and translate to PT-BR (#411)

* New strings and translate to PT-BR

* Minor change

* Update src/locales/pt_br/translation.json

* temp contracts for testing #395

* new contracts for sov claim #395

* removes address field from sov redeeming dialog #395

* new registry for origin claiming #395

* new contracts #395

* staking contract #395

* Master (#423)

* Fixes claiming bug

* Added changelog

* Issue #389 - Change connected wallet blue circle with address blockie (#409)

* add address blockie

* remove regeneration of address blockie

Co-authored-by: optisman <[email protected]>

* Minor changes PT-BR (#428)

* Minor change PT-BR (#431)

* Minor change PT-BR

* Update src/locales/pt_br/translation.json

* Minor change

* Update src/locales/pt_br/translation.json

* changed testnet contract for origin vesting registry #395

* changed testnet contract for origin claim #395

* new nodes #395

* changed nodes

* changed origin SOV price to 9736 satoshis #395

* new contracts #395

* fast btc rework #418 (#425)

* fast btc rework #418

* fastbtc history table #418

* Updated fast btc #418

* updated smart contracts #395

* mainnet contracts for origin claim #395

Co-authored-by: soulBit <[email protected]>
Co-authored-by: bitcoinuser <[email protected]>
Co-authored-by: optisman <[email protected]>
  • Loading branch information
4 people authored Mar 5, 2021
1 parent a12614a commit f154904
Show file tree
Hide file tree
Showing 33 changed files with 2,510 additions and 161 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"semver": "6.3.0",
"serve": "11.3.0",
"shelljs": "0.8.3",
"socket.io-client": "2.3.1",
"socket.io-client": "3.1.2",
"source-map-explorer": "2.5.0",
"storage-factory": "0.1.1",
"style-loader": "0.23.1",
Expand Down
5 changes: 5 additions & 0 deletions src/app/components/Button/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@
.button.inverted:active {
background: rgba(254, 192, 4, 0.5);
}

.button.disabled, .button:disabled {
opacity: 0.25;
cursor: not-allowed;
}
1 change: 1 addition & 0 deletions src/app/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function Button({ text, inverted, loading, ...props }: Props) {
styles.button,
props.className,
inverted && styles.inverted,
props.disabled && styles.disabled,
)}
>
{text}
Expand Down
26 changes: 26 additions & 0 deletions src/app/components/Form/AddressQrCode/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/** */
.qrCodeWrapper {

}

.qrCodeTitle {
font-size: 18px;
margin-bottom: 10px;
font-weight: 400;
line-height: 22px;
}

.qrCodeContainer {
background-color: #ffffff;
border-radius: 10px;
text-align: center;
margin-bottom: 20px;
}

.addressWrapper {
background-color: #222222;
padding: 12px 20px;
border: 1px solid #575757;
border-radius: 8px;
cursor: pointer;
}
69 changes: 69 additions & 0 deletions src/app/components/Form/AddressQrCode/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import React from 'react';
import { Text } from '@blueprintjs/core';
import QRCode from 'qrcode.react';
import { CopyToClipboard } from 'react-copy-to-clipboard';
import { useTranslation } from 'react-i18next';
import { toastSuccess } from 'utils/toaster';
import { translations } from 'locales/i18n';
import styles from './index.module.css';

interface Props {
address: string;
hideClickToCopy?: boolean;
}

export function AddressQrCode({ address, hideClickToCopy }: Props) {
const { t } = useTranslation();
return (
<>
<div className={styles.qrCodeContainer}>
<QRCode
value={address}
renderAs="svg"
bgColor="var(--white)"
fgColor="var(--primary)"
includeMargin={true}
className="rounded w-75 h-75"
/>
</div>
{!hideClickToCopy && (
<CopyToClipboard
text={address}
onCopy={() =>
toastSuccess(<>{t(translations.onCopy.address)}</>, 'copy')
}
>
<div className={styles.addressWrapper}>
<div className="d-flex flex-row justify-content-between align-items-center w-100">
<div className="flex-shrink-1 flex-grow-0 overflow-hidden">
<Text ellipsize>{address}</Text>
</div>
<div className="flex-shrink-0 flex-grow-0 ml-3">
<svg
id="content_copy-24px"
xmlns="http://www.w3.org/2000/svg"
width="20"
height="20"
viewBox="0 0 20 20"
>
<path
id="Path_11"
data-name="Path 11"
d="M0,0H20V20H0Z"
fill="none"
/>
<path
id="Path_12"
data-name="Path 12"
d="M13.053,1H3.579A1.613,1.613,0,0,0,2,2.636V14.091H3.579V2.636h9.474Zm2.368,3.273H6.737A1.613,1.613,0,0,0,5.158,5.909V17.364A1.613,1.613,0,0,0,6.737,19h8.684A1.613,1.613,0,0,0,17,17.364V5.909A1.613,1.613,0,0,0,15.421,4.273Zm0,13.091H6.737V5.909h8.684Z"
fill="#2274a5"
/>
</svg>
</div>
</div>
</div>
</CopyToClipboard>
)}
</>
);
}
28 changes: 0 additions & 28 deletions src/app/components/TopUpHint/index.tsx

This file was deleted.

31 changes: 21 additions & 10 deletions src/app/components/UserAssets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { contractReader } from '../../../utils/sovryn/contract-reader';
import { getTokenContractName } from '../../../utils/blockchain/contract-helpers';
import { Sovryn } from '../../../utils/sovryn';
import { CSovActions } from '../../containers/WalletPage/components/CSovActions';
import { FastBtcDialog } from '../../containers/FastBtcDialog';

export function UserAssets() {
const { t } = useTranslation();
Expand All @@ -35,6 +36,8 @@ export function UserAssets() {
const account = useAccount();
const assets = AssetsDictionary.list();

const [fastBtc, setFastBtc] = useState(false);

return (
<>
<div className="sovryn-border sovryn-table pt-1 pb-3 pr-3 pl-3 mb-5">
Expand Down Expand Up @@ -74,19 +77,27 @@ export function UserAssets() {
)}
{connected &&
account &&
assets.map(item => <AssetRow key={item.asset} item={item} />)}
assets.map(item => (
<AssetRow
key={item.asset}
item={item}
onFastBtc={() => setFastBtc(true)}
/>
))}
</tbody>
</table>
</div>
<FastBtcDialog isOpen={fastBtc} onClose={() => setFastBtc(false)} />
</>
);
}

interface AssetProps {
item: AssetDetails;
onFastBtc: () => void;
}

function AssetRow({ item }: AssetProps) {
function AssetRow({ item, onFastBtc }: AssetProps) {
const { t } = useTranslation();
const account = useAccount();
const [loading, setLoading] = useState(true);
Expand Down Expand Up @@ -161,14 +172,14 @@ function AssetRow({ item }: AssetProps) {
</td>
<td className="text-right d-none d-md-table-cell">
<ButtonGroup>
{/*{item.asset === Asset.BTC && (*/}
{/* <Button*/}
{/* minimal*/}
{/* text={t(translations.userAssets.actions.deposit)}*/}
{/* className="text-gold"*/}
{/* onClick={() => dispatch(actions.showDialog(true))}*/}
{/* />*/}
{/*)}*/}
{item.asset === Asset.BTC && (
<Button
minimal
text={t(translations.userAssets.actions.deposit)}
className="text-gold button-round"
onClick={() => onFastBtc()}
/>
)}
{item.asset !== Asset.CSOV ? (
<>
<Button
Expand Down
27 changes: 25 additions & 2 deletions src/app/components/UserAssets/useVestedStaking_balanceOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ export function useVestedStaking_balanceOf(address: string) {
const [loading, setLoading] = useState(true);
const [vestedValue, setVestedValue] = useState('0');
const [teamVestedValue, setTeamVestedValue] = useState('0');
const [originVestedValue, setOriginVestedValue] = useState('0');
const [error, setError] = useState<any>(null);

const [vestingContract, setVestingContract] = useState(ethGenesisAddress);
const [teamVestingContract, setTeamVestingContract] = useState(
ethGenesisAddress,
);
const [originVestingContract, setOriginVestingContract] = useState(
ethGenesisAddress,
);

useEffect(() => {
setLoading(true);
Expand All @@ -26,6 +30,11 @@ export function useVestedStaking_balanceOf(address: string) {
'getTeamVesting',
[address],
);
const adr3 = await contractReader.call(
'vestingRegistryOrigin',
'getVesting',
[address],
);

if (adr1 !== ethGenesisAddress) {
const vested = await contractReader.call('staking', 'balanceOf', [
Expand All @@ -43,9 +52,18 @@ export function useVestedStaking_balanceOf(address: string) {
setTeamVestedValue(String(teamVested));
}

if (adr1 === adr2 && adr1 === ethGenesisAddress) {
if (adr3 !== ethGenesisAddress) {
const originVested = await contractReader.call('staking', 'balanceOf', [
adr3,
]);
setOriginVestingContract(String(adr3));
setOriginVestedValue(String(originVested));
}

if (adr1 === adr2 && adr2 === adr3 && adr1 === ethGenesisAddress) {
setVestingContract(ethGenesisAddress);
setTeamVestingContract(ethGenesisAddress);
setOriginVestingContract(ethGenesisAddress);
}
setLoading(false);
setError(null);
Expand All @@ -59,12 +77,17 @@ export function useVestedStaking_balanceOf(address: string) {
}
}, [address]);
return {
value: bignumber(teamVestedValue).add(vestedValue).toString(),
value: bignumber(teamVestedValue)
.add(vestedValue)
.add(originVestedValue)
.toString(),
loading,
error,
vestingContract,
vestedValue,
teamVestedValue,
teamVestingContract,
originVestedValue,
originVestingContract,
};
}
25 changes: 25 additions & 0 deletions src/app/containers/FastBtcDialog/components/AddressButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import { Button } from '@blueprintjs/core';

interface Props {
loading: boolean;
ready: boolean;
onClick: () => void;
}

export function AddressButton({ loading, ready, onClick }: Props) {
return (
<>
<div className="justify-content-center items-center d-flex flex-row">
<Button
minimal
className="text-gold button-round font-size-lg mx-auto"
text="Generate deposit address"
loading={loading}
disabled={loading || !ready}
onClick={onClick}
/>
</div>
</>
);
}
64 changes: 64 additions & 0 deletions src/app/containers/FastBtcDialog/components/MainScreen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import React, { Dispatch } from 'react';
import { useTranslation } from 'react-i18next';
import { FastBtcDialogState, Step } from '../types';
import { actions } from '../slice';
import styles from '../index.module.css';
import { translations } from '../../../../locales/i18n';
import { AddressButton } from './AddressButton';
import { AddressQrCode } from '../../../components/Form/AddressQrCode';
import { toNumberFormat } from '../../../../utils/display-text/format';

interface MainScreenProps {
state: FastBtcDialogState;
dispatch: Dispatch<any>;
}

export function MainScreen({ state, dispatch }: MainScreenProps) {
const { t } = useTranslation();
return (
<>
<h2 className={styles.title}>{t(translations.fastBtcDialog.title)}</h2>
<div className={styles.subtitle}>
{t(translations.fastBtcDialog.subtitle)}
</div>

<div>
<div className={styles.limitsTitle}>
{t(translations.fastBtcDialog.limits.title)}
</div>
<div className={styles.limitsValue}>
{' '}
{t(translations.fastBtcDialog.limits.min, {
amount: toNumberFormat(state.limits.min, 4),
})}
<br />{' '}
{t(translations.fastBtcDialog.limits.max, {
amount: toNumberFormat(state.limits.max, 4),
})}
</div>
</div>

<div>
<div className={styles.instructionsTitle}>
{t(translations.fastBtcDialog.instructions.title)}
</div>
<div className={styles.instructionsValue}>
{t(translations.fastBtcDialog.instructions.point1)}
<br />{t(translations.fastBtcDialog.instructions.point2)}
<br />{t(translations.fastBtcDialog.instructions.point3)}
</div>
</div>

{state.step === Step.WALLET && (
<AddressQrCode address={state.deposit.address} />
)}
{state.step === Step.MAIN && (
<AddressButton
loading={state.deposit.loading}
ready={state.ready}
onClick={() => dispatch(actions.generateDepositAddress())}
/>
)}
</>
);
}
Loading

1 comment on commit f154904

@vercel
Copy link

@vercel vercel bot commented on f154904 Mar 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.