-
Notifications
You must be signed in to change notification settings - Fork 10
add poi verification before minting function #169
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 9 commits
0070789
88368b7
3587a0d
e1f8fb4
896c68b
5b91b43
fd7539c
5edc1bf
977706d
a1e6173
cf62367
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 |
|---|---|---|
|
|
@@ -75,17 +75,21 @@ export function handleReservation(event: ReservedEvent): void { | |
| reservation.save() | ||
| } | ||
|
|
||
| function updateIpnftMetadata(ipnft: Ipnft, uri: string, timestamp: BigInt): void { | ||
| let ipfsLocation = uri.replace('ipfs://', ''); | ||
| if (!ipfsLocation || ipfsLocation == uri) { | ||
| log.error("Invalid URI format for tokenId {}: {}", [ipnft.id, uri]) | ||
| return | ||
| } | ||
| function updateIpnftMetadata( | ||
| ipnft: Ipnft, | ||
| uri: string, | ||
| timestamp: BigInt | ||
| ): void { | ||
| let ipfsLocation = uri.replace('ipfs://', '') | ||
| if (!ipfsLocation || ipfsLocation == uri) { | ||
| log.error('Invalid URI format for tokenId {}: {}', [ipnft.id, uri]) | ||
| return | ||
| } | ||
|
|
||
| ipnft.tokenURI = uri | ||
| ipnft.metadata = ipfsLocation | ||
| ipnft.updatedAtTimestamp = timestamp | ||
| IpnftMetadataTemplate.create(ipfsLocation) | ||
| ipnft.tokenURI = uri | ||
| ipnft.metadata = ipfsLocation | ||
| ipnft.updatedAtTimestamp = timestamp | ||
| IpnftMetadataTemplate.create(ipfsLocation) | ||
| } | ||
|
|
||
| //the underlying parameter arrays are misaligned, hence we cannot cast or unify both events | ||
|
|
@@ -97,7 +101,6 @@ export function handleMint(event: IPNFTMintedEvent): void { | |
| updateIpnftMetadata(ipnft, event.params.tokenURI, event.block.timestamp) | ||
| store.remove('Reservation', event.params.tokenId.toString()) | ||
| ipnft.save() | ||
|
|
||
| } | ||
|
|
||
| export function handleMetadataUpdated(event: MetadataUpdateEvent): void { | ||
|
|
@@ -108,13 +111,14 @@ export function handleMetadataUpdated(event: MetadataUpdateEvent): void { | |
| } | ||
|
|
||
| //erc4906 is not emitting the new url, we must query it ourselves | ||
| let _ipnftContract = IPNFTContract.bind(event.params._event.address); | ||
| let _ipnftContract = IPNFTContract.bind(event.params._event.address) | ||
| let newUri = _ipnftContract.tokenURI(event.params._tokenId) | ||
| if (!newUri || newUri == "") { | ||
| log.debug("no new uri found for token, likely just minted {}", [event.params._tokenId.toString()]) | ||
| return | ||
| if (!newUri || newUri == '') { | ||
| log.debug('no new uri found for token, likely just minted {}', [ | ||
| event.params._tokenId.toString() | ||
| ]) | ||
| return | ||
| } | ||
| updateIpnftMetadata(ipnft, newUri, event.block.timestamp) | ||
| updateIpnftMetadata(ipnft, newUri, event.block.timestamp) | ||
|
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. 🛠️ Refactor suggestion Consider adding URI validation before metadata update. While Consider this improvement: + if (!newUri.startsWith('ipfs://')) {
+ log.error('Invalid URI format received in MetadataUpdate for token {}: {}', [
+ event.params._tokenId.toString(),
+ newUri
+ ])
+ return
+ }
updateIpnftMetadata(ipnft, newUri, event.block.timestamp)
ipnft.save()
|
||
| ipnft.save() | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.