-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0677dd
commit 30410fa
Showing
5 changed files
with
96 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { erc721Abi } from 'viem' | ||
import { usePublicClient, useReadContracts } from 'wagmi' | ||
|
||
import { getChainContractAddress } from '@ensdomains/ensjs/contracts' | ||
import { NameWithRelation } from '@ensdomains/ensjs/subgraph' | ||
|
||
export const useApprovedNamesForMigration = ({ | ||
names, | ||
}: { | ||
names: NameWithRelation[] | ||
}): NameWithRelation[] => { | ||
const client = usePublicClient() | ||
|
||
const { data } = useReadContracts({ | ||
contracts: names.map((name) => ({ | ||
address: getChainContractAddress({ | ||
client, | ||
contract: name.wrappedOwner ? 'ensNameWrapper' : 'ensBaseRegistrarImplementation', | ||
}), | ||
abi: erc721Abi, | ||
functionName: 'isApprovedForAll', | ||
args: ['migrator-contract-go-here', true], | ||
})), | ||
multicallAddress: getChainContractAddress({ client, contract: 'multicall3' }), | ||
}) | ||
|
||
return names.filter((d, i) => Boolean(data?.[i].result)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/transaction-flow/transaction/approveNameWrapperForMigration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import type { TFunction } from 'react-i18next' | ||
import { Address, encodeFunctionData } from 'viem' | ||
|
||
import { | ||
getChainContractAddress, | ||
registrySetApprovalForAllSnippet, | ||
} from '@ensdomains/ensjs/contracts' | ||
|
||
import { Transaction, TransactionDisplayItem, TransactionFunctionParameters } from '@app/types' | ||
|
||
type Data = { address: Address } | ||
|
||
const displayItems = ( | ||
{ address }: Data, | ||
t: TFunction<'translation', undefined>, | ||
): TransactionDisplayItem[] => [ | ||
{ | ||
label: 'address', | ||
value: address, | ||
type: 'address', | ||
}, | ||
{ | ||
label: 'action', | ||
value: t('transaction.description.approveNameWrapper'), | ||
}, | ||
{ | ||
label: 'info', | ||
value: t('transaction.info.approveNameWrapper'), | ||
}, | ||
] | ||
|
||
const transaction = async ({ client }: TransactionFunctionParameters<Data>) => { | ||
return { | ||
to: getChainContractAddress({ | ||
client, | ||
contract: 'ensNameWrapper', | ||
}), | ||
data: encodeFunctionData({ | ||
abi: registrySetApprovalForAllSnippet, | ||
functionName: 'setApprovalForAll', | ||
args: [ | ||
getChainContractAddress({ | ||
client, | ||
contract: 'migrator-contract-address-will-go-here', | ||
}), | ||
true, | ||
], | ||
}), | ||
} | ||
} | ||
|
||
export default { displayItems, transaction } satisfies Transaction<Data> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters