@ballkidz/defifa 0.0.28 → 0.0.30
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/ARCHITECTURE.md +2 -2
- package/CHANGELOG.md +2 -2
- package/CRYPTO_ECON.md +4 -4
- package/README.md +3 -3
- package/RISKS.md +1 -1
- package/SKILLS.md +1 -1
- package/STYLE_GUIDE.md +2 -50
- package/package.json +2 -2
- package/src/DefifaDeployer.sol +78 -61
- package/src/DefifaGovernor.sol +74 -63
- package/src/DefifaHook.sol +127 -183
- package/src/DefifaProjectOwner.sol +4 -2
- package/src/DefifaTokenUriResolver.sol +28 -16
- package/src/interfaces/IDefifaDeployer.sol +0 -16
- package/src/interfaces/IDefifaHook.sol +0 -4
- package/src/libraries/DefifaHookLib.sol +261 -151
|
@@ -17,7 +17,7 @@ contract DefifaProjectOwner is IERC721Receiver {
|
|
|
17
17
|
// --------------------------- custom errors ------------------------- //
|
|
18
18
|
//*********************************************************************//
|
|
19
19
|
|
|
20
|
-
error DefifaProjectOwner_InvalidSender();
|
|
20
|
+
error DefifaProjectOwner_InvalidSender(address caller, address expectedSender);
|
|
21
21
|
|
|
22
22
|
//*********************************************************************//
|
|
23
23
|
// --------------- public immutable stored properties ---------------- //
|
|
@@ -64,7 +64,9 @@ contract DefifaProjectOwner is IERC721Receiver {
|
|
|
64
64
|
operator;
|
|
65
65
|
|
|
66
66
|
// Make sure the 721 received is the JBProjects contract.
|
|
67
|
-
if (msg.sender != address(PROJECTS))
|
|
67
|
+
if (msg.sender != address(PROJECTS)) {
|
|
68
|
+
revert DefifaProjectOwner_InvalidSender({caller: msg.sender, expectedSender: address(PROJECTS)});
|
|
69
|
+
}
|
|
68
70
|
|
|
69
71
|
// Set the correct permission.
|
|
70
72
|
uint8[] memory permissionIds = new uint8[](1);
|
|
@@ -205,27 +205,30 @@ contract DefifaTokenUriResolver is IDefifaTokenUriResolver, IJB721TokenUriResolv
|
|
|
205
205
|
gamePhaseText,
|
|
206
206
|
"</text>",
|
|
207
207
|
'<text x="10" y="85" style="font-size:26px; font-family: Capsules-500; font-weight:500; fill: #c0b3f1;">',
|
|
208
|
-
_getSubstring(titleSvg, 0, 30),
|
|
208
|
+
_getSubstring({str: titleSvg, startIndex: 0, endIndex: 30}),
|
|
209
209
|
"</text>",
|
|
210
210
|
'<text x="10" y="120" style="font-size:26px; font-family: Capsules-500; font-weight:500; fill: #c0b3f1;">',
|
|
211
|
-
_getSubstring(titleSvg, 30, 60),
|
|
211
|
+
_getSubstring({str: titleSvg, startIndex: 30, endIndex: 60}),
|
|
212
212
|
"</text>",
|
|
213
213
|
'<text x="10" y="205" style="font-size:80px; font-family: Capsules-700; font-weight:700; fill: #fea282;">',
|
|
214
|
-
bytes(_getSubstring(teamSvg, 20, 30)).length != 0
|
|
215
|
-
|
|
214
|
+
bytes(_getSubstring({str: teamSvg, startIndex: 20, endIndex: 30})).length != 0
|
|
215
|
+
&& bytes(_getSubstring({str: teamSvg, startIndex: 10, endIndex: 20})).length != 0
|
|
216
|
+
? _getSubstring({str: teamSvg, startIndex: 0, endIndex: 10})
|
|
216
217
|
: "",
|
|
217
218
|
"</text>",
|
|
218
219
|
'<text x="10" y="295" style="font-size:80px; font-family: Capsules-700; font-weight:700; fill: #fea282;">',
|
|
219
|
-
bytes(_getSubstring(teamSvg, 20, 30)).length != 0
|
|
220
|
-
? _getSubstring(teamSvg, 10, 20)
|
|
221
|
-
: bytes(_getSubstring(teamSvg, 10, 20)).length != 0
|
|
220
|
+
bytes(_getSubstring({str: teamSvg, startIndex: 20, endIndex: 30})).length != 0
|
|
221
|
+
? _getSubstring({str: teamSvg, startIndex: 10, endIndex: 20})
|
|
222
|
+
: bytes(_getSubstring({str: teamSvg, startIndex: 10, endIndex: 20})).length != 0
|
|
223
|
+
? _getSubstring({str: teamSvg, startIndex: 0, endIndex: 10})
|
|
224
|
+
: "",
|
|
222
225
|
"</text>",
|
|
223
226
|
'<text x="10" y="385" style="font-size:80px; font-family: Capsules-700; font-weight:700; fill: #fea282;">',
|
|
224
|
-
bytes(_getSubstring(teamSvg, 20, 30)).length != 0
|
|
225
|
-
? _getSubstring(teamSvg, 20, 30)
|
|
226
|
-
: bytes(_getSubstring(teamSvg, 10, 20)).length != 0
|
|
227
|
-
? _getSubstring(teamSvg, 10, 20)
|
|
228
|
-
: _getSubstring(teamSvg, 0, 10),
|
|
227
|
+
bytes(_getSubstring({str: teamSvg, startIndex: 20, endIndex: 30})).length != 0
|
|
228
|
+
? _getSubstring({str: teamSvg, startIndex: 20, endIndex: 30})
|
|
229
|
+
: bytes(_getSubstring({str: teamSvg, startIndex: 10, endIndex: 20})).length != 0
|
|
230
|
+
? _getSubstring({str: teamSvg, startIndex: 10, endIndex: 20})
|
|
231
|
+
: _getSubstring({str: teamSvg, startIndex: 0, endIndex: 10}),
|
|
229
232
|
"</text>",
|
|
230
233
|
'<text x="10" y="430" style="font-size:16px; font-family: Capsules-500; font-weight:500; fill: #c0b3f1;">TOKEN ID: ',
|
|
231
234
|
tokenId.toString(),
|
|
@@ -240,7 +243,6 @@ contract DefifaTokenUriResolver is IDefifaTokenUriResolver, IJB721TokenUriResolv
|
|
|
240
243
|
)
|
|
241
244
|
);
|
|
242
245
|
parts[3] = string('"}');
|
|
243
|
-
// slither-disable-next-line encode-packed-collision
|
|
244
246
|
return string.concat(parts[0], Base64.encode(abi.encodePacked(parts[1], parts[2], parts[3])));
|
|
245
247
|
}
|
|
246
248
|
|
|
@@ -282,9 +284,19 @@ contract DefifaTokenUriResolver is IDefifaTokenUriResolver, IJB721TokenUriResolv
|
|
|
282
284
|
}
|
|
283
285
|
|
|
284
286
|
// Concatenate the strings
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
287
|
+
if (isEth) {
|
|
288
|
+
return string(abi.encodePacked("\u039E", integerPart, ".", decimalPartStr));
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// Try to get the token symbol; fall back to a truncated hex address if the call reverts.
|
|
292
|
+
string memory tokenSymbol;
|
|
293
|
+
try IERC20Metadata(token).symbol() returns (string memory s) {
|
|
294
|
+
tokenSymbol = _escapeSvg(s);
|
|
295
|
+
} catch {
|
|
296
|
+
tokenSymbol = Strings.toHexString(uint160(token), 20);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return string(abi.encodePacked(integerPart, ".", decimalPartStr, " ", tokenSymbol));
|
|
288
300
|
}
|
|
289
301
|
|
|
290
302
|
/// @notice Gets a substring.
|
|
@@ -20,12 +20,6 @@ interface IDefifaDeployer {
|
|
|
20
20
|
/// @param reason The revert reason bytes from the failed payout.
|
|
21
21
|
event CommitmentPayoutFailed(uint256 indexed gameId, uint256 amount, bytes reason);
|
|
22
22
|
|
|
23
|
-
/// @notice Emitted when a split receives a portion of the game pot.
|
|
24
|
-
/// @param split The split that received funds.
|
|
25
|
-
/// @param amount The amount sent to the split.
|
|
26
|
-
/// @param caller The address that triggered the distribution.
|
|
27
|
-
event DistributeToSplit(JBSplit split, uint256 amount, address caller);
|
|
28
|
-
|
|
29
23
|
/// @notice Emitted when a game's commitments have been fulfilled.
|
|
30
24
|
/// @param gameId The ID of the fulfilled game.
|
|
31
25
|
/// @param pot The total game pot that was fulfilled.
|
|
@@ -51,16 +45,6 @@ interface IDefifaDeployer {
|
|
|
51
45
|
/// @param caller The address that queued the phase transition.
|
|
52
46
|
event QueuedNoContest(uint256 indexed gameId, address caller);
|
|
53
47
|
|
|
54
|
-
/// @notice Emitted when a game is queued into its refund phase.
|
|
55
|
-
/// @param gameId The ID of the game.
|
|
56
|
-
/// @param caller The address that queued the phase transition.
|
|
57
|
-
event QueuedRefundPhase(uint256 indexed gameId, address caller);
|
|
58
|
-
|
|
59
|
-
/// @notice Emitted when a game is queued into its scoring phase.
|
|
60
|
-
/// @param gameId The ID of the game.
|
|
61
|
-
/// @param caller The address that queued the phase transition.
|
|
62
|
-
event QueuedScoringPhase(uint256 indexed gameId, address caller);
|
|
63
|
-
|
|
64
48
|
/// @notice The fee divisor for base protocol fees (100 / fee percent).
|
|
65
49
|
/// @return The fee divisor.
|
|
66
50
|
function BASE_PROTOCOL_FEE_DIVISOR() external view returns (uint256);
|
|
@@ -193,10 +193,6 @@ interface IDefifaHook is IJB721Hook {
|
|
|
193
193
|
/// @return The tier name.
|
|
194
194
|
function tierNameOf(uint256 tierId) external view returns (string memory);
|
|
195
195
|
|
|
196
|
-
/// @notice The token allocations (Defifa token amount, base protocol token amount).
|
|
197
|
-
/// @return The Defifa token allocation and the base protocol token allocation.
|
|
198
|
-
function tokenAllocations() external view returns (uint256, uint256);
|
|
199
|
-
|
|
200
196
|
/// @notice Get the claimable Defifa and base protocol tokens for a set of token IDs.
|
|
201
197
|
/// @param tokenIds The token IDs to check.
|
|
202
198
|
/// @return The claimable Defifa token amount and base protocol token amount.
|