@bananapus/omnichain-deployers-v6 0.0.40 → 0.0.41
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 +1 -1
- package/src/JBOmnichainDeployer.sol +47 -2
package/package.json
CHANGED
|
@@ -20,6 +20,7 @@ import {JBRulesetConfig} from "@bananapus/core-v6/src/structs/JBRulesetConfig.so
|
|
|
20
20
|
import {JBTerminalConfig} from "@bananapus/core-v6/src/structs/JBTerminalConfig.sol";
|
|
21
21
|
import {JBOwnable} from "@bananapus/ownable-v6/src/JBOwnable.sol";
|
|
22
22
|
import {JBPermissionIds} from "@bananapus/permission-ids-v6/src/JBPermissionIds.sol";
|
|
23
|
+
import {IJBPeerChainAdjustedAccounts} from "@bananapus/suckers-v6/src/interfaces/IJBPeerChainAdjustedAccounts.sol";
|
|
23
24
|
import {IJBSuckerRegistry} from "@bananapus/suckers-v6/src/interfaces/IJBSuckerRegistry.sol";
|
|
24
25
|
import {ERC2771Context} from "@openzeppelin/contracts/metatx/ERC2771Context.sol";
|
|
25
26
|
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
|
|
@@ -48,6 +49,7 @@ contract JBOmnichainDeployer is
|
|
|
48
49
|
JBPermissioned,
|
|
49
50
|
IJBOmnichainDeployer,
|
|
50
51
|
IJBRulesetDataHook,
|
|
52
|
+
IJBPeerChainAdjustedAccounts,
|
|
51
53
|
IERC721Receiver
|
|
52
54
|
{
|
|
53
55
|
//*********************************************************************//
|
|
@@ -691,6 +693,48 @@ contract JBOmnichainDeployer is
|
|
|
691
693
|
return (config.hook, config.useDataHookForCashOut);
|
|
692
694
|
}
|
|
693
695
|
|
|
696
|
+
/// @notice Forwards peer-chain adjusted accounts from the stored extra data hook. Suckers call this on the active
|
|
697
|
+
/// data hook (which is this deployer after wrapping) to learn about additional supply/surplus/balance that should
|
|
698
|
+
/// be included in cross-chain snapshots. Without forwarding, the extra hook's peer-chain adjustments are silently
|
|
699
|
+
/// masked, causing the bonding curve to use only local values and over-reclaiming on peer chains.
|
|
700
|
+
/// @dev Part of `IJBPeerChainAdjustedAccounts`. Uses staticcall to safely handle extra hooks that do not implement
|
|
701
|
+
/// this interface.
|
|
702
|
+
/// @param projectId The ID of the project to snapshot.
|
|
703
|
+
/// @param decimals The decimals the returned surplus and balance should use.
|
|
704
|
+
/// @param currency The currency the returned surplus and balance should be in terms of.
|
|
705
|
+
/// @return supply The extra supply to include in `sourceTotalSupply`.
|
|
706
|
+
/// @return surplus The extra surplus to include in `sourceSurplus`.
|
|
707
|
+
/// @return balance The extra balance to include in `sourceBalance`.
|
|
708
|
+
function peerChainAdjustedAccountsOf(
|
|
709
|
+
uint256 projectId,
|
|
710
|
+
uint256 decimals,
|
|
711
|
+
uint256 currency
|
|
712
|
+
)
|
|
713
|
+
external
|
|
714
|
+
view
|
|
715
|
+
override
|
|
716
|
+
returns (uint256 supply, uint256 surplus, uint256 balance)
|
|
717
|
+
{
|
|
718
|
+
// Get the current ruleset to look up the stored extra hook.
|
|
719
|
+
IJBController controller = IJBController(address(DIRECTORY.controllerOf(projectId)));
|
|
720
|
+
(JBRuleset memory ruleset,) = controller.currentRulesetOf(projectId);
|
|
721
|
+
|
|
722
|
+
// Look up the extra data hook for this project's current ruleset.
|
|
723
|
+
JBDeployerHookConfig memory extraHook = _extraDataHookOf[projectId][ruleset.id];
|
|
724
|
+
if (address(extraHook.dataHook) == address(0)) return (0, 0, 0);
|
|
725
|
+
|
|
726
|
+
// Forward via staticcall — the extra hook may or may not implement IJBPeerChainAdjustedAccounts.
|
|
727
|
+
(bool success, bytes memory data) = address(extraHook.dataHook)
|
|
728
|
+
.staticcall(
|
|
729
|
+
abi.encodeCall(
|
|
730
|
+
IJBPeerChainAdjustedAccounts.peerChainAdjustedAccountsOf, (projectId, decimals, currency)
|
|
731
|
+
)
|
|
732
|
+
);
|
|
733
|
+
if (!success || data.length < 96) return (0, 0, 0);
|
|
734
|
+
|
|
735
|
+
return abi.decode(data, (uint256, uint256, uint256));
|
|
736
|
+
}
|
|
737
|
+
|
|
694
738
|
//*********************************************************************//
|
|
695
739
|
// -------------------------- public views --------------------------- //
|
|
696
740
|
//*********************************************************************//
|
|
@@ -700,8 +744,9 @@ contract JBOmnichainDeployer is
|
|
|
700
744
|
/// @return A flag indicating if the provided interface ID is supported.
|
|
701
745
|
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
|
|
702
746
|
return interfaceId == type(IJBOmnichainDeployer).interfaceId
|
|
703
|
-
|| interfaceId == type(IJBRulesetDataHook).interfaceId
|
|
704
|
-
|| interfaceId == type(
|
|
747
|
+
|| interfaceId == type(IJBRulesetDataHook).interfaceId
|
|
748
|
+
|| interfaceId == type(IJBPeerChainAdjustedAccounts).interfaceId
|
|
749
|
+
|| interfaceId == type(IERC721Receiver).interfaceId || interfaceId == type(IERC165).interfaceId;
|
|
705
750
|
}
|
|
706
751
|
|
|
707
752
|
//*********************************************************************//
|