@bananapus/omnichain-deployers-v6 0.0.62 → 0.0.64

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/omnichain-deployers-v6",
3
- "version": "0.0.62",
3
+ "version": "0.0.64",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,16 +24,16 @@
24
24
  "artifacts": "source ./.env && npx sphinx artifacts --org-id 'ea165b21-7cdc-4d7b-be59-ecdd4c26bee4' --project-name 'nana-omnichain-deployers-v6'"
25
25
  },
26
26
  "dependencies": {
27
- "@bananapus/721-hook-v6": "^0.0.73",
28
- "@bananapus/core-v6": "^0.0.86",
29
- "@bananapus/ownable-v6": "^0.0.39",
30
- "@bananapus/permission-ids-v6": "^0.0.31",
31
- "@bananapus/suckers-v6": "^0.0.73",
27
+ "@bananapus/721-hook-v6": "^0.0.76",
28
+ "@bananapus/core-v6": "^0.0.87",
29
+ "@bananapus/ownable-v6": "^0.0.40",
30
+ "@bananapus/permission-ids-v6": "^0.0.32",
31
+ "@bananapus/suckers-v6": "^0.0.76",
32
32
  "@openzeppelin/contracts": "5.6.1"
33
33
  },
34
34
  "devDependencies": {
35
- "@bananapus/address-registry-v6": "^0.0.35",
36
- "@bananapus/buyback-hook-v6": "^0.0.71",
35
+ "@bananapus/address-registry-v6": "^0.0.36",
36
+ "@bananapus/buyback-hook-v6": "^0.0.73",
37
37
  "@sphinx-labs/plugins": "0.33.3",
38
38
  "@uniswap/v4-core": "1.0.2"
39
39
  }
@@ -22,6 +22,7 @@ import {JBOwnable} from "@bananapus/ownable-v6/src/JBOwnable.sol";
22
22
  import {JBPermissionIds} from "@bananapus/permission-ids-v6/src/JBPermissionIds.sol";
23
23
  import {IJBPeerChainAdjustedAccounts} from "@bananapus/suckers-v6/src/interfaces/IJBPeerChainAdjustedAccounts.sol";
24
24
  import {IJBSuckerRegistry} from "@bananapus/suckers-v6/src/interfaces/IJBSuckerRegistry.sol";
25
+ import {JBPeerChainAdjustedAccountsLib} from "@bananapus/suckers-v6/src/libraries/JBPeerChainAdjustedAccountsLib.sol";
25
26
  import {JBSourceContext} from "@bananapus/suckers-v6/src/structs/JBSourceContext.sol";
26
27
  import {ERC2771Context} from "@openzeppelin/contracts/metatx/ERC2771Context.sol";
27
28
  import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
@@ -712,7 +713,7 @@ contract JBOmnichainDeployer is
712
713
 
713
714
  if (!success) return (0, new JBSourceContext[](0));
714
715
 
715
- return _peerChainAdjustedAccountsFrom(data);
716
+ return JBPeerChainAdjustedAccountsLib.decode(data);
716
717
  }
717
718
 
718
719
  //*********************************************************************//
@@ -1056,98 +1057,6 @@ contract JBOmnichainDeployer is
1056
1057
  return ERC2771Context._msgSender();
1057
1058
  }
1058
1059
 
