-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #300 from reservoirprotocol/pedro/grwth-3094-add-o…
…n-chain-royalties-logic-to-batch-listings Add onChainRoyalties to BatchListing
- Loading branch information
Showing
7 changed files
with
203 additions
and
23 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { parseUnits } from 'viem' | ||
import { useContractReads } from 'wagmi' | ||
import { mainnet, goerli } from 'wagmi/chains' | ||
|
||
type Props = { | ||
tokens?: { | ||
contract: string | ||
tokenId: string | ||
}[] | ||
enabled: boolean | ||
chainId: number | ||
} | ||
|
||
export type OnChainRoyaltyReturnType = [`0x${string}`[], bigint[]] | ||
|
||
const MANIFOLD_ABI = [ | ||
{ | ||
inputs: [ | ||
{ | ||
internalType: 'address', | ||
name: 'tokenAddress', | ||
type: 'address', | ||
}, | ||
{ | ||
internalType: 'uint256', | ||
name: 'tokenId', | ||
type: 'uint256', | ||
}, | ||
{ | ||
internalType: 'uint256', | ||
name: 'value', | ||
type: 'uint256', | ||
}, | ||
], | ||
name: 'getRoyaltyView', | ||
outputs: [ | ||
{ | ||
internalType: 'address payable[]', | ||
name: 'recipients', | ||
type: 'address[]', | ||
}, | ||
{ | ||
internalType: 'uint256[]', | ||
name: 'amounts', | ||
type: 'uint256[]', | ||
}, | ||
], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
] as const | ||
|
||
export default function ({ tokens, enabled, chainId = mainnet.id }: Props) { | ||
let manifoldContract = '' | ||
switch (chainId) { | ||
case mainnet.id: { | ||
manifoldContract = '0x0385603ab55642cb4dd5de3ae9e306809991804f' | ||
break | ||
} | ||
case 137: { | ||
manifoldContract = '0x28EdFcF0Be7E86b07493466e7631a213bDe8eEF2' | ||
break | ||
} | ||
case 80001: | ||
manifoldContract = '0x0a01E11887f727D1b1Cd81251eeEE9BEE4262D07' | ||
break | ||
case goerli.id: | ||
case 10: | ||
case 8435: | ||
case 42161: | ||
case 43114: | ||
case 56: { | ||
manifoldContract = '0xEF770dFb6D5620977213f55f99bfd781D04BBE15' | ||
break | ||
} | ||
} | ||
|
||
const amount = parseUnits('1', 18) | ||
|
||
return useContractReads({ | ||
contracts: tokens?.map(({ tokenId, contract }) => ({ | ||
chainId: chainId, | ||
address: manifoldContract as any, | ||
abi: MANIFOLD_ABI, | ||
args: [contract as any, tokenId as any, amount as any], | ||
functionName: 'getRoyaltyView', | ||
})), | ||
enabled: | ||
manifoldContract.length > 0 && enabled && tokens && tokens?.length > 0 | ||
? true | ||
: false, | ||
cacheTime: 60 * 1000, | ||
}) | ||
} |
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
Oops, something went wrong.
1977081
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
artblocks-v2 – ./
artblocks-v2-git-main-unevenlabs.vercel.app
artblocks-v2-unevenlabs.vercel.app
artblocks-v2.vercel.app
1977081
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
explorer – ./
explorer-unevenlabs.vercel.app
explorer-git-main-unevenlabs.vercel.app
marketplace.reservoir.tools
testnets-marketplace.reservoir.tools
explorer.reservoir.tools