Skip to content

Commit

Permalink
Merge pull request #63 from ar-io/develop
Browse files Browse the repository at this point in the history
Releaes to Production
  • Loading branch information
kunstmusik authored Aug 1, 2024
2 parents 2666bb6 + 7761d8a commit c17f1e5
Show file tree
Hide file tree
Showing 13 changed files with 136 additions and 60 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
node-version-file: '.nvmrc'
cache: 'yarn'

- run: yarn install --frozen-lockfile
- run: yarn install --frozen-lockfile --ignore-engines
- run: yarn ${{ matrix.step }}

deploy-to-github:
Expand All @@ -40,7 +40,7 @@ jobs:

- name: Install and Build 🔧
run: |
yarn install --frozen-lockfile
yarn install --frozen-lockfile --ignore-engines
yarn build
env:
# FOR BUILD
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
]
steps:
- uses: actions/checkout@v3
- run: yarn install --frozen-lockfile
- run: yarn install --frozen-lockfile --ignore-engines
- run: yarn ${{ matrix.step }}

deploy-to-firebase:
Expand All @@ -29,7 +29,7 @@ jobs:
cache: 'yarn'
- name: Install and Build 🔧
run: |
yarn install --frozen-lockfile
yarn install --frozen-lockfile --ignore-engines
yarn build
env:
# FOR BUILD
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- run: yarn install --frozen-lockfile
- run: yarn install --frozen-lockfile --ignore-engines
- run: yarn ${{ matrix.step }}

deploy-to-firebase:
Expand All @@ -37,7 +37,7 @@ jobs:

- name: Install and Build 🔧
run: |
yarn install --frozen-lockfile
yarn install --frozen-lockfile --ignore-engines
yarn build
env:
# FOR BUILD
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:

- name: Install, Build, and Deploy 🔧
run: |
yarn install --frozen-lockfile
yarn install --frozen-lockfile --ignore-engines
yarn deploy
env:
# FOR BUILD
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"deploy": "yarn build && permaweb-deploy --ant-process ${DEPLOY_ANT_PROCESS_ID}"
},
"dependencies": {
"@ar.io/sdk": "2.0.2",
"@ar.io/sdk": "2.1.0-alpha.6",
"@fontsource/rubik": "^5.0.19",
"@headlessui/react": "^1.7.19",
"@radix-ui/react-tooltip": "^1.0.7",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Tooltip = ({
{/* <ReactTooltip.Arrow className={`${marginBottom}`} /> */}
<div className="text-sm text-low">{message}</div>
<div
className={`absolute bottom-0 left-[48.8%] size-[0.625rem] rotate-45 border border-grey-500 bg-containerL0 [clip-path:polygon(0%_100%,100%_0,100%_100%)] `}
className={`absolute bottom-0 left-[48.8%] size-2.5 rotate-45 border border-grey-500 bg-containerL0 [clip-path:polygon(0%_100%,100%_0,100%_100%)] `}
/>
</ReactTooltip.Content>
</ReactTooltip.Portal>
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/StakingModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const DisplayRow = ({
{value}
</a>
) : (
<div className="flex gap-1 text-left text-low items-center">
<div className="flex items-center gap-1 text-left text-low">
{value}
{rightIcon}
</div>
Expand Down
93 changes: 62 additions & 31 deletions src/pages/Gateway/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ const Gateway = () => {
? new mIOToken(gateway.operatorStake).toIO().valueOf() + (balances?.io || 0)
: undefined;

const weightFields: Array<[string, number | undefined]> = [
['Stake', gateway?.weights?.stakeWeight],
['Tenure', gateway?.weights?.tenureWeight],
['Gateway Reward Ratio', gateway?.weights?.gatewayRewardRatioWeight],
['Observer Reward Ratio', gateway?.weights?.observerRewardRatioWeight],
['Composite', gateway?.weights?.compositeWeight],
['Normalized', gateway?.weights?.normalizedCompositeWeight],
];

useEffect(() => {
setInitialState((currentState) => {
return {
Expand Down Expand Up @@ -381,39 +390,61 @@ const Gateway = () => {
<div className="flex h-screen max-w-full flex-col overflow-y-auto pr-6 scrollbar">
<GatewayHeader gateway={gateway} />
<div className="my-6 flex gap-6">
<div className="size-fit rounded-xl border border-transparent-100-16 text-sm">
<div className="px-6 py-4">
<div className="text-high">Stats</div>
<div className="flex flex-col gap-6">
<div className="size-fit rounded-xl border border-transparent-100-16 text-sm">
<div className="px-6 py-4">
<div className="text-high">Stats</div>
</div>
<StatsBox
title="Join Date"
value={
gateway?.startTimestamp
? formatDate(new Date(gateway?.startTimestamp))
: undefined
}
/>
<StatsBox
title="Uptime"
value={
healthCheckRes.isError
? 'N/A'
: healthCheckRes.isLoading
? undefined
: formatUptime(healthCheckRes.data?.uptime)
}
/>
<StatsBox
title="Delegates"
value={
gateway?.delegates
? Object.keys(gateway.delegates).length
: undefined
}
/>
{/* <StatsBox title="Rewards Distributed" value={gateway?} /> */}
</div>
<StatsBox
title="Join Date"
value={
gateway?.startTimestamp
? formatDate(new Date(gateway?.startTimestamp))
: undefined
}
/>
<StatsBox
title="Uptime"
value={
healthCheckRes.isError
? 'N/A'
: healthCheckRes.isLoading
? undefined
: formatUptime(healthCheckRes.data?.uptime)
}
/>
<StatsBox
title="Delegates"
value={
gateway?.delegates
? Object.keys(gateway.delegates).length
: undefined
}
/>
{/* <StatsBox title="Rewards Distributed" value={gateway?} /> */}

{gateway?.weights && (
<div className="w-full rounded-xl border border-transparent-100-16 text-sm">
<div className="px-6 py-4">
<div className="text-high">Weights</div>
</div>

{weightFields.map(([title, value], index) => (
<div
key={`weights${index}`}
className="flex items-center border-t border-transparent-100-16 px-6 py-4"
>
<div className="grow text-xs text-low">{title}:</div>
<div className="text-right text-sm">
{value ? value.toFixed(3) : <Placeholder />}
</div>
</div>
))}
</div>
)}
</div>
<div className="size-full grow overflow-hidden rounded-xl border border-transparent-100-16">
<div className="h-fit w-full grow overflow-hidden rounded-xl border border-transparent-100-16">
<div className="flex items-center py-4 pl-6 pr-3">
<div className="text-sm text-high">General Information</div>
<div className="flex grow gap-6" />
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Observers/ObserversTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ interface TableData {
const columnHelper = createColumnHelper<TableData>();

const ObserversTable = () => {

const navigate = useNavigate();

const { isLoading, data: observers } = useObservers();
Expand Down Expand Up @@ -92,6 +91,7 @@ const ObserversTable = () => {
href={`https://${row.getValue('domain')}`}
target="_blank"
rel="noreferrer"
onClick={(e) => e.stopPropagation()}
>
{row.getValue('domain')}
</a>{' '}
Expand Down Expand Up @@ -137,7 +137,7 @@ const ObserversTable = () => {
id: 'failedGateways',
header: 'Failed Gateways',
sortDescFirst: true,
cell: ({ row }) => row.original.failedGateways || "Pending",
cell: ({ row }) => row.original.failedGateways || 'Pending',
}),
];

Expand Down
10 changes: 9 additions & 1 deletion src/pages/Staking/ActiveStakes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import useGateways from '@src/hooks/useGateways';
import { useGlobalState } from '@src/store';
import { ColumnDef, createColumnHelper } from '@tanstack/react-table';
import { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';

interface TableData {
owner: string;
Expand All @@ -30,6 +31,8 @@ const ActiveStakes = () => {
const [stakingModalWalletAddress, setStakingModalWalletAddress] =
useState<string>();

const navigate = useNavigate();

useEffect(() => {
const activeStakes: Array<TableData> =
!walletAddress || !gateways
Expand Down Expand Up @@ -71,6 +74,7 @@ const ActiveStakes = () => {
href={`https://${row.getValue('domain')}`}
target="_blank"
rel="noreferrer"
onClick={(e) => e.stopPropagation()}
>
{row.getValue('domain')}
</a>{' '}
Expand Down Expand Up @@ -116,7 +120,8 @@ const ActiveStakes = () => {
title="Manage Stake"
text=" "
rightIcon={<GearIcon className="size-4" />}
onClick={() => {
onClick={(e) => {
e.stopPropagation();
setStakingModalWalletAddress(row.original.owner);
}}
/>
Expand Down Expand Up @@ -152,6 +157,9 @@ const ActiveStakes = () => {
id: 'delegatedStake',
desc: true,
}}
onRowClick={(row) => {
navigate(`/gateways/${row.owner}`);
}}
/>
{showUnstakeAllModal && (
<UnstakeAllModal
Expand Down
10 changes: 9 additions & 1 deletion src/pages/Staking/DelegateStakeTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { calculateGatewayRewards } from '@src/utils/rewards';
import { ColumnDef, createColumnHelper } from '@tanstack/react-table';
import { MathJax } from 'better-react-mathjax';
import { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';

interface TableData {
label: string;
Expand Down Expand Up @@ -52,6 +53,8 @@ const DelegateStake = () => {

const { data: protocolBalance } = useProtocolBalance();

const navigate = useNavigate();

useEffect(() => {
const stakeableGateways: Array<TableData> =
!gateways || !protocolBalance
Expand Down Expand Up @@ -118,6 +121,7 @@ const DelegateStake = () => {
href={`https://${row.getValue('domain')}`}
target="_blank"
rel="noreferrer"
onClick={(e) => e.stopPropagation()}
>
{row.getValue('domain')}
</a>{' '}
Expand Down Expand Up @@ -227,7 +231,8 @@ const DelegateStake = () => {
active={true}
title="Manage Stake"
text="Stake"
onClick={() => {
onClick={(e) => {
e.stopPropagation();
if (walletAddress) {
setStakingModalWalletAddress(row.getValue('owner') as string);
} else {
Expand All @@ -252,6 +257,9 @@ const DelegateStake = () => {
isLoading={isLoading}
noDataFoundText="No stakeable gateways found."
defaultSortingState={{ id: 'totalStake', desc: true }}
onRowClick={(row) => {
navigate(`/gateways/${row.owner}`);
}}
/>
{stakingModalWalletAddress && (
<StakingModal
Expand Down
9 changes: 4 additions & 5 deletions src/services/wallets/ArConnectWalletConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import { ArconnectError, WalletNotInstalledError } from '@src/utils/errors';
import { PermissionType } from 'arconnect';
import { ApiConfig } from 'arweave/web/lib/api';

import { ArconnectSigner } from '@ar.io/sdk/web';
import { log } from '@src/constants';
import { KEY_WALLET_TYPE } from '@src/store/persistent';
import { executeWithTimeout } from '@src/utils';
import { ArweaveTransactionID } from '@src/utils/ArweaveTransactionId';
import { ArweaveWalletConnector, WALLET_TYPES } from '../../types';
import { KEY_WALLET_TYPE } from '@src/store/persistent';
import { log } from '@src/constants';

export const ARCONNECT_WALLET_PERMISSIONS: PermissionType[] = [
'ACCESS_ADDRESS',
Expand All @@ -22,11 +21,11 @@ export const ARCONNECT_UNRESPONSIVE_ERROR =

export class ArConnectWalletConnector implements ArweaveWalletConnector {
private _wallet: Window['arweaveWallet'];
signer?: ArconnectSigner;
signer?: Window['arweaveWallet'];

constructor() {
this._wallet = window?.arweaveWallet;
this.signer = new ArconnectSigner(this._wallet, null as any);
this.signer = this._wallet;
}

// The API has been shown to be unreliable, so we call each function with a timeout
Expand Down
6 changes: 3 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ArconnectSigner } from '@ar.io/sdk/web';
import { ArweaveTransactionID } from './utils/ArweaveTransactionId';

export interface Equatable<T> {
Expand All @@ -10,7 +9,7 @@ export interface ArweaveWalletConnector {
disconnect(): Promise<void>;
getWalletAddress(): Promise<ArweaveTransactionID>;
// getGatewayConfig(): Promise<ApiConfig>;
signer?: ArconnectSigner;
signer?: Window['arweaveWallet'];
}

export enum WALLET_TYPES {
Expand Down Expand Up @@ -45,7 +44,8 @@ export interface OwnershipAssessment {
pass: boolean;
}

export interface ArNSAssessmentTimings extends Record<string, number | undefined> {
export interface ArNSAssessmentTimings
extends Record<string, number | undefined> {
dns: number | undefined;
download: number | undefined;
firstByte: number | undefined;
Expand Down
Loading

0 comments on commit c17f1e5

Please sign in to comment.