-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CustomEntitlement -> CrossChainEntitlement implementation in go (#1083)
The `ICrossChainEntitlement` type replaces `ICustomEntitlement` and takes an abi-encoded byte array of parameters that is decoded by the contract according to it's own application-specific logic. This PR migrates the ISENTITLED check type to expect ICrossChainEntitlement interfaces for ISENTITLED contracts and uses the v2 check type to encode the parameter byte array for passing directly to the contract. A follow-up PR will be released that implements the typescript change and re-enables e2e tests to complete #1046.
- Loading branch information
Showing
29 changed files
with
1,529 additions
and
782 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
import {ICrossChainEntitlement} from "contracts/src/spaces/entitlements/ICrossChainEntitlement.sol"; | ||
|
||
contract MockCrossChainEntitlement is ICrossChainEntitlement { | ||
mapping(bytes32 => bool) public isEntitledByUserAndId; | ||
|
||
function setIsEntitled(uint256 id, address user, bool entitled) external { | ||
bytes32 hash = keccak256(abi.encode(user, id)); | ||
isEntitledByUserAndId[hash] = entitled; | ||
} | ||
|
||
function isEntitled( | ||
address[] calldata users, | ||
bytes calldata data | ||
) external view returns (bool) { | ||
uint256 id = abi.decode(data, (uint256)); | ||
for (uint256 i = 0; i < users.length; ++i) { | ||
bytes32 hash = keccak256(abi.encode(users[i], id)); | ||
if (isEntitledByUserAndId[hash]) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
function parameters() external pure returns (Parameter[] memory) { | ||
Parameter[] memory schema = new Parameter[](1); | ||
schema[0] = Parameter("id", "uint256", "Simple parameter type for testing"); | ||
return schema; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
324 changes: 324 additions & 0 deletions
324
core/contracts/base/deploy/mock_cross_chain_entitlement.go
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.