GraphemeNFT / rarible-scaffold

MIT License
0 stars 0 forks source link

exposing contract values to the client #15

Closed dcsan closed 3 years ago

dcsan commented 3 years ago

when the client renders it gets basic info from the contract, ie the object has these properties below

however I don't think the other properties (such as DNA) are automatically exposed / available. perhaps we need to call the getDNA on the object to read those values?

or can certain properties be always exposed by default?

letter 
(8) ["id", "uri", "owner", "description", "external_url", "image", "name", "attributes"]
0: "id"
1: "uri"
2: "owner"
3: "description"
4: "external_url"
5: "image"
6: "name"

image

dcsan commented 3 years ago

the other traits etc are coming from the IPFS hash so that's not secure to read from

keepRunning commented 3 years ago

Contract will have a getDna(tokenId) method.

It will have to be queried and assigned here in the react app. Then it should be available for use. useEffect(() => { const updateYourCollectibles = async ()

dcsan commented 3 years ago

I did add that method, but it's not available in the debug contracts UI.

mintItem is there but not rollToMint

http://localhost:3000/debugcontracts

Does it need to be declared in the ABI.json?

image

keepRunning commented 3 years ago

can you compile your contract and try again. That should update your ABI. I see only the ERC721 methods and none of our custom methods

dcsan commented 3 years ago

I've updated the contract but new methods don't show up in the front-end. Do i need to manually copy across the ABI file? I noticed hardhat generates artifacts/contracts/YourCollectible.sol/YourCollectible.json

but that the front end react uses packages/react-app/src/contracts/YourCollectible.abi.js

so they're in different formats, in different places... surely an easier way or what am I missing?

I did yarn compile; yarn deploy and updated the contract address

dcsan commented 3 years ago

I manually edited the ABI

now I can call it but:

image

looks like the right version of contract isn't getting called:

Error: processing response error (body="{\"jsonrpc\":\"2.0\",\"id\":145,\"error\":{\"code\":-32603,\"message\":\"Transaction reverted: function selector was not recognized and there's no fallback function\"}}", error={"code":-32603}, requestBody="{\"method\":\"eth_call\",\"params\":[{\"from\":\"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266\",\"to\":\"0x67d269191c92caf3cd7723f116c85e6e9bf55933\",\"data\":\"0x8da5cb5b\"},\"latest\"],\"id\":145,\"jsonrpc\":\"2.0\"}", requestMethod="POST", url="http://localhost:8545", code=SERVER_ERROR, version=web/5.3.0)

at Logger.makeError (index.ts:213)
at Logger.throwError (index.ts:225)
at index.ts:284
at Generator.next (<anonymous>)
at fulfilled (index.ts:2)
keepRunning commented 3 years ago

Give me sometime and I will check and update. There must be an easy way.

On Wed, Aug 25, 2021, 8:45 PM DC @.***> wrote:

I manually edited the ABI but it looks like somehow the right version of contract isn't getting called?

Error: processing response error (body="{\"jsonrpc\":\"2.0\",\"id\":145,\"error\":{\"code\":-32603,\"message\":\"Transaction reverted: function selector was not recognized and there's no fallback function\"}}", error={"code":-32603}, requestBody="{\"method\":\"eth_call\",\"params\":[{\"from\":\"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266\",\"to\":\"0x67d269191c92caf3cd7723f116c85e6e9bf55933\",\"data\":\"0x8da5cb5b\"},\"latest\"],\"id\":145,\"jsonrpc\":\"2.0\"}", requestMethod="POST", url="http://localhost:8545", code=SERVER_ERROR, version=web/5.3.0) at Logger.makeError (index.ts:213) at Logger.throwError (index.ts:225) at index.ts:284 at Generator.next () at fulfilled (index.ts:2)

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/GraphemeNFT/rarible-scaffold/issues/15#issuecomment-905597747, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQPVAG7PLPDB3E6CCEIQYLT6UCIDANCNFSM5CZF5ASA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

keepRunning commented 3 years ago

Looks like we need to run hardhat\scripts\publish.js to populate contracts to react-app. But am getting an error on executing the script

keepRunning commented 3 years ago

finally. Update as this diff and then run publish-contracts.txt yarn publish-contracts

dcsan commented 3 years ago

yeah that seems to get the function to show up in the dynamic "contract debugger" UI now, but calling it does nothing. it doesn't throw an error though, which is a big step forward!

dcsan commented 3 years ago

getDNA is working.