From 358e88d065dabfc7b81ee68959f9bbeaf18c16c5 Mon Sep 17 00:00:00 2001 From: yashnevatia Date: Fri, 29 Nov 2024 20:39:58 +0000 Subject: [PATCH] Adding storage contract --- .../scripts/native_solc_zksolc_compile_ccip | 287 +++++------ contracts/src/v0.8/ccip/Storage.sol | 39 ++ .../ccip/generated/storage/storage.go | 481 ++++++++++++++++++ .../storage_contract/storage_contract.go | 481 ++++++++++++++++++ ...rapper-dependency-versions-do-not-edit.txt | 2 + core/gethwrappers/ccip/go_gen_zk.go | 2 + 6 files changed, 1149 insertions(+), 143 deletions(-) create mode 100644 contracts/src/v0.8/ccip/Storage.sol create mode 100644 core/gethwrappers/ccip/generated/storage/storage.go create mode 100644 core/gethwrappers/ccip/generated/storage_contract/storage_contract.go diff --git a/contracts/scripts/native_solc_zksolc_compile_ccip b/contracts/scripts/native_solc_zksolc_compile_ccip index c85f238b06..8b823171a0 100755 --- a/contracts/scripts/native_solc_zksolc_compile_ccip +++ b/contracts/scripts/native_solc_zksolc_compile_ccip @@ -88,148 +88,149 @@ compileContractZK () { - +compileContract ccip/Storage.sol +compileContractZK ccip/Storage.sol # Solc produces and overwrites intermediary contracts. # Contracts should be ordered in reverse-import-complexity-order to minimize overwrite risks. -compileContract ccip/offRamp/EVM2EVMOffRamp.sol -compileContract ccip/offRamp/OffRamp.sol -compileContract ccip/rmn/RMNRemote.sol -compileContract ccip/applications/PingPongDemo.sol -compileContract ccip/applications/SelfFundedPingPong.sol -compileContract ccip/applications/EtherSenderReceiver.sol -compileContract ccip/onRamp/OnRamp.sol -compileContract ccip/onRamp/EVM2EVMOnRamp.sol -compileContract ccip/CommitStore.sol -compileContract ccip/MultiAggregateRateLimiter.sol -compileContract ccip/Router.sol -compileContract ccip/FeeQuoter.sol -compileContract ccip/RMN.sol -compileContract ccip/ARMProxy.sol -compileContract ccip/tokenAdminRegistry/TokenAdminRegistry.sol -compileContract ccip/tokenAdminRegistry/RegistryModuleOwnerCustom.sol -compileContract ccip/capability/CCIPHome.sol -compileContract ccip/NonceManager.sol -compileContract shared/token/ERC677/BurnMintERC677.sol -compileContract ccip/PriceRegistry.sol - - -# Pools -compileContract ccip/pools/LockReleaseTokenPool.sol -compileContract ccip/pools/BurnMintTokenPool.sol -compileContract ccip/pools/BurnFromMintTokenPool.sol -compileContract ccip/pools/BurnWithFromMintTokenPool.sol -compileContract ccip/pools/LockReleaseTokenPoolAndProxy.sol -compileContract ccip/pools/BurnMintTokenPoolAndProxy.sol -compileContract ccip/pools/BurnWithFromMintTokenPoolAndProxy.sol -compileContract ccip/pools/BurnWithFromMintRebasingTokenPool.sol -compileContract ccip/pools/TokenPool.sol - - -# Test helpers -compileContract ccip/test/helpers/BurnMintERC677Helper.sol -compileContract ccip/test/helpers/CommitStoreHelper.sol -compileContract ccip/test/helpers/MessageHasher.sol -compileContract ccip/test/helpers/CCIPReaderTester.sol -compileContract ccip/test/helpers/ReportCodec.sol -compileContract ccip/test/helpers/receivers/MaybeRevertMessageReceiver.sol -compileContract ccip/test/helpers/MultiOCR3Helper.sol -compileContract ccip/test/mocks/MockE2EUSDCTokenMessenger.sol -compileContract ccip/test/mocks/MockE2EUSDCTransmitter.sol -compileContract ccip/test/WETH9.sol - - -# Encoding Utils -compileContract ccip/interfaces/encodingutils/ICCIPEncodingUtils.sol - -# Customer contracts -compileContract ccip/pools/USDC/USDCTokenPool.sol - -compileContract tests/MockV3Aggregator.sol - - - - -compileContractZK ccip/offRamp/EVM2EVMOffRamp.sol -compileContractZK ccip/offRamp/OffRamp.sol -compileContractZK ccip/rmn/RMNRemote.sol -compileContractZK ccip/applications/PingPongDemo.sol -compileContractZK ccip/applications/SelfFundedPingPong.sol -compileContractZK ccip/applications/EtherSenderReceiver.sol -compileContractZK ccip/onRamp/OnRamp.sol -compileContractZK ccip/onRamp/EVM2EVMOnRamp.sol -compileContractZK ccip/CommitStore.sol -compileContractZK ccip/MultiAggregateRateLimiter.sol -compileContractZK ccip/Router.sol -compileContractZK ccip/FeeQuoter.sol -compileContractZK ccip/RMN.sol -compileContractZK ccip/ARMProxy.sol -compileContractZK ccip/tokenAdminRegistry/TokenAdminRegistry.sol -compileContractZK ccip/tokenAdminRegistry/RegistryModuleOwnerCustom.sol -compileContractZK ccip/capability/CCIPHome.sol -compileContractZK ccip/NonceManager.sol -compileContractZK shared/token/ERC677/BurnMintERC677.sol -compileContractZK ccip/PriceRegistry.sol - - -# Pools -compileContractZK ccip/pools/LockReleaseTokenPool.sol -compileContractZK ccip/pools/BurnMintTokenPool.sol -compileContractZK ccip/pools/BurnFromMintTokenPool.sol -compileContractZK ccip/pools/BurnWithFromMintTokenPool.sol -compileContractZK ccip/pools/LockReleaseTokenPoolAndProxy.sol -compileContractZK ccip/pools/BurnMintTokenPoolAndProxy.sol -compileContractZK ccip/pools/BurnWithFromMintTokenPoolAndProxy.sol -compileContractZK ccip/pools/BurnWithFromMintRebasingTokenPool.sol -compileContractZK ccip/pools/TokenPool.sol - - -# Test helpers -compileContractZK ccip/test/helpers/BurnMintERC677Helper.sol -compileContractZK ccip/test/helpers/CommitStoreHelper.sol -compileContractZK ccip/test/helpers/MessageHasher.sol -compileContractZK ccip/test/helpers/CCIPReaderTester.sol -compileContractZK ccip/test/helpers/ReportCodec.sol -compileContractZK ccip/test/helpers/receivers/MaybeRevertMessageReceiver.sol -compileContractZK ccip/test/helpers/MultiOCR3Helper.sol -compileContractZK ccip/test/mocks/MockE2EUSDCTokenMessenger.sol -compileContractZK ccip/test/mocks/MockE2EUSDCTransmitter.sol -# this breaks with paybale error -compileContractZK ccip/test/WETH9.sol - - -# Encoding Utils -compileContractZK ccip/interfaces/encodingutils/ICCIPEncodingUtils.sol - -# Customer contracts -compileContractZK ccip/pools/USDC/USDCTokenPool.sol - -compileContractZK tests/MockV3Aggregator.sol - - -SOLC_VERSION="0.8.19" -solc-select install $SOLC_VERSION -solc-select use $SOLC_VERSION -export SOLC_VERSION=$SOLC_VERSION - -compileContractShared () { - local contract - contract=$(basename "$1" ".sol") - - solc --overwrite --optimize --optimize-runs $OPTIMIZE_RUNS --metadata-hash none \ - -o "$ROOT"/contracts/solc/v$SOLC_VERSION/"$contract" \ - --abi --bin --allow-paths "$ROOT"/contracts/src/v0.8\ - "$ROOT"/contracts/src/v0.8/"$1" -} - -compileContractSharedZK () { - local contract - contract=$(basename "$1" ".sol") - - zksolc --overwrite -O3 \ - -o "$ROOT"/contracts/zksolc/v$SOLC_VERSION/"$contract" \ - --bin --allow-paths "$ROOT"/contracts/src/v0.8 \ - "$ROOT"/contracts/src/v0.8/"$1" -} - -compileContractShared shared/token/ERC677/LinkToken.sol -compileContractSharedZK shared/token/ERC677/LinkToken.sol \ No newline at end of file +# compileContract ccip/offRamp/EVM2EVMOffRamp.sol +# compileContract ccip/offRamp/OffRamp.sol +# compileContract ccip/rmn/RMNRemote.sol +# compileContract ccip/applications/PingPongDemo.sol +# compileContract ccip/applications/SelfFundedPingPong.sol +# compileContract ccip/applications/EtherSenderReceiver.sol +# compileContract ccip/onRamp/OnRamp.sol +# compileContract ccip/onRamp/EVM2EVMOnRamp.sol +# compileContract ccip/CommitStore.sol +# compileContract ccip/MultiAggregateRateLimiter.sol +# compileContract ccip/Router.sol +# compileContract ccip/FeeQuoter.sol +# compileContract ccip/RMN.sol +# compileContract ccip/ARMProxy.sol +# compileContract ccip/tokenAdminRegistry/TokenAdminRegistry.sol +# compileContract ccip/tokenAdminRegistry/RegistryModuleOwnerCustom.sol +# compileContract ccip/capability/CCIPHome.sol +# compileContract ccip/NonceManager.sol +# compileContract shared/token/ERC677/BurnMintERC677.sol +# compileContract ccip/PriceRegistry.sol + + +# # Pools +# compileContract ccip/pools/LockReleaseTokenPool.sol +# compileContract ccip/pools/BurnMintTokenPool.sol +# compileContract ccip/pools/BurnFromMintTokenPool.sol +# compileContract ccip/pools/BurnWithFromMintTokenPool.sol +# compileContract ccip/pools/LockReleaseTokenPoolAndProxy.sol +# compileContract ccip/pools/BurnMintTokenPoolAndProxy.sol +# compileContract ccip/pools/BurnWithFromMintTokenPoolAndProxy.sol +# compileContract ccip/pools/BurnWithFromMintRebasingTokenPool.sol +# compileContract ccip/pools/TokenPool.sol + + +# # Test helpers +# compileContract ccip/test/helpers/BurnMintERC677Helper.sol +# compileContract ccip/test/helpers/CommitStoreHelper.sol +# compileContract ccip/test/helpers/MessageHasher.sol +# compileContract ccip/test/helpers/CCIPReaderTester.sol +# compileContract ccip/test/helpers/ReportCodec.sol +# compileContract ccip/test/helpers/receivers/MaybeRevertMessageReceiver.sol +# compileContract ccip/test/helpers/MultiOCR3Helper.sol +# compileContract ccip/test/mocks/MockE2EUSDCTokenMessenger.sol +# compileContract ccip/test/mocks/MockE2EUSDCTransmitter.sol +# compileContract ccip/test/WETH9.sol + + +# # Encoding Utils +# compileContract ccip/interfaces/encodingutils/ICCIPEncodingUtils.sol + +# # Customer contracts +# compileContract ccip/pools/USDC/USDCTokenPool.sol + +# compileContract tests/MockV3Aggregator.sol + + + + +# compileContractZK ccip/offRamp/EVM2EVMOffRamp.sol +# compileContractZK ccip/offRamp/OffRamp.sol +# compileContractZK ccip/rmn/RMNRemote.sol +# compileContractZK ccip/applications/PingPongDemo.sol +# compileContractZK ccip/applications/SelfFundedPingPong.sol +# compileContractZK ccip/applications/EtherSenderReceiver.sol +# compileContractZK ccip/onRamp/OnRamp.sol +# compileContractZK ccip/onRamp/EVM2EVMOnRamp.sol +# compileContractZK ccip/CommitStore.sol +# compileContractZK ccip/MultiAggregateRateLimiter.sol +# compileContractZK ccip/Router.sol +# compileContractZK ccip/FeeQuoter.sol +# compileContractZK ccip/RMN.sol +# compileContractZK ccip/ARMProxy.sol +# compileContractZK ccip/tokenAdminRegistry/TokenAdminRegistry.sol +# compileContractZK ccip/tokenAdminRegistry/RegistryModuleOwnerCustom.sol +# compileContractZK ccip/capability/CCIPHome.sol +# compileContractZK ccip/NonceManager.sol +# compileContractZK shared/token/ERC677/BurnMintERC677.sol +# compileContractZK ccip/PriceRegistry.sol + + +# # Pools +# compileContractZK ccip/pools/LockReleaseTokenPool.sol +# compileContractZK ccip/pools/BurnMintTokenPool.sol +# compileContractZK ccip/pools/BurnFromMintTokenPool.sol +# compileContractZK ccip/pools/BurnWithFromMintTokenPool.sol +# compileContractZK ccip/pools/LockReleaseTokenPoolAndProxy.sol +# compileContractZK ccip/pools/BurnMintTokenPoolAndProxy.sol +# compileContractZK ccip/pools/BurnWithFromMintTokenPoolAndProxy.sol +# compileContractZK ccip/pools/BurnWithFromMintRebasingTokenPool.sol +# compileContractZK ccip/pools/TokenPool.sol + + +# # Test helpers +# compileContractZK ccip/test/helpers/BurnMintERC677Helper.sol +# compileContractZK ccip/test/helpers/CommitStoreHelper.sol +# compileContractZK ccip/test/helpers/MessageHasher.sol +# compileContractZK ccip/test/helpers/CCIPReaderTester.sol +# compileContractZK ccip/test/helpers/ReportCodec.sol +# compileContractZK ccip/test/helpers/receivers/MaybeRevertMessageReceiver.sol +# compileContractZK ccip/test/helpers/MultiOCR3Helper.sol +# compileContractZK ccip/test/mocks/MockE2EUSDCTokenMessenger.sol +# compileContractZK ccip/test/mocks/MockE2EUSDCTransmitter.sol +# # this breaks with paybale error +# compileContractZK ccip/test/WETH9.sol + + +# # Encoding Utils +# compileContractZK ccip/interfaces/encodingutils/ICCIPEncodingUtils.sol + +# # Customer contracts +# compileContractZK ccip/pools/USDC/USDCTokenPool.sol + +# compileContractZK tests/MockV3Aggregator.sol + + +# SOLC_VERSION="0.8.19" +# solc-select install $SOLC_VERSION +# solc-select use $SOLC_VERSION +# export SOLC_VERSION=$SOLC_VERSION + +# compileContractShared () { +# local contract +# contract=$(basename "$1" ".sol") + +# solc --overwrite --optimize --optimize-runs $OPTIMIZE_RUNS --metadata-hash none \ +# -o "$ROOT"/contracts/solc/v$SOLC_VERSION/"$contract" \ +# --abi --bin --allow-paths "$ROOT"/contracts/src/v0.8\ +# "$ROOT"/contracts/src/v0.8/"$1" +# } + +# compileContractSharedZK () { +# local contract +# contract=$(basename "$1" ".sol") + +# zksolc --overwrite -O3 \ +# -o "$ROOT"/contracts/zksolc/v$SOLC_VERSION/"$contract" \ +# --bin --allow-paths "$ROOT"/contracts/src/v0.8 \ +# "$ROOT"/contracts/src/v0.8/"$1" +# } + +# compileContractShared shared/token/ERC677/LinkToken.sol +# compileContractSharedZK shared/token/ERC677/LinkToken.sol \ No newline at end of file diff --git a/contracts/src/v0.8/ccip/Storage.sol b/contracts/src/v0.8/ccip/Storage.sol new file mode 100644 index 0000000000..ebd636758c --- /dev/null +++ b/contracts/src/v0.8/ccip/Storage.sol @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +/** + * @title Storage + * @dev Store & retrieve value in a variable + */ + +contract Storage { + uint256 number; + + + event storedNumber( + address indexed _from, + uint256 indexed _oldNumber, + uint256 indexed _number + ); + + /** + * @dev Store value in variable + * @param num value to store + */ + function store(uint256 num) public { + uint256 old = number; + number = num; + emit storedNumber(msg.sender, old, num); + + } + + /** + * @dev Return value + * @return value of 'number' + */ + function retrieve() public view returns (uint256) { + return number; + + } +} \ No newline at end of file diff --git a/core/gethwrappers/ccip/generated/storage/storage.go b/core/gethwrappers/ccip/generated/storage/storage.go new file mode 100644 index 0000000000..426358f807 --- /dev/null +++ b/core/gethwrappers/ccip/generated/storage/storage.go @@ -0,0 +1,481 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package storage + +import ( + "context" + "errors" + "fmt" + "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/ethclient" + "github.com/ethereum/go-ethereum/event" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated" + zkSyncAccounts "github.com/zksync-sdk/zksync2-go/accounts" + zkSyncClient "github.com/zksync-sdk/zksync2-go/clients" + zktypes "github.com/zksync-sdk/zksync2-go/types" +) + +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +var StorageMetaData = &bind.MetaData{ + ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"_oldNumber\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"_number\",\"type\":\"uint256\"}],\"name\":\"storedNumber\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"retrieve\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"num\",\"type\":\"uint256\"}],\"name\":\"store\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x608060405234801561001057600080fd5b5060bc8061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80632e64cec11460375780636057361d14604c575b600080fd5b60005460405190815260200160405180910390f35b605b60573660046097565b605d565b005b6000805482825560405190918391839133917f87f16aa184eca14ea45e132328a5effbb79b9f921657bd03d83608f26d76f3cf9190a45050565b60006020828403121560a857600080fd5b503591905056fea164736f6c6343000818000a", +} + +var StorageABI = StorageMetaData.ABI + +var StorageBin = StorageMetaData.Bin + +func DeployStorage(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *CustomTransaction, *Storage, error) { + client, ok := backend.(*ethclient.Client) + if !ok { + return common.Address{}, nil, nil, errors.New("backend is not an ethclient") + } + chainId, err := client.ChainID(context.Background()) + if err != nil { + return common.Address{}, nil, nil, err + } + switch chainId.Uint64() { + + case 324, 280, 300: + return DeployZkSyncStorage(auth, backend) + } + + parsed, err := StorageMetaData.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(StorageBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, &CustomTransaction{Transaction: tx, CustomHash: tx.Hash()}, &Storage{address: address, abi: *parsed, StorageCaller: StorageCaller{contract: contract}, StorageTransactor: StorageTransactor{contract: contract}, StorageFilterer: StorageFilterer{contract: contract}}, nil +} + +type Storage struct { + address common.Address + abi abi.ABI + StorageCaller + StorageTransactor + StorageFilterer +} + +type StorageCaller struct { + contract *bind.BoundContract +} + +type StorageTransactor struct { + contract *bind.BoundContract +} + +type StorageFilterer struct { + contract *bind.BoundContract +} + +type StorageSession struct { + Contract *Storage + CallOpts bind.CallOpts + TransactOpts bind.TransactOpts +} + +type StorageCallerSession struct { + Contract *StorageCaller + CallOpts bind.CallOpts +} + +type StorageTransactorSession struct { + Contract *StorageTransactor + TransactOpts bind.TransactOpts +} + +type StorageRaw struct { + Contract *Storage +} + +type StorageCallerRaw struct { + Contract *StorageCaller +} + +type StorageTransactorRaw struct { + Contract *StorageTransactor +} + +func NewStorage(address common.Address, backend bind.ContractBackend) (*Storage, error) { + abi, err := abi.JSON(strings.NewReader(StorageABI)) + if err != nil { + return nil, err + } + contract, err := bindStorage(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Storage{address: address, abi: abi, StorageCaller: StorageCaller{contract: contract}, StorageTransactor: StorageTransactor{contract: contract}, StorageFilterer: StorageFilterer{contract: contract}}, nil +} + +func NewStorageCaller(address common.Address, caller bind.ContractCaller) (*StorageCaller, error) { + contract, err := bindStorage(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &StorageCaller{contract: contract}, nil +} + +func NewStorageTransactor(address common.Address, transactor bind.ContractTransactor) (*StorageTransactor, error) { + contract, err := bindStorage(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &StorageTransactor{contract: contract}, nil +} + +func NewStorageFilterer(address common.Address, filterer bind.ContractFilterer) (*StorageFilterer, error) { + contract, err := bindStorage(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &StorageFilterer{contract: contract}, nil +} + +func bindStorage(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := StorageMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +func (_Storage *StorageRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Storage.Contract.StorageCaller.contract.Call(opts, result, method, params...) +} + +func (_Storage *StorageRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Storage.Contract.StorageTransactor.contract.Transfer(opts) +} + +func (_Storage *StorageRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Storage.Contract.StorageTransactor.contract.Transact(opts, method, params...) +} + +func (_Storage *StorageCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Storage.Contract.contract.Call(opts, result, method, params...) +} + +func (_Storage *StorageTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Storage.Contract.contract.Transfer(opts) +} + +func (_Storage *StorageTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Storage.Contract.contract.Transact(opts, method, params...) +} + +func (_Storage *StorageCaller) Retrieve(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Storage.contract.Call(opts, &out, "retrieve") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +func (_Storage *StorageSession) Retrieve() (*big.Int, error) { + return _Storage.Contract.Retrieve(&_Storage.CallOpts) +} + +func (_Storage *StorageCallerSession) Retrieve() (*big.Int, error) { + return _Storage.Contract.Retrieve(&_Storage.CallOpts) +} + +func (_Storage *StorageTransactor) Store(opts *bind.TransactOpts, num *big.Int) (*types.Transaction, error) { + return _Storage.contract.Transact(opts, "store", num) +} + +func (_Storage *StorageSession) Store(num *big.Int) (*types.Transaction, error) { + return _Storage.Contract.Store(&_Storage.TransactOpts, num) +} + +func (_Storage *StorageTransactorSession) Store(num *big.Int) (*types.Transaction, error) { + return _Storage.Contract.Store(&_Storage.TransactOpts, num) +} + +type StorageStoredNumberIterator struct { + Event *StorageStoredNumber + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *StorageStoredNumberIterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(StorageStoredNumber) + 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 + } + } + + select { + case log := <-it.logs: + it.Event = new(StorageStoredNumber) + 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() + } +} + +func (it *StorageStoredNumberIterator) Error() error { + return it.fail +} + +func (it *StorageStoredNumberIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type StorageStoredNumber struct { + From common.Address + OldNumber *big.Int + Number *big.Int + Raw types.Log +} + +func (_Storage *StorageFilterer) FilterStoredNumber(opts *bind.FilterOpts, _from []common.Address, _oldNumber []*big.Int, _number []*big.Int) (*StorageStoredNumberIterator, error) { + + var _fromRule []interface{} + for _, _fromItem := range _from { + _fromRule = append(_fromRule, _fromItem) + } + var _oldNumberRule []interface{} + for _, _oldNumberItem := range _oldNumber { + _oldNumberRule = append(_oldNumberRule, _oldNumberItem) + } + var _numberRule []interface{} + for _, _numberItem := range _number { + _numberRule = append(_numberRule, _numberItem) + } + + logs, sub, err := _Storage.contract.FilterLogs(opts, "storedNumber", _fromRule, _oldNumberRule, _numberRule) + if err != nil { + return nil, err + } + return &StorageStoredNumberIterator{contract: _Storage.contract, event: "storedNumber", logs: logs, sub: sub}, nil +} + +func (_Storage *StorageFilterer) WatchStoredNumber(opts *bind.WatchOpts, sink chan<- *StorageStoredNumber, _from []common.Address, _oldNumber []*big.Int, _number []*big.Int) (event.Subscription, error) { + + var _fromRule []interface{} + for _, _fromItem := range _from { + _fromRule = append(_fromRule, _fromItem) + } + var _oldNumberRule []interface{} + for _, _oldNumberItem := range _oldNumber { + _oldNumberRule = append(_oldNumberRule, _oldNumberItem) + } + var _numberRule []interface{} + for _, _numberItem := range _number { + _numberRule = append(_numberRule, _numberItem) + } + + logs, sub, err := _Storage.contract.WatchLogs(opts, "storedNumber", _fromRule, _oldNumberRule, _numberRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(StorageStoredNumber) + if err := _Storage.contract.UnpackLog(event, "storedNumber", 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 +} + +func (_Storage *StorageFilterer) ParseStoredNumber(log types.Log) (*StorageStoredNumber, error) { + event := new(StorageStoredNumber) + if err := _Storage.contract.UnpackLog(event, "storedNumber", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +var StorageZkBin string = ("0x0000008003000039000000400030043f0000000100200190000000150000c13d00000060021002700000001002200197000000040020008c000000340000413d000000000301043b000000e003300270000000120030009c0000001d0000613d000000130030009c000000340000c13d0000000001000416000000000001004b000000340000c13d000000000100041a000000800010043f00000016010000410000003c0001042e0000000001000416000000000001004b000000340000c13d00000020010000390000010000100443000001200000044300000011010000410000003c0001042e000000240020008c000000340000413d0000000002000416000000000002004b000000340000c13d0000000401100370000000000701043b000000000600041a000000000070041b0000000001000414000000100010009c0000001001008041000000c00110021000000014011001c70000800d02000039000000040300003900000000050004110000001504000041003b00360000040f0000000100200190000000340000613d00000000010000190000003c0001042e00000000010000190000003d0001043000000039002104210000000102000039000000000001042d0000000002000019000000000001042d0000003b000004320000003c0001042e0000003d000104300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffff0000000200000000000000000000000000000040000001000000000000000000000000000000000000000000000000000000000000000000000000006057361d000000000000000000000000000000000000000000000000000000002e64cec1020000000000000000000000000000000000000000000000000000000000000087f16aa184eca14ea45e132328a5effbb79b9f921657bd03d83608f26d76f3cf00000000000000000000000000000000000000200000008000000000000000000000000000000000000000000000000000000000000000000000000000000000d05624d43b7436b857a8c30563e36489cd4edac61bd40b452ab9052253f0fef5") + +func (_Storage *Storage) ParseLog(log types.Log) (generated.AbigenLog, error) { + switch log.Topics[0] { + case _Storage.abi.Events["StoredNumber"].ID: + return _Storage.ParseStoredNumber(log) + + default: + return nil, fmt.Errorf("abigen wrapper received unknown log topic: %v", log.Topics[0]) + } +} + +func (StorageStoredNumber) Topic() common.Hash { + return common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000") +} + +func (_Storage *Storage) Address() common.Address { + return _Storage.address +} + +type CustomTransaction struct { + *types.Transaction + CustomHash common.Hash +} + +func (tx *CustomTransaction) Hash() common.Hash { + return tx.CustomHash +} + +func ConvertToTransaction(resp zktypes.TransactionResponse) *CustomTransaction { + dtx := &types.DynamicFeeTx{ + ChainID: resp.ChainID.ToInt(), + Nonce: uint64(resp.Nonce), + GasTipCap: resp.MaxPriorityFeePerGas.ToInt(), + GasFeeCap: resp.MaxFeePerGas.ToInt(), + To: &resp.To, + Value: resp.Value.ToInt(), + Data: resp.Data, + Gas: uint64(resp.Gas), + } + + tx := types.NewTx(dtx) + customTransaction := CustomTransaction{Transaction: tx, CustomHash: resp.Hash} + return &customTransaction +} + +func DeployZkSyncStorage(auth *bind.TransactOpts, backend bind.ContractBackend, params ...interface{}) (common.Address, *CustomTransaction, *Storage, error) { + client, ok := backend.(*ethclient.Client) + if !ok { + return common.Address{}, nil, nil, errors.New("backend is not an ethclient") + } + + zksyncClient := zkSyncClient.NewClient(client.Client()) + + wallet := auth.Context.Value("wallet").(*zkSyncAccounts.Wallet) + + decodedBytes := common.FromHex(StorageZkBin) + + StorageAbi, err := StorageMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + constructor, err := StorageAbi.Pack("", params...) + if err != nil { + return common.Address{}, nil, nil, err + } + + hash, err := wallet.DeployWithCreate(nil, zkSyncAccounts.CreateTransaction{ + Bytecode: decodedBytes, + Calldata: constructor, + }) + if err != nil { + return common.Address{}, nil, nil, err + } + + receipt, err := zksyncClient.WaitMined(context.Background(), hash) + if err != nil { + return common.Address{}, nil, nil, err + } + tx, _, err := zksyncClient.TransactionByHash(context.Background(), hash) + if err != nil { + return common.Address{}, nil, nil, err + } + + ethTx := ConvertToTransaction(*tx) + address := receipt.ContractAddress + + parsed, err := StorageMetaData.GetAbi() + contractBind := bind.NewBoundContract(address, *parsed, backend, backend, backend) + + contractReturn := &Storage{address: address, abi: *parsed, StorageCaller: StorageCaller{contract: contractBind}, StorageTransactor: StorageTransactor{contract: contractBind}, StorageFilterer: StorageFilterer{contract: contractBind}} + + return address, ethTx, contractReturn, err +} + +type StorageInterface interface { + Retrieve(opts *bind.CallOpts) (*big.Int, error) + + Store(opts *bind.TransactOpts, num *big.Int) (*types.Transaction, error) + + FilterStoredNumber(opts *bind.FilterOpts, _from []common.Address, _oldNumber []*big.Int, _number []*big.Int) (*StorageStoredNumberIterator, error) + + WatchStoredNumber(opts *bind.WatchOpts, sink chan<- *StorageStoredNumber, _from []common.Address, _oldNumber []*big.Int, _number []*big.Int) (event.Subscription, error) + + ParseStoredNumber(log types.Log) (*StorageStoredNumber, error) + + ParseLog(log types.Log) (generated.AbigenLog, error) + + Address() common.Address +} diff --git a/core/gethwrappers/ccip/generated/storage_contract/storage_contract.go b/core/gethwrappers/ccip/generated/storage_contract/storage_contract.go new file mode 100644 index 0000000000..9bad99103a --- /dev/null +++ b/core/gethwrappers/ccip/generated/storage_contract/storage_contract.go @@ -0,0 +1,481 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package storage_contract + +import ( + "context" + "errors" + "fmt" + "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/ethclient" + "github.com/ethereum/go-ethereum/event" + "github.com/smartcontractkit/chainlink/v2/core/gethwrappers/generated" + zkSyncAccounts "github.com/zksync-sdk/zksync2-go/accounts" + zkSyncClient "github.com/zksync-sdk/zksync2-go/clients" + zktypes "github.com/zksync-sdk/zksync2-go/types" +) + +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +var StorageContractMetaData = &bind.MetaData{ + ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"_oldNumber\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"_number\",\"type\":\"uint256\"}],\"name\":\"storedNumber\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"retrieve\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"num\",\"type\":\"uint256\"}],\"name\":\"store\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x608060405234801561001057600080fd5b5060bc8061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80632e64cec11460375780636057361d14604c575b600080fd5b60005460405190815260200160405180910390f35b605b60573660046097565b605d565b005b6000805482825560405190918391839133917f87f16aa184eca14ea45e132328a5effbb79b9f921657bd03d83608f26d76f3cf9190a45050565b60006020828403121560a857600080fd5b503591905056fea164736f6c6343000818000a", +} + +var StorageContractABI = StorageContractMetaData.ABI + +var StorageContractBin = StorageContractMetaData.Bin + +func DeployStorageContract(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *CustomTransaction, *StorageContract, error) { + client, ok := backend.(*ethclient.Client) + if !ok { + return common.Address{}, nil, nil, errors.New("backend is not an ethclient") + } + chainId, err := client.ChainID(context.Background()) + if err != nil { + return common.Address{}, nil, nil, err + } + switch chainId.Uint64() { + + case 324, 280, 300: + return DeployZkSyncStorageContract(auth, backend) + } + + parsed, err := StorageContractMetaData.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(StorageContractBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, &CustomTransaction{Transaction: tx, CustomHash: tx.Hash()}, &StorageContract{address: address, abi: *parsed, StorageContractCaller: StorageContractCaller{contract: contract}, StorageContractTransactor: StorageContractTransactor{contract: contract}, StorageContractFilterer: StorageContractFilterer{contract: contract}}, nil +} + +type StorageContract struct { + address common.Address + abi abi.ABI + StorageContractCaller + StorageContractTransactor + StorageContractFilterer +} + +type StorageContractCaller struct { + contract *bind.BoundContract +} + +type StorageContractTransactor struct { + contract *bind.BoundContract +} + +type StorageContractFilterer struct { + contract *bind.BoundContract +} + +type StorageContractSession struct { + Contract *StorageContract + CallOpts bind.CallOpts + TransactOpts bind.TransactOpts +} + +type StorageContractCallerSession struct { + Contract *StorageContractCaller + CallOpts bind.CallOpts +} + +type StorageContractTransactorSession struct { + Contract *StorageContractTransactor + TransactOpts bind.TransactOpts +} + +type StorageContractRaw struct { + Contract *StorageContract +} + +type StorageContractCallerRaw struct { + Contract *StorageContractCaller +} + +type StorageContractTransactorRaw struct { + Contract *StorageContractTransactor +} + +func NewStorageContract(address common.Address, backend bind.ContractBackend) (*StorageContract, error) { + abi, err := abi.JSON(strings.NewReader(StorageContractABI)) + if err != nil { + return nil, err + } + contract, err := bindStorageContract(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &StorageContract{address: address, abi: abi, StorageContractCaller: StorageContractCaller{contract: contract}, StorageContractTransactor: StorageContractTransactor{contract: contract}, StorageContractFilterer: StorageContractFilterer{contract: contract}}, nil +} + +func NewStorageContractCaller(address common.Address, caller bind.ContractCaller) (*StorageContractCaller, error) { + contract, err := bindStorageContract(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &StorageContractCaller{contract: contract}, nil +} + +func NewStorageContractTransactor(address common.Address, transactor bind.ContractTransactor) (*StorageContractTransactor, error) { + contract, err := bindStorageContract(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &StorageContractTransactor{contract: contract}, nil +} + +func NewStorageContractFilterer(address common.Address, filterer bind.ContractFilterer) (*StorageContractFilterer, error) { + contract, err := bindStorageContract(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &StorageContractFilterer{contract: contract}, nil +} + +func bindStorageContract(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := StorageContractMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +func (_StorageContract *StorageContractRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _StorageContract.Contract.StorageContractCaller.contract.Call(opts, result, method, params...) +} + +func (_StorageContract *StorageContractRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _StorageContract.Contract.StorageContractTransactor.contract.Transfer(opts) +} + +func (_StorageContract *StorageContractRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _StorageContract.Contract.StorageContractTransactor.contract.Transact(opts, method, params...) +} + +func (_StorageContract *StorageContractCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _StorageContract.Contract.contract.Call(opts, result, method, params...) +} + +func (_StorageContract *StorageContractTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _StorageContract.Contract.contract.Transfer(opts) +} + +func (_StorageContract *StorageContractTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _StorageContract.Contract.contract.Transact(opts, method, params...) +} + +func (_StorageContract *StorageContractCaller) Retrieve(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _StorageContract.contract.Call(opts, &out, "retrieve") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +func (_StorageContract *StorageContractSession) Retrieve() (*big.Int, error) { + return _StorageContract.Contract.Retrieve(&_StorageContract.CallOpts) +} + +func (_StorageContract *StorageContractCallerSession) Retrieve() (*big.Int, error) { + return _StorageContract.Contract.Retrieve(&_StorageContract.CallOpts) +} + +func (_StorageContract *StorageContractTransactor) Store(opts *bind.TransactOpts, num *big.Int) (*types.Transaction, error) { + return _StorageContract.contract.Transact(opts, "store", num) +} + +func (_StorageContract *StorageContractSession) Store(num *big.Int) (*types.Transaction, error) { + return _StorageContract.Contract.Store(&_StorageContract.TransactOpts, num) +} + +func (_StorageContract *StorageContractTransactorSession) Store(num *big.Int) (*types.Transaction, error) { + return _StorageContract.Contract.Store(&_StorageContract.TransactOpts, num) +} + +type StorageContractStoredNumberIterator struct { + Event *StorageContractStoredNumber + + contract *bind.BoundContract + event string + + logs chan types.Log + sub ethereum.Subscription + done bool + fail error +} + +func (it *StorageContractStoredNumberIterator) Next() bool { + + if it.fail != nil { + return false + } + + if it.done { + select { + case log := <-it.logs: + it.Event = new(StorageContractStoredNumber) + 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 + } + } + + select { + case log := <-it.logs: + it.Event = new(StorageContractStoredNumber) + 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() + } +} + +func (it *StorageContractStoredNumberIterator) Error() error { + return it.fail +} + +func (it *StorageContractStoredNumberIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +type StorageContractStoredNumber struct { + From common.Address + OldNumber *big.Int + Number *big.Int + Raw types.Log +} + +func (_StorageContract *StorageContractFilterer) FilterStoredNumber(opts *bind.FilterOpts, _from []common.Address, _oldNumber []*big.Int, _number []*big.Int) (*StorageContractStoredNumberIterator, error) { + + var _fromRule []interface{} + for _, _fromItem := range _from { + _fromRule = append(_fromRule, _fromItem) + } + var _oldNumberRule []interface{} + for _, _oldNumberItem := range _oldNumber { + _oldNumberRule = append(_oldNumberRule, _oldNumberItem) + } + var _numberRule []interface{} + for _, _numberItem := range _number { + _numberRule = append(_numberRule, _numberItem) + } + + logs, sub, err := _StorageContract.contract.FilterLogs(opts, "storedNumber", _fromRule, _oldNumberRule, _numberRule) + if err != nil { + return nil, err + } + return &StorageContractStoredNumberIterator{contract: _StorageContract.contract, event: "storedNumber", logs: logs, sub: sub}, nil +} + +func (_StorageContract *StorageContractFilterer) WatchStoredNumber(opts *bind.WatchOpts, sink chan<- *StorageContractStoredNumber, _from []common.Address, _oldNumber []*big.Int, _number []*big.Int) (event.Subscription, error) { + + var _fromRule []interface{} + for _, _fromItem := range _from { + _fromRule = append(_fromRule, _fromItem) + } + var _oldNumberRule []interface{} + for _, _oldNumberItem := range _oldNumber { + _oldNumberRule = append(_oldNumberRule, _oldNumberItem) + } + var _numberRule []interface{} + for _, _numberItem := range _number { + _numberRule = append(_numberRule, _numberItem) + } + + logs, sub, err := _StorageContract.contract.WatchLogs(opts, "storedNumber", _fromRule, _oldNumberRule, _numberRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + + event := new(StorageContractStoredNumber) + if err := _StorageContract.contract.UnpackLog(event, "storedNumber", 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 +} + +func (_StorageContract *StorageContractFilterer) ParseStoredNumber(log types.Log) (*StorageContractStoredNumber, error) { + event := new(StorageContractStoredNumber) + if err := _StorageContract.contract.UnpackLog(event, "storedNumber", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +var StorageContractZkBin string = ("0x0000008003000039000000400030043f0000000100200190000000150000c13d00000060021002700000001002200197000000040020008c000000340000413d000000000301043b000000e003300270000000120030009c0000001d0000613d000000130030009c000000340000c13d0000000001000416000000000001004b000000340000c13d000000000100041a000000800010043f00000016010000410000003c0001042e0000000001000416000000000001004b000000340000c13d00000020010000390000010000100443000001200000044300000011010000410000003c0001042e000000240020008c000000340000413d0000000002000416000000000002004b000000340000c13d0000000401100370000000000701043b000000000600041a000000000070041b0000000001000414000000100010009c0000001001008041000000c00110021000000014011001c70000800d02000039000000040300003900000000050004110000001504000041003b00360000040f0000000100200190000000340000613d00000000010000190000003c0001042e00000000010000190000003d0001043000000039002104210000000102000039000000000001042d0000000002000019000000000001042d0000003b000004320000003c0001042e0000003d000104300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffff0000000200000000000000000000000000000040000001000000000000000000000000000000000000000000000000000000000000000000000000006057361d000000000000000000000000000000000000000000000000000000002e64cec1020000000000000000000000000000000000000000000000000000000000000087f16aa184eca14ea45e132328a5effbb79b9f921657bd03d83608f26d76f3cf00000000000000000000000000000000000000200000008000000000000000000000000000000000000000000000000000000000000000000000000000000000d05624d43b7436b857a8c30563e36489cd4edac61bd40b452ab9052253f0fef5") + +func (_StorageContract *StorageContract) ParseLog(log types.Log) (generated.AbigenLog, error) { + switch log.Topics[0] { + case _StorageContract.abi.Events["StoredNumber"].ID: + return _StorageContract.ParseStoredNumber(log) + + default: + return nil, fmt.Errorf("abigen wrapper received unknown log topic: %v", log.Topics[0]) + } +} + +func (StorageContractStoredNumber) Topic() common.Hash { + return common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000") +} + +func (_StorageContract *StorageContract) Address() common.Address { + return _StorageContract.address +} + +type CustomTransaction struct { + *types.Transaction + CustomHash common.Hash +} + +func (tx *CustomTransaction) Hash() common.Hash { + return tx.CustomHash +} + +func ConvertToTransaction(resp zktypes.TransactionResponse) *CustomTransaction { + dtx := &types.DynamicFeeTx{ + ChainID: resp.ChainID.ToInt(), + Nonce: uint64(resp.Nonce), + GasTipCap: resp.MaxPriorityFeePerGas.ToInt(), + GasFeeCap: resp.MaxFeePerGas.ToInt(), + To: &resp.To, + Value: resp.Value.ToInt(), + Data: resp.Data, + Gas: uint64(resp.Gas), + } + + tx := types.NewTx(dtx) + customTransaction := CustomTransaction{Transaction: tx, CustomHash: resp.Hash} + return &customTransaction +} + +func DeployZkSyncStorageContract(auth *bind.TransactOpts, backend bind.ContractBackend, params ...interface{}) (common.Address, *CustomTransaction, *StorageContract, error) { + client, ok := backend.(*ethclient.Client) + if !ok { + return common.Address{}, nil, nil, errors.New("backend is not an ethclient") + } + + zksyncClient := zkSyncClient.NewClient(client.Client()) + + wallet := auth.Context.Value("wallet").(*zkSyncAccounts.Wallet) + + decodedBytes := common.FromHex(StorageContractZkBin) + + StorageContractAbi, err := StorageContractMetaData.GetAbi() + if err != nil { + return common.Address{}, nil, nil, err + } + constructor, err := StorageContractAbi.Pack("", params...) + if err != nil { + return common.Address{}, nil, nil, err + } + + hash, err := wallet.DeployWithCreate(nil, zkSyncAccounts.CreateTransaction{ + Bytecode: decodedBytes, + Calldata: constructor, + }) + if err != nil { + return common.Address{}, nil, nil, err + } + + receipt, err := zksyncClient.WaitMined(context.Background(), hash) + if err != nil { + return common.Address{}, nil, nil, err + } + tx, _, err := zksyncClient.TransactionByHash(context.Background(), hash) + if err != nil { + return common.Address{}, nil, nil, err + } + + ethTx := ConvertToTransaction(*tx) + address := receipt.ContractAddress + + parsed, err := StorageContractMetaData.GetAbi() + contractBind := bind.NewBoundContract(address, *parsed, backend, backend, backend) + + contractReturn := &StorageContract{address: address, abi: *parsed, StorageContractCaller: StorageContractCaller{contract: contractBind}, StorageContractTransactor: StorageContractTransactor{contract: contractBind}, StorageContractFilterer: StorageContractFilterer{contract: contractBind}} + + return address, ethTx, contractReturn, err +} + +type StorageContractInterface interface { + Retrieve(opts *bind.CallOpts) (*big.Int, error) + + Store(opts *bind.TransactOpts, num *big.Int) (*types.Transaction, error) + + FilterStoredNumber(opts *bind.FilterOpts, _from []common.Address, _oldNumber []*big.Int, _number []*big.Int) (*StorageContractStoredNumberIterator, error) + + WatchStoredNumber(opts *bind.WatchOpts, sink chan<- *StorageContractStoredNumber, _from []common.Address, _oldNumber []*big.Int, _number []*big.Int) (event.Subscription, error) + + ParseStoredNumber(log types.Log) (*StorageContractStoredNumber, error) + + ParseLog(log types.Log) (generated.AbigenLog, error) + + Address() common.Address +} diff --git a/core/gethwrappers/ccip/generation/generated-wrapper-dependency-versions-do-not-edit.txt b/core/gethwrappers/ccip/generation/generated-wrapper-dependency-versions-do-not-edit.txt index 073e58358f..bfb140b2e1 100644 --- a/core/gethwrappers/ccip/generation/generated-wrapper-dependency-versions-do-not-edit.txt +++ b/core/gethwrappers/ccip/generation/generated-wrapper-dependency-versions-do-not-edit.txt @@ -38,6 +38,8 @@ rmn_proxy_contract: ../../../contracts/solc/v0.8.24/ARMProxy/ARMProxy.abi ../../ rmn_remote: ../../../contracts/solc/v0.8.24/RMNRemote/RMNRemote.abi ../../../contracts/solc/v0.8.24/RMNRemote/RMNRemote.bin 8d7f0e4581acac5c6b42c7cca1c06e699fdcf9dbca782dde153b7d190cdbe9bc router: ../../../contracts/solc/v0.8.24/Router/Router.abi ../../../contracts/solc/v0.8.24/Router/Router.bin 2e4f0a7826c8abb49d882bb49fc5ff20a186dbd3137624b9097ffed903ae4888 self_funded_ping_pong: ../../../contracts/solc/v0.8.24/SelfFundedPingPong/SelfFundedPingPong.abi ../../../contracts/solc/v0.8.24/SelfFundedPingPong/SelfFundedPingPong.bin 8ea5d75dbc3f8afd90d22c4a665a94e02892259cd16520c1c6b4cf0dc80c9148 +storage: ../../../contracts/solc/v0.8.24/Storage/Storage.abi ../../../contracts/solc/v0.8.24/Storage/Storage.bin 9b024adc8bca1941c8b9110f8f495a70c188a521fdf05ff38273f19569f4e8b4 +storage_contract: ../../../contracts/solc/v0.8.24/Storage/Storage.abi ../../../contracts/solc/v0.8.24/Storage/Storage.bin 9b024adc8bca1941c8b9110f8f495a70c188a521fdf05ff38273f19569f4e8b4 token_admin_registry: ../../../contracts/solc/v0.8.24/TokenAdminRegistry/TokenAdminRegistry.abi ../../../contracts/solc/v0.8.24/TokenAdminRegistry/TokenAdminRegistry.bin 942be7d1681ac102e0615bee13f76838ebb0b261697cf1270d2bf82c12e57aeb token_pool: ../../../contracts/solc/v0.8.24/TokenPool/TokenPool.abi ../../../contracts/solc/v0.8.24/TokenPool/TokenPool.bin 7c01fd89f5153baa4d7409d14beabb3f861abfbf8880d3c6d06802cc398570f9 usdc_token_pool: ../../../contracts/solc/v0.8.24/USDCTokenPool/USDCTokenPool.abi ../../../contracts/solc/v0.8.24/USDCTokenPool/USDCTokenPool.bin 8e7eae4c7277ce4a0092cca815c046cc49094028c23d2d113de9335fa4358030 diff --git a/core/gethwrappers/ccip/go_gen_zk.go b/core/gethwrappers/ccip/go_gen_zk.go index fccadd089d..9ebc3016e5 100644 --- a/core/gethwrappers/ccip/go_gen_zk.go +++ b/core/gethwrappers/ccip/go_gen_zk.go @@ -20,3 +20,5 @@ package ccip //go:generate go run ../generation/generate/wrap.go ../../../contracts/solc/v0.8.24/WETH9/WETH9.abi ../../../contracts/solc/v0.8.24/WETH9/WETH9.bin WETH9 weth9 ../../../contracts/zksolc/v0.8.24/WETH9/WETH9.sol/WETH9.zbin //go:generate go run ../generation/generate/wrap.go ../../../contracts/solc/v0.8.24/SelfFundedPingPong/SelfFundedPingPong.abi ../../../contracts/solc/v0.8.24/SelfFundedPingPong/SelfFundedPingPong.bin SelfFundedPingPong self_funded_ping_pong ../../../contracts/zksolc/v0.8.24/SelfFundedPingPong/SelfFundedPingPong.sol/SelfFundedPingPong.zbin + +//go:generate go run ../generation/generate/wrap.go ../../../contracts/solc/v0.8.24/Storage/Storage.abi ../../../contracts/solc/v0.8.24/Storage/Storage.bin Storage storage ../../../contracts/zksolc/v0.8.24/Storage/Storage.sol/Storage.zbin