@@ -18,6 +18,8 @@ import { useState } from "react";
1818import { getAddress } from "viem" ;
1919
2020import { isChainIdSupported } from "@/lib/isChainIdSupported" ;
21+ import { useReadTransferRestrictions } from "@/hooks/use-read-transfer-restrictions" ;
22+ import { TransferRestrictions } from "@hypercerts-org/sdk" ;
2123
2224export function ListForSaleButton ( {
2325 hypercert,
@@ -34,29 +36,9 @@ export function ListForSaleButton({
3436 const { chain_id : chainId , contract_address : contractAddress } =
3537 hypercert . contract || { } ;
3638
37- const { data : transferRestrictions } = useReadContract ( {
38- abi : [
39- {
40- inputs : [ { internalType : "uint256" , name : "tokenID" , type : "uint256" } ] ,
41- name : "readTransferRestriction" ,
42- outputs : [
43- {
44- internalType : "string" ,
45- name : "" ,
46- type : "string" ,
47- } ,
48- ] ,
49- stateMutability : "view" ,
50- type : "function" ,
51- } ,
52- ] ,
53- address : getAddress ( contractAddress || "" ) ,
54- functionName : "readTransferRestriction" ,
55- args : [ tokenId ! ] ,
56- query : {
57- enabled : ! ! contractAddress && ! ! tokenId ,
58- } ,
59- } ) ;
39+ const transferRestrictions = useReadTransferRestrictions (
40+ hypercert . hypercert_id || "" ,
41+ ) ;
6042
6143 const [ isOpen , setIsOpen ] = useState ( false ) ;
6244
@@ -87,8 +69,8 @@ export function ListForSaleButton({
8769 ! client ||
8870 ! client . isClaimOrFractionOnConnectedChain ( hypercertId ) ||
8971 ! fractionsOwnedByUser . length ||
90- transferRestrictions === " DisallowAll" ||
91- ( transferRestrictions === " FromCreatorOnly" &&
72+ transferRestrictions === TransferRestrictions . DisallowAll ||
73+ ( transferRestrictions === TransferRestrictions . FromCreatorOnly &&
9274 address ?. toLowerCase ( ) !== hypercert . creator_address ?. toLowerCase ( ) ) ;
9375
9476 const getToolTipMessage = ( ) => {
@@ -114,11 +96,11 @@ export function ListForSaleButton({
11496 return "You do not own any fractions of this hypercert" ;
11597 }
11698
117- if ( transferRestrictions === " DisallowAll" ) {
99+ if ( transferRestrictions === TransferRestrictions . DisallowAll ) {
118100 return "Secondary sales are not allowed for this hypercert" ;
119101 }
120102
121- if ( transferRestrictions === " FromCreatorOnly" ) {
103+ if ( transferRestrictions === TransferRestrictions . FromCreatorOnly ) {
122104 return "Only the creator can sell this hypercert" ;
123105 }
124106
0 commit comments