Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
"dependencies": {
"@ant-design/icons": "5.4.0",
"@ar.io/sdk": "3.14.0",
"@ar.io/wayfinder-core": "^1.0.4",
"@ar.io/wayfinder-react": "^1.0.6",
"@ardrive/turbo-sdk": "^1.23.1",
"@permaweb/aoconnect": "^0.0.59",
"@permaweb/aoconnect": "0.0.69",
"@radix-ui/react-checkbox": "^1.1.4",
"@radix-ui/react-radio-group": "^1.2.1",
"@radix-ui/react-select": "^2.1.4",
Expand Down Expand Up @@ -163,8 +165,5 @@
"extends": [
"plugin:storybook/recommended"
]
},
"resolutions": {
"@permaweb/aoconnect": "0.0.59"
}
}
24 changes: 15 additions & 9 deletions src/components/cards/ARNSCard/ARNSCard.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
import { NETWORK_DEFAULTS } from '@src/utils/constants';
import { useWayfinderUrl } from '@ar.io/wayfinder-react';
import { useGlobalState } from '@src/state';
import { useMemo } from 'react';
import { Link } from 'react-router-dom';

import { ARNSMapping } from '../../../types';
import './styles.css';

const protocol = 'https';

function ARNSCard({
domain,
gateway = NETWORK_DEFAULTS.ARNS.HOST,
imageUrl,
}: Omit<ARNSMapping, 'processId'> & { gateway?: string; imageUrl: string }) {
}: Omit<ARNSMapping, 'processId'> & { imageUrl: string }) {
const [{ gateway }] = useGlobalState();
const params = useMemo(() => ({ arnsName: domain }), [domain]);
const { resolvedUrl, error } = useWayfinderUrl(params);

if (error) {
console.error(error);
}

return (
<Link
target="_blank"
to={`${protocol}://${domain}.${gateway}`}
to={resolvedUrl?.toString() ?? `https://${domain}.${gateway}`}
className="arns-card hover"
rel="noreferrer"
>
<img
className="arns-preview fade-in"
src={imageUrl}
key={imageUrl}
alt={`${domain}.${gateway}`}
alt={`${domain}`}
width={'100%'}
height={'100%'}
/>

<div
className="flex flex-column link"
style={{
Expand All @@ -38,7 +44,7 @@ function ARNSCard({
justifyContent: 'center',
}}
>
<span className="flex white">{`${domain}.${gateway}`}</span>
<span className="flex white">{`ar://${domain}`}</span>
</div>
</Link>
);
Expand Down
2 changes: 2 additions & 0 deletions src/components/devtools/NetworkSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ function NetworkSettings() {
GATEWAY_URL: 'https://' + gateway,
CU_URL: newConfig.ARIO.CU_URL,
MU_URL: newConfig.ARIO.MU_URL,
MODE: 'legacy' as const,
});
dispatchGlobalState({
type: 'setARIOAoClient',
Expand Down Expand Up @@ -170,6 +171,7 @@ function NetworkSettings() {
const ao = connect({
GATEWAY_URL: 'https://' + gateway,
CU_URL: newConfig.ANT.CU_URL,
MODE: 'legacy' as const,
});
dispatchGlobalState({
type: 'setANTAoClient',
Expand Down
62 changes: 15 additions & 47 deletions src/components/layout/FeaturedDomains/FeaturedDomains.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
import { shuffleArray } from '@src/utils';
import { FEATURED_DOMAINS } from '@src/utils/constants';
import { useState } from 'react';

import { ARNSCard } from '../../cards';
import './styles.css';

const featuredGateways = ['permagate.io', 'g8way.io', 'ar.io'];
const defaultGateways = [
...featuredGateways,
...featuredGateways,
...featuredGateways,
];

function FeaturedDomains() {
// show three at a time by default
const DEFAULT_INCREMENT = 3;
// how many rows of cards to display
const MAX_COUNT = DEFAULT_INCREMENT * 3;
const [displayCount, setDisplayCount] = useState(DEFAULT_INCREMENT);
const [gateways, setGateways] = useState<string[]>(defaultGateways);

function showMore(e: any) {
e.preventDefault();
Expand All @@ -30,10 +21,6 @@ function FeaturedDomains() {
setDisplayCount(DEFAULT_INCREMENT);
}

function shuffleGateways() {
setGateways(shuffleArray(gateways));
}

return (
<div className="featured-domains flex-center fade-in">
<span
Expand All @@ -46,40 +33,22 @@ function FeaturedDomains() {
FEATURED DOMAINS
</span>
<div className="card-container flex-center">
{gateways &&
Object.keys(FEATURED_DOMAINS).map((domain, index) => {
if (
index >= displayCount ||
index >= Object.keys(FEATURED_DOMAINS).length
)
return;
return (
<ARNSCard
domain={domain}
key={index}
gateway={gateways[index]}
imageUrl={FEATURED_DOMAINS[domain].imageUrl}
/>
);
})}
{Object.keys(FEATURED_DOMAINS).map((domain, index) => {
if (
index >= displayCount ||
index >= Object.keys(FEATURED_DOMAINS).length
)
return;
return (
<ARNSCard
domain={domain}
key={domain}
imageUrl={FEATURED_DOMAINS[domain].imageUrl}
/>
);
})}
</div>
<div
className="flex flex-row mb-8"
style={{ gap: '10px', maxWidth: '800px' }}
>
<button
className="outline-button center faded"
onClick={() => shuffleGateways()}
style={{
padding: 0,
fontSize: '15px',
width: '100%',
height: 50,
color: 'var(--text-white)',
}}
>
Shuffle Gateways
</button>
<div className="flex flex-row mb-8 max-w-md gap-4">
<button
className="button-secondary center faded"
onClick={displayCount < MAX_COUNT ? showMore : showLess}
Expand All @@ -89,7 +58,6 @@ function FeaturedDomains() {
width: '100%',
height: 50,
color: 'var(--text-white)',
// backgroundColor: 'var(--text-faded)',
}}
>
{displayCount < MAX_COUNT ? 'View More Domains' : 'View Less Domains'}
Expand Down
1 change: 1 addition & 0 deletions src/components/pages/Settings/NetworkSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ function NetworkSettings() {
GATEWAY_URL: 'https://' + gateway,
CU_URL: newConfig.CU_URL,
MU_URL: newConfig.MU_URL,
MODE: 'legacy' as const,
});
dispatchGlobalState({
type: 'setARIOAoClient',
Expand Down
31 changes: 30 additions & 1 deletion src/state/contexts/GlobalState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ import {
AoARIOWrite,
AoClient,
} from '@ar.io/sdk/web';
import {
NetworkGatewaysProvider,
RandomRoutingStrategy,
} from '@ar.io/wayfinder-core';
import {
LocalStorageGatewaysProvider,
WayfinderProvider,
} from '@ar.io/wayfinder-react';
import { connect } from '@permaweb/aoconnect';
import eventEmitter from '@src/utils/events';
import React, {
Expand All @@ -18,6 +26,7 @@ import React, {
import { ArweaveCompositeDataProvider } from '../../services/arweave/ArweaveCompositeDataProvider';
import { SimpleArweaveDataProvider } from '../../services/arweave/SimpleArweaveDataProvider';
import {
APP_VERSION,
ARIO_AO_CU_URL,
ARIO_PROCESS_ID,
ARWEAVE_HOST,
Expand All @@ -33,6 +42,7 @@ export const defaultArIO = ARIO.init({
processId: ARIO_PROCESS_ID,
ao: connect({
CU_URL: ARIO_AO_CU_URL,
MODE: 'legacy',
}),
}),
});
Expand Down Expand Up @@ -116,7 +126,26 @@ export function GlobalStateProvider({

return (
<GlobalStateContext.Provider value={[state, dispatchGlobalState]}>
{children}
{/* Wrap global state in wayfinder provider */}
<WayfinderProvider
gatewaysProvider={
new LocalStorageGatewaysProvider({
gatewaysProvider: new NetworkGatewaysProvider({
ario: state.arioContract,
}),
})
}
routingSettings={{
strategy: new RandomRoutingStrategy(),
}}
telemetrySettings={{
enabled: true,
clientName: 'arns-app',
clientVersion: APP_VERSION,
}}
>
{children}
</WayfinderProvider>
</GlobalStateContext.Provider>
);
}
11 changes: 5 additions & 6 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
ANT_LUA_ID,
ARIO_TESTNET_PROCESS_ID,
DEFAULT_SCHEDULER_ID,
arioDevnetProcessId,
} from '@ar.io/sdk/web';
import { TokenType } from '@ardrive/turbo-sdk';
import Arweave from 'arweave';
Expand Down Expand Up @@ -93,7 +93,7 @@ export const URL_REGEX = new RegExp(
'i',
);
export const ARIO_PROCESS_ID =
import.meta.env.VITE_ARIO_PROCESS_ID || arioDevnetProcessId;
import.meta.env.VITE_ARIO_PROCESS_ID || ARIO_TESTNET_PROCESS_ID;

export const DEFAULT_ANT_LUA_ID = ANT_LUA_ID;

Expand Down Expand Up @@ -131,13 +131,15 @@ export const NETWORK_DEFAULTS = {
MU_URL: 'https://mu.ao-testnet.xyz',
SCHEDULER: DEFAULT_SCHEDULER_ID,
HYPERBEAM_URL: HYPERBEAM_URL,
MODE: 'legacy' as const,
},
ANT: {
CU_URL: ANT_AO_CU_URL,
MU_URL: 'https://mu.ao-testnet.xyz',
SCHEDULER: DEFAULT_SCHEDULER_ID,
GRAPHQL_URL: ARWEAVE_GRAPHQL_URL,
HYPERBEAM_URL: HYPERBEAM_URL,
MODE: 'legacy' as const,
},
},
ARWEAVE: {
Expand Down Expand Up @@ -169,17 +171,14 @@ export const YEAR_IN_MILLISECONDS = 31536000000;
export const AVERAGE_BLOCK_TIME_MS = 120_000; // 2 mins

export const FEATURED_DOMAINS: { [x: string]: { imageUrl: string } } = {
// TODO: pull from the ARIO contract
arlink: { imageUrl: ARLINK_IMAGE },

metalinks: { imageUrl: METALINKS_IMAGE },
ardrive: { imageUrl: ARDRIVE_IMAGE },
arwiki: { imageUrl: ARWIKI_IMAGE },
permaswap: { imageUrl: PERMASWAP_IMAGE },
'ar-fees': { imageUrl: AR_FEES_IMAGE },
// alex: { imageUrl: ALEX_IMAGE },
// cookbook: { imageUrl: COOKBOOK_IMAGE },
ao: { imageUrl: AO_IMAGE },

sam: { imageUrl: SAM_IMAGE },
mfers: { imageUrl: MFERS_IMAGE },
};
Expand Down
Loading