@bananapus/router-terminal-v6 0.0.45 → 0.0.46

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/router-terminal-v6",
3
- "version": "0.0.45",
3
+ "version": "0.0.46",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,10 +26,10 @@
26
26
  "artifacts": "source ./.env && npx sphinx artifacts --org-id 'ea165b21-7cdc-4d7b-be59-ecdd4c26bee4' --project-name 'nana-router-terminal-v6'"
27
27
  },
28
28
  "dependencies": {
29
- "@bananapus/buyback-hook-v6": "^0.0.47",
30
- "@bananapus/core-v6": "^0.0.54",
31
- "@bananapus/permission-ids-v6": "^0.0.22",
32
- "@bananapus/univ4-router-v6": "^0.0.32",
29
+ "@bananapus/buyback-hook-v6": "^0.0.49",
30
+ "@bananapus/core-v6": "^0.0.57",
31
+ "@bananapus/permission-ids-v6": "^0.0.26",
32
+ "@bananapus/univ4-router-v6": "^0.0.34",
33
33
  "@openzeppelin/contracts": "5.6.1",
34
34
  "@uniswap/permit2": "github:Uniswap/permit2#cc56ad0f3439c502c246fc5cfcc3db92bb8b7219",
35
35
  "@uniswap/v3-core": "github:Uniswap/v3-core#6562c52e8f75f0c10f9deaf44861847585fc8129",
@@ -151,7 +151,7 @@ contract JBRouterTerminalRegistry is IJBRouterTerminalRegistry, JBPermissioned,
151
151
  returns (JBAccountingContext memory context)
152
152
  {
153
153
  // Get the terminal for the project (falls back to the threshold-resolved default).
154
- IJBTerminal terminal = _resolvedTerminalOf(projectId);
154
+ IJBTerminal terminal = _requireResolvedTerminalOf(projectId);
155
155
 
156
156
  // Get the accounting context for the token.
157
157
  return terminal.accountingContextForTokenOf({projectId: projectId, token: token});
@@ -167,7 +167,7 @@ contract JBRouterTerminalRegistry is IJBRouterTerminalRegistry, JBPermissioned,
167
167
  returns (JBAccountingContext[] memory contexts)
168
168
  {
169
169
  // Get the terminal for the project (falls back to the threshold-resolved default).
170
- IJBTerminal terminal = _resolvedTerminalOf(projectId);
170
+ IJBTerminal terminal = _requireResolvedTerminalOf(projectId);
171
171
 
172
172
  // Get the accounting contexts.
173
173
  return terminal.accountingContextsOf(projectId);
@@ -254,7 +254,7 @@ contract JBRouterTerminalRegistry is IJBRouterTerminalRegistry, JBPermissioned,
254
254
  {
255
255
  // Read the terminal explicitly configured for this project, falling back to the
256
256
  // threshold-resolved default if none is pinned.
257
- IJBTerminal terminal = _resolvedTerminalOf(projectId);
257
+ IJBTerminal terminal = _requireResolvedTerminalOf(projectId);
258
258
 
259
259
  // Forward the preview request unchanged to whichever terminal was resolved above.
260
260
  return terminal.previewPayFor({
@@ -387,6 +387,16 @@ contract JBRouterTerminalRegistry is IJBRouterTerminalRegistry, JBPermissioned,
387
387
  if (terminal == IJBTerminal(address(0))) terminal = _defaultTerminalFor(projectId);
388
388
  }
389
389
 
390
+ /// @notice Resolve the effective terminal for call paths that need to forward into a real terminal.
391
+ /// @dev `terminalOf`/`defaultTerminalFor` may intentionally return zero for the cold-start cohort. Transactional
392
+ /// and passthrough view paths must fail before accepting funds or calling address(0).
393
+ /// @param projectId The project to resolve the terminal for.
394
+ /// @return terminal The project-specific terminal or threshold-resolved default.
395
+ function _requireResolvedTerminalOf(uint256 projectId) internal view returns (IJBTerminal terminal) {
396
+ terminal = _resolvedTerminalOf(projectId);
397
+ if (terminal == IJBTerminal(address(0))) revert JBRouterTerminalRegistry_TerminalNotSet(projectId);
398
+ }
399
+
390
400
  //*********************************************************************//
391
401
  // ---------------------- external transactions ---------------------- //
392
402
  //*********************************************************************//
@@ -422,8 +432,8 @@ contract JBRouterTerminalRegistry is IJBRouterTerminalRegistry, JBPermissioned,
422
432
  payable
423
433
  override
424
434
  {
425
- // Resolve the terminal that should receive this forwarded add-to-balance call.
426
- IJBTerminal terminal = _resolvedTerminalOf(projectId);
435
+ // Resolve the terminal that should receive this forwarded add-to-balance call before accepting funds.
436
+ IJBTerminal terminal = _requireResolvedTerminalOf(projectId);
427
437
 
428
438
  // Accept the funds for the token.
429
439
  amount = _acceptFundsFor({token: token, amount: amount, metadata: metadata});
@@ -573,8 +583,8 @@ contract JBRouterTerminalRegistry is IJBRouterTerminalRegistry, JBPermissioned,
573
583
  override
574
584
  returns (uint256 result)
575
585
  {
576
- // Resolve the terminal that should receive this forwarded payment.
577
- IJBTerminal terminal = _resolvedTerminalOf(projectId);
586
+ // Resolve the terminal that should receive this forwarded payment before accepting funds.
587
+ IJBTerminal terminal = _requireResolvedTerminalOf(projectId);
578
588
 
579
589
  // Accept the funds for the token.
580
590
  amount = _acceptFundsFor({token: token, amount: amount, metadata: metadata});