-
Notifications
You must be signed in to change notification settings - Fork 50
fix(mcp-server): resolve NFT owners and cover EVM resources (PLT-347) #335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
182e9bd
dcd5ce6
a558505
5a22e67
890a121
a1902e5
170558b
dc657b9
e488c02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@sei-js/mcp-server': patch | ||
| --- | ||
|
|
||
| Return the current ERC-721 owner from NFT detail resources and expose owner lookup failures. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,18 @@ const erc1155Abi = [ | |
| } | ||
| ] as const; | ||
|
|
||
| async function readERC721Owner(tokenAddress: Address, tokenId: bigint, network: string): Promise<Address> { | ||
| return (await readContract( | ||
| { | ||
| address: tokenAddress, | ||
| abi: erc721Abi, | ||
| functionName: 'ownerOf', | ||
| args: [tokenId] | ||
| }, | ||
| network | ||
| )) as Address; | ||
| } | ||
|
|
||
| /** | ||
| * Get the Sei balance for an address | ||
| * @param address Sei address | ||
|
|
@@ -121,6 +133,19 @@ export async function getERC20Balance( | |
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Get the current owner of a specific NFT | ||
| * @param tokenAddress NFT contract address | ||
| * @param tokenId Token ID to query | ||
| * @param network Network name or chain ID | ||
| * @returns Current owner address | ||
| */ | ||
| export async function getERC721Owner(tokenAddress: string, tokenId: bigint, network = DEFAULT_NETWORK): Promise<Address> { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [suggestion] |
||
| const validatedTokenAddress = services.helpers.validateAddress(tokenAddress); | ||
|
|
||
| return readERC721Owner(validatedTokenAddress, tokenId, network); | ||
| } | ||
|
|
||
| /** | ||
| * Check if an address owns a specific NFT | ||
| * @param tokenAddress NFT contract address | ||
|
|
@@ -134,15 +159,7 @@ export async function isNFTOwner(tokenAddress: string, ownerAddress: string, tok | |
| const validatedOwnerAddress = services.helpers.validateAddress(ownerAddress); | ||
|
|
||
| try { | ||
| const actualOwner = (await readContract( | ||
| { | ||
| address: validatedTokenAddress, | ||
| abi: erc721Abi, | ||
| functionName: 'ownerOf', | ||
| args: [tokenId] | ||
| }, | ||
| network | ||
| )) as Address; | ||
| const actualOwner = await readERC721Owner(validatedTokenAddress, tokenId, network); | ||
|
|
||
| return actualOwner.toLowerCase() === validatedOwnerAddress.toLowerCase(); | ||
| } catch (error: unknown) { | ||
|
|
||
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.
[nit]
error.messagefrom viemreadContractfailures is verbose and typically embeds the request URL and raw request body. Because RPC endpoints are operator-overridable viaMAINNET_RPC_URL/TESTNET_RPC_URL, this can put a private endpoint URL into a model-visible response. Consider trimming to the first line (error.message.split('\n')[0]) or a short classified message, keeping the full text onconsole.error. Same applies to tools.ts:1049.