From c4d484eb9f7236a6233ded295c9d5c6aaa08a15f Mon Sep 17 00:00:00 2001 From: fredo Date: Tue, 26 Nov 2024 13:49:50 +0100 Subject: [PATCH 01/13] shutter-service: add initial ShutterRegistry --- foundry.toml | 2 +- src/shutter-service/ShutterRegistry.sol | 71 +++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 src/shutter-service/ShutterRegistry.sol diff --git a/foundry.toml b/foundry.toml index 121e417..3cf092a 100644 --- a/foundry.toml +++ b/foundry.toml @@ -2,7 +2,7 @@ src = "src" out = "out" libs = ["lib"] -solc = "0.8.22" +solc = "0.8.28" extra_output = ['devdoc', 'userdoc', 'metadata', 'storageLayout'] bytecode_hash = 'none' diff --git a/src/shutter-service/ShutterRegistry.sol b/src/shutter-service/ShutterRegistry.sol new file mode 100644 index 0000000..7848730 --- /dev/null +++ b/src/shutter-service/ShutterRegistry.sol @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.28; + +import "openzeppelin/contracts/access/Ownable.sol"; + +/** + * @title ShutterRegistry + * @dev A contract for managing the registration of identities with timestamps, ensuring unique and future-dated registrations. + * Inherits from OpenZeppelin's Ownable contract to enable ownership-based access control. + */ +contract ShutterRegistry is Ownable { + + // Custom error for when an identity is already registered. + error AlreadyRegistered(); + + // Custom error for when a provided timestamp is in the past. + error TimestampInThePast(); + + /** + * @dev Mapping to store registration timestamps for each identity. + * The identity is represented as a `bytes32` hash and mapped to a uint64 timestamp. + */ + mapping(bytes32 identity => uint64 timestamp) public registrations; + + /** + * @dev Emitted when a new identity is successfully registered. + * @param identityPrefix The raw prefix input used to derive the registered identity hash. + * @param sender The address of the account that performed the registration. + * @param timestamp The timestamp associated with the registered identity. + */ + event IdentityRegistered( + bytes32 identityPrefix, + address sender, + uint64 timestamp + ); + + /** + * @dev Initializes the contract and assigns ownership to the deployer. + */ + constructor() Ownable(msg.sender) {} + + /** + * @notice Registers a new identity with a specified timestamp. + * @dev The identity is derived by hashing the provided `identityPrefix` concatenated with the sender's address. + * @param identityPrefix The input used to derive the identity hash. + * @param timestamp The future timestamp to be associated with the identity. + * @custom:requirements + * - The identity must not already be registered. + * - The provided timestamp must not be in the past. + */ + function register(bytes32 identityPrefix, uint64 timestamp) external { + // Generate the identity hash from the provided prefix and the sender's address. + bytes32 identity = keccak256(abi.encodePacked(identityPrefix, msg.sender)); + + // Ensure the identity is not already registered. + require(registrations[identity] == uint64(0), AlreadyRegistered()); + + // Ensure the timestamp is not in the past. + require(timestamp >= block.timestamp, TimestampInThePast()); + + // Store the registration timestamp. + registrations[identity] = timestamp; + + // Emit the IdentityRegistered event. + emit IdentityRegistered( + identityPrefix, + msg.sender, + timestamp + ); + } +} From eba819af42f3ac27128588366af5fa829a853988 Mon Sep 17 00:00:00 2001 From: blockchainluffy Date: Wed, 27 Nov 2024 13:59:25 +0530 Subject: [PATCH 02/13] shutter-service: added eon key and go bindings --- bindings/shutterregistry/shutterregistry.go | 595 ++++++++++++++++++++ src/shutter-service/ShutterRegistry.sol | 5 +- 2 files changed, 599 insertions(+), 1 deletion(-) create mode 100644 bindings/shutterregistry/shutterregistry.go diff --git a/bindings/shutterregistry/shutterregistry.go b/bindings/shutterregistry/shutterregistry.go new file mode 100644 index 0000000..372f5bf --- /dev/null +++ b/bindings/shutterregistry/shutterregistry.go @@ -0,0 +1,595 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package shutterregistry + +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 +) + +// ShutterregistryMetaData contains all meta data concerning the Shutterregistry contract. +var ShutterregistryMetaData = &bind.MetaData{ + ABI: "[{\"type\":\"constructor\",\"inputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"register\",\"inputs\":[{\"name\":\"eon\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"identityPrefix\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"registrations\",\"inputs\":[{\"name\":\"identity\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"IdentityRegistered\",\"inputs\":[{\"name\":\"eon\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"identityPrefix\",\"type\":\"bytes32\",\"indexed\":false,\"internalType\":\"bytes32\"},{\"name\":\"sender\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"timestamp\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"AlreadyRegistered\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"OwnableInvalidOwner\",\"inputs\":[{\"name\":\"owner\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"OwnableUnauthorizedAccount\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"TimestampInThePast\",\"inputs\":[]}]", +} + +// ShutterregistryABI is the input ABI used to generate the binding from. +// Deprecated: Use ShutterregistryMetaData.ABI instead. +var ShutterregistryABI = ShutterregistryMetaData.ABI + +// Shutterregistry is an auto generated Go binding around an Ethereum contract. +type Shutterregistry struct { + ShutterregistryCaller // Read-only binding to the contract + ShutterregistryTransactor // Write-only binding to the contract + ShutterregistryFilterer // Log filterer for contract events +} + +// ShutterregistryCaller is an auto generated read-only Go binding around an Ethereum contract. +type ShutterregistryCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ShutterregistryTransactor is an auto generated write-only Go binding around an Ethereum contract. +type ShutterregistryTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ShutterregistryFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type ShutterregistryFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ShutterregistrySession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type ShutterregistrySession struct { + Contract *Shutterregistry // 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 +} + +// ShutterregistryCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type ShutterregistryCallerSession struct { + Contract *ShutterregistryCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// ShutterregistryTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type ShutterregistryTransactorSession struct { + Contract *ShutterregistryTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ShutterregistryRaw is an auto generated low-level Go binding around an Ethereum contract. +type ShutterregistryRaw struct { + Contract *Shutterregistry // Generic contract binding to access the raw methods on +} + +// ShutterregistryCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type ShutterregistryCallerRaw struct { + Contract *ShutterregistryCaller // Generic read-only contract binding to access the raw methods on +} + +// ShutterregistryTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type ShutterregistryTransactorRaw struct { + Contract *ShutterregistryTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewShutterregistry creates a new instance of Shutterregistry, bound to a specific deployed contract. +func NewShutterregistry(address common.Address, backend bind.ContractBackend) (*Shutterregistry, error) { + contract, err := bindShutterregistry(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Shutterregistry{ShutterregistryCaller: ShutterregistryCaller{contract: contract}, ShutterregistryTransactor: ShutterregistryTransactor{contract: contract}, ShutterregistryFilterer: ShutterregistryFilterer{contract: contract}}, nil +} + +// NewShutterregistryCaller creates a new read-only instance of Shutterregistry, bound to a specific deployed contract. +func NewShutterregistryCaller(address common.Address, caller bind.ContractCaller) (*ShutterregistryCaller, error) { + contract, err := bindShutterregistry(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &ShutterregistryCaller{contract: contract}, nil +} + +// NewShutterregistryTransactor creates a new write-only instance of Shutterregistry, bound to a specific deployed contract. +func NewShutterregistryTransactor(address common.Address, transactor bind.ContractTransactor) (*ShutterregistryTransactor, error) { + contract, err := bindShutterregistry(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &ShutterregistryTransactor{contract: contract}, nil +} + +// NewShutterregistryFilterer creates a new log filterer instance of Shutterregistry, bound to a specific deployed contract. +func NewShutterregistryFilterer(address common.Address, filterer bind.ContractFilterer) (*ShutterregistryFilterer, error) { + contract, err := bindShutterregistry(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &ShutterregistryFilterer{contract: contract}, nil +} + +// bindShutterregistry binds a generic wrapper to an already deployed contract. +func bindShutterregistry(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(ShutterregistryABI)) + 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 (_Shutterregistry *ShutterregistryRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Shutterregistry.Contract.ShutterregistryCaller.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 (_Shutterregistry *ShutterregistryRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Shutterregistry.Contract.ShutterregistryTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Shutterregistry *ShutterregistryRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Shutterregistry.Contract.ShutterregistryTransactor.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 (_Shutterregistry *ShutterregistryCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Shutterregistry.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 (_Shutterregistry *ShutterregistryTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Shutterregistry.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Shutterregistry *ShutterregistryTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Shutterregistry.Contract.contract.Transact(opts, method, params...) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Shutterregistry *ShutterregistryCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Shutterregistry.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Shutterregistry *ShutterregistrySession) Owner() (common.Address, error) { + return _Shutterregistry.Contract.Owner(&_Shutterregistry.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Shutterregistry *ShutterregistryCallerSession) Owner() (common.Address, error) { + return _Shutterregistry.Contract.Owner(&_Shutterregistry.CallOpts) +} + +// Registrations is a free data retrieval call binding the contract method 0xda7c6a42. +// +// Solidity: function registrations(bytes32 identity) view returns(uint64 timestamp) +func (_Shutterregistry *ShutterregistryCaller) Registrations(opts *bind.CallOpts, identity [32]byte) (uint64, error) { + var out []interface{} + err := _Shutterregistry.contract.Call(opts, &out, "registrations", identity) + + if err != nil { + return *new(uint64), err + } + + out0 := *abi.ConvertType(out[0], new(uint64)).(*uint64) + + return out0, err + +} + +// Registrations is a free data retrieval call binding the contract method 0xda7c6a42. +// +// Solidity: function registrations(bytes32 identity) view returns(uint64 timestamp) +func (_Shutterregistry *ShutterregistrySession) Registrations(identity [32]byte) (uint64, error) { + return _Shutterregistry.Contract.Registrations(&_Shutterregistry.CallOpts, identity) +} + +// Registrations is a free data retrieval call binding the contract method 0xda7c6a42. +// +// Solidity: function registrations(bytes32 identity) view returns(uint64 timestamp) +func (_Shutterregistry *ShutterregistryCallerSession) Registrations(identity [32]byte) (uint64, error) { + return _Shutterregistry.Contract.Registrations(&_Shutterregistry.CallOpts, identity) +} + +// Register is a paid mutator transaction binding the contract method 0xeaac3573. +// +// Solidity: function register(uint64 eon, bytes32 identityPrefix, uint64 timestamp) returns() +func (_Shutterregistry *ShutterregistryTransactor) Register(opts *bind.TransactOpts, eon uint64, identityPrefix [32]byte, timestamp uint64) (*types.Transaction, error) { + return _Shutterregistry.contract.Transact(opts, "register", eon, identityPrefix, timestamp) +} + +// Register is a paid mutator transaction binding the contract method 0xeaac3573. +// +// Solidity: function register(uint64 eon, bytes32 identityPrefix, uint64 timestamp) returns() +func (_Shutterregistry *ShutterregistrySession) Register(eon uint64, identityPrefix [32]byte, timestamp uint64) (*types.Transaction, error) { + return _Shutterregistry.Contract.Register(&_Shutterregistry.TransactOpts, eon, identityPrefix, timestamp) +} + +// Register is a paid mutator transaction binding the contract method 0xeaac3573. +// +// Solidity: function register(uint64 eon, bytes32 identityPrefix, uint64 timestamp) returns() +func (_Shutterregistry *ShutterregistryTransactorSession) Register(eon uint64, identityPrefix [32]byte, timestamp uint64) (*types.Transaction, error) { + return _Shutterregistry.Contract.Register(&_Shutterregistry.TransactOpts, eon, identityPrefix, timestamp) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Shutterregistry *ShutterregistryTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Shutterregistry.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Shutterregistry *ShutterregistrySession) RenounceOwnership() (*types.Transaction, error) { + return _Shutterregistry.Contract.RenounceOwnership(&_Shutterregistry.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Shutterregistry *ShutterregistryTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _Shutterregistry.Contract.RenounceOwnership(&_Shutterregistry.TransactOpts) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Shutterregistry *ShutterregistryTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _Shutterregistry.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Shutterregistry *ShutterregistrySession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _Shutterregistry.Contract.TransferOwnership(&_Shutterregistry.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Shutterregistry *ShutterregistryTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _Shutterregistry.Contract.TransferOwnership(&_Shutterregistry.TransactOpts, newOwner) +} + +// ShutterregistryIdentityRegisteredIterator is returned from FilterIdentityRegistered and is used to iterate over the raw logs and unpacked data for IdentityRegistered events raised by the Shutterregistry contract. +type ShutterregistryIdentityRegisteredIterator struct { + Event *ShutterregistryIdentityRegistered // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ShutterregistryIdentityRegisteredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ShutterregistryIdentityRegistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ShutterregistryIdentityRegistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ShutterregistryIdentityRegisteredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ShutterregistryIdentityRegisteredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ShutterregistryIdentityRegistered represents a IdentityRegistered event raised by the Shutterregistry contract. +type ShutterregistryIdentityRegistered struct { + Eon uint64 + IdentityPrefix [32]byte + Sender common.Address + Timestamp uint64 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterIdentityRegistered is a free log retrieval operation binding the contract event 0xa254e5a8078a79959db8c7203cbd84a28d6e1b9750d0c4fd743a1a069c21b05b. +// +// Solidity: event IdentityRegistered(uint64 eon, bytes32 identityPrefix, address sender, uint64 timestamp) +func (_Shutterregistry *ShutterregistryFilterer) FilterIdentityRegistered(opts *bind.FilterOpts) (*ShutterregistryIdentityRegisteredIterator, error) { + + logs, sub, err := _Shutterregistry.contract.FilterLogs(opts, "IdentityRegistered") + if err != nil { + return nil, err + } + return &ShutterregistryIdentityRegisteredIterator{contract: _Shutterregistry.contract, event: "IdentityRegistered", logs: logs, sub: sub}, nil +} + +// WatchIdentityRegistered is a free log subscription operation binding the contract event 0xa254e5a8078a79959db8c7203cbd84a28d6e1b9750d0c4fd743a1a069c21b05b. +// +// Solidity: event IdentityRegistered(uint64 eon, bytes32 identityPrefix, address sender, uint64 timestamp) +func (_Shutterregistry *ShutterregistryFilterer) WatchIdentityRegistered(opts *bind.WatchOpts, sink chan<- *ShutterregistryIdentityRegistered) (event.Subscription, error) { + + logs, sub, err := _Shutterregistry.contract.WatchLogs(opts, "IdentityRegistered") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ShutterregistryIdentityRegistered) + if err := _Shutterregistry.contract.UnpackLog(event, "IdentityRegistered", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseIdentityRegistered is a log parse operation binding the contract event 0xa254e5a8078a79959db8c7203cbd84a28d6e1b9750d0c4fd743a1a069c21b05b. +// +// Solidity: event IdentityRegistered(uint64 eon, bytes32 identityPrefix, address sender, uint64 timestamp) +func (_Shutterregistry *ShutterregistryFilterer) ParseIdentityRegistered(log types.Log) (*ShutterregistryIdentityRegistered, error) { + event := new(ShutterregistryIdentityRegistered) + if err := _Shutterregistry.contract.UnpackLog(event, "IdentityRegistered", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ShutterregistryOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the Shutterregistry contract. +type ShutterregistryOwnershipTransferredIterator struct { + Event *ShutterregistryOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ShutterregistryOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ShutterregistryOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ShutterregistryOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ShutterregistryOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ShutterregistryOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ShutterregistryOwnershipTransferred represents a OwnershipTransferred event raised by the Shutterregistry contract. +type ShutterregistryOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Shutterregistry *ShutterregistryFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*ShutterregistryOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _Shutterregistry.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &ShutterregistryOwnershipTransferredIterator{contract: _Shutterregistry.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Shutterregistry *ShutterregistryFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *ShutterregistryOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _Shutterregistry.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ShutterregistryOwnershipTransferred) + if err := _Shutterregistry.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Shutterregistry *ShutterregistryFilterer) ParseOwnershipTransferred(log types.Log) (*ShutterregistryOwnershipTransferred, error) { + event := new(ShutterregistryOwnershipTransferred) + if err := _Shutterregistry.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/src/shutter-service/ShutterRegistry.sol b/src/shutter-service/ShutterRegistry.sol index 7848730..cd05dc1 100644 --- a/src/shutter-service/ShutterRegistry.sol +++ b/src/shutter-service/ShutterRegistry.sol @@ -29,6 +29,7 @@ contract ShutterRegistry is Ownable { * @param timestamp The timestamp associated with the registered identity. */ event IdentityRegistered( + uint64 eon, bytes32 identityPrefix, address sender, uint64 timestamp @@ -42,13 +43,14 @@ contract ShutterRegistry is Ownable { /** * @notice Registers a new identity with a specified timestamp. * @dev The identity is derived by hashing the provided `identityPrefix` concatenated with the sender's address. + * @param eon The eon associated with the identity. * @param identityPrefix The input used to derive the identity hash. * @param timestamp The future timestamp to be associated with the identity. * @custom:requirements * - The identity must not already be registered. * - The provided timestamp must not be in the past. */ - function register(bytes32 identityPrefix, uint64 timestamp) external { + function register(uint64 eon, bytes32 identityPrefix, uint64 timestamp) external { // Generate the identity hash from the provided prefix and the sender's address. bytes32 identity = keccak256(abi.encodePacked(identityPrefix, msg.sender)); @@ -63,6 +65,7 @@ contract ShutterRegistry is Ownable { // Emit the IdentityRegistered event. emit IdentityRegistered( + eon, identityPrefix, msg.sender, timestamp From 33e7d082ed581d0d40921936ebf5bb4bb72a6490 Mon Sep 17 00:00:00 2001 From: faheelsattar Date: Wed, 27 Nov 2024 21:38:09 +0500 Subject: [PATCH 03/13] fix doc --- src/shutter-service/ShutterRegistry.sol | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/shutter-service/ShutterRegistry.sol b/src/shutter-service/ShutterRegistry.sol index cd05dc1..d9bf71a 100644 --- a/src/shutter-service/ShutterRegistry.sol +++ b/src/shutter-service/ShutterRegistry.sol @@ -9,7 +9,6 @@ import "openzeppelin/contracts/access/Ownable.sol"; * Inherits from OpenZeppelin's Ownable contract to enable ownership-based access control. */ contract ShutterRegistry is Ownable { - // Custom error for when an identity is already registered. error AlreadyRegistered(); @@ -24,6 +23,7 @@ contract ShutterRegistry is Ownable { /** * @dev Emitted when a new identity is successfully registered. + * @param eon The eon associated with the identity. * @param identityPrefix The raw prefix input used to derive the registered identity hash. * @param sender The address of the account that performed the registration. * @param timestamp The timestamp associated with the registered identity. @@ -50,9 +50,15 @@ contract ShutterRegistry is Ownable { * - The identity must not already be registered. * - The provided timestamp must not be in the past. */ - function register(uint64 eon, bytes32 identityPrefix, uint64 timestamp) external { + function register( + uint64 eon, + bytes32 identityPrefix, + uint64 timestamp + ) external { // Generate the identity hash from the provided prefix and the sender's address. - bytes32 identity = keccak256(abi.encodePacked(identityPrefix, msg.sender)); + bytes32 identity = keccak256( + abi.encodePacked(identityPrefix, msg.sender) + ); // Ensure the identity is not already registered. require(registrations[identity] == uint64(0), AlreadyRegistered()); @@ -64,11 +70,6 @@ contract ShutterRegistry is Ownable { registrations[identity] = timestamp; // Emit the IdentityRegistered event. - emit IdentityRegistered( - eon, - identityPrefix, - msg.sender, - timestamp - ); + emit IdentityRegistered(eon, identityPrefix, msg.sender, timestamp); } } From 41acc96a2db442d2179c25848ba9607a9a1631d7 Mon Sep 17 00:00:00 2001 From: faheelsattar Date: Fri, 29 Nov 2024 17:10:00 +0500 Subject: [PATCH 04/13] shutter-service: update storage --- bindings/shutterregistry/shutterregistry.go | 39 ++++++++++++++------- gen_bindings.sh | 1 + src/shutter-service/ShutterRegistry.sol | 21 ++++++----- 3 files changed, 41 insertions(+), 20 deletions(-) diff --git a/bindings/shutterregistry/shutterregistry.go b/bindings/shutterregistry/shutterregistry.go index 372f5bf..b1378be 100644 --- a/bindings/shutterregistry/shutterregistry.go +++ b/bindings/shutterregistry/shutterregistry.go @@ -26,11 +26,12 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = event.NewSubscription + _ = abi.ConvertType ) // ShutterregistryMetaData contains all meta data concerning the Shutterregistry contract. var ShutterregistryMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"constructor\",\"inputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"register\",\"inputs\":[{\"name\":\"eon\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"identityPrefix\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"registrations\",\"inputs\":[{\"name\":\"identity\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"IdentityRegistered\",\"inputs\":[{\"name\":\"eon\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"identityPrefix\",\"type\":\"bytes32\",\"indexed\":false,\"internalType\":\"bytes32\"},{\"name\":\"sender\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"timestamp\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"AlreadyRegistered\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"OwnableInvalidOwner\",\"inputs\":[{\"name\":\"owner\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"OwnableUnauthorizedAccount\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"TimestampInThePast\",\"inputs\":[]}]", + ABI: "[{\"type\":\"constructor\",\"inputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"register\",\"inputs\":[{\"name\":\"eon\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"identityPrefix\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"registrations\",\"inputs\":[{\"name\":\"identity\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"eon\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"IdentityRegistered\",\"inputs\":[{\"name\":\"eon\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"identityPrefix\",\"type\":\"bytes32\",\"indexed\":false,\"internalType\":\"bytes32\"},{\"name\":\"sender\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"timestamp\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"AlreadyRegistered\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"OwnableInvalidOwner\",\"inputs\":[{\"name\":\"owner\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"OwnableUnauthorizedAccount\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"TimestampInThePast\",\"inputs\":[]}]", } // ShutterregistryABI is the input ABI used to generate the binding from. @@ -134,11 +135,11 @@ func NewShutterregistryFilterer(address common.Address, filterer bind.ContractFi // bindShutterregistry binds a generic wrapper to an already deployed contract. func bindShutterregistry(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(ShutterregistryABI)) + parsed, err := ShutterregistryMetaData.GetAbi() if err != nil { return nil, err } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil } // Call invokes the (constant) contract method with params as input values and @@ -212,32 +213,46 @@ func (_Shutterregistry *ShutterregistryCallerSession) Owner() (common.Address, e // Registrations is a free data retrieval call binding the contract method 0xda7c6a42. // -// Solidity: function registrations(bytes32 identity) view returns(uint64 timestamp) -func (_Shutterregistry *ShutterregistryCaller) Registrations(opts *bind.CallOpts, identity [32]byte) (uint64, error) { +// Solidity: function registrations(bytes32 identity) view returns(uint64 eon, uint64 timestamp) +func (_Shutterregistry *ShutterregistryCaller) Registrations(opts *bind.CallOpts, identity [32]byte) (struct { + Eon uint64 + Timestamp uint64 +}, error) { var out []interface{} err := _Shutterregistry.contract.Call(opts, &out, "registrations", identity) + outstruct := new(struct { + Eon uint64 + Timestamp uint64 + }) if err != nil { - return *new(uint64), err + return *outstruct, err } - out0 := *abi.ConvertType(out[0], new(uint64)).(*uint64) + outstruct.Eon = *abi.ConvertType(out[0], new(uint64)).(*uint64) + outstruct.Timestamp = *abi.ConvertType(out[1], new(uint64)).(*uint64) - return out0, err + return *outstruct, err } // Registrations is a free data retrieval call binding the contract method 0xda7c6a42. // -// Solidity: function registrations(bytes32 identity) view returns(uint64 timestamp) -func (_Shutterregistry *ShutterregistrySession) Registrations(identity [32]byte) (uint64, error) { +// Solidity: function registrations(bytes32 identity) view returns(uint64 eon, uint64 timestamp) +func (_Shutterregistry *ShutterregistrySession) Registrations(identity [32]byte) (struct { + Eon uint64 + Timestamp uint64 +}, error) { return _Shutterregistry.Contract.Registrations(&_Shutterregistry.CallOpts, identity) } // Registrations is a free data retrieval call binding the contract method 0xda7c6a42. // -// Solidity: function registrations(bytes32 identity) view returns(uint64 timestamp) -func (_Shutterregistry *ShutterregistryCallerSession) Registrations(identity [32]byte) (uint64, error) { +// Solidity: function registrations(bytes32 identity) view returns(uint64 eon, uint64 timestamp) +func (_Shutterregistry *ShutterregistryCallerSession) Registrations(identity [32]byte) (struct { + Eon uint64 + Timestamp uint64 +}, error) { return _Shutterregistry.Contract.Registrations(&_Shutterregistry.CallOpts, identity) } diff --git a/gen_bindings.sh b/gen_bindings.sh index 8c37ba6..f017c4c 100755 --- a/gen_bindings.sh +++ b/gen_bindings.sh @@ -8,6 +8,7 @@ CONTRACTS=( "EonKeyPublish" "KeyBroadcastContract" "Inbox" + "ShutterRegistry" ) OUTPUT_DIR="bindings" PACKAGE_NAME="bindings" diff --git a/src/shutter-service/ShutterRegistry.sol b/src/shutter-service/ShutterRegistry.sol index d9bf71a..ee1d7a5 100644 --- a/src/shutter-service/ShutterRegistry.sol +++ b/src/shutter-service/ShutterRegistry.sol @@ -15,15 +15,19 @@ contract ShutterRegistry is Ownable { // Custom error for when a provided timestamp is in the past. error TimestampInThePast(); + struct RegsitrationData { + uint64 eon; + uint64 timestamp; + } /** * @dev Mapping to store registration timestamps for each identity. * The identity is represented as a `bytes32` hash and mapped to a uint64 timestamp. */ - mapping(bytes32 identity => uint64 timestamp) public registrations; + mapping(bytes32 identity => RegsitrationData) public registrations; /** * @dev Emitted when a new identity is successfully registered. - * @param eon The eon associated with the identity. + * @param eon The eon associated with the identity. * @param identityPrefix The raw prefix input used to derive the registered identity hash. * @param sender The address of the account that performed the registration. * @param timestamp The timestamp associated with the registered identity. @@ -55,19 +59,20 @@ contract ShutterRegistry is Ownable { bytes32 identityPrefix, uint64 timestamp ) external { + // Ensure the timestamp is not in the past. + require(timestamp >= block.timestamp, TimestampInThePast()); + // Generate the identity hash from the provided prefix and the sender's address. bytes32 identity = keccak256( abi.encodePacked(identityPrefix, msg.sender) ); - + RegsitrationData storage registrationData = registrations[identity]; // Ensure the identity is not already registered. - require(registrations[identity] == uint64(0), AlreadyRegistered()); - - // Ensure the timestamp is not in the past. - require(timestamp >= block.timestamp, TimestampInThePast()); + require(registrationData.timestamp == 0, AlreadyRegistered()); // Store the registration timestamp. - registrations[identity] = timestamp; + registrationData.eon = eon; + registrationData.timestamp = timestamp; // Emit the IdentityRegistered event. emit IdentityRegistered(eon, identityPrefix, msg.sender, timestamp); From 94a4748cd4ea6148626a39f8a784e5d6406cbb24 Mon Sep 17 00:00:00 2001 From: faheelsattar Date: Fri, 29 Nov 2024 17:13:44 +0500 Subject: [PATCH 05/13] shutter-service: update doc --- src/shutter-service/ShutterRegistry.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/shutter-service/ShutterRegistry.sol b/src/shutter-service/ShutterRegistry.sol index ee1d7a5..a04b8d9 100644 --- a/src/shutter-service/ShutterRegistry.sol +++ b/src/shutter-service/ShutterRegistry.sol @@ -20,8 +20,8 @@ contract ShutterRegistry is Ownable { uint64 timestamp; } /** - * @dev Mapping to store registration timestamps for each identity. - * The identity is represented as a `bytes32` hash and mapped to a uint64 timestamp. + * @dev Mapping to store registration data for each identity. + * The identity is represented as a `bytes32` hash and mapped to struct RegsitrationData. */ mapping(bytes32 identity => RegsitrationData) public registrations; @@ -45,7 +45,7 @@ contract ShutterRegistry is Ownable { constructor() Ownable(msg.sender) {} /** - * @notice Registers a new identity with a specified timestamp. + * @notice Registers a new identity with a specified timestamp and eon. * @dev The identity is derived by hashing the provided `identityPrefix` concatenated with the sender's address. * @param eon The eon associated with the identity. * @param identityPrefix The input used to derive the identity hash. From e843e747ddb10e801e84537f86767fad8397f9f9 Mon Sep 17 00:00:00 2001 From: faheelsattar Date: Fri, 29 Nov 2024 22:25:33 +0500 Subject: [PATCH 06/13] shutter-service: fix typo --- src/shutter-service/ShutterRegistry.sol | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/shutter-service/ShutterRegistry.sol b/src/shutter-service/ShutterRegistry.sol index a04b8d9..b0482ba 100644 --- a/src/shutter-service/ShutterRegistry.sol +++ b/src/shutter-service/ShutterRegistry.sol @@ -15,15 +15,15 @@ contract ShutterRegistry is Ownable { // Custom error for when a provided timestamp is in the past. error TimestampInThePast(); - struct RegsitrationData { + struct RegistrationData { uint64 eon; uint64 timestamp; } /** * @dev Mapping to store registration data for each identity. - * The identity is represented as a `bytes32` hash and mapped to struct RegsitrationData. + * The identity is represented as a `bytes32` hash and mapped to struct RegistrationData. */ - mapping(bytes32 identity => RegsitrationData) public registrations; + mapping(bytes32 identity => RegistrationData) public registrations; /** * @dev Emitted when a new identity is successfully registered. @@ -66,7 +66,7 @@ contract ShutterRegistry is Ownable { bytes32 identity = keccak256( abi.encodePacked(identityPrefix, msg.sender) ); - RegsitrationData storage registrationData = registrations[identity]; + RegistrationData storage registrationData = registrations[identity]; // Ensure the identity is not already registered. require(registrationData.timestamp == 0, AlreadyRegistered()); From 416868749e9c251c6314dff656d2d5832d552da9 Mon Sep 17 00:00:00 2001 From: blockchainluffy Date: Thu, 12 Dec 2024 17:05:18 +0530 Subject: [PATCH 07/13] shutter-service: added scripts to deploy and submit tx --- script/DeployRegistry.service.s.sol | 23 +++++++++++++++++++++++ script/SubmitTransaction.service.s.sol | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 script/DeployRegistry.service.s.sol create mode 100644 script/SubmitTransaction.service.s.sol diff --git a/script/DeployRegistry.service.s.sol b/script/DeployRegistry.service.s.sol new file mode 100644 index 0000000..baeb70a --- /dev/null +++ b/script/DeployRegistry.service.s.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +import "forge-std/Script.sol"; +import "../src/shutter-service/ShutterRegistry.sol"; + +contract Deploy is Script { + function run() external { + uint256 deployKey = vm.envUint("DEPLOY_KEY"); + address deployerAddress = vm.addr(deployKey); + console.log("Deployer:", deployerAddress); + vm.startBroadcast(deployKey); + deploySequencer(); + vm.stopBroadcast(); + } + + function deploySequencer() public returns (ShutterRegistry) { + ShutterRegistry s = new ShutterRegistry(); + console.log("ShutterRegistry:", address(s)); + return s; + } + +} diff --git a/script/SubmitTransaction.service.s.sol b/script/SubmitTransaction.service.s.sol new file mode 100644 index 0000000..d01ca88 --- /dev/null +++ b/script/SubmitTransaction.service.s.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +import "forge-std/Script.sol"; +import { ShutterRegistry } from "src/shutter-service/ShutterRegistry.sol"; + +contract SubmitTransaction is Script { + function run() external { + uint256 privateKey = vm.envUint("TX_SENDER_KEY"); + ShutterRegistry registry = ShutterRegistry(vm.envAddress("REGISTRY_ADDRESS")); + uint64 eon = uint64(vm.envUint("EON")); + bytes32 identityPrefix = vm.envBytes32("IDENTITY_PREFIX"); + uint64 ts = uint64(vm.envUint("TIMESTAMP")); + + vm.startBroadcast(privateKey); + registry.register( + eon, + identityPrefix, + ts + ); + vm.stopBroadcast(); + } +} From 8774a699cc32db3aad4d64ce1c1675c82024240d Mon Sep 17 00:00:00 2001 From: blockchainluffy Date: Mon, 16 Dec 2024 18:58:01 +0530 Subject: [PATCH 08/13] shutter-service: fix pre-commit --- .gitignore | 1 + script/DeployRegistry.service.s.sol | 1 - script/SubmitTransaction.service.s.sol | 15 +++++++-------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index e9e5e07..9120c09 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ gnoshcontracts/ shopcontracts/ out/ .tool-versions +.env diff --git a/script/DeployRegistry.service.s.sol b/script/DeployRegistry.service.s.sol index baeb70a..85b6945 100644 --- a/script/DeployRegistry.service.s.sol +++ b/script/DeployRegistry.service.s.sol @@ -19,5 +19,4 @@ contract Deploy is Script { console.log("ShutterRegistry:", address(s)); return s; } - } diff --git a/script/SubmitTransaction.service.s.sol b/script/SubmitTransaction.service.s.sol index d01ca88..b2f51fe 100644 --- a/script/SubmitTransaction.service.s.sol +++ b/script/SubmitTransaction.service.s.sol @@ -2,22 +2,21 @@ pragma solidity ^0.8.20; import "forge-std/Script.sol"; -import { ShutterRegistry } from "src/shutter-service/ShutterRegistry.sol"; +import {ShutterRegistry} from "src/shutter-service/ShutterRegistry.sol"; contract SubmitTransaction is Script { function run() external { uint256 privateKey = vm.envUint("TX_SENDER_KEY"); - ShutterRegistry registry = ShutterRegistry(vm.envAddress("REGISTRY_ADDRESS")); + ShutterRegistry registry = ShutterRegistry( + vm.envAddress("REGISTRY_ADDRESS") + ); uint64 eon = uint64(vm.envUint("EON")); - bytes32 identityPrefix = vm.envBytes32("IDENTITY_PREFIX"); + // bytes32 identityPrefix = vm.envBytes32("IDENTITY_PREFIX"); + bytes32 identityPrefix = "xxnxxx"; uint64 ts = uint64(vm.envUint("TIMESTAMP")); vm.startBroadcast(privateKey); - registry.register( - eon, - identityPrefix, - ts - ); + registry.register(eon, identityPrefix, ts); vm.stopBroadcast(); } } From 04daf12cada3f3952e426ec00056cb81dbec8388 Mon Sep 17 00:00:00 2001 From: blockchainluffy Date: Thu, 19 Dec 2024 18:28:18 +0530 Subject: [PATCH 09/13] shutter-service: added unit tests --- bindings/shutterregistry/shutterregistry.go | 7 +- src/shutter-service/ShutterRegistry.sol | 6 ++ test/ShutterRegistry.t.sol | 113 ++++++++++++++++++++ 3 files changed, 122 insertions(+), 4 deletions(-) create mode 100644 test/ShutterRegistry.t.sol diff --git a/bindings/shutterregistry/shutterregistry.go b/bindings/shutterregistry/shutterregistry.go index b1378be..b8fbe26 100644 --- a/bindings/shutterregistry/shutterregistry.go +++ b/bindings/shutterregistry/shutterregistry.go @@ -26,12 +26,11 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = event.NewSubscription - _ = abi.ConvertType ) // ShutterregistryMetaData contains all meta data concerning the Shutterregistry contract. var ShutterregistryMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"constructor\",\"inputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"register\",\"inputs\":[{\"name\":\"eon\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"identityPrefix\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"registrations\",\"inputs\":[{\"name\":\"identity\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"eon\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"IdentityRegistered\",\"inputs\":[{\"name\":\"eon\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"identityPrefix\",\"type\":\"bytes32\",\"indexed\":false,\"internalType\":\"bytes32\"},{\"name\":\"sender\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"timestamp\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"AlreadyRegistered\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"OwnableInvalidOwner\",\"inputs\":[{\"name\":\"owner\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"OwnableUnauthorizedAccount\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"TimestampInThePast\",\"inputs\":[]}]", + ABI: "[{\"type\":\"constructor\",\"inputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"owner\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"register\",\"inputs\":[{\"name\":\"eon\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"identityPrefix\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"registrations\",\"inputs\":[{\"name\":\"identity\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"eon\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"timestamp\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"renounceOwnership\",\"inputs\":[],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"transferOwnership\",\"inputs\":[{\"name\":\"newOwner\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"IdentityRegistered\",\"inputs\":[{\"name\":\"eon\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"identityPrefix\",\"type\":\"bytes32\",\"indexed\":false,\"internalType\":\"bytes32\"},{\"name\":\"sender\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"timestamp\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OwnershipTransferred\",\"inputs\":[{\"name\":\"previousOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"newOwner\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"error\",\"name\":\"AlreadyRegistered\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"InvalidIdentityPrefix\",\"inputs\":[]},{\"type\":\"error\",\"name\":\"OwnableInvalidOwner\",\"inputs\":[{\"name\":\"owner\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"OwnableUnauthorizedAccount\",\"inputs\":[{\"name\":\"account\",\"type\":\"address\",\"internalType\":\"address\"}]},{\"type\":\"error\",\"name\":\"TimestampInThePast\",\"inputs\":[]}]", } // ShutterregistryABI is the input ABI used to generate the binding from. @@ -135,11 +134,11 @@ func NewShutterregistryFilterer(address common.Address, filterer bind.ContractFi // bindShutterregistry binds a generic wrapper to an already deployed contract. func bindShutterregistry(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := ShutterregistryMetaData.GetAbi() + parsed, err := abi.JSON(strings.NewReader(ShutterregistryABI)) if err != nil { return nil, err } - return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil } // Call invokes the (constant) contract method with params as input values and diff --git a/src/shutter-service/ShutterRegistry.sol b/src/shutter-service/ShutterRegistry.sol index b0482ba..4aa8f37 100644 --- a/src/shutter-service/ShutterRegistry.sol +++ b/src/shutter-service/ShutterRegistry.sol @@ -15,6 +15,9 @@ contract ShutterRegistry is Ownable { // Custom error for when a provided timestamp is in the past. error TimestampInThePast(); + // Custom error for when a identityPrefix provided is empty. + error InvalidIdentityPrefix(); + struct RegistrationData { uint64 eon; uint64 timestamp; @@ -62,6 +65,9 @@ contract ShutterRegistry is Ownable { // Ensure the timestamp is not in the past. require(timestamp >= block.timestamp, TimestampInThePast()); + // Ensure identityPrefix passed in correct. + require(identityPrefix != bytes32(0), InvalidIdentityPrefix()); + // Generate the identity hash from the provided prefix and the sender's address. bytes32 identity = keccak256( abi.encodePacked(identityPrefix, msg.sender) diff --git a/test/ShutterRegistry.t.sol b/test/ShutterRegistry.t.sol new file mode 100644 index 0000000..e7a13bf --- /dev/null +++ b/test/ShutterRegistry.t.sol @@ -0,0 +1,113 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.22; + +import "forge-std/Test.sol"; +import "../src/shutter-service/ShutterRegistry.sol"; + +contract ShutterRegistryTest is Test{ + ShutterRegistry public shutterRegistry; + + function setUp() public { + shutterRegistry = new ShutterRegistry(); + } + + function testIdentityRegistration() public { + uint64 eon = 5; + bytes32 identityPrefix = hex"001122"; + uint64 timestamp = uint64(block.timestamp) + 100; + address sender = makeAddr("sender"); + + vm.expectEmit(address(shutterRegistry)); + emit ShutterRegistry.IdentityRegistered( + eon, + identityPrefix, + sender, + timestamp + ); + + hoax(sender); + shutterRegistry.register( + eon, + identityPrefix, + timestamp + ); + + bytes32 identity = keccak256( + abi.encodePacked(identityPrefix, sender) + ); + (uint64 registeredEon, uint64 registeredTimestamp) = shutterRegistry.registrations(identity); + + //verifying registered timestamp + assertEqUint(registeredEon, eon); + assertEqUint(registeredTimestamp, timestamp); + } + + function testDuplicateRegistration() public { + uint64 eon = 5; + bytes32 identityPrefix = hex"001122"; + uint64 timestamp = uint64(block.timestamp) + 100; + address sender = makeAddr("sender"); + + vm.expectEmit(address(shutterRegistry)); + emit ShutterRegistry.IdentityRegistered( + eon, + identityPrefix, + sender, + timestamp + ); + + hoax(sender); + shutterRegistry.register( + eon, + identityPrefix, + timestamp + ); + + uint64 newTimestamp = uint64(block.timestamp) + 200; + vm.expectRevert(ShutterRegistry.AlreadyRegistered.selector); + hoax(sender); + shutterRegistry.register( + eon, + identityPrefix, + newTimestamp + ); + + //verifying registered timestamp + bytes32 identity = keccak256( + abi.encodePacked(identityPrefix, sender) + ); + (, uint64 registeredTimestamp) = shutterRegistry.registrations(identity); + assertEqUint(registeredTimestamp, timestamp); + } + + function testInvalidTimestamp() public { + uint64 eon = 5; + bytes32 identityPrefix = hex"001122"; + uint64 timestamp = uint64(block.timestamp) - 1; + address sender = makeAddr("sender"); + + vm.expectRevert(ShutterRegistry.TimestampInThePast.selector); + hoax(sender); + shutterRegistry.register( + eon, + identityPrefix, + timestamp + ); + } + + function testMissingIdentity() public { + uint64 eon = 5; + // zero bytes for identity prefix should fail + bytes32 identityPrefix = hex"00"; + uint64 timestamp = uint64(block.timestamp) + 100; + address sender = makeAddr("sender"); + + vm.expectRevert(ShutterRegistry.InvalidIdentityPrefix.selector); + hoax(sender); + shutterRegistry.register( + eon, + identityPrefix, + timestamp + ); + } +} \ No newline at end of file From f9d4575bf95c87dfe2f3236388a49a01fda7c8db Mon Sep 17 00:00:00 2001 From: blockchainluffy Date: Fri, 20 Dec 2024 15:41:52 +0530 Subject: [PATCH 10/13] shutter-service: fix precommit --- test/ShutterRegistry.t.sol | 47 +++++++++++--------------------------- 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/test/ShutterRegistry.t.sol b/test/ShutterRegistry.t.sol index e7a13bf..efa0acf 100644 --- a/test/ShutterRegistry.t.sol +++ b/test/ShutterRegistry.t.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.22; import "forge-std/Test.sol"; import "../src/shutter-service/ShutterRegistry.sol"; -contract ShutterRegistryTest is Test{ +contract ShutterRegistryTest is Test { ShutterRegistry public shutterRegistry; function setUp() public { @@ -26,16 +26,11 @@ contract ShutterRegistryTest is Test{ ); hoax(sender); - shutterRegistry.register( - eon, - identityPrefix, - timestamp - ); + shutterRegistry.register(eon, identityPrefix, timestamp); - bytes32 identity = keccak256( - abi.encodePacked(identityPrefix, sender) - ); - (uint64 registeredEon, uint64 registeredTimestamp) = shutterRegistry.registrations(identity); + bytes32 identity = keccak256(abi.encodePacked(identityPrefix, sender)); + (uint64 registeredEon, uint64 registeredTimestamp) = shutterRegistry + .registrations(identity); //verifying registered timestamp assertEqUint(registeredEon, eon); @@ -57,26 +52,18 @@ contract ShutterRegistryTest is Test{ ); hoax(sender); - shutterRegistry.register( - eon, - identityPrefix, - timestamp - ); + shutterRegistry.register(eon, identityPrefix, timestamp); uint64 newTimestamp = uint64(block.timestamp) + 200; vm.expectRevert(ShutterRegistry.AlreadyRegistered.selector); hoax(sender); - shutterRegistry.register( - eon, - identityPrefix, - newTimestamp - ); + shutterRegistry.register(eon, identityPrefix, newTimestamp); //verifying registered timestamp - bytes32 identity = keccak256( - abi.encodePacked(identityPrefix, sender) + bytes32 identity = keccak256(abi.encodePacked(identityPrefix, sender)); + (, uint64 registeredTimestamp) = shutterRegistry.registrations( + identity ); - (, uint64 registeredTimestamp) = shutterRegistry.registrations(identity); assertEqUint(registeredTimestamp, timestamp); } @@ -88,11 +75,7 @@ contract ShutterRegistryTest is Test{ vm.expectRevert(ShutterRegistry.TimestampInThePast.selector); hoax(sender); - shutterRegistry.register( - eon, - identityPrefix, - timestamp - ); + shutterRegistry.register(eon, identityPrefix, timestamp); } function testMissingIdentity() public { @@ -104,10 +87,6 @@ contract ShutterRegistryTest is Test{ vm.expectRevert(ShutterRegistry.InvalidIdentityPrefix.selector); hoax(sender); - shutterRegistry.register( - eon, - identityPrefix, - timestamp - ); + shutterRegistry.register(eon, identityPrefix, timestamp); } -} \ No newline at end of file +} From f62ce8021da2e4e59a43b1db75e2b19bda79846d Mon Sep 17 00:00:00 2001 From: blockchainluffy Date: Thu, 26 Dec 2024 14:27:33 +0530 Subject: [PATCH 11/13] shutter-service: added combined deploy script --- script/Deploy.service.s.sol | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 script/Deploy.service.s.sol diff --git a/script/Deploy.service.s.sol b/script/Deploy.service.s.sol new file mode 100644 index 0000000..f0e8aa7 --- /dev/null +++ b/script/Deploy.service.s.sol @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.20; + +import "forge-std/Script.sol"; +import "../src/common/KeyBroadcastContract.sol"; +import "../src/common/KeyperSet.sol"; +import "../src/common/KeyperSetManager.sol"; +import "../src/shutter-service/ShutterRegistry.sol"; + +contract Deploy is Script { + function deployKeyperSetManager( + address deployerAddress + ) public returns (KeyperSetManager) { + KeyperSetManager ksm = new KeyperSetManager(deployerAddress); + + // add bootstrap keyper set + KeyperSet fakeKeyperset = new KeyperSet(); + fakeKeyperset.setFinalized(); + ksm.addKeyperSet(0, address(fakeKeyperset)); + + console.log("KeyperSetManager:", address(ksm)); + return ksm; + } + + function deployKeyBroadcastContract( + KeyperSetManager ksm + ) public returns (KeyBroadcastContract) { + KeyBroadcastContract kbc = new KeyBroadcastContract(address(ksm)); + console.log("KeyBroadcastContract:", address(kbc)); + return kbc; + } + + function deployRegistry() public returns (ShutterRegistry) { + ShutterRegistry s = new ShutterRegistry(); + console.log("Registry:", address(s)); + return s; + } + + function run() external { + uint256 deployKey = vm.envUint("DEPLOY_KEY"); + address deployerAddress = vm.addr(deployKey); + console.log("Deployer:", deployerAddress); + vm.startBroadcast(deployKey); + + KeyperSetManager ksm = deployKeyperSetManager(deployerAddress); + deployKeyBroadcastContract(ksm); + deployRegistry(); + + vm.stopBroadcast(); + } +} From f95c2db759a0035b3bb7c9964edec2a32ceba007 Mon Sep 17 00:00:00 2001 From: blockchainluffy Date: Thu, 26 Dec 2024 18:05:00 +0530 Subject: [PATCH 12/13] shutter-service: updated deploy script --- script/Deploy.service.s.sol | 1 + script/SubmitTransaction.service.s.sol | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/script/Deploy.service.s.sol b/script/Deploy.service.s.sol index f0e8aa7..5d9940a 100644 --- a/script/Deploy.service.s.sol +++ b/script/Deploy.service.s.sol @@ -12,6 +12,7 @@ contract Deploy is Script { address deployerAddress ) public returns (KeyperSetManager) { KeyperSetManager ksm = new KeyperSetManager(deployerAddress); + ksm.initialize(deployerAddress, deployerAddress); // add bootstrap keyper set KeyperSet fakeKeyperset = new KeyperSet(); diff --git a/script/SubmitTransaction.service.s.sol b/script/SubmitTransaction.service.s.sol index b2f51fe..7be93a7 100644 --- a/script/SubmitTransaction.service.s.sol +++ b/script/SubmitTransaction.service.s.sol @@ -11,8 +11,7 @@ contract SubmitTransaction is Script { vm.envAddress("REGISTRY_ADDRESS") ); uint64 eon = uint64(vm.envUint("EON")); - // bytes32 identityPrefix = vm.envBytes32("IDENTITY_PREFIX"); - bytes32 identityPrefix = "xxnxxx"; + bytes32 identityPrefix = vm.envBytes32("IDENTITY_PREFIX"); uint64 ts = uint64(vm.envUint("TIMESTAMP")); vm.startBroadcast(privateKey); From e5f673320602e45203e753b68c8cd13bd4f366ef Mon Sep 17 00:00:00 2001 From: blockchainluffy Date: Sun, 29 Dec 2024 16:39:22 +0530 Subject: [PATCH 13/13] shutter-service: added log --- script/Deploy.service.s.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/script/Deploy.service.s.sol b/script/Deploy.service.s.sol index 5d9940a..4534d2e 100644 --- a/script/Deploy.service.s.sol +++ b/script/Deploy.service.s.sol @@ -13,6 +13,7 @@ contract Deploy is Script { ) public returns (KeyperSetManager) { KeyperSetManager ksm = new KeyperSetManager(deployerAddress); ksm.initialize(deployerAddress, deployerAddress); + console.log("keyper set manager initialised"); // add bootstrap keyper set KeyperSet fakeKeyperset = new KeyperSet();