diff --git a/contracts/test/mocks/MockCrossChainEntitlement.sol b/contracts/test/mocks/MockCrossChainEntitlement.sol new file mode 100644 index 000000000..81531af6d --- /dev/null +++ b/contracts/test/mocks/MockCrossChainEntitlement.sol @@ -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; + } +} diff --git a/core/cmd/run_cs.go b/core/cmd/run_cs.go index 0a2c2db43..86ab3cea1 100644 --- a/core/cmd/run_cs.go +++ b/core/cmd/run_cs.go @@ -70,10 +70,6 @@ out: go xc.RunClientSimulator(bc, cmdConfig, wallet, xc.ERC20) case 'b': go xc.RunClientSimulator(bc, cmdConfig, wallet, xc.ERC721) - case 'c': - go xc.RunClientSimulator(bc, cmdConfig, wallet, xc.ISENTITLED) - case 'd': - go xc.RunClientSimulator(bc, cmdConfig, wallet, xc.TOGGLEISENTITLED) case 'q': log.Info("Quit Exit") break out diff --git a/core/contracts/base/deploy/mock_cross_chain_entitlement.go b/core/contracts/base/deploy/mock_cross_chain_entitlement.go new file mode 100644 index 000000000..f46e139bf --- /dev/null +++ b/core/contracts/base/deploy/mock_cross_chain_entitlement.go @@ -0,0 +1,324 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package deploy + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// ICrossChainEntitlementParameter is an auto generated low-level Go binding around an user-defined struct. +type ICrossChainEntitlementParameter struct { + Name string + Primitive string + Description string +} + +// MockCrossChainEntitlementMetaData contains all meta data concerning the MockCrossChainEntitlement contract. +var MockCrossChainEntitlementMetaData = &bind.MetaData{ + ABI: "[{\"type\":\"function\",\"name\":\"isEntitled\",\"inputs\":[{\"name\":\"users\",\"type\":\"address[]\",\"internalType\":\"address[]\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"isEntitledByUserAndId\",\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"parameters\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"tuple[]\",\"internalType\":\"structICrossChainEntitlement.Parameter[]\",\"components\":[{\"name\":\"name\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"primitive\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"description\",\"type\":\"string\",\"internalType\":\"string\"}]}],\"stateMutability\":\"pure\"},{\"type\":\"function\",\"name\":\"setIsEntitled\",\"inputs\":[{\"name\":\"id\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"user\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"entitled\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"}]", + Bin: "0x608060405234801561001057600080fd5b50610531806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806316089f65146100515780637addd58714610079578063890357301461009c578063b48900e8146100b1575b600080fd5b61006461005f3660046102af565b610118565b60405190151581526020015b60405180910390f35b610064610087366004610374565b60006020819052908152604090205460ff1681565b6100a46101cc565b60405161007091906103d3565b6101166100bf366004610492565b604080516001600160a01b038416602082015290810184905260009060600160408051808303601f1901815291815281516020928301206000908152918290529020805460ff191692151592909217909155505050565b005b60008061012783850185610374565b905060005b858110156101bd576000878783818110610148576101486104d7565b905060200201602081019061015d91906104ed565b604080516001600160a01b039092166020830152810184905260600160408051601f19818403018152918152815160209283012060008181529283905291205490915060ff16156101b457600193505050506101c4565b5060010161012c565b5060009150505b949350505050565b60408051600180825281830190925260609160009190816020015b61020b60405180606001604052806060815260200160608152602001606081525090565b8152602001906001900390816101e75790505090506040518060600160405280604051806040016040528060028152602001611a5960f21b8152508152602001604051806040016040528060078152602001663ab4b73a191a9b60c91b8152508152602001604051806060016040528060218152602001610510602191398152508160008151811061029f5761029f6104d7565b6020908102919091010152919050565b600080600080604085870312156102c557600080fd5b843567ffffffffffffffff808211156102dd57600080fd5b818701915087601f8301126102f157600080fd5b81358181111561030057600080fd5b8860208260051b850101111561031557600080fd5b60209283019650945090860135908082111561033057600080fd5b818701915087601f83011261034457600080fd5b81358181111561035357600080fd5b88602082850101111561036557600080fd5b95989497505060200194505050565b60006020828403121561038657600080fd5b5035919050565b6000815180845260005b818110156103b357602081850181015186830182015201610397565b506000602082860101526020601f19601f83011685010191505092915050565b600060208083018184528085518083526040925060408601915060408160051b87010184880160005b8381101561046857603f198984030185528151606081518186526104228287018261038d565b915050888201518582038a87015261043a828261038d565b91505087820151915084810388860152610454818361038d565b9689019694505050908601906001016103fc565b509098975050505050505050565b80356001600160a01b038116811461048d57600080fd5b919050565b6000806000606084860312156104a757600080fd5b833592506104b760208501610476565b9150604084013580151581146104cc57600080fd5b809150509250925092565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156104ff57600080fd5b61050882610476565b939250505056fe53696d706c6520706172616d65746572207479706520666f722074657374696e67", +} + +// MockCrossChainEntitlementABI is the input ABI used to generate the binding from. +// Deprecated: Use MockCrossChainEntitlementMetaData.ABI instead. +var MockCrossChainEntitlementABI = MockCrossChainEntitlementMetaData.ABI + +// MockCrossChainEntitlementBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use MockCrossChainEntitlementMetaData.Bin instead. +var MockCrossChainEntitlementBin = MockCrossChainEntitlementMetaData.Bin + +// DeployMockCrossChainEntitlement deploys a new Ethereum contract, binding an instance of MockCrossChainEntitlement to it. +func DeployMockCrossChainEntitlement(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *MockCrossChainEntitlement, error) { + parsed, err := MockCrossChainEntitlementMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + if parsed == nil { + return common.Address{}, nil, nil, errors.New("GetABI returned nil") + } + + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(MockCrossChainEntitlementBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &MockCrossChainEntitlement{MockCrossChainEntitlementCaller: MockCrossChainEntitlementCaller{contract: contract}, MockCrossChainEntitlementTransactor: MockCrossChainEntitlementTransactor{contract: contract}, MockCrossChainEntitlementFilterer: MockCrossChainEntitlementFilterer{contract: contract}}, nil +} + +// MockCrossChainEntitlement is an auto generated Go binding around an Ethereum contract. +type MockCrossChainEntitlement struct { + MockCrossChainEntitlementCaller // Read-only binding to the contract + MockCrossChainEntitlementTransactor // Write-only binding to the contract + MockCrossChainEntitlementFilterer // Log filterer for contract events +} + +// MockCrossChainEntitlementCaller is an auto generated read-only Go binding around an Ethereum contract. +type MockCrossChainEntitlementCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// MockCrossChainEntitlementTransactor is an auto generated write-only Go binding around an Ethereum contract. +type MockCrossChainEntitlementTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// MockCrossChainEntitlementFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type MockCrossChainEntitlementFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// MockCrossChainEntitlementSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type MockCrossChainEntitlementSession struct { + Contract *MockCrossChainEntitlement // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// MockCrossChainEntitlementCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type MockCrossChainEntitlementCallerSession struct { + Contract *MockCrossChainEntitlementCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// MockCrossChainEntitlementTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type MockCrossChainEntitlementTransactorSession struct { + Contract *MockCrossChainEntitlementTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// MockCrossChainEntitlementRaw is an auto generated low-level Go binding around an Ethereum contract. +type MockCrossChainEntitlementRaw struct { + Contract *MockCrossChainEntitlement // Generic contract binding to access the raw methods on +} + +// MockCrossChainEntitlementCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type MockCrossChainEntitlementCallerRaw struct { + Contract *MockCrossChainEntitlementCaller // Generic read-only contract binding to access the raw methods on +} + +// MockCrossChainEntitlementTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type MockCrossChainEntitlementTransactorRaw struct { + Contract *MockCrossChainEntitlementTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewMockCrossChainEntitlement creates a new instance of MockCrossChainEntitlement, bound to a specific deployed contract. +func NewMockCrossChainEntitlement(address common.Address, backend bind.ContractBackend) (*MockCrossChainEntitlement, error) { + contract, err := bindMockCrossChainEntitlement(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &MockCrossChainEntitlement{MockCrossChainEntitlementCaller: MockCrossChainEntitlementCaller{contract: contract}, MockCrossChainEntitlementTransactor: MockCrossChainEntitlementTransactor{contract: contract}, MockCrossChainEntitlementFilterer: MockCrossChainEntitlementFilterer{contract: contract}}, nil +} + +// NewMockCrossChainEntitlementCaller creates a new read-only instance of MockCrossChainEntitlement, bound to a specific deployed contract. +func NewMockCrossChainEntitlementCaller(address common.Address, caller bind.ContractCaller) (*MockCrossChainEntitlementCaller, error) { + contract, err := bindMockCrossChainEntitlement(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &MockCrossChainEntitlementCaller{contract: contract}, nil +} + +// NewMockCrossChainEntitlementTransactor creates a new write-only instance of MockCrossChainEntitlement, bound to a specific deployed contract. +func NewMockCrossChainEntitlementTransactor(address common.Address, transactor bind.ContractTransactor) (*MockCrossChainEntitlementTransactor, error) { + contract, err := bindMockCrossChainEntitlement(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &MockCrossChainEntitlementTransactor{contract: contract}, nil +} + +// NewMockCrossChainEntitlementFilterer creates a new log filterer instance of MockCrossChainEntitlement, bound to a specific deployed contract. +func NewMockCrossChainEntitlementFilterer(address common.Address, filterer bind.ContractFilterer) (*MockCrossChainEntitlementFilterer, error) { + contract, err := bindMockCrossChainEntitlement(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &MockCrossChainEntitlementFilterer{contract: contract}, nil +} + +// bindMockCrossChainEntitlement binds a generic wrapper to an already deployed contract. +func bindMockCrossChainEntitlement(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := MockCrossChainEntitlementMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_MockCrossChainEntitlement *MockCrossChainEntitlementRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _MockCrossChainEntitlement.Contract.MockCrossChainEntitlementCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_MockCrossChainEntitlement *MockCrossChainEntitlementRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _MockCrossChainEntitlement.Contract.MockCrossChainEntitlementTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_MockCrossChainEntitlement *MockCrossChainEntitlementRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _MockCrossChainEntitlement.Contract.MockCrossChainEntitlementTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_MockCrossChainEntitlement *MockCrossChainEntitlementCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _MockCrossChainEntitlement.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_MockCrossChainEntitlement *MockCrossChainEntitlementTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _MockCrossChainEntitlement.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_MockCrossChainEntitlement *MockCrossChainEntitlementTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _MockCrossChainEntitlement.Contract.contract.Transact(opts, method, params...) +} + +// IsEntitled is a free data retrieval call binding the contract method 0x16089f65. +// +// Solidity: function isEntitled(address[] users, bytes data) view returns(bool) +func (_MockCrossChainEntitlement *MockCrossChainEntitlementCaller) IsEntitled(opts *bind.CallOpts, users []common.Address, data []byte) (bool, error) { + var out []interface{} + err := _MockCrossChainEntitlement.contract.Call(opts, &out, "isEntitled", users, data) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// IsEntitled is a free data retrieval call binding the contract method 0x16089f65. +// +// Solidity: function isEntitled(address[] users, bytes data) view returns(bool) +func (_MockCrossChainEntitlement *MockCrossChainEntitlementSession) IsEntitled(users []common.Address, data []byte) (bool, error) { + return _MockCrossChainEntitlement.Contract.IsEntitled(&_MockCrossChainEntitlement.CallOpts, users, data) +} + +// IsEntitled is a free data retrieval call binding the contract method 0x16089f65. +// +// Solidity: function isEntitled(address[] users, bytes data) view returns(bool) +func (_MockCrossChainEntitlement *MockCrossChainEntitlementCallerSession) IsEntitled(users []common.Address, data []byte) (bool, error) { + return _MockCrossChainEntitlement.Contract.IsEntitled(&_MockCrossChainEntitlement.CallOpts, users, data) +} + +// IsEntitledByUserAndId is a free data retrieval call binding the contract method 0x7addd587. +// +// Solidity: function isEntitledByUserAndId(bytes32 ) view returns(bool) +func (_MockCrossChainEntitlement *MockCrossChainEntitlementCaller) IsEntitledByUserAndId(opts *bind.CallOpts, arg0 [32]byte) (bool, error) { + var out []interface{} + err := _MockCrossChainEntitlement.contract.Call(opts, &out, "isEntitledByUserAndId", arg0) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// IsEntitledByUserAndId is a free data retrieval call binding the contract method 0x7addd587. +// +// Solidity: function isEntitledByUserAndId(bytes32 ) view returns(bool) +func (_MockCrossChainEntitlement *MockCrossChainEntitlementSession) IsEntitledByUserAndId(arg0 [32]byte) (bool, error) { + return _MockCrossChainEntitlement.Contract.IsEntitledByUserAndId(&_MockCrossChainEntitlement.CallOpts, arg0) +} + +// IsEntitledByUserAndId is a free data retrieval call binding the contract method 0x7addd587. +// +// Solidity: function isEntitledByUserAndId(bytes32 ) view returns(bool) +func (_MockCrossChainEntitlement *MockCrossChainEntitlementCallerSession) IsEntitledByUserAndId(arg0 [32]byte) (bool, error) { + return _MockCrossChainEntitlement.Contract.IsEntitledByUserAndId(&_MockCrossChainEntitlement.CallOpts, arg0) +} + +// Parameters is a free data retrieval call binding the contract method 0x89035730. +// +// Solidity: function parameters() pure returns((string,string,string)[]) +func (_MockCrossChainEntitlement *MockCrossChainEntitlementCaller) Parameters(opts *bind.CallOpts) ([]ICrossChainEntitlementParameter, error) { + var out []interface{} + err := _MockCrossChainEntitlement.contract.Call(opts, &out, "parameters") + + if err != nil { + return *new([]ICrossChainEntitlementParameter), err + } + + out0 := *abi.ConvertType(out[0], new([]ICrossChainEntitlementParameter)).(*[]ICrossChainEntitlementParameter) + + return out0, err + +} + +// Parameters is a free data retrieval call binding the contract method 0x89035730. +// +// Solidity: function parameters() pure returns((string,string,string)[]) +func (_MockCrossChainEntitlement *MockCrossChainEntitlementSession) Parameters() ([]ICrossChainEntitlementParameter, error) { + return _MockCrossChainEntitlement.Contract.Parameters(&_MockCrossChainEntitlement.CallOpts) +} + +// Parameters is a free data retrieval call binding the contract method 0x89035730. +// +// Solidity: function parameters() pure returns((string,string,string)[]) +func (_MockCrossChainEntitlement *MockCrossChainEntitlementCallerSession) Parameters() ([]ICrossChainEntitlementParameter, error) { + return _MockCrossChainEntitlement.Contract.Parameters(&_MockCrossChainEntitlement.CallOpts) +} + +// SetIsEntitled is a paid mutator transaction binding the contract method 0xb48900e8. +// +// Solidity: function setIsEntitled(uint256 id, address user, bool entitled) returns() +func (_MockCrossChainEntitlement *MockCrossChainEntitlementTransactor) SetIsEntitled(opts *bind.TransactOpts, id *big.Int, user common.Address, entitled bool) (*types.Transaction, error) { + return _MockCrossChainEntitlement.contract.Transact(opts, "setIsEntitled", id, user, entitled) +} + +// SetIsEntitled is a paid mutator transaction binding the contract method 0xb48900e8. +// +// Solidity: function setIsEntitled(uint256 id, address user, bool entitled) returns() +func (_MockCrossChainEntitlement *MockCrossChainEntitlementSession) SetIsEntitled(id *big.Int, user common.Address, entitled bool) (*types.Transaction, error) { + return _MockCrossChainEntitlement.Contract.SetIsEntitled(&_MockCrossChainEntitlement.TransactOpts, id, user, entitled) +} + +// SetIsEntitled is a paid mutator transaction binding the contract method 0xb48900e8. +// +// Solidity: function setIsEntitled(uint256 id, address user, bool entitled) returns() +func (_MockCrossChainEntitlement *MockCrossChainEntitlementTransactorSession) SetIsEntitled(id *big.Int, user common.Address, entitled bool) (*types.Transaction, error) { + return _MockCrossChainEntitlement.Contract.SetIsEntitled(&_MockCrossChainEntitlement.TransactOpts, id, user, entitled) +} diff --git a/core/contracts/base/deploy/mock_custom_entitlement.go b/core/contracts/base/deploy/mock_custom_entitlement.go deleted file mode 100644 index 926775fd2..000000000 --- a/core/contracts/base/deploy/mock_custom_entitlement.go +++ /dev/null @@ -1,286 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package deploy - -import ( - "errors" - "math/big" - "strings" - - ethereum "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/event" -) - -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = errors.New - _ = big.NewInt - _ = strings.NewReader - _ = ethereum.NotFound - _ = bind.Bind - _ = common.Big1 - _ = types.BloomLookup - _ = event.NewSubscription - _ = abi.ConvertType -) - -// MockCustomEntitlementMetaData contains all meta data concerning the MockCustomEntitlement contract. -var MockCustomEntitlementMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"constructor\",\"inputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"isEntitled\",\"inputs\":[{\"name\":\"users\",\"type\":\"address[]\",\"internalType\":\"address[]\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"setEntitled\",\"inputs\":[{\"name\":\"users\",\"type\":\"address[]\",\"internalType\":\"address[]\"},{\"name\":\"userIsEntitled\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"supportsInterface\",\"inputs\":[{\"name\":\"interfaceId\",\"type\":\"bytes4\",\"internalType\":\"bytes4\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"}]", - Bin: "0x608060405234801561001057600080fd5b50610377806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806301ffc9a7146100465780633f4c4d831461007e578063ddc6e68e14610093575b600080fd5b61006a6100543660046101c5565b6001600160e01b031916636ee3734760e11b1490565b604051901515815260200160405180910390f35b61009161008c3660046102cd565b6100a6565b005b61006a6100a1366004610324565b610130565b60005b825181101561012b57816000808584815181106100c8576100c8610361565b60200260200101516040516020016100ef91906001600160a01b0391909116815260200190565b60408051808303601f19018152918152815160209283012083529082019290925201600020805460ff19169115159190911790556001016100a9565b505050565b6000805b82518110156101bc5760008084838151811061015257610152610361565b602002602001015160405160200161017991906001600160a01b0391909116815260200190565b60408051601f198184030181529181528151602092830120835290820192909252016000205460ff1615156001036101b45750600192915050565b600101610134565b50600092915050565b6000602082840312156101d757600080fd5b81356001600160e01b0319811681146101ef57600080fd5b9392505050565b634e487b7160e01b600052604160045260246000fd5b80356001600160a01b038116811461022357600080fd5b919050565b600082601f83011261023957600080fd5b8135602067ffffffffffffffff80831115610256576102566101f6565b8260051b604051601f19603f8301168101818110848211171561027b5761027b6101f6565b604052938452602081870181019490810192508785111561029b57600080fd5b6020870191505b848210156102c2576102b38261020c565b835291830191908301906102a2565b979650505050505050565b600080604083850312156102e057600080fd5b823567ffffffffffffffff8111156102f757600080fd5b61030385828601610228565b9250506020830135801515811461031957600080fd5b809150509250929050565b60006020828403121561033657600080fd5b813567ffffffffffffffff81111561034d57600080fd5b61035984828501610228565b949350505050565b634e487b7160e01b600052603260045260246000fd", -} - -// MockCustomEntitlementABI is the input ABI used to generate the binding from. -// Deprecated: Use MockCustomEntitlementMetaData.ABI instead. -var MockCustomEntitlementABI = MockCustomEntitlementMetaData.ABI - -// MockCustomEntitlementBin is the compiled bytecode used for deploying new contracts. -// Deprecated: Use MockCustomEntitlementMetaData.Bin instead. -var MockCustomEntitlementBin = MockCustomEntitlementMetaData.Bin - -// DeployMockCustomEntitlement deploys a new Ethereum contract, binding an instance of MockCustomEntitlement to it. -func DeployMockCustomEntitlement(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *MockCustomEntitlement, error) { - parsed, err := MockCustomEntitlementMetaData.GetAbi() - if err != nil { - return common.Address{}, nil, nil, err - } - if parsed == nil { - return common.Address{}, nil, nil, errors.New("GetABI returned nil") - } - - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(MockCustomEntitlementBin), backend) - if err != nil { - return common.Address{}, nil, nil, err - } - return address, tx, &MockCustomEntitlement{MockCustomEntitlementCaller: MockCustomEntitlementCaller{contract: contract}, MockCustomEntitlementTransactor: MockCustomEntitlementTransactor{contract: contract}, MockCustomEntitlementFilterer: MockCustomEntitlementFilterer{contract: contract}}, nil -} - -// MockCustomEntitlement is an auto generated Go binding around an Ethereum contract. -type MockCustomEntitlement struct { - MockCustomEntitlementCaller // Read-only binding to the contract - MockCustomEntitlementTransactor // Write-only binding to the contract - MockCustomEntitlementFilterer // Log filterer for contract events -} - -// MockCustomEntitlementCaller is an auto generated read-only Go binding around an Ethereum contract. -type MockCustomEntitlementCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// MockCustomEntitlementTransactor is an auto generated write-only Go binding around an Ethereum contract. -type MockCustomEntitlementTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// MockCustomEntitlementFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type MockCustomEntitlementFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// MockCustomEntitlementSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type MockCustomEntitlementSession struct { - Contract *MockCustomEntitlement // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// MockCustomEntitlementCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type MockCustomEntitlementCallerSession struct { - Contract *MockCustomEntitlementCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// MockCustomEntitlementTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type MockCustomEntitlementTransactorSession struct { - Contract *MockCustomEntitlementTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// MockCustomEntitlementRaw is an auto generated low-level Go binding around an Ethereum contract. -type MockCustomEntitlementRaw struct { - Contract *MockCustomEntitlement // Generic contract binding to access the raw methods on -} - -// MockCustomEntitlementCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type MockCustomEntitlementCallerRaw struct { - Contract *MockCustomEntitlementCaller // Generic read-only contract binding to access the raw methods on -} - -// MockCustomEntitlementTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type MockCustomEntitlementTransactorRaw struct { - Contract *MockCustomEntitlementTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewMockCustomEntitlement creates a new instance of MockCustomEntitlement, bound to a specific deployed contract. -func NewMockCustomEntitlement(address common.Address, backend bind.ContractBackend) (*MockCustomEntitlement, error) { - contract, err := bindMockCustomEntitlement(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &MockCustomEntitlement{MockCustomEntitlementCaller: MockCustomEntitlementCaller{contract: contract}, MockCustomEntitlementTransactor: MockCustomEntitlementTransactor{contract: contract}, MockCustomEntitlementFilterer: MockCustomEntitlementFilterer{contract: contract}}, nil -} - -// NewMockCustomEntitlementCaller creates a new read-only instance of MockCustomEntitlement, bound to a specific deployed contract. -func NewMockCustomEntitlementCaller(address common.Address, caller bind.ContractCaller) (*MockCustomEntitlementCaller, error) { - contract, err := bindMockCustomEntitlement(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &MockCustomEntitlementCaller{contract: contract}, nil -} - -// NewMockCustomEntitlementTransactor creates a new write-only instance of MockCustomEntitlement, bound to a specific deployed contract. -func NewMockCustomEntitlementTransactor(address common.Address, transactor bind.ContractTransactor) (*MockCustomEntitlementTransactor, error) { - contract, err := bindMockCustomEntitlement(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &MockCustomEntitlementTransactor{contract: contract}, nil -} - -// NewMockCustomEntitlementFilterer creates a new log filterer instance of MockCustomEntitlement, bound to a specific deployed contract. -func NewMockCustomEntitlementFilterer(address common.Address, filterer bind.ContractFilterer) (*MockCustomEntitlementFilterer, error) { - contract, err := bindMockCustomEntitlement(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &MockCustomEntitlementFilterer{contract: contract}, nil -} - -// bindMockCustomEntitlement binds a generic wrapper to an already deployed contract. -func bindMockCustomEntitlement(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := MockCustomEntitlementMetaData.GetAbi() - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_MockCustomEntitlement *MockCustomEntitlementRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _MockCustomEntitlement.Contract.MockCustomEntitlementCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_MockCustomEntitlement *MockCustomEntitlementRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _MockCustomEntitlement.Contract.MockCustomEntitlementTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_MockCustomEntitlement *MockCustomEntitlementRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _MockCustomEntitlement.Contract.MockCustomEntitlementTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_MockCustomEntitlement *MockCustomEntitlementCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _MockCustomEntitlement.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_MockCustomEntitlement *MockCustomEntitlementTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _MockCustomEntitlement.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_MockCustomEntitlement *MockCustomEntitlementTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _MockCustomEntitlement.Contract.contract.Transact(opts, method, params...) -} - -// IsEntitled is a free data retrieval call binding the contract method 0xddc6e68e. -// -// Solidity: function isEntitled(address[] users) view returns(bool) -func (_MockCustomEntitlement *MockCustomEntitlementCaller) IsEntitled(opts *bind.CallOpts, users []common.Address) (bool, error) { - var out []interface{} - err := _MockCustomEntitlement.contract.Call(opts, &out, "isEntitled", users) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// IsEntitled is a free data retrieval call binding the contract method 0xddc6e68e. -// -// Solidity: function isEntitled(address[] users) view returns(bool) -func (_MockCustomEntitlement *MockCustomEntitlementSession) IsEntitled(users []common.Address) (bool, error) { - return _MockCustomEntitlement.Contract.IsEntitled(&_MockCustomEntitlement.CallOpts, users) -} - -// IsEntitled is a free data retrieval call binding the contract method 0xddc6e68e. -// -// Solidity: function isEntitled(address[] users) view returns(bool) -func (_MockCustomEntitlement *MockCustomEntitlementCallerSession) IsEntitled(users []common.Address) (bool, error) { - return _MockCustomEntitlement.Contract.IsEntitled(&_MockCustomEntitlement.CallOpts, users) -} - -// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. -// -// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) -func (_MockCustomEntitlement *MockCustomEntitlementCaller) SupportsInterface(opts *bind.CallOpts, interfaceId [4]byte) (bool, error) { - var out []interface{} - err := _MockCustomEntitlement.contract.Call(opts, &out, "supportsInterface", interfaceId) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. -// -// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) -func (_MockCustomEntitlement *MockCustomEntitlementSession) SupportsInterface(interfaceId [4]byte) (bool, error) { - return _MockCustomEntitlement.Contract.SupportsInterface(&_MockCustomEntitlement.CallOpts, interfaceId) -} - -// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. -// -// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) -func (_MockCustomEntitlement *MockCustomEntitlementCallerSession) SupportsInterface(interfaceId [4]byte) (bool, error) { - return _MockCustomEntitlement.Contract.SupportsInterface(&_MockCustomEntitlement.CallOpts, interfaceId) -} - -// SetEntitled is a paid mutator transaction binding the contract method 0x3f4c4d83. -// -// Solidity: function setEntitled(address[] users, bool userIsEntitled) returns() -func (_MockCustomEntitlement *MockCustomEntitlementTransactor) SetEntitled(opts *bind.TransactOpts, users []common.Address, userIsEntitled bool) (*types.Transaction, error) { - return _MockCustomEntitlement.contract.Transact(opts, "setEntitled", users, userIsEntitled) -} - -// SetEntitled is a paid mutator transaction binding the contract method 0x3f4c4d83. -// -// Solidity: function setEntitled(address[] users, bool userIsEntitled) returns() -func (_MockCustomEntitlement *MockCustomEntitlementSession) SetEntitled(users []common.Address, userIsEntitled bool) (*types.Transaction, error) { - return _MockCustomEntitlement.Contract.SetEntitled(&_MockCustomEntitlement.TransactOpts, users, userIsEntitled) -} - -// SetEntitled is a paid mutator transaction binding the contract method 0x3f4c4d83. -// -// Solidity: function setEntitled(address[] users, bool userIsEntitled) returns() -func (_MockCustomEntitlement *MockCustomEntitlementTransactorSession) SetEntitled(users []common.Address, userIsEntitled bool) (*types.Transaction, error) { - return _MockCustomEntitlement.Contract.SetEntitled(&_MockCustomEntitlement.TransactOpts, users, userIsEntitled) -} diff --git a/core/contracts/base/i_cross_chain_entitlement.go b/core/contracts/base/i_cross_chain_entitlement.go new file mode 100644 index 000000000..fabd91f8e --- /dev/null +++ b/core/contracts/base/i_cross_chain_entitlement.go @@ -0,0 +1,250 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package base + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// ICrossChainEntitlementParameter is an auto generated low-level Go binding around an user-defined struct. +type ICrossChainEntitlementParameter struct { + Name string + Primitive string + Description string +} + +// ICrossChainEntitlementMetaData contains all meta data concerning the ICrossChainEntitlement contract. +var ICrossChainEntitlementMetaData = &bind.MetaData{ + ABI: "[{\"type\":\"function\",\"name\":\"isEntitled\",\"inputs\":[{\"name\":\"users\",\"type\":\"address[]\",\"internalType\":\"address[]\"},{\"name\":\"parameters\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"parameters\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"tuple[]\",\"internalType\":\"structICrossChainEntitlement.Parameter[]\",\"components\":[{\"name\":\"name\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"primitive\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"description\",\"type\":\"string\",\"internalType\":\"string\"}]}],\"stateMutability\":\"view\"}]", +} + +// ICrossChainEntitlementABI is the input ABI used to generate the binding from. +// Deprecated: Use ICrossChainEntitlementMetaData.ABI instead. +var ICrossChainEntitlementABI = ICrossChainEntitlementMetaData.ABI + +// ICrossChainEntitlement is an auto generated Go binding around an Ethereum contract. +type ICrossChainEntitlement struct { + ICrossChainEntitlementCaller // Read-only binding to the contract + ICrossChainEntitlementTransactor // Write-only binding to the contract + ICrossChainEntitlementFilterer // Log filterer for contract events +} + +// ICrossChainEntitlementCaller is an auto generated read-only Go binding around an Ethereum contract. +type ICrossChainEntitlementCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ICrossChainEntitlementTransactor is an auto generated write-only Go binding around an Ethereum contract. +type ICrossChainEntitlementTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ICrossChainEntitlementFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type ICrossChainEntitlementFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ICrossChainEntitlementSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type ICrossChainEntitlementSession struct { + Contract *ICrossChainEntitlement // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ICrossChainEntitlementCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type ICrossChainEntitlementCallerSession struct { + Contract *ICrossChainEntitlementCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// ICrossChainEntitlementTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type ICrossChainEntitlementTransactorSession struct { + Contract *ICrossChainEntitlementTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ICrossChainEntitlementRaw is an auto generated low-level Go binding around an Ethereum contract. +type ICrossChainEntitlementRaw struct { + Contract *ICrossChainEntitlement // Generic contract binding to access the raw methods on +} + +// ICrossChainEntitlementCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type ICrossChainEntitlementCallerRaw struct { + Contract *ICrossChainEntitlementCaller // Generic read-only contract binding to access the raw methods on +} + +// ICrossChainEntitlementTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type ICrossChainEntitlementTransactorRaw struct { + Contract *ICrossChainEntitlementTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewICrossChainEntitlement creates a new instance of ICrossChainEntitlement, bound to a specific deployed contract. +func NewICrossChainEntitlement(address common.Address, backend bind.ContractBackend) (*ICrossChainEntitlement, error) { + contract, err := bindICrossChainEntitlement(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &ICrossChainEntitlement{ICrossChainEntitlementCaller: ICrossChainEntitlementCaller{contract: contract}, ICrossChainEntitlementTransactor: ICrossChainEntitlementTransactor{contract: contract}, ICrossChainEntitlementFilterer: ICrossChainEntitlementFilterer{contract: contract}}, nil +} + +// NewICrossChainEntitlementCaller creates a new read-only instance of ICrossChainEntitlement, bound to a specific deployed contract. +func NewICrossChainEntitlementCaller(address common.Address, caller bind.ContractCaller) (*ICrossChainEntitlementCaller, error) { + contract, err := bindICrossChainEntitlement(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &ICrossChainEntitlementCaller{contract: contract}, nil +} + +// NewICrossChainEntitlementTransactor creates a new write-only instance of ICrossChainEntitlement, bound to a specific deployed contract. +func NewICrossChainEntitlementTransactor(address common.Address, transactor bind.ContractTransactor) (*ICrossChainEntitlementTransactor, error) { + contract, err := bindICrossChainEntitlement(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &ICrossChainEntitlementTransactor{contract: contract}, nil +} + +// NewICrossChainEntitlementFilterer creates a new log filterer instance of ICrossChainEntitlement, bound to a specific deployed contract. +func NewICrossChainEntitlementFilterer(address common.Address, filterer bind.ContractFilterer) (*ICrossChainEntitlementFilterer, error) { + contract, err := bindICrossChainEntitlement(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &ICrossChainEntitlementFilterer{contract: contract}, nil +} + +// bindICrossChainEntitlement binds a generic wrapper to an already deployed contract. +func bindICrossChainEntitlement(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := ICrossChainEntitlementMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ICrossChainEntitlement *ICrossChainEntitlementRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ICrossChainEntitlement.Contract.ICrossChainEntitlementCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ICrossChainEntitlement *ICrossChainEntitlementRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ICrossChainEntitlement.Contract.ICrossChainEntitlementTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ICrossChainEntitlement *ICrossChainEntitlementRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ICrossChainEntitlement.Contract.ICrossChainEntitlementTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ICrossChainEntitlement *ICrossChainEntitlementCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ICrossChainEntitlement.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ICrossChainEntitlement *ICrossChainEntitlementTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ICrossChainEntitlement.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ICrossChainEntitlement *ICrossChainEntitlementTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ICrossChainEntitlement.Contract.contract.Transact(opts, method, params...) +} + +// IsEntitled is a free data retrieval call binding the contract method 0x16089f65. +// +// Solidity: function isEntitled(address[] users, bytes parameters) view returns(bool) +func (_ICrossChainEntitlement *ICrossChainEntitlementCaller) IsEntitled(opts *bind.CallOpts, users []common.Address, parameters []byte) (bool, error) { + var out []interface{} + err := _ICrossChainEntitlement.contract.Call(opts, &out, "isEntitled", users, parameters) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// IsEntitled is a free data retrieval call binding the contract method 0x16089f65. +// +// Solidity: function isEntitled(address[] users, bytes parameters) view returns(bool) +func (_ICrossChainEntitlement *ICrossChainEntitlementSession) IsEntitled(users []common.Address, parameters []byte) (bool, error) { + return _ICrossChainEntitlement.Contract.IsEntitled(&_ICrossChainEntitlement.CallOpts, users, parameters) +} + +// IsEntitled is a free data retrieval call binding the contract method 0x16089f65. +// +// Solidity: function isEntitled(address[] users, bytes parameters) view returns(bool) +func (_ICrossChainEntitlement *ICrossChainEntitlementCallerSession) IsEntitled(users []common.Address, parameters []byte) (bool, error) { + return _ICrossChainEntitlement.Contract.IsEntitled(&_ICrossChainEntitlement.CallOpts, users, parameters) +} + +// Parameters is a free data retrieval call binding the contract method 0x89035730. +// +// Solidity: function parameters() view returns((string,string,string)[]) +func (_ICrossChainEntitlement *ICrossChainEntitlementCaller) Parameters(opts *bind.CallOpts) ([]ICrossChainEntitlementParameter, error) { + var out []interface{} + err := _ICrossChainEntitlement.contract.Call(opts, &out, "parameters") + + if err != nil { + return *new([]ICrossChainEntitlementParameter), err + } + + out0 := *abi.ConvertType(out[0], new([]ICrossChainEntitlementParameter)).(*[]ICrossChainEntitlementParameter) + + return out0, err + +} + +// Parameters is a free data retrieval call binding the contract method 0x89035730. +// +// Solidity: function parameters() view returns((string,string,string)[]) +func (_ICrossChainEntitlement *ICrossChainEntitlementSession) Parameters() ([]ICrossChainEntitlementParameter, error) { + return _ICrossChainEntitlement.Contract.Parameters(&_ICrossChainEntitlement.CallOpts) +} + +// Parameters is a free data retrieval call binding the contract method 0x89035730. +// +// Solidity: function parameters() view returns((string,string,string)[]) +func (_ICrossChainEntitlement *ICrossChainEntitlementCallerSession) Parameters() ([]ICrossChainEntitlementParameter, error) { + return _ICrossChainEntitlement.Contract.Parameters(&_ICrossChainEntitlement.CallOpts) +} diff --git a/core/contracts/base/i_custom_entitlement.go b/core/contracts/base/i_custom_entitlement.go deleted file mode 100644 index a8f582d4f..000000000 --- a/core/contracts/base/i_custom_entitlement.go +++ /dev/null @@ -1,243 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package base - -import ( - "errors" - "math/big" - "strings" - - ethereum "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/event" -) - -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = errors.New - _ = big.NewInt - _ = strings.NewReader - _ = ethereum.NotFound - _ = bind.Bind - _ = common.Big1 - _ = types.BloomLookup - _ = event.NewSubscription - _ = abi.ConvertType -) - -// ICustomEntitlementMetaData contains all meta data concerning the ICustomEntitlement contract. -var ICustomEntitlementMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"function\",\"name\":\"isEntitled\",\"inputs\":[{\"name\":\"user\",\"type\":\"address[]\",\"internalType\":\"address[]\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"supportsInterface\",\"inputs\":[{\"name\":\"interfaceId\",\"type\":\"bytes4\",\"internalType\":\"bytes4\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"}]", -} - -// ICustomEntitlementABI is the input ABI used to generate the binding from. -// Deprecated: Use ICustomEntitlementMetaData.ABI instead. -var ICustomEntitlementABI = ICustomEntitlementMetaData.ABI - -// ICustomEntitlement is an auto generated Go binding around an Ethereum contract. -type ICustomEntitlement struct { - ICustomEntitlementCaller // Read-only binding to the contract - ICustomEntitlementTransactor // Write-only binding to the contract - ICustomEntitlementFilterer // Log filterer for contract events -} - -// ICustomEntitlementCaller is an auto generated read-only Go binding around an Ethereum contract. -type ICustomEntitlementCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ICustomEntitlementTransactor is an auto generated write-only Go binding around an Ethereum contract. -type ICustomEntitlementTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ICustomEntitlementFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type ICustomEntitlementFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ICustomEntitlementSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type ICustomEntitlementSession struct { - Contract *ICustomEntitlement // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// ICustomEntitlementCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type ICustomEntitlementCallerSession struct { - Contract *ICustomEntitlementCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// ICustomEntitlementTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type ICustomEntitlementTransactorSession struct { - Contract *ICustomEntitlementTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// ICustomEntitlementRaw is an auto generated low-level Go binding around an Ethereum contract. -type ICustomEntitlementRaw struct { - Contract *ICustomEntitlement // Generic contract binding to access the raw methods on -} - -// ICustomEntitlementCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type ICustomEntitlementCallerRaw struct { - Contract *ICustomEntitlementCaller // Generic read-only contract binding to access the raw methods on -} - -// ICustomEntitlementTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type ICustomEntitlementTransactorRaw struct { - Contract *ICustomEntitlementTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewICustomEntitlement creates a new instance of ICustomEntitlement, bound to a specific deployed contract. -func NewICustomEntitlement(address common.Address, backend bind.ContractBackend) (*ICustomEntitlement, error) { - contract, err := bindICustomEntitlement(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &ICustomEntitlement{ICustomEntitlementCaller: ICustomEntitlementCaller{contract: contract}, ICustomEntitlementTransactor: ICustomEntitlementTransactor{contract: contract}, ICustomEntitlementFilterer: ICustomEntitlementFilterer{contract: contract}}, nil -} - -// NewICustomEntitlementCaller creates a new read-only instance of ICustomEntitlement, bound to a specific deployed contract. -func NewICustomEntitlementCaller(address common.Address, caller bind.ContractCaller) (*ICustomEntitlementCaller, error) { - contract, err := bindICustomEntitlement(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &ICustomEntitlementCaller{contract: contract}, nil -} - -// NewICustomEntitlementTransactor creates a new write-only instance of ICustomEntitlement, bound to a specific deployed contract. -func NewICustomEntitlementTransactor(address common.Address, transactor bind.ContractTransactor) (*ICustomEntitlementTransactor, error) { - contract, err := bindICustomEntitlement(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &ICustomEntitlementTransactor{contract: contract}, nil -} - -// NewICustomEntitlementFilterer creates a new log filterer instance of ICustomEntitlement, bound to a specific deployed contract. -func NewICustomEntitlementFilterer(address common.Address, filterer bind.ContractFilterer) (*ICustomEntitlementFilterer, error) { - contract, err := bindICustomEntitlement(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &ICustomEntitlementFilterer{contract: contract}, nil -} - -// bindICustomEntitlement binds a generic wrapper to an already deployed contract. -func bindICustomEntitlement(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := ICustomEntitlementMetaData.GetAbi() - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_ICustomEntitlement *ICustomEntitlementRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _ICustomEntitlement.Contract.ICustomEntitlementCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_ICustomEntitlement *ICustomEntitlementRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _ICustomEntitlement.Contract.ICustomEntitlementTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_ICustomEntitlement *ICustomEntitlementRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _ICustomEntitlement.Contract.ICustomEntitlementTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_ICustomEntitlement *ICustomEntitlementCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _ICustomEntitlement.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_ICustomEntitlement *ICustomEntitlementTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _ICustomEntitlement.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_ICustomEntitlement *ICustomEntitlementTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _ICustomEntitlement.Contract.contract.Transact(opts, method, params...) -} - -// IsEntitled is a free data retrieval call binding the contract method 0xddc6e68e. -// -// Solidity: function isEntitled(address[] user) view returns(bool) -func (_ICustomEntitlement *ICustomEntitlementCaller) IsEntitled(opts *bind.CallOpts, user []common.Address) (bool, error) { - var out []interface{} - err := _ICustomEntitlement.contract.Call(opts, &out, "isEntitled", user) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// IsEntitled is a free data retrieval call binding the contract method 0xddc6e68e. -// -// Solidity: function isEntitled(address[] user) view returns(bool) -func (_ICustomEntitlement *ICustomEntitlementSession) IsEntitled(user []common.Address) (bool, error) { - return _ICustomEntitlement.Contract.IsEntitled(&_ICustomEntitlement.CallOpts, user) -} - -// IsEntitled is a free data retrieval call binding the contract method 0xddc6e68e. -// -// Solidity: function isEntitled(address[] user) view returns(bool) -func (_ICustomEntitlement *ICustomEntitlementCallerSession) IsEntitled(user []common.Address) (bool, error) { - return _ICustomEntitlement.Contract.IsEntitled(&_ICustomEntitlement.CallOpts, user) -} - -// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. -// -// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) -func (_ICustomEntitlement *ICustomEntitlementCaller) SupportsInterface(opts *bind.CallOpts, interfaceId [4]byte) (bool, error) { - var out []interface{} - err := _ICustomEntitlement.contract.Call(opts, &out, "supportsInterface", interfaceId) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. -// -// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) -func (_ICustomEntitlement *ICustomEntitlementSession) SupportsInterface(interfaceId [4]byte) (bool, error) { - return _ICustomEntitlement.Contract.SupportsInterface(&_ICustomEntitlement.CallOpts, interfaceId) -} - -// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. -// -// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) -func (_ICustomEntitlement *ICustomEntitlementCallerSession) SupportsInterface(interfaceId [4]byte) (bool, error) { - return _ICustomEntitlement.Contract.SupportsInterface(&_ICustomEntitlement.CallOpts, interfaceId) -} diff --git a/core/contracts/types/entitlement_data_test.go b/core/contracts/types/entitlement_data_test.go index 85b0e4657..e77dad0d6 100644 --- a/core/contracts/types/entitlement_data_test.go +++ b/core/contracts/types/entitlement_data_test.go @@ -131,24 +131,6 @@ func TestConvertV1RuleDataToV2(t *testing.T) { }, }, }, - "Custom": { - ruleData: test_util.CustomEntitlementCheck(10, testAddress), - expected: base.IRuleEntitlementBaseRuleDataV2{ - Operations: []base.IRuleEntitlementBaseOperation{ - { - OpType: uint8(types.CHECK), - Index: 0, - }, - }, - CheckOperations: []base.IRuleEntitlementBaseCheckOperationV2{ - { - OpType: uint8(types.ISENTITLED), - ChainId: big.NewInt(10), - ContractAddress: testAddress, - }, - }, - }, - }, "EthBalance": { ruleData: test_util.EthBalanceCheck(15, 1500), expected: base.IRuleEntitlementBaseRuleDataV2{ diff --git a/core/contracts/types/test_util/entitlements.go b/core/contracts/types/test_util/entitlements.go index a137570d2..b2807fb31 100644 --- a/core/contracts/types/test_util/entitlements.go +++ b/core/contracts/types/test_util/entitlements.go @@ -6,6 +6,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/river-build/river/core/contracts/base" + "github.com/river-build/river/core/node/crypto" contract_types "github.com/river-build/river/core/contracts/types" ) @@ -81,20 +82,37 @@ func Erc20Check(chainId uint64, contractAddress common.Address, threshold uint64 } } -func CustomEntitlementCheck(chainId uint64, contractAddress common.Address) base.IRuleEntitlementBaseRuleData { - return base.IRuleEntitlementBaseRuleData{ +func MockCrossChainEntitlementCheck( + chainId uint64, + contractAddress common.Address, + id *big.Int, +) base.IRuleEntitlementBaseRuleDataV2 { + params := crypto.ABIEncodeUint256(id) + return CrossChainEntitlementCheck( + chainId, + contractAddress, + params, + ) +} + +func CrossChainEntitlementCheck( + chainId uint64, + contractAddress common.Address, + params []byte, +) base.IRuleEntitlementBaseRuleDataV2 { + return base.IRuleEntitlementBaseRuleDataV2{ Operations: []base.IRuleEntitlementBaseOperation{ { OpType: uint8(contract_types.CHECK), Index: 0, }, }, - CheckOperations: []base.IRuleEntitlementBaseCheckOperation{ + CheckOperations: []base.IRuleEntitlementBaseCheckOperationV2{ { OpType: uint8(contract_types.ISENTITLED), ChainId: new(big.Int).SetUint64(chainId), ContractAddress: contractAddress, - Threshold: new(big.Int).SetUint64(0), + Params: params, }, }, } diff --git a/core/node/crypto/config.go b/core/node/crypto/config.go index 8c193952b..67037ce73 100644 --- a/core/node/crypto/config.go +++ b/core/node/crypto/config.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "math" + "math/big" "reflect" "slices" "strings" @@ -449,9 +450,10 @@ func (occ *onChainConfiguration) applyEvent(ctx context.Context, event *river.Ri } var ( - int64Type, _ = abi.NewType("int64", "", nil) - uint64Type, _ = abi.NewType("uint64", "", nil) - stringType, _ = abi.NewType("string", "string", nil) + int64Type, _ = abi.NewType("int64", "", nil) + uint64Type, _ = abi.NewType("uint64", "", nil) + uint256Type, _ = abi.NewType("uint256", "", nil) + stringType, _ = abi.NewType("string", "string", nil) ) // ABIEncodeInt64 returns Solidity abi.encode(i) @@ -482,6 +484,20 @@ func ABIDecodeUint64(data []byte) (uint64, error) { return args[0].(uint64), nil } +// ABIEncodeUint256 returns Solidity abi.encode(i) +func ABIEncodeUint256(i *big.Int) []byte { + value, _ := abi.Arguments{{Type: uint256Type}}.Pack(i) + return value +} + +func ABIDecodeUint256(data []byte) (*big.Int, error) { + args, err := abi.Arguments{{Type: uint256Type}}.Unpack(data) + if err != nil { + return nil, err + } + return args[0].(*big.Int), nil +} + // ABIEncodeString returns Solidity abi.encode(s) func ABIEncodeString(s string) []byte { value, _ := abi.Arguments{{Type: stringType}}.Pack(s) diff --git a/core/xchain/client_simulator/client_simulator.go b/core/xchain/client_simulator/client_simulator.go index aaa54804d..d447558ef 100644 --- a/core/xchain/client_simulator/client_simulator.go +++ b/core/xchain/client_simulator/client_simulator.go @@ -2,7 +2,6 @@ package client_simulator import ( "context" - "crypto/ecdsa" "fmt" "math/big" "time" @@ -17,8 +16,6 @@ import ( node_crypto "github.com/river-build/river/core/node/crypto" "github.com/river-build/river/core/node/dlog" - xc "github.com/river-build/river/core/xchain/common" - "github.com/river-build/river/core/contracts/base" "github.com/river-build/river/core/contracts/base/deploy" @@ -26,101 +23,8 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/ethclient" ) -var isEntitled = false - -func toggleCustomEntitlement( - ctx context.Context, - cfg *config.Config, - fromAddress common.Address, - client *ethclient.Client, - privateKey *ecdsa.PrivateKey, -) { - log := dlog.FromCtx(ctx).With("application", "clientSimulator") - - nonce, err := client.PendingNonceAt(context.Background(), fromAddress) - if err != nil { - log.Error("Failed getting PendingNonceAt", "err", err) - return - } - - gasPrice, err := client.SuggestGasPrice(context.Background()) - if err != nil { - log.Error("Failed SuggestGasPrice", "err", err) - return - } - - auth, err := bind.NewKeyedTransactorWithChainID( - privateKey, - big.NewInt(31337), - ) // replace 31337 with your actual chainID - if err != nil { - log.Error("NewKeyedTransactorWithChainID", "err", err) - return - } - auth.Nonce = big.NewInt(int64(nonce)) - auth.Value = big.NewInt(0) // in wei - auth.GasLimit = uint64(30000000) // in units - auth.GasPrice = gasPrice - - mockCustomContract, err := deploy.NewMockCustomEntitlement( - cfg.GetTestCustomEntitlementContractAddress(), - client, - ) - if err != nil { - log.Error("Failed to parse contract ABI", "err", err) - return - } - - isEntitled = !isEntitled - - txn, err := mockCustomContract.SetEntitled(auth, []common.Address{fromAddress}, isEntitled) - if err != nil { - log.Error("Failed to SetEntitled", "err", err) - return - } - - rawBlockNumber := xc.WaitForTransaction(client, txn) - - if rawBlockNumber == nil { - log.Error("Client MockCustomContract SetEntitled failed to mine") - return - } - - log.Info( - "Client SetEntitled mined in block", - "rawBlockNumber", - rawBlockNumber, - "id", - txn.Hash(), - "hex", - txn.Hash().Hex(), - ) -} - -func customEntitlementExample(cfg *config.Config) base.IRuleEntitlementBaseRuleData { - return base.IRuleEntitlementBaseRuleData{ - Operations: []base.IRuleEntitlementBaseOperation{ - { - OpType: uint8(contract_types.CHECK), - Index: 0, - }, - }, - CheckOperations: []base.IRuleEntitlementBaseCheckOperation{ - { - OpType: uint8(contract_types.ISENTITLED), - ChainId: big.NewInt(1), - // This contract is deployed on our local base dev chain. - ContractAddress: cfg.GetTestCustomEntitlementContractAddress(), - Threshold: big.NewInt(0), - }, - }, - } -} - func erc721Example() base.IRuleEntitlementBaseRuleData { return base.IRuleEntitlementBaseRuleData{ Operations: []base.IRuleEntitlementBaseOperation{ @@ -167,8 +71,6 @@ type SimulationType int const ( ERC721 SimulationType = iota ERC20 - ISENTITLED - TOGGLEISENTITLED ) type postResult struct { @@ -665,11 +567,6 @@ func (cs *clientSimulator) EvaluateRuleData( } func RunClientSimulator(ctx context.Context, cfg *config.Config, wallet *node_crypto.Wallet, simType SimulationType) { - if simType == TOGGLEISENTITLED { - ToggleEntitlement(ctx, cfg, wallet) - return - } - ctx, cancel := context.WithCancel(ctx) defer cancel() @@ -690,10 +587,6 @@ func RunClientSimulator(ctx context.Context, cfg *config.Config, wallet *node_cr ruleData = erc721Example() case ERC20: ruleData = erc20Example() - case ISENTITLED: - ruleData = customEntitlementExample(cfg) - case TOGGLEISENTITLED: - fallthrough default: log.Error("--- ClientSimulator invalid SimulationType", "simType", simType) return @@ -701,43 +594,3 @@ func RunClientSimulator(ctx context.Context, cfg *config.Config, wallet *node_cr _, _ = cs.EvaluateRuleData(ctx, cfg, ruleData) } - -func ToggleEntitlement(ctx context.Context, cfg *config.Config, wallet *node_crypto.Wallet) { - log := dlog.FromCtx(ctx).With("application", "clientSimulator") - - privateKey := wallet.PrivateKeyStruct - publicKey := privateKey.Public() - publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey) - if !ok { - log.Error("error casting public key to ECDSA") - return - } - - fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA) - - log.Info("ClientSimulator fromAddress", "fromAddress", fromAddress.Hex()) - - baseWebsocketURL, err := xc.ConvertHTTPToWebSocket(cfg.BaseChain.NetworkUrl) - if err != nil { - log.Error("Failed to convert BaseChain HTTP to WebSocket", "err", err) - return - } - - client, err := ethclient.Dial(baseWebsocketURL) - if err != nil { - log.Error("Failed to connect to the Ethereum client", "err", err) - return - } - log.Info("ClientSimulator connected to Ethereum client") - - bc := context.Background() - var result interface{} - err = client.Client().CallContext(bc, &result, "anvil_setBalance", fromAddress, 1_000_000_000_000_000_000) - if err != nil { - log.Info("Failed call anvil_setBalance", "error=", err) - return - } - log.Info("ClientSimulator add funds on anvil to wallet address", "result", result) - - toggleCustomEntitlement(ctx, cfg, fromAddress, client, privateKey) -} diff --git a/core/xchain/entitlement/check_operation.go b/core/xchain/entitlement/check_operation.go index cd9a0cdae..d0372914c 100644 --- a/core/xchain/entitlement/check_operation.go +++ b/core/xchain/entitlement/check_operation.go @@ -198,7 +198,7 @@ func (e *Evaluator) evaluateIsEntitledOperation( return false, fmt.Errorf("evaluateIsEntitledOperation: Chain ID %v not found", op.ChainID) } - customEntitlementChecker, err := base.NewICustomEntitlement( + crossChainEntitlementChecker, err := base.NewICrossChainEntitlement( op.ContractAddress, client, ) @@ -212,9 +212,10 @@ func (e *Evaluator) evaluateIsEntitledOperation( } for _, wallet := range linkedWallets { // Check if the caller is entitled - isEntitled, err := customEntitlementChecker.IsEntitled( + isEntitled, err := crossChainEntitlementChecker.IsEntitled( &bind.CallOpts{Context: ctx}, []common.Address{wallet}, + op.Params, ) if err != nil { log.Error("Failed to check if caller is entitled", diff --git a/core/xchain/server/server_test.go b/core/xchain/server/server_test.go index c43c5eb0b..7ba23837d 100644 --- a/core/xchain/server/server_test.go +++ b/core/xchain/server/server_test.go @@ -56,10 +56,10 @@ type serviceTester struct { stopBlockAutoMining func() // Addresses - mockEntitlementGatedAddress common.Address - mockCustomEntitlementAddress common.Address - entitlementCheckerAddress common.Address - walletLinkingAddress common.Address + mockEntitlementGatedAddress common.Address + mockCrossChainEntitlementAddress common.Address + entitlementCheckerAddress common.Address + walletLinkingAddress common.Address // Contracts entitlementChecker *base.IEntitlementChecker @@ -149,10 +149,10 @@ func (st *serviceTester) deployXchainTestContracts() { st.require.NoError(err) st.mockEntitlementGatedAddress = addr - // Deploy the mock custom entitlement contract - addr, _, _, err = test_contracts.DeployMockCustomEntitlement(auth, client) + // Deploy the mock cross chain entitlement contract + addr, _, _, err = test_contracts.DeployMockCrossChainEntitlement(auth, client) st.require.NoError(err) - st.mockCustomEntitlementAddress = addr + st.mockCrossChainEntitlementAddress = addr // Deploy the wallet linking contract addr, _, _, err = test_contracts.DeployMockWalletLink(auth, client) @@ -172,8 +172,8 @@ func (st *serviceTester) deployXchainTestContracts() { st.entitlementCheckerAddress.Hex(), "mockEntitlementGated", st.mockEntitlementGatedAddress.Hex(), - "mockCustomEntitlement", - st.mockCustomEntitlementAddress.Hex(), + "mockCrossChainEntitlement", + st.mockCrossChainEntitlementAddress.Hex(), "walletLink", st.walletLinkingAddress.Hex(), ) @@ -302,7 +302,7 @@ func (st *serviceTester) Config() *config.Config { Address: st.walletLinkingAddress, }, TestCustomEntitlementContract: config.ContractConfig{ - Address: st.mockCustomEntitlementAddress, + Address: st.mockCrossChainEntitlementAddress, }, Log: config.LogConfig{ NoColor: true, @@ -869,8 +869,9 @@ func TestErc20Entitlements(t *testing.T) { func toggleEntitlement( require *require.Assertions, auth *bind.TransactOpts, - customEntitlement *deploy.MockCustomEntitlement, + crossChainEntitlement *deploy.MockCrossChainEntitlement, wallet *node_crypto.Wallet, + id int64, response bool, ) { // Update nonce @@ -879,17 +880,17 @@ func toggleEntitlement( auth.Nonce = big.NewInt(int64(nonce)) // Toggle contract response - txn, err := customEntitlement.SetEntitled(auth, []common.Address{wallet.Address}, response) + txn, err := crossChainEntitlement.SetIsEntitled(auth, big.NewInt(id), wallet.Address, response) require.NoError(err) blockNum := xc_common.WaitForTransaction(anvilClient, txn) require.NotNil(blockNum) } -func deployMockCustomEntitlement( +func deployMockCrossChainEntitlement( require *require.Assertions, st *serviceTester, -) (*bind.TransactOpts, common.Address, *deploy.MockCustomEntitlement) { - // Deploy mock custom entitlement contract to anvil chain +) (*bind.TransactOpts, common.Address, *deploy.MockCrossChainEntitlement) { + // Deploy mock crosschain entitlement contract to anvil chain nonce, err := anvilClient.PendingNonceAt(context.Background(), anvilWallet.Address) require.NoError(err) auth, err := bind.NewKeyedTransactorWithChainID(anvilWallet.PrivateKeyStruct, big.NewInt(31337)) @@ -898,27 +899,24 @@ func deployMockCustomEntitlement( auth.Value = big.NewInt(0) // in wei auth.GasLimit = uint64(30_000_000) // in units - contractAddress, txn, customEntitlement, err := deploy.DeployMockCustomEntitlement( + contractAddress, txn, crossChainEntitlement, err := deploy.DeployMockCrossChainEntitlement( auth, anvilClient, ) require.NoError(err) require.NotNil( xc_common.WaitForTransaction(anvilClient, txn), - "Failed to mine custom entitlement contract deployment", + "Failed to mine cross chain entitlement contract deployment", ) - return auth, contractAddress, customEntitlement + return auth, contractAddress, crossChainEntitlement } -func TestCustomEntitlements(t *testing.T) { +func TestCrossChainEntitlements(t *testing.T) { tests := map[string]struct { - v2 bool sentByRootKeyWallet bool }{ - "v1 request sent by root key wallet": {sentByRootKeyWallet: true}, - "v1 request sent by linked wallet": {sentByRootKeyWallet: false}, - "v2 request sent by root key wallet": {v2: true, sentByRootKeyWallet: true}, - "v2 request sent by linked wallet": {v2: true, sentByRootKeyWallet: false}, + "v2 request sent by root key wallet": {sentByRootKeyWallet: true}, + "v2 request sent by linked wallet": {sentByRootKeyWallet: false}, } for name, tc := range tests { t.Run(name, func(t *testing.T) { @@ -937,64 +935,53 @@ func TestCustomEntitlements(t *testing.T) { cs.Start(ctx) defer cs.Stop() + // Deploy mock crosschain entitlement contract to anvil chain + auth, contractAddress, crossChainEntitlement := deployMockCrossChainEntitlement(require, st) + t.Log("Deployed crosschain entitlement contract", contractAddress.Hex(), ChainID) + check := func( - v1Check base.IRuleEntitlementBaseRuleData, - expected bool, + check base.IRuleEntitlementBaseRuleDataV2, + result bool, ) { - if tc.v2 { - v2Check, err := contract_types.ConvertV1RuleDataToV2(ctx, &v1Check) - require.NoError(err) - expectV2EntitlementCheckResult( - require, - cs, - ctx, - cfg, - *v2Check, - expected, - ) - } else { - expectEntitlementCheckResult( - require, - cs, - ctx, - cfg, - v1Check, - expected, - ) - } + expectV2EntitlementCheckResult( + require, + cs, + ctx, + cfg, + check, + result, + ) } - // Deploy mock custom entitlement contract to anvil chain - auth, contractAddress, customEntitlement := deployMockCustomEntitlement(require, st) - t.Log("Deployed custom entitlement contract", contractAddress.Hex(), ChainID) - // Initially the check should fail. - customCheck := test_util.CustomEntitlementCheck(ChainID, contractAddress) - check(customCheck, false) + isEntitledCheck := test_util.MockCrossChainEntitlementCheck(ChainID, contractAddress, big.NewInt(1)) + check(isEntitledCheck, false) - toggleEntitlement(require, auth, customEntitlement, cs.Wallet(), true) + // Toggle entitlemenet result for user's wallet + toggleEntitlement(require, auth, crossChainEntitlement, cs.Wallet(), 1, true) // Check should now succeed. - check(customCheck, true) - - // Untoggle entitlement for client simulator wallet - toggleEntitlement(require, auth, customEntitlement, cs.Wallet(), false) + check(isEntitledCheck, true) // Create a set of 3 linked wallets using client simulator address. _, wallet1, wallet2, wallet3 := generateLinkedWallets(ctx, require, tc.sentByRootKeyWallet, st, cs.Wallet()) - for _, wallet := range []*node_crypto.Wallet{wallet1, wallet2, wallet3} { + for i, wallet := range []*node_crypto.Wallet{wallet1, wallet2, wallet3} { + // Use a new id for each check + id := int64(i) + 2 + isEntitledCheck = test_util.MockCrossChainEntitlementCheck(ChainID, contractAddress, big.NewInt(id)) + // Check should fail for all wallets. - check(customCheck, false) + check(isEntitledCheck, false) // Toggle entitlement for a particular linked wallet - toggleEntitlement(require, auth, customEntitlement, wallet, true) + toggleEntitlement(require, auth, crossChainEntitlement, wallet, id, true) // Check should now succeed for the wallet. - check(customCheck, true) + check(isEntitledCheck, true) // Untoggle entitlement for the wallet - toggleEntitlement(require, auth, customEntitlement, wallet, false) + toggleEntitlement(require, auth, crossChainEntitlement, wallet, id, false) } }) } diff --git a/packages/generated/dev/abis/ICrossChainEntitlement.abi.json b/packages/generated/dev/abis/ICrossChainEntitlement.abi.json new file mode 100644 index 000000000..0f3e2cdf7 --- /dev/null +++ b/packages/generated/dev/abis/ICrossChainEntitlement.abi.json @@ -0,0 +1,56 @@ +[ + { + "type": "function", + "name": "isEntitled", + "inputs": [ + { + "name": "users", + "type": "address[]", + "internalType": "address[]" + }, + { + "name": "parameters", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "parameters", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "tuple[]", + "internalType": "struct ICrossChainEntitlement.Parameter[]", + "components": [ + { + "name": "name", + "type": "string", + "internalType": "string" + }, + { + "name": "primitive", + "type": "string", + "internalType": "string" + }, + { + "name": "description", + "type": "string", + "internalType": "string" + } + ] + } + ], + "stateMutability": "view" + } +] \ No newline at end of file diff --git a/packages/generated/dev/abis/ICrossChainEntitlement.abi.ts b/packages/generated/dev/abis/ICrossChainEntitlement.abi.ts new file mode 100644 index 000000000..e0e460750 --- /dev/null +++ b/packages/generated/dev/abis/ICrossChainEntitlement.abi.ts @@ -0,0 +1,56 @@ +export default [ + { + "type": "function", + "name": "isEntitled", + "inputs": [ + { + "name": "users", + "type": "address[]", + "internalType": "address[]" + }, + { + "name": "parameters", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "parameters", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "tuple[]", + "internalType": "struct ICrossChainEntitlement.Parameter[]", + "components": [ + { + "name": "name", + "type": "string", + "internalType": "string" + }, + { + "name": "primitive", + "type": "string", + "internalType": "string" + }, + { + "name": "description", + "type": "string", + "internalType": "string" + } + ] + } + ], + "stateMutability": "view" + } +] as const diff --git a/packages/generated/dev/abis/ICrossChainEntitlement.bin b/packages/generated/dev/abis/ICrossChainEntitlement.bin new file mode 100644 index 000000000..e69de29bb diff --git a/packages/generated/dev/abis/ICrossChainEntitlement.json b/packages/generated/dev/abis/ICrossChainEntitlement.json new file mode 100644 index 000000000..b2d98c43a --- /dev/null +++ b/packages/generated/dev/abis/ICrossChainEntitlement.json @@ -0,0 +1 @@ +{"abi":[{"type":"function","name":"isEntitled","inputs":[{"name":"users","type":"address[]","internalType":"address[]"},{"name":"parameters","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"parameters","inputs":[],"outputs":[{"name":"","type":"tuple[]","internalType":"struct ICrossChainEntitlement.Parameter[]","components":[{"name":"name","type":"string","internalType":"string"},{"name":"primitive","type":"string","internalType":"string"},{"name":"description","type":"string","internalType":"string"}]}],"stateMutability":"view"}],"bytecode":{"object":"0x","sourceMap":"","linkReferences":{}},"deployedBytecode":{"object":"0x","sourceMap":"","linkReferences":{}},"methodIdentifiers":{"isEntitled(address[],bytes)":"16089f65","parameters()":"89035730"},"rawMetadata":"{\"compiler\":{\"version\":\"0.8.24+commit.e11b9ed9\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"users\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"parameters\",\"type\":\"bytes\"}],\"name\":\"isEntitled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"parameters\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"primitive\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"description\",\"type\":\"string\"}],\"internalType\":\"struct ICrossChainEntitlement.Parameter[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/src/spaces/entitlements/ICrossChainEntitlement.sol\":\"ICrossChainEntitlement\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"appendCBOR\":false,\"bytecodeHash\":\"none\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[\":@openzeppelin/=node_modules/@openzeppelin/\",\":@prb/math/=node_modules/@prb/math/src/\",\":@prb/test/=node_modules/@prb/test/src/\",\":account-abstraction/=node_modules/account-abstraction/contracts/\",\":ds-test/=node_modules/ds-test/src/\",\":forge-std/=node_modules/forge-std/src/\",\":hardhat-deploy/=node_modules/hardhat-deploy/\",\":solady/=node_modules/solady/src/\"]},\"sources\":{\"contracts/src/spaces/entitlements/ICrossChainEntitlement.sol\":{\"keccak256\":\"0xc4f8345418d1a53484a0896639f1201f6afd899be0a9ca89c7e4a4717b91635b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://615519730737ea5621fb1feeda4dc652ad2a5823d7d5613e4a4d0be6f17d9cef\",\"dweb:/ipfs/QmZnajX2f3o7KsTWwYdq4a1Ss37ckJd9FsmBoAADjjNHnn\"]}},\"version\":1}","metadata":{"compiler":{"version":"0.8.24+commit.e11b9ed9"},"language":"Solidity","output":{"abi":[{"inputs":[{"internalType":"address[]","name":"users","type":"address[]"},{"internalType":"bytes","name":"parameters","type":"bytes"}],"stateMutability":"view","type":"function","name":"isEntitled","outputs":[{"internalType":"bool","name":"","type":"bool"}]},{"inputs":[],"stateMutability":"view","type":"function","name":"parameters","outputs":[{"internalType":"struct ICrossChainEntitlement.Parameter[]","name":"","type":"tuple[]","components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"primitive","type":"string"},{"internalType":"string","name":"description","type":"string"}]}]}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"remappings":["@openzeppelin/=node_modules/@openzeppelin/","@prb/math/=node_modules/@prb/math/src/","@prb/test/=node_modules/@prb/test/src/","account-abstraction/=node_modules/account-abstraction/contracts/","ds-test/=node_modules/ds-test/src/","forge-std/=node_modules/forge-std/src/","hardhat-deploy/=node_modules/hardhat-deploy/","solady/=node_modules/solady/src/"],"optimizer":{"enabled":true,"runs":200},"metadata":{"bytecodeHash":"none","appendCBOR":false},"compilationTarget":{"contracts/src/spaces/entitlements/ICrossChainEntitlement.sol":"ICrossChainEntitlement"},"evmVersion":"paris","libraries":{}},"sources":{"contracts/src/spaces/entitlements/ICrossChainEntitlement.sol":{"keccak256":"0xc4f8345418d1a53484a0896639f1201f6afd899be0a9ca89c7e4a4717b91635b","urls":["bzz-raw://615519730737ea5621fb1feeda4dc652ad2a5823d7d5613e4a4d0be6f17d9cef","dweb:/ipfs/QmZnajX2f3o7KsTWwYdq4a1Ss37ckJd9FsmBoAADjjNHnn"],"license":"MIT"}},"version":1},"id":223} \ No newline at end of file diff --git a/packages/generated/dev/abis/ICrossChainEntitlement.metadata.json b/packages/generated/dev/abis/ICrossChainEntitlement.metadata.json new file mode 100644 index 000000000..0e989a1a3 --- /dev/null +++ b/packages/generated/dev/abis/ICrossChainEntitlement.metadata.json @@ -0,0 +1,110 @@ +{ + "compiler": { + "version": "0.8.24+commit.e11b9ed9" + }, + "language": "Solidity", + "output": { + "abi": [ + { + "inputs": [ + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + }, + { + "internalType": "bytes", + "name": "parameters", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function", + "name": "isEntitled", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ] + }, + { + "inputs": [], + "stateMutability": "view", + "type": "function", + "name": "parameters", + "outputs": [ + { + "internalType": "struct ICrossChainEntitlement.Parameter[]", + "name": "", + "type": "tuple[]", + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "primitive", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + } + ] + } + ] + } + ], + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + } + }, + "settings": { + "remappings": [ + "@openzeppelin/=node_modules/@openzeppelin/", + "@prb/math/=node_modules/@prb/math/src/", + "@prb/test/=node_modules/@prb/test/src/", + "account-abstraction/=node_modules/account-abstraction/contracts/", + "ds-test/=node_modules/ds-test/src/", + "forge-std/=node_modules/forge-std/src/", + "hardhat-deploy/=node_modules/hardhat-deploy/", + "solady/=node_modules/solady/src/" + ], + "optimizer": { + "enabled": true, + "runs": 200 + }, + "metadata": { + "bytecodeHash": "none", + "appendCBOR": false + }, + "compilationTarget": { + "contracts/src/spaces/entitlements/ICrossChainEntitlement.sol": "ICrossChainEntitlement" + }, + "evmVersion": "paris", + "libraries": {} + }, + "sources": { + "contracts/src/spaces/entitlements/ICrossChainEntitlement.sol": { + "keccak256": "0xc4f8345418d1a53484a0896639f1201f6afd899be0a9ca89c7e4a4717b91635b", + "urls": [ + "bzz-raw://615519730737ea5621fb1feeda4dc652ad2a5823d7d5613e4a4d0be6f17d9cef", + "dweb:/ipfs/QmZnajX2f3o7KsTWwYdq4a1Ss37ckJd9FsmBoAADjjNHnn" + ], + "license": "MIT" + } + }, + "version": 1 +} \ No newline at end of file diff --git a/packages/generated/dev/abis/MockCrossChainEntitlement.abi.json b/packages/generated/dev/abis/MockCrossChainEntitlement.abi.json new file mode 100644 index 000000000..9718b69a4 --- /dev/null +++ b/packages/generated/dev/abis/MockCrossChainEntitlement.abi.json @@ -0,0 +1,98 @@ +[ + { + "type": "function", + "name": "isEntitled", + "inputs": [ + { + "name": "users", + "type": "address[]", + "internalType": "address[]" + }, + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "isEntitledByUserAndId", + "inputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "parameters", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "tuple[]", + "internalType": "struct ICrossChainEntitlement.Parameter[]", + "components": [ + { + "name": "name", + "type": "string", + "internalType": "string" + }, + { + "name": "primitive", + "type": "string", + "internalType": "string" + }, + { + "name": "description", + "type": "string", + "internalType": "string" + } + ] + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "setIsEntitled", + "inputs": [ + { + "name": "id", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "user", + "type": "address", + "internalType": "address" + }, + { + "name": "entitled", + "type": "bool", + "internalType": "bool" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + } +] \ No newline at end of file diff --git a/packages/generated/dev/abis/MockCrossChainEntitlement.abi.ts b/packages/generated/dev/abis/MockCrossChainEntitlement.abi.ts new file mode 100644 index 000000000..3095a5d62 --- /dev/null +++ b/packages/generated/dev/abis/MockCrossChainEntitlement.abi.ts @@ -0,0 +1,98 @@ +export default [ + { + "type": "function", + "name": "isEntitled", + "inputs": [ + { + "name": "users", + "type": "address[]", + "internalType": "address[]" + }, + { + "name": "data", + "type": "bytes", + "internalType": "bytes" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "isEntitledByUserAndId", + "inputs": [ + { + "name": "", + "type": "bytes32", + "internalType": "bytes32" + } + ], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "parameters", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "tuple[]", + "internalType": "struct ICrossChainEntitlement.Parameter[]", + "components": [ + { + "name": "name", + "type": "string", + "internalType": "string" + }, + { + "name": "primitive", + "type": "string", + "internalType": "string" + }, + { + "name": "description", + "type": "string", + "internalType": "string" + } + ] + } + ], + "stateMutability": "pure" + }, + { + "type": "function", + "name": "setIsEntitled", + "inputs": [ + { + "name": "id", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "user", + "type": "address", + "internalType": "address" + }, + { + "name": "entitled", + "type": "bool", + "internalType": "bool" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + } +] as const diff --git a/packages/generated/dev/abis/MockCrossChainEntitlement.bin b/packages/generated/dev/abis/MockCrossChainEntitlement.bin new file mode 100644 index 000000000..64d07b9af --- /dev/null +++ b/packages/generated/dev/abis/MockCrossChainEntitlement.bin @@ -0,0 +1 @@ +608060405234801561001057600080fd5b50610531806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806316089f65146100515780637addd58714610079578063890357301461009c578063b48900e8146100b1575b600080fd5b61006461005f3660046102af565b610118565b60405190151581526020015b60405180910390f35b610064610087366004610374565b60006020819052908152604090205460ff1681565b6100a46101cc565b60405161007091906103d3565b6101166100bf366004610492565b604080516001600160a01b038416602082015290810184905260009060600160408051808303601f1901815291815281516020928301206000908152918290529020805460ff191692151592909217909155505050565b005b60008061012783850185610374565b905060005b858110156101bd576000878783818110610148576101486104d7565b905060200201602081019061015d91906104ed565b604080516001600160a01b039092166020830152810184905260600160408051601f19818403018152918152815160209283012060008181529283905291205490915060ff16156101b457600193505050506101c4565b5060010161012c565b5060009150505b949350505050565b60408051600180825281830190925260609160009190816020015b61020b60405180606001604052806060815260200160608152602001606081525090565b8152602001906001900390816101e75790505090506040518060600160405280604051806040016040528060028152602001611a5960f21b8152508152602001604051806040016040528060078152602001663ab4b73a191a9b60c91b8152508152602001604051806060016040528060218152602001610510602191398152508160008151811061029f5761029f6104d7565b6020908102919091010152919050565b600080600080604085870312156102c557600080fd5b843567ffffffffffffffff808211156102dd57600080fd5b818701915087601f8301126102f157600080fd5b81358181111561030057600080fd5b8860208260051b850101111561031557600080fd5b60209283019650945090860135908082111561033057600080fd5b818701915087601f83011261034457600080fd5b81358181111561035357600080fd5b88602082850101111561036557600080fd5b95989497505060200194505050565b60006020828403121561038657600080fd5b5035919050565b6000815180845260005b818110156103b357602081850181015186830182015201610397565b506000602082860101526020601f19601f83011685010191505092915050565b600060208083018184528085518083526040925060408601915060408160051b87010184880160005b8381101561046857603f198984030185528151606081518186526104228287018261038d565b915050888201518582038a87015261043a828261038d565b91505087820151915084810388860152610454818361038d565b9689019694505050908601906001016103fc565b509098975050505050505050565b80356001600160a01b038116811461048d57600080fd5b919050565b6000806000606084860312156104a757600080fd5b833592506104b760208501610476565b9150604084013580151581146104cc57600080fd5b809150509250925092565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156104ff57600080fd5b61050882610476565b939250505056fe53696d706c6520706172616d65746572207479706520666f722074657374696e67 \ No newline at end of file diff --git a/packages/generated/dev/abis/MockCrossChainEntitlement.json b/packages/generated/dev/abis/MockCrossChainEntitlement.json new file mode 100644 index 000000000..d68021447 --- /dev/null +++ b/packages/generated/dev/abis/MockCrossChainEntitlement.json @@ -0,0 +1 @@ +{"abi":[{"type":"function","name":"isEntitled","inputs":[{"name":"users","type":"address[]","internalType":"address[]"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"isEntitledByUserAndId","inputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"parameters","inputs":[],"outputs":[{"name":"","type":"tuple[]","internalType":"struct ICrossChainEntitlement.Parameter[]","components":[{"name":"name","type":"string","internalType":"string"},{"name":"primitive","type":"string","internalType":"string"},{"name":"description","type":"string","internalType":"string"}]}],"stateMutability":"pure"},{"type":"function","name":"setIsEntitled","inputs":[{"name":"id","type":"uint256","internalType":"uint256"},{"name":"user","type":"address","internalType":"address"},{"name":"entitled","type":"bool","internalType":"bool"}],"outputs":[],"stateMutability":"nonpayable"}],"bytecode":{"object":"0x608060405234801561001057600080fd5b50610531806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806316089f65146100515780637addd58714610079578063890357301461009c578063b48900e8146100b1575b600080fd5b61006461005f3660046102af565b610118565b60405190151581526020015b60405180910390f35b610064610087366004610374565b60006020819052908152604090205460ff1681565b6100a46101cc565b60405161007091906103d3565b6101166100bf366004610492565b604080516001600160a01b038416602082015290810184905260009060600160408051808303601f1901815291815281516020928301206000908152918290529020805460ff191692151592909217909155505050565b005b60008061012783850185610374565b905060005b858110156101bd576000878783818110610148576101486104d7565b905060200201602081019061015d91906104ed565b604080516001600160a01b039092166020830152810184905260600160408051601f19818403018152918152815160209283012060008181529283905291205490915060ff16156101b457600193505050506101c4565b5060010161012c565b5060009150505b949350505050565b60408051600180825281830190925260609160009190816020015b61020b60405180606001604052806060815260200160608152602001606081525090565b8152602001906001900390816101e75790505090506040518060600160405280604051806040016040528060028152602001611a5960f21b8152508152602001604051806040016040528060078152602001663ab4b73a191a9b60c91b8152508152602001604051806060016040528060218152602001610510602191398152508160008151811061029f5761029f6104d7565b6020908102919091010152919050565b600080600080604085870312156102c557600080fd5b843567ffffffffffffffff808211156102dd57600080fd5b818701915087601f8301126102f157600080fd5b81358181111561030057600080fd5b8860208260051b850101111561031557600080fd5b60209283019650945090860135908082111561033057600080fd5b818701915087601f83011261034457600080fd5b81358181111561035357600080fd5b88602082850101111561036557600080fd5b95989497505060200194505050565b60006020828403121561038657600080fd5b5035919050565b6000815180845260005b818110156103b357602081850181015186830182015201610397565b506000602082860101526020601f19601f83011685010191505092915050565b600060208083018184528085518083526040925060408601915060408160051b87010184880160005b8381101561046857603f198984030185528151606081518186526104228287018261038d565b915050888201518582038a87015261043a828261038d565b91505087820151915084810388860152610454818361038d565b9689019694505050908601906001016103fc565b509098975050505050505050565b80356001600160a01b038116811461048d57600080fd5b919050565b6000806000606084860312156104a757600080fd5b833592506104b760208501610476565b9150604084013580151581146104cc57600080fd5b809150509250925092565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156104ff57600080fd5b61050882610476565b939250505056fe53696d706c6520706172616d65746572207479706520666f722074657374696e67","sourceMap":"160:890:388:-:0;;;;;;;;;;;;;;;;;;;","linkReferences":{}},"deployedBytecode":{"object":"0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806316089f65146100515780637addd58714610079578063890357301461009c578063b48900e8146100b1575b600080fd5b61006461005f3660046102af565b610118565b60405190151581526020015b60405180910390f35b610064610087366004610374565b60006020819052908152604090205460ff1681565b6100a46101cc565b60405161007091906103d3565b6101166100bf366004610492565b604080516001600160a01b038416602082015290810184905260009060600160408051808303601f1901815291815281516020928301206000908152918290529020805460ff191692151592909217909155505050565b005b60008061012783850185610374565b905060005b858110156101bd576000878783818110610148576101486104d7565b905060200201602081019061015d91906104ed565b604080516001600160a01b039092166020830152810184905260600160408051601f19818403018152918152815160209283012060008181529283905291205490915060ff16156101b457600193505050506101c4565b5060010161012c565b5060009150505b949350505050565b60408051600180825281830190925260609160009190816020015b61020b60405180606001604052806060815260200160608152602001606081525090565b8152602001906001900390816101e75790505090506040518060600160405280604051806040016040528060028152602001611a5960f21b8152508152602001604051806040016040528060078152602001663ab4b73a191a9b60c91b8152508152602001604051806060016040528060218152602001610510602191398152508160008151811061029f5761029f6104d7565b6020908102919091010152919050565b600080600080604085870312156102c557600080fd5b843567ffffffffffffffff808211156102dd57600080fd5b818701915087601f8301126102f157600080fd5b81358181111561030057600080fd5b8860208260051b850101111561031557600080fd5b60209283019650945090860135908082111561033057600080fd5b818701915087601f83011261034457600080fd5b81358181111561035357600080fd5b88602082850101111561036557600080fd5b95989497505060200194505050565b60006020828403121561038657600080fd5b5035919050565b6000815180845260005b818110156103b357602081850181015186830182015201610397565b506000602082860101526020601f19601f83011685010191505092915050565b600060208083018184528085518083526040925060408601915060408160051b87010184880160005b8381101561046857603f198984030185528151606081518186526104228287018261038d565b915050888201518582038a87015261043a828261038d565b91505087820151915084810388860152610454818361038d565b9689019694505050908601906001016103fc565b509098975050505050505050565b80356001600160a01b038116811461048d57600080fd5b919050565b6000806000606084860312156104a757600080fd5b833592506104b760208501610476565b9150604084013580151581146104cc57600080fd5b809150509250925092565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156104ff57600080fd5b61050882610476565b939250505056fe53696d706c6520706172616d65746572207479706520666f722074657374696e67","sourceMap":"160:890:388:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;461:361;;;;;;:::i;:::-;;:::i;:::-;;;1265:14:589;;1258:22;1240:41;;1228:2;1213:18;461:361:388;;;;;;;;225:53;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;826:222;;;:::i;:::-;;;;;;;:::i;283:174::-;;;;;;:::i;:::-;387:20;;;-1:-1:-1;;;;;4568:32:589;;387:20:388;;;4550:51:589;4617:18;;;4610:34;;;362:12:388;;4523:18:589;;387:20:388;;;;;;-1:-1:-1;;387:20:388;;;;;;377:31;;387:20;377:31;;;;414:21;:27;;;;;;;;;:38;;-1:-1:-1;;414:38:388;;;;;;;;;;;-1:-1:-1;;;283:174:388;;;461:361;563:4;;588:27;;;;599:4;588:27;:::i;:::-;575:40;;626:9;621:178;641:16;;;621:178;;;672:12;708:5;;714:1;708:8;;;;;;;:::i;:::-;;;;;;;;;;;;;;:::i;:::-;697:24;;;-1:-1:-1;;;;;4568:32:589;;;697:24:388;;;4550:51:589;4617:18;;4610:34;;;4523:18;;697:24:388;;;-1:-1:-1;;697:24:388;;;;;;;;;687:35;;697:24;687:35;;;;734:21;:27;;;;;;;;;;687:35;;-1:-1:-1;734:27:388;;730:63;;;780:4;773:11;;;;;;;730:63;-1:-1:-1;659:3:388;;621:178;;;;812:5;805:12;;;461:361;;;;;;;:::o;826:222::-;925:18;;;941:1;925:18;;;;;;;;;871;;897:25;;925:18;;;;;;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;925:18:388;;;;;;;;;;;;;;;;897:46;;961:63;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;961:63:388;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;961:63:388;;;;;;;;;;;;;;;;;;;;;;;;;;;949:6;956:1;949:9;;;;;;;;:::i;:::-;;;;;;;;;;:75;1037:6;826:222;-1:-1:-1;826:222:388:o;14:1081:589:-;120:6;128;136;144;197:2;185:9;176:7;172:23;168:32;165:52;;;213:1;210;203:12;165:52;253:9;240:23;282:18;323:2;315:6;312:14;309:34;;;339:1;336;329:12;309:34;377:6;366:9;362:22;352:32;;422:7;415:4;411:2;407:13;403:27;393:55;;444:1;441;434:12;393:55;484:2;471:16;510:2;502:6;499:14;496:34;;;526:1;523;516:12;496:34;581:7;574:4;564:6;561:1;557:14;553:2;549:23;545:34;542:47;539:67;;;602:1;599;592:12;539:67;633:4;625:13;;;;-1:-1:-1;657:6:589;-1:-1:-1;701:20:589;;;688:34;;734:16;;;731:36;;;763:1;760;753:12;731:36;801:8;790:9;786:24;776:34;;848:7;841:4;837:2;833:13;829:27;819:55;;870:1;867;860:12;819:55;912:2;899:16;940:2;930:8;927:16;924:36;;;956:1;953;946:12;924:36;1005:7;998:4;987:8;983:2;979:17;975:28;972:41;969:61;;;1026:1;1023;1016:12;969:61;14:1081;;;;-1:-1:-1;;1057:4:589;1049:13;;-1:-1:-1;;;14:1081:589:o;1292:180::-;1351:6;1404:2;1392:9;1383:7;1379:23;1375:32;1372:52;;;1420:1;1417;1410:12;1372:52;-1:-1:-1;1443:23:589;;1292:180;-1:-1:-1;1292:180:589:o;1477:423::-;1519:3;1557:5;1551:12;1584:6;1579:3;1572:19;1609:1;1619:162;1633:6;1630:1;1627:13;1619:162;;;1695:4;1751:13;;;1747:22;;1741:29;1723:11;;;1719:20;;1712:59;1648:12;1619:162;;;1623:3;1826:1;1819:4;1810:6;1805:3;1801:16;1797:27;1790:38;1889:4;1882:2;1878:7;1873:2;1865:6;1861:15;1857:29;1852:3;1848:39;1844:50;1837:57;;;1477:423;;;;:::o;1905:1360::-;2103:4;2132:2;2172;2161:9;2157:18;2202:2;2191:9;2184:21;2225:6;2260;2254:13;2291:6;2283;2276:22;2317:2;2307:12;;2350:2;2339:9;2335:18;2328:25;;2412:2;2402:6;2399:1;2395:14;2384:9;2380:30;2376:39;2450:2;2442:6;2438:15;2471:1;2481:755;2495:6;2492:1;2489:13;2481:755;;;2588:2;2584:7;2572:9;2564:6;2560:22;2556:36;2551:3;2544:49;2622:6;2616:13;2652:4;2695:2;2689:9;2726:2;2718:6;2711:18;2756:48;2800:2;2792:6;2788:15;2774:12;2756:48;:::i;:::-;2742:62;;;2853:2;2849;2845:11;2839:18;2906:6;2898;2894:19;2889:2;2881:6;2877:15;2870:44;2941:41;2975:6;2959:14;2941:41;:::i;:::-;2927:55;;;3031:2;3027;3023:11;3017:18;2995:40;;3084:6;3076;3072:19;3067:2;3059:6;3055:15;3048:44;3115:41;3149:6;3133:14;3115:41;:::i;:::-;3214:12;;;;3105:51;-1:-1:-1;;;3179:15:589;;;;2517:1;2510:9;2481:755;;;-1:-1:-1;3253:6:589;;1905:1360;-1:-1:-1;;;;;;;;1905:1360:589:o;3270:173::-;3338:20;;-1:-1:-1;;;;;3387:31:589;;3377:42;;3367:70;;3433:1;3430;3423:12;3367:70;3270:173;;;:::o;3448:415::-;3522:6;3530;3538;3591:2;3579:9;3570:7;3566:23;3562:32;3559:52;;;3607:1;3604;3597:12;3559:52;3643:9;3630:23;3620:33;;3672:38;3706:2;3695:9;3691:18;3672:38;:::i;:::-;3662:48;;3760:2;3749:9;3745:18;3732:32;3807:5;3800:13;3793:21;3786:5;3783:32;3773:60;;3829:1;3826;3819:12;3773:60;3852:5;3842:15;;;3448:415;;;;;:::o;4053:127::-;4114:10;4109:3;4105:20;4102:1;4095:31;4145:4;4142:1;4135:15;4169:4;4166:1;4159:15;4185:186;4244:6;4297:2;4285:9;4276:7;4272:23;4268:32;4265:52;;;4313:1;4310;4303:12;4265:52;4336:29;4355:9;4336:29;:::i;:::-;4326:39;4185:186;-1:-1:-1;;;4185:186:589:o","linkReferences":{}},"methodIdentifiers":{"isEntitled(address[],bytes)":"16089f65","isEntitledByUserAndId(bytes32)":"7addd587","parameters()":"89035730","setIsEntitled(uint256,address,bool)":"b48900e8"},"rawMetadata":"{\"compiler\":{\"version\":\"0.8.24+commit.e11b9ed9\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"users\",\"type\":\"address[]\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"isEntitled\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"isEntitledByUserAndId\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"parameters\",\"outputs\":[{\"components\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"primitive\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"description\",\"type\":\"string\"}],\"internalType\":\"struct ICrossChainEntitlement.Parameter[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"entitled\",\"type\":\"bool\"}],\"name\":\"setIsEntitled\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/test/mocks/MockCrossChainEntitlement.sol\":\"MockCrossChainEntitlement\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"appendCBOR\":false,\"bytecodeHash\":\"none\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[\":@openzeppelin/=node_modules/@openzeppelin/\",\":@prb/math/=node_modules/@prb/math/src/\",\":@prb/test/=node_modules/@prb/test/src/\",\":account-abstraction/=node_modules/account-abstraction/contracts/\",\":ds-test/=node_modules/ds-test/src/\",\":forge-std/=node_modules/forge-std/src/\",\":hardhat-deploy/=node_modules/hardhat-deploy/\",\":solady/=node_modules/solady/src/\"]},\"sources\":{\"contracts/src/spaces/entitlements/ICrossChainEntitlement.sol\":{\"keccak256\":\"0xc4f8345418d1a53484a0896639f1201f6afd899be0a9ca89c7e4a4717b91635b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://615519730737ea5621fb1feeda4dc652ad2a5823d7d5613e4a4d0be6f17d9cef\",\"dweb:/ipfs/QmZnajX2f3o7KsTWwYdq4a1Ss37ckJd9FsmBoAADjjNHnn\"]},\"contracts/test/mocks/MockCrossChainEntitlement.sol\":{\"keccak256\":\"0xd6e47a178d38b26536e9c8b0fe3233e76e91a9f331742db919d8edff229082f2\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://085f18ab6529ff949097e029b71dbf51b94b88b8e91a1712aaeb0048df03e026\",\"dweb:/ipfs/QmVhNcDUqcR5WoKQJtEBGATbs2sRqn35SEXJ67DUeFDXuu\"]}},\"version\":1}","metadata":{"compiler":{"version":"0.8.24+commit.e11b9ed9"},"language":"Solidity","output":{"abi":[{"inputs":[{"internalType":"address[]","name":"users","type":"address[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"stateMutability":"view","type":"function","name":"isEntitled","outputs":[{"internalType":"bool","name":"","type":"bool"}]},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function","name":"isEntitledByUserAndId","outputs":[{"internalType":"bool","name":"","type":"bool"}]},{"inputs":[],"stateMutability":"pure","type":"function","name":"parameters","outputs":[{"internalType":"struct ICrossChainEntitlement.Parameter[]","name":"","type":"tuple[]","components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"primitive","type":"string"},{"internalType":"string","name":"description","type":"string"}]}]},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address","name":"user","type":"address"},{"internalType":"bool","name":"entitled","type":"bool"}],"stateMutability":"nonpayable","type":"function","name":"setIsEntitled"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"remappings":["@openzeppelin/=node_modules/@openzeppelin/","@prb/math/=node_modules/@prb/math/src/","@prb/test/=node_modules/@prb/test/src/","account-abstraction/=node_modules/account-abstraction/contracts/","ds-test/=node_modules/ds-test/src/","forge-std/=node_modules/forge-std/src/","hardhat-deploy/=node_modules/hardhat-deploy/","solady/=node_modules/solady/src/"],"optimizer":{"enabled":true,"runs":200},"metadata":{"bytecodeHash":"none","appendCBOR":false},"compilationTarget":{"contracts/test/mocks/MockCrossChainEntitlement.sol":"MockCrossChainEntitlement"},"evmVersion":"paris","libraries":{}},"sources":{"contracts/src/spaces/entitlements/ICrossChainEntitlement.sol":{"keccak256":"0xc4f8345418d1a53484a0896639f1201f6afd899be0a9ca89c7e4a4717b91635b","urls":["bzz-raw://615519730737ea5621fb1feeda4dc652ad2a5823d7d5613e4a4d0be6f17d9cef","dweb:/ipfs/QmZnajX2f3o7KsTWwYdq4a1Ss37ckJd9FsmBoAADjjNHnn"],"license":"MIT"},"contracts/test/mocks/MockCrossChainEntitlement.sol":{"keccak256":"0xd6e47a178d38b26536e9c8b0fe3233e76e91a9f331742db919d8edff229082f2","urls":["bzz-raw://085f18ab6529ff949097e029b71dbf51b94b88b8e91a1712aaeb0048df03e026","dweb:/ipfs/QmVhNcDUqcR5WoKQJtEBGATbs2sRqn35SEXJ67DUeFDXuu"],"license":"MIT"}},"version":1},"id":388} \ No newline at end of file diff --git a/packages/generated/dev/abis/MockCrossChainEntitlement.metadata.json b/packages/generated/dev/abis/MockCrossChainEntitlement.metadata.json new file mode 100644 index 000000000..2fd2135e0 --- /dev/null +++ b/packages/generated/dev/abis/MockCrossChainEntitlement.metadata.json @@ -0,0 +1,159 @@ +{ + "compiler": { + "version": "0.8.24+commit.e11b9ed9" + }, + "language": "Solidity", + "output": { + "abi": [ + { + "inputs": [ + { + "internalType": "address[]", + "name": "users", + "type": "address[]" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function", + "name": "isEntitled", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ] + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function", + "name": "isEntitledByUserAndId", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ] + }, + { + "inputs": [], + "stateMutability": "pure", + "type": "function", + "name": "parameters", + "outputs": [ + { + "internalType": "struct ICrossChainEntitlement.Parameter[]", + "name": "", + "type": "tuple[]", + "components": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "primitive", + "type": "string" + }, + { + "internalType": "string", + "name": "description", + "type": "string" + } + ] + } + ] + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "id", + "type": "uint256" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "bool", + "name": "entitled", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function", + "name": "setIsEntitled" + } + ], + "devdoc": { + "kind": "dev", + "methods": {}, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": {}, + "version": 1 + } + }, + "settings": { + "remappings": [ + "@openzeppelin/=node_modules/@openzeppelin/", + "@prb/math/=node_modules/@prb/math/src/", + "@prb/test/=node_modules/@prb/test/src/", + "account-abstraction/=node_modules/account-abstraction/contracts/", + "ds-test/=node_modules/ds-test/src/", + "forge-std/=node_modules/forge-std/src/", + "hardhat-deploy/=node_modules/hardhat-deploy/", + "solady/=node_modules/solady/src/" + ], + "optimizer": { + "enabled": true, + "runs": 200 + }, + "metadata": { + "bytecodeHash": "none", + "appendCBOR": false + }, + "compilationTarget": { + "contracts/test/mocks/MockCrossChainEntitlement.sol": "MockCrossChainEntitlement" + }, + "evmVersion": "paris", + "libraries": {} + }, + "sources": { + "contracts/src/spaces/entitlements/ICrossChainEntitlement.sol": { + "keccak256": "0xc4f8345418d1a53484a0896639f1201f6afd899be0a9ca89c7e4a4717b91635b", + "urls": [ + "bzz-raw://615519730737ea5621fb1feeda4dc652ad2a5823d7d5613e4a4d0be6f17d9cef", + "dweb:/ipfs/QmZnajX2f3o7KsTWwYdq4a1Ss37ckJd9FsmBoAADjjNHnn" + ], + "license": "MIT" + }, + "contracts/test/mocks/MockCrossChainEntitlement.sol": { + "keccak256": "0xd6e47a178d38b26536e9c8b0fe3233e76e91a9f331742db919d8edff229082f2", + "urls": [ + "bzz-raw://085f18ab6529ff949097e029b71dbf51b94b88b8e91a1712aaeb0048df03e026", + "dweb:/ipfs/QmVhNcDUqcR5WoKQJtEBGATbs2sRqn35SEXJ67DUeFDXuu" + ], + "license": "MIT" + } + }, + "version": 1 +} \ No newline at end of file diff --git a/packages/generated/dev/typings/ICrossChainEntitlement.ts b/packages/generated/dev/typings/ICrossChainEntitlement.ts new file mode 100644 index 000000000..eadbcb799 --- /dev/null +++ b/packages/generated/dev/typings/ICrossChainEntitlement.ts @@ -0,0 +1,143 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BytesLike, + CallOverrides, + PopulatedTransaction, + Signer, + utils, +} from "ethers"; +import type { FunctionFragment, Result } from "@ethersproject/abi"; +import type { Listener, Provider } from "@ethersproject/providers"; +import type { + TypedEventFilter, + TypedEvent, + TypedListener, + OnEvent, + PromiseOrValue, +} from "./common"; + +export declare namespace ICrossChainEntitlement { + export type ParameterStruct = { + name: PromiseOrValue; + primitive: PromiseOrValue; + description: PromiseOrValue; + }; + + export type ParameterStructOutput = [string, string, string] & { + name: string; + primitive: string; + description: string; + }; +} + +export interface ICrossChainEntitlementInterface extends utils.Interface { + functions: { + "isEntitled(address[],bytes)": FunctionFragment; + "parameters()": FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: "isEntitled" | "parameters" + ): FunctionFragment; + + encodeFunctionData( + functionFragment: "isEntitled", + values: [PromiseOrValue[], PromiseOrValue] + ): string; + encodeFunctionData( + functionFragment: "parameters", + values?: undefined + ): string; + + decodeFunctionResult(functionFragment: "isEntitled", data: BytesLike): Result; + decodeFunctionResult(functionFragment: "parameters", data: BytesLike): Result; + + events: {}; +} + +export interface ICrossChainEntitlement extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: ICrossChainEntitlementInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined + ): Promise>; + + listeners( + eventFilter?: TypedEventFilter + ): Array>; + listeners(eventName?: string): Array; + removeAllListeners( + eventFilter: TypedEventFilter + ): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + isEntitled( + users: PromiseOrValue[], + parameters: PromiseOrValue, + overrides?: CallOverrides + ): Promise<[boolean]>; + + parameters( + overrides?: CallOverrides + ): Promise<[ICrossChainEntitlement.ParameterStructOutput[]]>; + }; + + isEntitled( + users: PromiseOrValue[], + parameters: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + parameters( + overrides?: CallOverrides + ): Promise; + + callStatic: { + isEntitled( + users: PromiseOrValue[], + parameters: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + parameters( + overrides?: CallOverrides + ): Promise; + }; + + filters: {}; + + estimateGas: { + isEntitled( + users: PromiseOrValue[], + parameters: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + parameters(overrides?: CallOverrides): Promise; + }; + + populateTransaction: { + isEntitled( + users: PromiseOrValue[], + parameters: PromiseOrValue, + overrides?: CallOverrides + ): Promise; + + parameters(overrides?: CallOverrides): Promise; + }; +} diff --git a/packages/generated/dev/typings/factories/ICrossChainEntitlement__factory.ts b/packages/generated/dev/typings/factories/ICrossChainEntitlement__factory.ts new file mode 100644 index 000000000..fe8f5b0c5 --- /dev/null +++ b/packages/generated/dev/typings/factories/ICrossChainEntitlement__factory.ts @@ -0,0 +1,84 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from "ethers"; +import type { Provider } from "@ethersproject/providers"; +import type { + ICrossChainEntitlement, + ICrossChainEntitlementInterface, +} from "../ICrossChainEntitlement"; + +const _abi = [ + { + type: "function", + name: "isEntitled", + inputs: [ + { + name: "users", + type: "address[]", + internalType: "address[]", + }, + { + name: "parameters", + type: "bytes", + internalType: "bytes", + }, + ], + outputs: [ + { + name: "", + type: "bool", + internalType: "bool", + }, + ], + stateMutability: "view", + }, + { + type: "function", + name: "parameters", + inputs: [], + outputs: [ + { + name: "", + type: "tuple[]", + internalType: "struct ICrossChainEntitlement.Parameter[]", + components: [ + { + name: "name", + type: "string", + internalType: "string", + }, + { + name: "primitive", + type: "string", + internalType: "string", + }, + { + name: "description", + type: "string", + internalType: "string", + }, + ], + }, + ], + stateMutability: "view", + }, +] as const; + +export class ICrossChainEntitlement__factory { + static readonly abi = _abi; + static createInterface(): ICrossChainEntitlementInterface { + return new utils.Interface(_abi) as ICrossChainEntitlementInterface; + } + static connect( + address: string, + signerOrProvider: Signer | Provider + ): ICrossChainEntitlement { + return new Contract( + address, + _abi, + signerOrProvider + ) as ICrossChainEntitlement; + } +} diff --git a/packages/sdk/src/channelsWithEntitlements.test.ts b/packages/sdk/src/channelsWithEntitlements.test.ts index 72f2121d5..bf5bad888 100644 --- a/packages/sdk/src/channelsWithEntitlements.test.ts +++ b/packages/sdk/src/channelsWithEntitlements.test.ts @@ -995,7 +995,8 @@ describe('channelsWithEntitlements', () => { log('Done', Date.now() - doneStart) }) - test('custom entitlement gate pass', async () => { + // TODO: re-enable as part of https://github.com/river-build/river/issues/1046 + test.skip('custom entitlement gate pass', async () => { const ruleData = treeToRuleData(await customCheckOp('TestCustom')) const { alice, bob, alicesWallet, aliceSpaceDapp, spaceId, channelId } = @@ -1017,7 +1018,8 @@ describe('channelsWithEntitlements', () => { log('Done', Date.now() - doneStart) }) - test('custom entitlement gate fail', async () => { + // TODO: re-enable as part of https://github.com/river-build/river/issues/1046 + test.skip('custom entitlement gate fail', async () => { const ruleData = treeToRuleData(await customCheckOp('TestCustom')) const { alice, bob, alicesWallet, aliceSpaceDapp, spaceId, channelId } = @@ -1039,7 +1041,8 @@ describe('channelsWithEntitlements', () => { log('Done', Date.now() - doneStart) }) - test('custom entitlement gate join pass - join as root, linked wallet entitled', async () => { + // TODO: re-enable as part of https://github.com/river-build/river/issues/1046 + test.skip('custom entitlement gate join pass - join as root, linked wallet entitled', async () => { const ruleData = treeToRuleData(await customCheckOp('TestCustom')) const { @@ -1079,7 +1082,8 @@ describe('channelsWithEntitlements', () => { log('Done', Date.now() - doneStart) }) - test('custom entitlement gated join - join as linked wallet, assets in root wallet', async () => { + // TODO: re-enable as part of https://github.com/river-build/river/issues/1046 + test.skip('custom entitlement gated join - join as linked wallet, assets in root wallet', async () => { const ruleData = treeToRuleData(await customCheckOp('TestCustom')) const { alice, diff --git a/packages/sdk/src/spaceWithEntitlements.test.ts b/packages/sdk/src/spaceWithEntitlements.test.ts index e832afe15..281343dba 100644 --- a/packages/sdk/src/spaceWithEntitlements.test.ts +++ b/packages/sdk/src/spaceWithEntitlements.test.ts @@ -950,7 +950,8 @@ describe('spaceWithEntitlements', () => { log('Done', Date.now() - doneStart) }) - test('customEntitlementGateJoinPass', async () => { + // TODO: re-enable as part of https://github.com/river-build/river/issues/1046 + test.skip('customEntitlementGateJoinPass', async () => { const ruleData = treeToRuleData(await customCheckOp('TestCustom')) const { alice, bob, aliceSpaceDapp, aliceProvider, alicesWallet, spaceId, channelId } = @@ -984,7 +985,8 @@ describe('spaceWithEntitlements', () => { log('Done', Date.now() - doneStart) }) - test('customEntitlementGateJoinFail', async () => { + // TODO: re-enable as part of https://github.com/river-build/river/issues/1046 + test.skip('customEntitlementGateJoinFail', async () => { const ruleData = treeToRuleData(await customCheckOp('TestCustom')) const { alice, bob, aliceSpaceDapp, aliceProvider, alicesWallet, spaceId } = await createTownWithRequirements({ @@ -1012,7 +1014,8 @@ describe('spaceWithEntitlements', () => { log('Done', Date.now() - doneStart) }) - test('customEntitlementGateJoinPass - join as root, asset in linked wallet', async () => { + // TODO: re-enable as part of https://github.com/river-build/river/issues/1046 + test.skip('customEntitlementGateJoinPass - join as root, asset in linked wallet', async () => { const ruleData = treeToRuleData(await customCheckOp('TestCustom')) const { alice, @@ -1057,7 +1060,7 @@ describe('spaceWithEntitlements', () => { log('Done', Date.now() - doneStart) }) - test('customEntitlementGateJoinPass - join as linked wallet, asset in root wallet', async () => { + test.skip('customEntitlementGateJoinPass - join as linked wallet, asset in root wallet', async () => { const contractName = 'TestCustom' const customAddress = await TestCustomEntitlement.getContractAddress(contractName) const op: Operation = { diff --git a/packages/sdk/src/util.test.ts b/packages/sdk/src/util.test.ts index 9bea02154..4d7a1c387 100644 --- a/packages/sdk/src/util.test.ts +++ b/packages/sdk/src/util.test.ts @@ -182,6 +182,7 @@ export async function erc20CheckOp(contractName: string, threshold: bigint): Pro } } +// TODO: update to crossChainCheckOp as part of https://github.com/river-build/river/issues/1046 export async function customCheckOp(contractName: string): Promise { const contractAddress = await TestCustomEntitlement.getContractAddress(contractName) return { diff --git a/scripts/build-contract-types.sh b/scripts/build-contract-types.sh index 13b9cc9ab..66aa636eb 100755 --- a/scripts/build-contract-types.sh +++ b/scripts/build-contract-types.sh @@ -9,11 +9,11 @@ ABI_DIR="packages/generated/dev/abis" forge build -CONTRACT_INTERFACES="(IDiamond|IDiamondCut|IArchitect|ILegacyArchitect|IProxyManager|IPausable|IEntitlementsManager|IChannel|IRoles|IMulticall|IRuleEntitlement|IRuleEntitlementV2|IWalletLink|INodeRegistry|IOperatorRegistry|IStreamRegistry|OwnableFacet|TokenPausableFacet|UserEntitlement|ISpaceOwner|MockERC721A|MembershipFacet|Member|IBanning|IPricingModules|ICustomEntitlement|MockEntitlementGated|PrepayFacet|IERC721AQueryable|IEntitlementDataQueryable|PlatformRequirementsFacet|IERC721A|INodeOperator|ISpaceDelegation|IEntitlementChecker|IERC5267)" +CONTRACT_INTERFACES="(IDiamond|IDiamondCut|IArchitect|ILegacyArchitect|IProxyManager|IPausable|IEntitlementsManager|IChannel|IRoles|IMulticall|IRuleEntitlement|IRuleEntitlementV2|IWalletLink|INodeRegistry|IOperatorRegistry|IStreamRegistry|OwnableFacet|TokenPausableFacet|UserEntitlement|ISpaceOwner|MockERC721A|MembershipFacet|Member|IBanning|IPricingModules|ICrossChainEntitlement|MockEntitlementGated|PrepayFacet|IERC721AQueryable|IEntitlementDataQueryable|PlatformRequirementsFacet|IERC721A|INodeOperator|ISpaceDelegation|IEntitlementChecker|IERC5267)" yarn typechain --target=ethers-v5 "contracts/out/**/?${CONTRACT_INTERFACES}.json" --out-dir "packages/generated/dev/typings" -mkdir -p $ABI_DIR && cp -a contracts/out/{Diamond,DiamondCutFacet,Architect,MockLegacyArchitect,ProxyManager,IPausable,EntitlementsManager,Channels,Roles,IMulticall,OwnableFacet,WalletLink,MockWalletLink,NodeRegistry,OperatorRegistry,StreamRegistry,TokenPausableFacet,IRuleEntitlement,UserEntitlement,SpaceOwner,MockERC721A,MembershipFacet,Member,MockRiverRegistry,IBanning,IPricingModules,ICustomEntitlement,MockCustomEntitlement,MockEntitlementGated,PrepayFacet,IERC721AQueryable,IEntitlementDataQueryable,PlatformRequirementsFacet,IERC721A,INodeOperator,ISpaceDelegation,IEntitlementChecker,IERC5267}.sol/* "$ABI_DIR" +mkdir -p $ABI_DIR && cp -a contracts/out/{Diamond,DiamondCutFacet,Architect,MockLegacyArchitect,ProxyManager,IPausable,EntitlementsManager,Channels,Roles,IMulticall,OwnableFacet,WalletLink,MockWalletLink,NodeRegistry,OperatorRegistry,StreamRegistry,TokenPausableFacet,IRuleEntitlement,UserEntitlement,SpaceOwner,MockERC721A,MembershipFacet,Member,MockRiverRegistry,IBanning,IPricingModules,ICrossChainEntitlement,MockCrossChainEntitlement,MockEntitlementGated,PrepayFacet,IERC721AQueryable,IEntitlementDataQueryable,PlatformRequirementsFacet,IERC721A,INodeOperator,ISpaceDelegation,IEntitlementChecker,IERC5267}.sol/* "$ABI_DIR" # Copy the json abis to TS files for type inference for file in $ABI_DIR/*.abi.json; do diff --git a/scripts/gen-river-node-bindings.sh b/scripts/gen-river-node-bindings.sh index 7e93ab7f5..89d4f2795 100755 --- a/scripts/gen-river-node-bindings.sh +++ b/scripts/gen-river-node-bindings.sh @@ -43,10 +43,10 @@ generate_go base base IRuleEntitlementV2 rule_entitlement_v2 IRuleEntitlement generate_go base base IEntitlementChecker i_entitlement_checker generate_go base base IEntitlementGated i_entitlement_gated generate_go base base IEntitlement i_entitlement -generate_go base base ICustomEntitlement i_custom_entitlement +generate_go base base ICrossChainEntitlement i_cross_chain_entitlement # Full Base (and other) contracts for deployment from tests -generate_go base/deploy deploy MockCustomEntitlement mock_custom_entitlement +generate_go base/deploy deploy MockCrossChainEntitlement mock_cross_chain_entitlement generate_go base/deploy deploy MockEntitlementGated mock_entitlement_gated generate_go base/deploy deploy MockEntitlementChecker mock_entitlement_checker generate_go base/deploy deploy EntitlementChecker entitlement_checker