Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
yanok87 committed Nov 14, 2023
1 parent e889635 commit c0cc019
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
20 changes: 15 additions & 5 deletions explorer/src/components/Delegations/components/DelegateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,18 @@ export const DelegateModal: FCWithChildren<{
useEffect(() => {
const getClient = async () => {
await getSigningCosmWasmClient()
.then((res) => setCosmWasmSignerClient(res))
.then((res) => {
setCosmWasmSignerClient(res);
console.log('res :>> ', res);
})
.catch((e) => console.log('e :>> ', e));
};

getClient();
}, []);
isWalletConnected && getClient();
}, [isWalletConnected]);

console.log('cosmWasmSignerClient :>> ', cosmWasmSignerClient);
console.log('isWalletConnected :>> ', isWalletConnected);

useEffect(() => {
const getBalance = async (walletAddress: string) => {
Expand Down Expand Up @@ -182,9 +188,11 @@ export const DelegateModal: FCWithChildren<{
memo?: string,
_funds?: DecCoin[],
): Promise<ExecuteResult> => {
console.log('cosmWasmSignerClient :>> ', cosmWasmSignerClient);
return await cosmWasmSignerClient.execute(
address,
MIXNET_CONTRACT_ADDRESS,
//sandboxContractAddress,
{
delegate_to_mixnode: {
mix_id: mixId,
Expand All @@ -198,9 +206,11 @@ export const DelegateModal: FCWithChildren<{

const handleConfirm = async () => {
const memo: string = 'test delegation';
const fee = { gas: '1000000', amount: [{ amount: '100000', denom: 'unym' }] };

if (mixId && amount) {
await delegateToMixnode({ mixId }, 'auto', memo, [amount]);
console.log('trying to delegate :>> ');
await delegateToMixnode({ mixId }, fee, memo, [amount]);
}
};

Expand Down Expand Up @@ -316,7 +326,7 @@ export const DelegateModal: FCWithChildren<{
required
fullWidth
label="Amount"
initialValue={amount}
// initialValue={amount}
autoFocus={Boolean(initialIdentityKey)}
onChanged={handleAmountChanged}
denom={denom}
Expand Down
24 changes: 21 additions & 3 deletions explorer/src/components/TableToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export const TableToolbar: FCWithChildren<TableToolBarProps> = ({
const [showNewDelegationModal, setShowNewDelegationModal] = useState<boolean>(false);

const assetsFixedUp = useMemo(() => {
const nyx = assets.find((a) => a.chain_name === 'nyx');
const nyx = assets.find((a) => a.chain_name === 'sandbox');
if (nyx) {
const nyxCoin = nyx.assets.find((a) => a.name === 'nyx');
const nyxCoin = nyx.assets.find((a) => a.name === 'sandbox');
if (nyxCoin) {
nyxCoin.coingecko_id = 'nyx';
}
Expand All @@ -59,6 +59,23 @@ export const TableToolbar: FCWithChildren<TableToolBarProps> = ({
return chains;
}, [chains]);

// SANDBOX
// const chainsFixedUp = useMemo(() => {
// const nyx = chains.find((c) => c.chain_id === 'sandbox');
// if (nyx) {
// if (!nyx.staking) {
// nyx.staking = {
// staking_tokens: [{ denom: 'unyx' }],
// lock_duration: {
// blocks: 10000,
// },
// };
// if (nyx.apis) nyx.apis.rpc = [{ address: 'https://sandbox-validator1.nymtech.net', provider: 'nym' }];
// }
// }
// return chains;
// }, [chains]);

const isMobile = useIsMobile();
return (
<Box
Expand Down Expand Up @@ -122,10 +139,11 @@ export const TableToolbar: FCWithChildren<TableToolBarProps> = ({
}}
>
<Button
size="large"
variant="contained"
disableElevation
onClick={() => setShowNewDelegationModal(true)}
sx={{ py: 1.5, px: 5, color: 'primary.contrastText' }}
sx={{ px: 5, color: 'primary.contrastText' }}
>
Delegate
</Button>
Expand Down

0 comments on commit c0cc019

Please sign in to comment.