@ballkidz/defifa 0.0.37 → 0.0.38
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 +4 -4
- package/src/DefifaDeployer.sol +1 -1
- package/src/DefifaHook.sol +27 -20
- package/src/DefifaTokenUriResolver.sol +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ballkidz/defifa",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.38",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "25.9.0"
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"remappings.txt"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@bananapus/721-hook-v6": "^0.0.
|
|
35
|
-
"@bananapus/address-registry-v6": "^0.0.
|
|
36
|
-
"@bananapus/core-v6": "^0.0.
|
|
34
|
+
"@bananapus/721-hook-v6": "^0.0.52",
|
|
35
|
+
"@bananapus/address-registry-v6": "^0.0.26",
|
|
36
|
+
"@bananapus/core-v6": "^0.0.55",
|
|
37
37
|
"@bananapus/permission-ids-v6": "^0.0.25",
|
|
38
38
|
"@openzeppelin/contracts": "5.6.1",
|
|
39
39
|
"@prb/math": "4.1.1",
|
package/src/DefifaDeployer.sol
CHANGED
|
@@ -546,7 +546,7 @@ contract DefifaDeployer is IDefifaDeployer, IDefifaGamePhaseReporter, IDefifaGam
|
|
|
546
546
|
votingUnits: 0,
|
|
547
547
|
reserveFrequency: defifaTier.reservedRate,
|
|
548
548
|
reserveBeneficiary: defifaTier.reservedTokenBeneficiary,
|
|
549
|
-
|
|
549
|
+
encodedIpfsUri: defifaTier.encodedIpfsUri,
|
|
550
550
|
category: 0,
|
|
551
551
|
discountPercent: 0,
|
|
552
552
|
flags: JB721TierConfigFlags({
|
package/src/DefifaHook.sol
CHANGED
|
@@ -403,7 +403,7 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
|
|
|
403
403
|
returns (uint256 defifaTokenAmount, uint256 baseProtocolTokenAmount)
|
|
404
404
|
{
|
|
405
405
|
// If the game isn't complete, we do not have any tokens to claim.
|
|
406
|
-
if (_currentGamePhaseOf(
|
|
406
|
+
if (_currentGamePhaseOf(projectId) != DefifaGamePhase.COMPLETE) return (0, 0);
|
|
407
407
|
|
|
408
408
|
// Include unminted reserves in the denominator. Once reserves are pending, their future recipients are
|
|
409
409
|
// entitled to fee-token claims as if the reserve NFTs had already been minted; otherwise paid holders could
|
|
@@ -462,12 +462,14 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
|
|
|
462
462
|
virtual
|
|
463
463
|
override(IJBPayHook, JB721Hook)
|
|
464
464
|
{
|
|
465
|
-
uint256
|
|
465
|
+
uint256 localProjectId = projectId;
|
|
466
466
|
|
|
467
467
|
// Make sure the caller is a terminal of the project, and that the call is being made on behalf of an
|
|
468
468
|
// interaction with the correct project.
|
|
469
|
-
if (msg.value != 0 || !_isProjectTerminal(
|
|
470
|
-
revert JB721Hook_InvalidPay({
|
|
469
|
+
if (msg.value != 0 || !_isProjectTerminal(localProjectId) || context.projectId != localProjectId) {
|
|
470
|
+
revert JB721Hook_InvalidPay({
|
|
471
|
+
caller: msg.sender, contextProjectId: context.projectId, projectId: localProjectId
|
|
472
|
+
});
|
|
471
473
|
}
|
|
472
474
|
|
|
473
475
|
// Process the payment.
|
|
@@ -519,7 +521,7 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
|
|
|
519
521
|
if (address(store) != address(0)) revert();
|
|
520
522
|
|
|
521
523
|
// Initialize the superclass.
|
|
522
|
-
_initialize({
|
|
524
|
+
_initialize({initialProjectId: _gameId, name: _name, symbol: _symbol});
|
|
523
525
|
|
|
524
526
|
// Store stuff.
|
|
525
527
|
rulesets = _rulesets;
|
|
@@ -566,14 +568,14 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
|
|
|
566
568
|
function mintReservesFor(uint256 tierId, uint256 count) public override {
|
|
567
569
|
// Minting reserves must not be paused.
|
|
568
570
|
if (JB721TiersRulesetMetadataResolver.mintPendingReservesPaused(_rulesetMetadata())) {
|
|
569
|
-
revert DefifaHook_ReservedTokenMintingPaused({projectId:
|
|
571
|
+
revert DefifaHook_ReservedTokenMintingPaused({projectId: projectId, tierId: tierId});
|
|
570
572
|
}
|
|
571
573
|
|
|
572
574
|
// Block reserve minting while the game is in NO_CONTEST. Reserve mints inflate `totalMintCost` (so reserved
|
|
573
575
|
// recipients can claim fee tokens), which would otherwise let a game that failed `minParticipation` revive
|
|
574
576
|
// back to SCORING via free notional face value before `triggerNoContestFor` latches the failure.
|
|
575
|
-
if (_currentGamePhaseOf(
|
|
576
|
-
revert DefifaHook_ReservedTokenMintingBlockedInNoContest({projectId:
|
|
577
|
+
if (_currentGamePhaseOf(projectId) == DefifaGamePhase.NO_CONTEST) {
|
|
578
|
+
revert DefifaHook_ReservedTokenMintingBlockedInNoContest({projectId: projectId, tierId: tierId});
|
|
577
579
|
}
|
|
578
580
|
|
|
579
581
|
// Cache the store reference in a local variable to avoid repeated SLOAD.
|
|
@@ -657,9 +659,11 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
|
|
|
657
659
|
{
|
|
658
660
|
// Make sure the caller is a terminal of the project, and that the call is being made on behalf of an
|
|
659
661
|
// interaction with the correct project.
|
|
660
|
-
|
|
662
|
+
uint256 localProjectId = projectId;
|
|
663
|
+
|
|
664
|
+
if (msg.value != 0 || !_isProjectTerminal(localProjectId) || context.projectId != localProjectId) {
|
|
661
665
|
revert JB721Hook_InvalidCashOut({
|
|
662
|
-
caller: msg.sender, contextProjectId: context.projectId, projectId:
|
|
666
|
+
caller: msg.sender, contextProjectId: context.projectId, projectId: localProjectId, msgValue: msg.value
|
|
663
667
|
});
|
|
664
668
|
}
|
|
665
669
|
|
|
@@ -683,7 +687,7 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
|
|
|
683
687
|
uint256 tokenId;
|
|
684
688
|
|
|
685
689
|
// Keep track of whether the cashOut is happening during the complete phase.
|
|
686
|
-
bool isComplete = _currentGamePhaseOf(
|
|
690
|
+
bool isComplete = _currentGamePhaseOf(localProjectId) == DefifaGamePhase.COMPLETE;
|
|
687
691
|
|
|
688
692
|
// Cache the store reference in a local variable to avoid repeated SLOAD in the loop.
|
|
689
693
|
IJB721TiersHookStore hookStore = store;
|
|
@@ -779,15 +783,16 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
|
|
|
779
783
|
/// @param tierWeights The tier weights to set.
|
|
780
784
|
function setTierCashOutWeightsTo(DefifaTierCashOutWeight[] memory tierWeights) external override onlyOwner {
|
|
781
785
|
// Get a reference to the game phase.
|
|
782
|
-
|
|
786
|
+
uint256 localProjectId = projectId;
|
|
787
|
+
DefifaGamePhase gamePhase = _currentGamePhaseOf(localProjectId);
|
|
783
788
|
|
|
784
789
|
// Make sure the game has ended.
|
|
785
790
|
if (gamePhase != DefifaGamePhase.SCORING) {
|
|
786
|
-
revert DefifaHook_GameIsntScoringYet({projectId:
|
|
791
|
+
revert DefifaHook_GameIsntScoringYet({projectId: localProjectId, phase: gamePhase});
|
|
787
792
|
}
|
|
788
793
|
|
|
789
794
|
// Make sure the cashOut weights haven't already been set.
|
|
790
|
-
if (cashOutWeightIsSet) revert DefifaHook_CashoutWeightsAlreadySet({projectId:
|
|
795
|
+
if (cashOutWeightIsSet) revert DefifaHook_CashoutWeightsAlreadySet({projectId: localProjectId});
|
|
791
796
|
|
|
792
797
|
// Validate weights and build the array. Reverts on invalid input.
|
|
793
798
|
_tierCashOutWeights =
|
|
@@ -807,9 +812,10 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
|
|
|
807
812
|
if (delegatee == address(0)) revert DefifaHook_DelegateAddressZero({tierId: tierId});
|
|
808
813
|
|
|
809
814
|
// Make sure the current game phase is the minting phase.
|
|
810
|
-
|
|
815
|
+
uint256 localProjectId = projectId;
|
|
816
|
+
DefifaGamePhase gamePhase = _currentGamePhaseOf(localProjectId);
|
|
811
817
|
if (gamePhase != DefifaGamePhase.MINT) {
|
|
812
|
-
revert DefifaHook_DelegateChangesUnavailableInThisPhase({projectId:
|
|
818
|
+
revert DefifaHook_DelegateChangesUnavailableInThisPhase({projectId: localProjectId, phase: gamePhase});
|
|
813
819
|
}
|
|
814
820
|
|
|
815
821
|
_delegateTier({account: msg.sender, delegatee: delegatee, tierId: tierId});
|
|
@@ -819,9 +825,10 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
|
|
|
819
825
|
/// @param delegations An array of tiers to set delegates for.
|
|
820
826
|
function setTierDelegatesTo(DefifaDelegation[] memory delegations) external virtual override {
|
|
821
827
|
// Make sure the current game phase is the minting phase.
|
|
822
|
-
|
|
828
|
+
uint256 localProjectId = projectId;
|
|
829
|
+
DefifaGamePhase gamePhase = _currentGamePhaseOf(localProjectId);
|
|
823
830
|
if (gamePhase != DefifaGamePhase.MINT) {
|
|
824
|
-
revert DefifaHook_DelegateChangesUnavailableInThisPhase({projectId:
|
|
831
|
+
revert DefifaHook_DelegateChangesUnavailableInThisPhase({projectId: localProjectId, phase: gamePhase});
|
|
825
832
|
}
|
|
826
833
|
|
|
827
834
|
// Keep a reference to the number of tier delegates.
|
|
@@ -1143,7 +1150,7 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
|
|
|
1143
1150
|
if (tier.flags.transfersPausable) {
|
|
1144
1151
|
// If transfers are paused and the NFT isn't being transferred to the zero address, revert.
|
|
1145
1152
|
if (to != address(0) && JB721TiersRulesetMetadataResolver.transfersPaused(_rulesetMetadata())) {
|
|
1146
|
-
revert DefifaHook_TransfersPaused({projectId:
|
|
1153
|
+
revert DefifaHook_TransfersPaused({projectId: projectId, tokenId: tokenId, from: from, to: to});
|
|
1147
1154
|
}
|
|
1148
1155
|
}
|
|
1149
1156
|
|
|
@@ -1199,6 +1206,6 @@ contract DefifaHook is JB721Hook, Ownable, IDefifaHook {
|
|
|
1199
1206
|
/// @notice Returns the current ruleset metadata for this project.
|
|
1200
1207
|
/// @return The packed ruleset metadata.
|
|
1201
1208
|
function _rulesetMetadata() internal view returns (uint256) {
|
|
1202
|
-
return JBRulesetMetadataResolver.metadata(rulesets.currentOf(
|
|
1209
|
+
return JBRulesetMetadataResolver.metadata(rulesets.currentOf(projectId));
|
|
1203
1210
|
}
|
|
1204
1211
|
}
|
|
@@ -60,7 +60,7 @@ contract DefifaTokenUriResolver is IDefifaTokenUriResolver, IJB721TokenUriResolv
|
|
|
60
60
|
IDefifaHook hook = IDefifaHook(nft);
|
|
61
61
|
|
|
62
62
|
// Get the game ID.
|
|
63
|
-
uint256 gameId = hook.
|
|
63
|
+
uint256 gameId = hook.projectId();
|
|
64
64
|
|
|
65
65
|
// Keep a reference to the game phase text.
|
|
66
66
|
string memory gamePhaseText;
|
|
@@ -95,8 +95,8 @@ contract DefifaTokenUriResolver is IDefifaTokenUriResolver, IJB721TokenUriResolv
|
|
|
95
95
|
teamSvg = _escapeSvg(rawTeam);
|
|
96
96
|
|
|
97
97
|
// Check to see if the tier has a URI. Return it if it does.
|
|
98
|
-
if (tier.
|
|
99
|
-
return JBIpfsDecoder.decode({baseUri: hook.baseURI(), hexString: tier.
|
|
98
|
+
if (tier.encodedIpfsUri != bytes32(0)) {
|
|
99
|
+
return JBIpfsDecoder.decode({baseUri: hook.baseURI(), hexString: tier.encodedIpfsUri});
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
parts[0] = string("data:application/json;base64,");
|