Skip to content

Commit

Permalink
Merge pull request #622 from ar-io/develop
Browse files Browse the repository at this point in the history
Release eth wallet compatibility fix
  • Loading branch information
atticusofsparta authored Dec 11, 2024
2 parents 90957ac + c7d236d commit f8fef58
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 6 deletions.
2 changes: 1 addition & 1 deletion assets/ant-changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

## [9] - [ezS3Z57rq_0skoG0WYmIqJ33mJiu0HbYNn9vEu12Mc4] - (2024-12-4)
## [9] - [16_FyX-V2QU0RPSh1GIaEETSaUjNb0oVjCFpVbAfQq4] - (2024-12-4)

### Changed

Expand Down
1 change: 0 additions & 1 deletion src/components/forms/DomainSettings/DomainSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ function DomainSettings({
const isAuthorized = isOwner || isController;
const antHandlers =
data?.info?.Handlers ?? data?.info?.HandlerNames ?? ([] as AoANTHandler[]);
console.log(antHandlers);

const maxLeaseDuration = isMaxLeaseDuration(
data?.arnsRecord && isLeasedArNSRecord(data?.arnsRecord)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function ReturnNameModal({
}) {
const queryClient = useQueryClient();
const navigate = useNavigate();
const [{ arioProcessId }] = useGlobalState();
const [{ arioProcessId, aoClient }] = useGlobalState();
const [{ arnsEmitter }, dispatchArNSState] = useArNSState();
const [{ signing }, dispatchTransactionState] = useTransactionState();
const [{ wallet, walletAddress }] = useWalletState();
Expand Down Expand Up @@ -83,6 +83,7 @@ export function ReturnNameModal({
});

dispatchArNSUpdate({
ao: aoClient,
walletAddress: walletAddress,
arioProcessId,
dispatch: dispatchArNSState,
Expand Down
3 changes: 2 additions & 1 deletion src/components/pages/Manage/Manage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { RefreshIcon, SearchIcon } from '../../icons';
import './styles.css';

function Manage() {
const [{ arioProcessId }] = useGlobalState();
const [{ arioProcessId, aoClient }] = useGlobalState();
const [
{ loading: loadingArnsState, domains, ants, arnsEmitter },
dispatchArNSState,
Expand Down Expand Up @@ -94,6 +94,7 @@ function Manage() {
onClick={() =>
walletAddress
? dispatchArNSUpdate({
ao: aoClient,
emitter: arnsEmitter,
dispatch: dispatchArNSState,
walletAddress: walletAddress,
Expand Down
1 change: 1 addition & 0 deletions src/components/pages/Transaction/TransactionReview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ function TransactionReview() {
} finally {
if (walletAddress) {
dispatchArNSUpdate({
ao: aoClient,
emitter: arnsEmitter,
dispatch: dispatchArNSState,
arioProcessId,
Expand Down
35 changes: 34 additions & 1 deletion src/state/actions/dispatchArNSUpdate.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { ANT, AoANTState, ArNSEventEmitter } from '@ar.io/sdk/web';
import {
ANT,
AoANTHandler,
AoANTState,
AoClient,
ArNSEventEmitter,
} from '@ar.io/sdk/web';
import { captureException } from '@sentry/react';
import { AoAddress } from '@src/types';
import eventEmitter from '@src/utils/events';
import { queryClient } from '@src/utils/network';
import { Tag } from 'arweave/node/lib/transaction';
import { Dispatch } from 'react';

import { ArNSAction } from '../reducers/ArNSReducer';
Expand All @@ -12,11 +19,13 @@ export function dispatchArNSUpdate({
dispatch,
walletAddress,
arioProcessId,
ao,
}: {
emitter: ArNSEventEmitter;
dispatch: Dispatch<ArNSAction>;
walletAddress: AoAddress;
arioProcessId: string;
ao: AoClient;
}) {
dispatch({ type: 'setDomains', payload: {} });
dispatch({ type: 'setAnts', payload: {} });
Expand All @@ -30,6 +39,30 @@ export function dispatchArNSUpdate({
const handlers = await queryClient.fetchQuery({
queryKey: ['handlers', id],
queryFn: async () => {
// validate transfer supports eth addresses
const dryTransferRes = await ao
.dryrun({
process: id,
Owner: walletAddress.toString(),
From: walletAddress.toString(),
tags: [
{ name: 'Action', value: 'Transfer' },
{ name: 'Recipient', value: '0x'.padEnd(42, '0') },
],
})
.catch(() => {
return {} as ReturnType<typeof ao.dryrun>;
});

const hasError =
dryTransferRes.Messages.find((msg) => {
return msg.Tags.find((t: Tag) => t.name === 'Error');
}) !== undefined;

if (hasError) {
return [] as AoANTHandler[];
}

return await ANT.init({
processId: id,
})
Expand Down
3 changes: 2 additions & 1 deletion src/state/contexts/ArNSState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function ArNSStateProvider({
reducer,
children,
}: ArNSStateProviderProps): JSX.Element {
const [{ arioContract, arioProcessId }] = useGlobalState();
const [{ arioContract, arioProcessId, aoClient }] = useGlobalState();
const [state, dispatchArNSState] = useReducer(reducer, initialArNSState);
const [{ walletAddress }] = useWalletState();

Expand All @@ -77,6 +77,7 @@ export function ArNSStateProvider({
useEffect(() => {
if (!walletAddress) return;
dispatchArNSUpdate({
ao: aoClient,
dispatch: dispatchArNSState,
emitter: state.arnsEmitter,
walletAddress: walletAddress,
Expand Down

0 comments on commit f8fef58

Please sign in to comment.