@bananapus/721-hook-v6 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bananapus/721-hook-v6",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,10 +17,10 @@
17
17
  "artifacts": "source ./.env && npx sphinx artifacts --org-id 'ea165b21-7cdc-4d7b-be59-ecdd4c26bee4' --project-name 'nana-721-hook-v6'"
18
18
  },
19
19
  "dependencies": {
20
- "@bananapus/address-registry-v6": "^0.0.1",
21
- "@bananapus/core-v6": "^0.0.4",
22
- "@bananapus/ownable-v6": "^0.0.1",
23
- "@bananapus/permission-ids-v6": "^0.0.2",
20
+ "@bananapus/address-registry-v6": "^0.0.3",
21
+ "@bananapus/core-v6": "^0.0.5",
22
+ "@bananapus/ownable-v6": "^0.0.4",
23
+ "@bananapus/permission-ids-v6": "^0.0.3",
24
24
  "@openzeppelin/contracts": "5.2.0",
25
25
  "@prb/math": "^4.1.0",
26
26
  "solady": "^0.1.8"
@@ -31,7 +31,6 @@ import {IJB721TiersHookStore} from "./interfaces/IJB721TiersHookStore.sol";
31
31
  import {IJB721TokenUriResolver} from "./interfaces/IJB721TokenUriResolver.sol";
32
32
  import {JB721TiersHookLib} from "./libraries/JB721TiersHookLib.sol";
33
33
  import {JB721TiersRulesetMetadataResolver} from "./libraries/JB721TiersRulesetMetadataResolver.sol";
34
- import {JBIpfsDecoder} from "./libraries/JBIpfsDecoder.sol";
35
34
  import {JB721Tier} from "./structs/JB721Tier.sol";
36
35
  import {JB721TierConfig} from "./structs/JB721TierConfig.sol";
37
36
  import {JB721TiersSetDiscountPercentConfig} from "./structs/JB721TiersSetDiscountPercentConfig.sol";
@@ -350,16 +349,7 @@ contract JB721TiersHook is JBOwnable, ERC2771Context, ERC721, IJB721TiersHook {
350
349
  /// @return The token URI from the `tokenUriResolver` if it is set. If it isn't set, the token URI for the NFT's
351
350
  /// tier.
352
351
  function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
353
- // Get a reference to the `tokenUriResolver`.
354
- IJB721TokenUriResolver resolver = STORE.tokenUriResolverOf(address(this));
355
-
356
- // If a `tokenUriResolver` is set, use it to resolve the token URI.
357
- if (address(resolver) != address(0)) return resolver.tokenUriOf({nft: address(this), tokenId: tokenId});
358
-
359
- // Otherwise, return the token URI corresponding with the NFT's tier.
360
- return JBIpfsDecoder.decode({
361
- baseUri: baseURI, hexString: STORE.encodedTierIPFSUriOf({hook: address(this), tokenId: tokenId})
362
- });
352
+ return JB721TiersHookLib.resolveTokenURI(STORE, address(this), baseURI, tokenId);
363
353
  }
364
354
 
365
355
  //*********************************************************************//
@@ -16,7 +16,9 @@ import {mulDiv} from "@prb/math/src/Common.sol";
16
16
  import {JBSplitGroup} from "@bananapus/core-v6/src/structs/JBSplitGroup.sol";
17
17
 
18
18
  import {IJB721TiersHookStore} from "../interfaces/IJB721TiersHookStore.sol";
19
+ import {IJB721TokenUriResolver} from "../interfaces/IJB721TokenUriResolver.sol";
19
20
  import {JB721TierConfig} from "../structs/JB721TierConfig.sol";
21
+ import {JBIpfsDecoder} from "./JBIpfsDecoder.sol";
20
22
 
21
23
  /// @notice External library for JB721TiersHook operations extracted to stay within the EIP-170 contract size limit.
22
24
  /// @dev Handles tier adjustments, split calculations, price normalization, and split fund distribution.
@@ -333,4 +335,34 @@ library JB721TiersHookLib {
333
335
  terminal.pay(projectId, token, amount, beneficiary, 0, "", bytes(""));
334
336
  }
335
337
  }
338
+
339
+ /// @notice Resolves the token URI for a given NFT token ID.
340
+ /// @dev Extracted to the library to keep JBIpfsDecoder bytecode out of the hook contract (EIP-170 compliance).
341
+ /// @param store The 721 tiers hook store.
342
+ /// @param hook The hook address.
343
+ /// @param baseUri The base URI for IPFS-based token URIs.
344
+ /// @param tokenId The token ID to resolve the URI for.
345
+ /// @return The resolved token URI string.
346
+ function resolveTokenURI(
347
+ IJB721TiersHookStore store,
348
+ address hook,
349
+ string memory baseUri,
350
+ uint256 tokenId
351
+ )
352
+ external
353
+ view
354
+ returns (string memory)
355
+ {
356
+ // Get a reference to the `tokenUriResolver`.
357
+ IJB721TokenUriResolver resolver = store.tokenUriResolverOf(hook);
358
+
359
+ // If a `tokenUriResolver` is set, use it to resolve the token URI.
360
+ if (address(resolver) != address(0)) return resolver.tokenUriOf({nft: hook, tokenId: tokenId});
361
+
362
+ // Otherwise, return the token URI corresponding with the NFT's tier.
363
+ return
364
+ JBIpfsDecoder.decode({
365
+ baseUri: baseUri, hexString: store.encodedTierIPFSUriOf({hook: hook, tokenId: tokenId})
366
+ });
367
+ }
336
368
  }