1059
- /// @notice Decodes a peer-chain adjusted accounting return, falling back to no contribution if malformed.
1060
- /// @param data The raw return data from an extra hook's `peerChainAdjustedAccountsOf` call.
1061
- /// @return supply The extra supply to include in `sourceTotalSupply`.
1062
- /// @return contexts The extra per-context surplus and balance to include in the snapshot, un-valued.
1063
- function _peerChainAdjustedAccountsFrom(bytes memory data)
1064
- internal
1065
- pure
1066
- returns (uint256 supply, JBSourceContext[] memory contexts)
1067
- {
1068
- // `data` is a Solidity `bytes` value. Its first memory word is the byte length, and the ABI return payload
1069
- // starts at `data + 32`.
1070
- //
1071
- // The payload for `(uint256, JBSourceContext[])` is:
1072
- // word 0: supply
1073
- // word 1: offset to the dynamic `contexts` array tail, relative to the payload start
1074
- // tail word 0: contexts.length
1075
- // tail words: each `JBSourceContext`, encoded as 4 ABI words.
1076
- //
1077
- // Anything shorter than the two tuple head words plus the array-length word cannot be decoded safely.
1078
- if (data.length < 96) return (0, new JBSourceContext[](0));
1079
-
1080
- uint256 contextsOffset;
1081
- assembly ("memory-safe") {
1082
- // Skip the `bytes` length word, then read the first two ABI words from the payload head.
1083
- supply := mload(add(data, 32))
1084
- contextsOffset := mload(add(data, 64))
1085
- }
1086
-
1087
- // The array tail must begin after the two-word tuple head, remain ABI-word aligned, and leave room for its own
1088
- // length word. If the offset points into the head, into the middle of a word, or past the buffer, a normal
1089
- // `abi.decode` would revert. This wrapper instead treats the optional hook contribution as absent.
1090
- if (contextsOffset < 64 || contextsOffset % 32 != 0 || contextsOffset > data.length - 32) {
1091
- return (0, new JBSourceContext[](0));
1092
- }
1093
-
1094
- uint256 contextCount;
1095
- assembly ("memory-safe") {
1096
- // The offset is relative to the payload start (`data + 32`), not the start of the `bytes` object.
1097
- contextCount := mload(add(add(data, 32), contextsOffset))
1098
- }
1099
-
1100
- // Skip the array-length word to reach the first encoded `JBSourceContext`.
1101
- uint256 contextsStart = contextsOffset + 32;
1102
- // Each `JBSourceContext` has four static ABI words: token, decimals, surplus, and balance. Check the count
1103
- // against the remaining bytes before allocating the array so a hostile length cannot force a large allocation
1104
- // or make the loop read past the returned buffer.
1105
- if (contextCount > (data.length - contextsStart) / 128) return (0, new JBSourceContext[](0));
1106
-
1107
- contexts = new JBSourceContext[](contextCount);
1108
-
1109
- for (uint256 i; i < contextCount; i++) {
1110
- // Move to the encoded struct for this index. The offset is still payload-relative.
1111
- uint256 contextOffset = contextsStart + i * 128;
1112
- bytes32 token;
1113
- uint256 decimals;
1114
- uint256 surplus;
1115
- uint256 contextBalance;
1116
-
1117
- assembly ("memory-safe") {
1118
- // Point at the first word of this encoded struct and read its four ABI words directly.
1119
- let contextPointer := add(add(data, 32), contextOffset)
1120
- token := mload(contextPointer)
1121
- decimals := mload(add(contextPointer, 32))
1122
- surplus := mload(add(contextPointer, 64))
1123
- contextBalance := mload(add(contextPointer, 96))
1124
- }
1125
-
1126
- // The ABI decoder would reject values that do not fit their declared Solidity types. Because this function
1127
- // decodes manually, it must enforce the same bounds before casting so malformed data cannot silently
1128
- // truncate into `uint8` or `uint128`.
1129
- if (decimals > type(uint8).max || surplus > type(uint128).max || contextBalance > type(uint128).max) {
1130
- return (0, new JBSourceContext[](0));
1131
- }
1132
-
1133
- // Store the checked values using the struct's real types. At this point every read was inside the buffer
1134
- // and every narrowed cast has been proven safe.
1135
- // Casting to `uint8` is safe because the guard above rejected larger values.
1136
- // forge-lint: disable-next-line(unsafe-typecast)
1137
- uint8 checkedDecimals = uint8(decimals);
1138
- // Casting to `uint128` is safe because the guard above rejected larger values.
1139
- // forge-lint: disable-next-line(unsafe-typecast)
1140
- uint128 checkedSurplus = uint128(surplus);
1141
- // Casting to `uint128` is safe because the guard above rejected larger values.
1142
- // forge-lint: disable-next-line(unsafe-typecast)
1143
- uint128 checkedBalance = uint128(contextBalance);
1144
-
1145
- contexts[i] = JBSourceContext({
1146
- token: token, decimals: checkedDecimals, surplus: checkedSurplus, balance: checkedBalance
1147
- });
1148
- }
1149
- }
1150
-
1151
1060
  /// @notice Revert unless the trusted directory records `CONTROLLER` for `projectId`.
1152
1061
  /// @dev Use `allowUnset = true` as a pre-launch check: a fresh project with no controller wired yet is accepted.
1153
1062
  /// Use `allowUnset = false` as a post-launch check: `CONTROLLER` must be live in the directory.