diff --git a/bindings/L1StandardBridge/L1StandardBridge.go b/bindings/L1StandardBridge/L1StandardBridge.go new file mode 100644 index 0000000..d3439a9 --- /dev/null +++ b/bindings/L1StandardBridge/L1StandardBridge.go @@ -0,0 +1,6985 @@ +// This file was generated by seer: https://github.com/G7DAO/seer. +// seer version: 0.3.15 +// seer command: seer evm generate --package L1StandardBridge --cli --foundry ../../base-org/optimism/packages/contracts-bedrock/forge-artifacts/L1StandardBridge.sol/L1StandardBridge.json --struct L1StandardBridge --output bindings/L1StandardBridge/L1StandardBridge.go +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package L1StandardBridge + +import ( + "bytes" + "crypto/rand" + "errors" + "math/big" + "net/http" + "strings" + + "context" + + 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" + "github.com/ethereum/go-ethereum/signer/core/apitypes" + + // Reference imports to suppress errors if they are not otherwise used. + "encoding/hex" + "encoding/json" + "fmt" + "os" + "time" + + "github.com/G7DAO/seer/bindings/CreateCall" + "github.com/G7DAO/seer/bindings/GnosisSafe" + "github.com/ethereum/go-ethereum/accounts/keystore" + "github.com/ethereum/go-ethereum/ethclient" + "github.com/spf13/cobra" + "golang.org/x/term" + + // L1StandardBridgeMetaData contains all meta data concerning the L1StandardBridge contract. + "github.com/ethereum/go-ethereum/common/math" + "github.com/ethereum/go-ethereum/crypto" +) + +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +var L1StandardBridgeMetaData = &bind.MetaData{ + ABI: "[{\"type\":\"constructor\",\"inputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"receive\",\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"MESSENGER\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractCrossDomainMessenger\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"OTHER_BRIDGE\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractStandardBridge\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"bridgeERC20\",\"inputs\":[{\"name\":\"_localToken\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_remoteToken\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_minGasLimit\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"_extraData\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"bridgeERC20To\",\"inputs\":[{\"name\":\"_localToken\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_remoteToken\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_to\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_minGasLimit\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"_extraData\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"bridgeETH\",\"inputs\":[{\"name\":\"_minGasLimit\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"_extraData\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"bridgeETHTo\",\"inputs\":[{\"name\":\"_to\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_minGasLimit\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"_extraData\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"depositERC20\",\"inputs\":[{\"name\":\"_l1Token\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_l2Token\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_minGasLimit\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"_extraData\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"depositERC20To\",\"inputs\":[{\"name\":\"_l1Token\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_l2Token\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_to\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_minGasLimit\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"_extraData\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"depositETH\",\"inputs\":[{\"name\":\"_minGasLimit\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"_extraData\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"depositETHTo\",\"inputs\":[{\"name\":\"_to\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_minGasLimit\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"_extraData\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"deposits\",\"inputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"finalizeBridgeERC20\",\"inputs\":[{\"name\":\"_localToken\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_remoteToken\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_from\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_to\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_extraData\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"finalizeBridgeETH\",\"inputs\":[{\"name\":\"_from\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_to\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_extraData\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"finalizeERC20Withdrawal\",\"inputs\":[{\"name\":\"_l1Token\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_l2Token\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_from\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_to\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_extraData\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"finalizeETHWithdrawal\",\"inputs\":[{\"name\":\"_from\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_to\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_amount\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"_extraData\",\"type\":\"bytes\",\"internalType\":\"bytes\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"initialize\",\"inputs\":[{\"name\":\"_messenger\",\"type\":\"address\",\"internalType\":\"contractCrossDomainMessenger\"},{\"name\":\"_superchainConfig\",\"type\":\"address\",\"internalType\":\"contractSuperchainConfig\"},{\"name\":\"_systemConfig\",\"type\":\"address\",\"internalType\":\"contractSystemConfig\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"l2TokenBridge\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"messenger\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractCrossDomainMessenger\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"otherBridge\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractStandardBridge\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"paused\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"superchainConfig\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractSuperchainConfig\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"systemConfig\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"contractSystemConfig\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"version\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"view\"},{\"type\":\"event\",\"name\":\"ERC20BridgeFinalized\",\"inputs\":[{\"name\":\"localToken\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"remoteToken\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"from\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"to\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"extraData\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ERC20BridgeInitiated\",\"inputs\":[{\"name\":\"localToken\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"remoteToken\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"from\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"to\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"extraData\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ERC20DepositInitiated\",\"inputs\":[{\"name\":\"l1Token\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"l2Token\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"from\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"to\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"extraData\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ERC20WithdrawalFinalized\",\"inputs\":[{\"name\":\"l1Token\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"l2Token\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"from\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"to\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"extraData\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ETHBridgeFinalized\",\"inputs\":[{\"name\":\"from\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"to\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"extraData\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ETHBridgeInitiated\",\"inputs\":[{\"name\":\"from\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"to\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"extraData\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ETHDepositInitiated\",\"inputs\":[{\"name\":\"from\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"to\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"extraData\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ETHWithdrawalFinalized\",\"inputs\":[{\"name\":\"from\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"to\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"},{\"name\":\"extraData\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"Initialized\",\"inputs\":[{\"name\":\"version\",\"type\":\"uint8\",\"indexed\":false,\"internalType\":\"uint8\"}],\"anonymous\":false}]", + Bin: "0x60806040523480156200001157600080fd5b50620000206000808062000026565b6200024b565b600054610100900460ff1615808015620000475750600054600160ff909116105b806200007757506200006430620001a160201b620005891760201c565b15801562000077575060005460ff166001145b620000e05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff19166001179055801562000104576000805461ff0019166101001790555b603280546001600160a01b038086166001600160a01b03199283161790925560338054928516929091169190911790556200015484734200000000000000000000000000000000000010620001b0565b80156200019b576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050565b6001600160a01b03163b151590565b600054610100900460ff166200021d5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401620000d7565b600380546001600160a01b039384166001600160a01b03199182161790915560048054929093169116179055565b612fad806200025b6000396000f3fe6080604052600436106101845760003560e01c80637f46ddb2116100d65780639a2ac6d51161007f578063c0c53b8b11610059578063c0c53b8b14610529578063c89701a214610549578063e11013dd1461057657600080fd5b80639a2ac6d5146104e3578063a9f9e675146104f6578063b1a1a8821461051657600080fd5b80638f601f66116100b05780638f601f661461047257806391c49bf814610407578063927ede2d146104b857600080fd5b80637f46ddb214610407578063838b252014610432578063870876231461045257600080fd5b806335e80ab31161013857806354fd4d501161011257806354fd4d501461036c57806358a997f6146103c25780635c975abb146103e257600080fd5b806335e80ab3146102f25780633cb747bf1461031f578063540abf731461034c57600080fd5b80631532ec34116101695780631532ec34146102755780631635f5fd1461028857806333d7e2bd1461029b57600080fd5b80630166a07a1461024257806309fc88431461026257600080fd5b3661023d57333b1561021d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603760248201527f5374616e646172644272696467653a2066756e6374696f6e2063616e206f6e6c60448201527f792062652063616c6c65642066726f6d20616e20454f4100000000000000000060648201526084015b60405180910390fd5b61023b333362030d40604051806020016040528060008152506105a5565b005b600080fd5b34801561024e57600080fd5b5061023b61025d366004612991565b6105b8565b61023b610270366004612a42565b6109d2565b61023b610283366004612a95565b610aa9565b61023b610296366004612a95565b610abd565b3480156102a757600080fd5b506033546102c89073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b3480156102fe57600080fd5b506032546102c89073ffffffffffffffffffffffffffffffffffffffff1681565b34801561032b57600080fd5b506003546102c89073ffffffffffffffffffffffffffffffffffffffff1681565b34801561035857600080fd5b5061023b610367366004612b08565b61101b565b34801561037857600080fd5b506103b56040518060400160405280600581526020017f322e322e3000000000000000000000000000000000000000000000000000000081525081565b6040516102e99190612bf5565b3480156103ce57600080fd5b5061023b6103dd366004612c08565b611060565b3480156103ee57600080fd5b506103f7611134565b60405190151581526020016102e9565b34801561041357600080fd5b5060045473ffffffffffffffffffffffffffffffffffffffff166102c8565b34801561043e57600080fd5b5061023b61044d366004612b08565b6111cd565b34801561045e57600080fd5b5061023b61046d366004612c08565b611212565b34801561047e57600080fd5b506104aa61048d366004612c8b565b600260209081526000928352604080842090915290825290205481565b6040519081526020016102e9565b3480156104c457600080fd5b5060035473ffffffffffffffffffffffffffffffffffffffff166102c8565b61023b6104f1366004612cc4565b6112e6565b34801561050257600080fd5b5061023b610511366004612991565b611328565b61023b610524366004612a42565b611337565b34801561053557600080fd5b5061023b610544366004612d27565b611408565b34801561055557600080fd5b506004546102c89073ffffffffffffffffffffffffffffffffffffffff1681565b61023b610584366004612cc4565b611607565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b6105b2848434858561164a565b50505050565b60035473ffffffffffffffffffffffffffffffffffffffff163314801561068b575060048054600354604080517f6e296e45000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff938416949390921692636e296e459282820192602092908290030181865afa15801561064f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106739190612d72565b73ffffffffffffffffffffffffffffffffffffffff16145b61073d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604160248201527f5374616e646172644272696467653a2066756e6374696f6e2063616e206f6e6c60448201527f792062652063616c6c65642066726f6d20746865206f7468657220627269646760648201527f6500000000000000000000000000000000000000000000000000000000000000608482015260a401610214565b610745611134565b156107ac576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f5374616e646172644272696467653a20706175736564000000000000000000006044820152606401610214565b6107b5876118a9565b15610903576107c4878761190b565b610876576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604a60248201527f5374616e646172644272696467653a2077726f6e672072656d6f746520746f6b60448201527f656e20666f72204f7074696d69736d204d696e7461626c65204552433230206c60648201527f6f63616c20746f6b656e00000000000000000000000000000000000000000000608482015260a401610214565b6040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8581166004830152602482018590528816906340c10f1990604401600060405180830381600087803b1580156108e657600080fd5b505af11580156108fa573d6000803e3d6000fd5b50505050610985565b73ffffffffffffffffffffffffffffffffffffffff8088166000908152600260209081526040808320938a1683529290522054610941908490612dbe565b73ffffffffffffffffffffffffffffffffffffffff8089166000818152600260209081526040808320948c1683529390529190912091909155610985908585611a2b565b6109c9878787878787878080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611aff92505050565b50505050505050565b333b15610a61576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603760248201527f5374616e646172644272696467653a2066756e6374696f6e2063616e206f6e6c60448201527f792062652063616c6c65642066726f6d20616e20454f410000000000000000006064820152608401610214565b610aa43333348686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061164a92505050565b505050565b610ab68585858585610abd565b5050505050565b60035473ffffffffffffffffffffffffffffffffffffffff1633148015610b90575060048054600354604080517f6e296e45000000000000000000000000000000000000000000000000000000008152905173ffffffffffffffffffffffffffffffffffffffff938416949390921692636e296e459282820192602092908290030181865afa158015610b54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b789190612d72565b73ffffffffffffffffffffffffffffffffffffffff16145b610c42576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604160248201527f5374616e646172644272696467653a2066756e6374696f6e2063616e206f6e6c60448201527f792062652063616c6c65642066726f6d20746865206f7468657220627269646760648201527f6500000000000000000000000000000000000000000000000000000000000000608482015260a401610214565b610c4a611134565b15610cb1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f5374616e646172644272696467653a20706175736564000000000000000000006044820152606401610214565b610cb9611b8d565b15610d46576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603760248201527f5374616e646172644272696467653a2063616e6e6f742062726964676520455460448201527f48207769746820637573746f6d2067617320746f6b656e0000000000000000006064820152608401610214565b823414610dd5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603a60248201527f5374616e646172644272696467653a20616d6f756e742073656e7420646f657360448201527f206e6f74206d6174636820616d6f756e742072657175697265640000000000006064820152608401610214565b3073ffffffffffffffffffffffffffffffffffffffff851603610e7a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f5374616e646172644272696467653a2063616e6e6f742073656e6420746f207360448201527f656c6600000000000000000000000000000000000000000000000000000000006064820152608401610214565b60035473ffffffffffffffffffffffffffffffffffffffff90811690851603610f25576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602860248201527f5374616e646172644272696467653a2063616e6e6f742073656e6420746f206d60448201527f657373656e6765720000000000000000000000000000000000000000000000006064820152608401610214565b610f6785858585858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611bcc92505050565b6000610f84855a8660405180602001604052806000815250611c3f565b905080611013576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f5374616e646172644272696467653a20455448207472616e736665722066616960448201527f6c656400000000000000000000000000000000000000000000000000000000006064820152608401610214565b505050505050565b6109c987873388888888888080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611c5792505050565b333b156110ef576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603760248201527f5374616e646172644272696467653a2066756e6374696f6e2063616e206f6e6c60448201527f792062652063616c6c65642066726f6d20616e20454f410000000000000000006064820152608401610214565b61101386863333888888888080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061201092505050565b603254604080517f5c975abb000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff1691635c975abb9160048083019260209291908290030181865afa1580156111a4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c89190612dd5565b905090565b6109c987873388888888888080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061201092505050565b333b156112a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603760248201527f5374616e646172644272696467653a2066756e6374696f6e2063616e206f6e6c60448201527f792062652063616c6c65642066726f6d20616e20454f410000000000000000006064820152608401610214565b61101386863333888888888080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611c5792505050565b6105b233858585858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506105a592505050565b6109c9878787878787876105b8565b333b156113c6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603760248201527f5374616e646172644272696467653a2066756e6374696f6e2063616e206f6e6c60448201527f792062652063616c6c65642066726f6d20616e20454f410000000000000000006064820152608401610214565b610aa433338585858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506105a592505050565b600054610100900460ff16158080156114285750600054600160ff909116105b806114425750303b158015611442575060005460ff166001145b6114ce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610214565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055801561152c57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6032805473ffffffffffffffffffffffffffffffffffffffff8086167fffffffffffffffffffffffff000000000000000000000000000000000000000092831617909255603380549285169290911691909117905561159f8473420000000000000000000000000000000000001061201f565b80156105b257600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150505050565b6105b23385348686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061164a92505050565b611652611b8d565b156116df576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603760248201527f5374616e646172644272696467653a2063616e6e6f742062726964676520455460448201527f48207769746820637573746f6d2067617320746f6b656e0000000000000000006064820152608401610214565b82341461176e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603e60248201527f5374616e646172644272696467653a206272696467696e6720455448206d757360448201527f7420696e636c7564652073756666696369656e74204554482076616c756500006064820152608401610214565b61177a85858584612109565b60035460045460405173ffffffffffffffffffffffffffffffffffffffff92831692633dbb202b9287929116907f1635f5fd00000000000000000000000000000000000000000000000000000000906117dd908b908b9086908a90602401612df7565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009485161790525160e086901b909216825261187092918890600401612e40565b6000604051808303818588803b15801561188957600080fd5b505af115801561189d573d6000803e3d6000fd5b50505050505050505050565b60006118d5827f1d1d8b630000000000000000000000000000000000000000000000000000000061217c565b806119055750611905827fec4fc8e30000000000000000000000000000000000000000000000000000000061217c565b92915050565b6000611937837f1d1d8b630000000000000000000000000000000000000000000000000000000061217c565b156119e0578273ffffffffffffffffffffffffffffffffffffffff1663c01e1bd66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611987573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ab9190612d72565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16149050611905565b8273ffffffffffffffffffffffffffffffffffffffff1663d6c0b2c46040518163ffffffff1660e01b8152600401602060405180830381865afa158015611987573d6000803e3d6000fd5b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052610aa49084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915261219f565b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167f3ceee06c1e37648fcbb6ed52e17b3e1f275a1f8c7b22a84b2b84732431e046b3868686604051611b7793929190612e85565b60405180910390a46110138686868686866122ab565b600080611b98612333565b5073ffffffffffffffffffffffffffffffffffffffff1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee141592915050565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f2ac69ee804d9a7a0984249f508dfab7cb2534b465b6ce1580f99a38ba9c5e6318484604051611c2b929190612ec3565b60405180910390a36105b2848484846123d0565b6000806000835160208501868989f195945050505050565b3415611ce5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f5374616e646172644272696467653a2063616e6e6f742073656e642076616c7560448201527f65000000000000000000000000000000000000000000000000000000000000006064820152608401610214565b611cee876118a9565b15611e3c57611cfd878761190b565b611daf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152604a60248201527f5374616e646172644272696467653a2077726f6e672072656d6f746520746f6b60448201527f656e20666f72204f7074696d69736d204d696e7461626c65204552433230206c60648201527f6f63616c20746f6b656e00000000000000000000000000000000000000000000608482015260a401610214565b6040517f9dc29fac00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff868116600483015260248201859052881690639dc29fac90604401600060405180830381600087803b158015611e1f57600080fd5b505af1158015611e33573d6000803e3d6000fd5b50505050611ed0565b611e5e73ffffffffffffffffffffffffffffffffffffffff881686308661243d565b73ffffffffffffffffffffffffffffffffffffffff8088166000908152600260209081526040808320938a1683529290522054611e9c908490612edc565b73ffffffffffffffffffffffffffffffffffffffff8089166000908152600260209081526040808320938b16835292905220555b611ede87878787878661249b565b60035460045460405173ffffffffffffffffffffffffffffffffffffffff92831692633dbb202b9216907f0166a07a0000000000000000000000000000000000000000000000000000000090611f42908b908d908c908c908c908b90602401612ef4565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009485161790525160e085901b9092168252611fd592918790600401612e40565b600060405180830381600087803b158015611fef57600080fd5b505af1158015612003573d6000803e3d6000fd5b5050505050505050505050565b6109c987878787878787611c57565b600054610100900460ff166120b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610214565b6003805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560048054929093169116179055565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f35d79ab81f2b2017e19afb5c5571778877782d7a8786f5907f93b0f4702f4f238484604051612168929190612ec3565b60405180910390a36105b284848484612529565b600061218783612588565b8015612198575061219883836125ec565b9392505050565b6000612201826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166126bb9092919063ffffffff16565b805190915015610aa4578080602001905181019061221f9190612dd5565b610aa4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610214565b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167fd59c65b35445225835c83f50b6ede06a7be047d22e357073e250d9af537518cd86868660405161232393929190612e85565b60405180910390a4505050505050565b603354604080517f4397dfef0000000000000000000000000000000000000000000000000000000081528151600093849373ffffffffffffffffffffffffffffffffffffffff90911692634397dfef92600480830193928290030181865afa1580156123a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123c79190612f4f565b90939092509050565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f31b2166ff604fc5672ea5df08a78081d2bc6d746cadce880747f3643d819e83d848460405161242f929190612ec3565b60405180910390a350505050565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526105b29085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401611a7d565b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167f718594027abd4eaed59f95162563e0cc6d0e8d5b86b1c7be8b1b0ac3343d039686868660405161251393929190612e85565b60405180910390a46110138686868686866126d2565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f2849b43074093a05396b6f2a937dee8565b15a48a7b3d4bffb732a5017380af5848460405161242f929190612ec3565b60006125b4827f01ffc9a7000000000000000000000000000000000000000000000000000000006125ec565b801561190557506125e5827fffffffff000000000000000000000000000000000000000000000000000000006125ec565b1592915050565b604080517fffffffff000000000000000000000000000000000000000000000000000000008316602480830191909152825180830390910181526044909101909152602080820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f01ffc9a700000000000000000000000000000000000000000000000000000000178152825160009392849283928392918391908a617530fa92503d915060005190508280156126a4575060208210155b80156126b05750600081115b979650505050505050565b60606126ca848460008561274a565b949350505050565b8373ffffffffffffffffffffffffffffffffffffffff168573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167f7ff126db8024424bbfd9826e8ab82ff59136289ea440b04b39a0df1b03b9cabf86868660405161232393929190612e85565b6060824710156127dc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610214565b73ffffffffffffffffffffffffffffffffffffffff85163b61285a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610214565b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516128839190612f84565b60006040518083038185875af1925050503d80600081146128c0576040519150601f19603f3d011682016040523d82523d6000602084013e6128c5565b606091505b50915091506126b0828286606083156128df575081612198565b8251156128ef5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102149190612bf5565b73ffffffffffffffffffffffffffffffffffffffff8116811461294557600080fd5b50565b60008083601f84011261295a57600080fd5b50813567ffffffffffffffff81111561297257600080fd5b60208301915083602082850101111561298a57600080fd5b9250929050565b600080600080600080600060c0888a0312156129ac57600080fd5b87356129b781612923565b965060208801356129c781612923565b955060408801356129d781612923565b945060608801356129e781612923565b93506080880135925060a088013567ffffffffffffffff811115612a0a57600080fd5b612a168a828b01612948565b989b979a50959850939692959293505050565b803563ffffffff81168114612a3d57600080fd5b919050565b600080600060408486031215612a5757600080fd5b612a6084612a29565b9250602084013567ffffffffffffffff811115612a7c57600080fd5b612a8886828701612948565b9497909650939450505050565b600080600080600060808688031215612aad57600080fd5b8535612ab881612923565b94506020860135612ac881612923565b935060408601359250606086013567ffffffffffffffff811115612aeb57600080fd5b612af788828901612948565b969995985093965092949392505050565b600080600080600080600060c0888a031215612b2357600080fd5b8735612b2e81612923565b96506020880135612b3e81612923565b95506040880135612b4e81612923565b945060608801359350612b6360808901612a29565b925060a088013567ffffffffffffffff811115612a0a57600080fd5b60005b83811015612b9a578181015183820152602001612b82565b838111156105b25750506000910152565b60008151808452612bc3816020860160208601612b7f565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006121986020830184612bab565b60008060008060008060a08789031215612c2157600080fd5b8635612c2c81612923565b95506020870135612c3c81612923565b945060408701359350612c5160608801612a29565b9250608087013567ffffffffffffffff811115612c6d57600080fd5b612c7989828a01612948565b979a9699509497509295939492505050565b60008060408385031215612c9e57600080fd5b8235612ca981612923565b91506020830135612cb981612923565b809150509250929050565b60008060008060608587031215612cda57600080fd5b8435612ce581612923565b9350612cf360208601612a29565b9250604085013567ffffffffffffffff811115612d0f57600080fd5b612d1b87828801612948565b95989497509550505050565b600080600060608486031215612d3c57600080fd5b8335612d4781612923565b92506020840135612d5781612923565b91506040840135612d6781612923565b809150509250925092565b600060208284031215612d8457600080fd5b815161219881612923565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082821015612dd057612dd0612d8f565b500390565b600060208284031215612de757600080fd5b8151801515811461219857600080fd5b600073ffffffffffffffffffffffffffffffffffffffff808716835280861660208401525083604083015260806060830152612e366080830184612bab565b9695505050505050565b73ffffffffffffffffffffffffffffffffffffffff84168152606060208201526000612e6f6060830185612bab565b905063ffffffff83166040830152949350505050565b73ffffffffffffffffffffffffffffffffffffffff84168152826020820152606060408201526000612eba6060830184612bab565b95945050505050565b8281526040602082015260006126ca6040830184612bab565b60008219821115612eef57612eef612d8f565b500190565b600073ffffffffffffffffffffffffffffffffffffffff80891683528088166020840152808716604084015280861660608401525083608083015260c060a0830152612f4360c0830184612bab565b98975050505050505050565b60008060408385031215612f6257600080fd5b8251612f6d81612923565b602084015190925060ff81168114612cb957600080fd5b60008251612f96818460208701612b7f565b919091019291505056fea164736f6c634300080f000a", +} + +// L1StandardBridgeABI is the input ABI used to generate the binding from. +// Deprecated: Use L1StandardBridgeMetaData.ABI instead. +var L1StandardBridgeABI = L1StandardBridgeMetaData.ABI + +// L1StandardBridgeBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use L1StandardBridgeMetaData.Bin instead. +var L1StandardBridgeBin = L1StandardBridgeMetaData.Bin + +// DeployL1StandardBridge deploys a new Ethereum contract, binding an instance of L1StandardBridge to it. +func DeployL1StandardBridge(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *L1StandardBridge, error) { + parsed, err := L1StandardBridgeMetaData.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(L1StandardBridgeBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &L1StandardBridge{L1StandardBridgeCaller: L1StandardBridgeCaller{contract: contract}, L1StandardBridgeTransactor: L1StandardBridgeTransactor{contract: contract}, L1StandardBridgeFilterer: L1StandardBridgeFilterer{contract: contract}}, nil +} + +// L1StandardBridge is an auto generated Go binding around an Ethereum contract. +type L1StandardBridge struct { + L1StandardBridgeCaller // Read-only binding to the contract + L1StandardBridgeTransactor // Write-only binding to the contract + L1StandardBridgeFilterer // Log filterer for contract events +} + +// L1StandardBridgeCaller is an auto generated read-only Go binding around an Ethereum contract. +type L1StandardBridgeCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// L1StandardBridgeTransactor is an auto generated write-only Go binding around an Ethereum contract. +type L1StandardBridgeTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// L1StandardBridgeFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type L1StandardBridgeFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// L1StandardBridgeSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type L1StandardBridgeSession struct { + Contract *L1StandardBridge // 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 +} + +// L1StandardBridgeCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type L1StandardBridgeCallerSession struct { + Contract *L1StandardBridgeCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// L1StandardBridgeTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type L1StandardBridgeTransactorSession struct { + Contract *L1StandardBridgeTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// L1StandardBridgeRaw is an auto generated low-level Go binding around an Ethereum contract. +type L1StandardBridgeRaw struct { + Contract *L1StandardBridge // Generic contract binding to access the raw methods on +} + +// L1StandardBridgeCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type L1StandardBridgeCallerRaw struct { + Contract *L1StandardBridgeCaller // Generic read-only contract binding to access the raw methods on +} + +// L1StandardBridgeTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type L1StandardBridgeTransactorRaw struct { + Contract *L1StandardBridgeTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewL1StandardBridge creates a new instance of L1StandardBridge, bound to a specific deployed contract. +func NewL1StandardBridge(address common.Address, backend bind.ContractBackend) (*L1StandardBridge, error) { + contract, err := bindL1StandardBridge(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &L1StandardBridge{L1StandardBridgeCaller: L1StandardBridgeCaller{contract: contract}, L1StandardBridgeTransactor: L1StandardBridgeTransactor{contract: contract}, L1StandardBridgeFilterer: L1StandardBridgeFilterer{contract: contract}}, nil +} + +// NewL1StandardBridgeCaller creates a new read-only instance of L1StandardBridge, bound to a specific deployed contract. +func NewL1StandardBridgeCaller(address common.Address, caller bind.ContractCaller) (*L1StandardBridgeCaller, error) { + contract, err := bindL1StandardBridge(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &L1StandardBridgeCaller{contract: contract}, nil +} + +// NewL1StandardBridgeTransactor creates a new write-only instance of L1StandardBridge, bound to a specific deployed contract. +func NewL1StandardBridgeTransactor(address common.Address, transactor bind.ContractTransactor) (*L1StandardBridgeTransactor, error) { + contract, err := bindL1StandardBridge(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &L1StandardBridgeTransactor{contract: contract}, nil +} + +// NewL1StandardBridgeFilterer creates a new log filterer instance of L1StandardBridge, bound to a specific deployed contract. +func NewL1StandardBridgeFilterer(address common.Address, filterer bind.ContractFilterer) (*L1StandardBridgeFilterer, error) { + contract, err := bindL1StandardBridge(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &L1StandardBridgeFilterer{contract: contract}, nil +} + +// bindL1StandardBridge binds a generic wrapper to an already deployed contract. +func bindL1StandardBridge(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := L1StandardBridgeMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_L1StandardBridge *L1StandardBridgeRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _L1StandardBridge.Contract.L1StandardBridgeCaller.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 (_L1StandardBridge *L1StandardBridgeRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _L1StandardBridge.Contract.L1StandardBridgeTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_L1StandardBridge *L1StandardBridgeRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _L1StandardBridge.Contract.L1StandardBridgeTransactor.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 (_L1StandardBridge *L1StandardBridgeCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _L1StandardBridge.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 (_L1StandardBridge *L1StandardBridgeTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _L1StandardBridge.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_L1StandardBridge *L1StandardBridgeTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _L1StandardBridge.Contract.contract.Transact(opts, method, params...) +} + +// MESSENGER is a free data retrieval call binding the contract method 0x927ede2d. +// +// Solidity: function MESSENGER() view returns(address) +func (_L1StandardBridge *L1StandardBridgeCaller) MESSENGER(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _L1StandardBridge.contract.Call(opts, &out, "MESSENGER") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// MESSENGER is a free data retrieval call binding the contract method 0x927ede2d. +// +// Solidity: function MESSENGER() view returns(address) +func (_L1StandardBridge *L1StandardBridgeSession) MESSENGER() (common.Address, error) { + return _L1StandardBridge.Contract.MESSENGER(&_L1StandardBridge.CallOpts) +} + +// MESSENGER is a free data retrieval call binding the contract method 0x927ede2d. +// +// Solidity: function MESSENGER() view returns(address) +func (_L1StandardBridge *L1StandardBridgeCallerSession) MESSENGER() (common.Address, error) { + return _L1StandardBridge.Contract.MESSENGER(&_L1StandardBridge.CallOpts) +} + +// OTHERBRIDGE is a free data retrieval call binding the contract method 0x7f46ddb2. +// +// Solidity: function OTHER_BRIDGE() view returns(address) +func (_L1StandardBridge *L1StandardBridgeCaller) OTHERBRIDGE(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _L1StandardBridge.contract.Call(opts, &out, "OTHER_BRIDGE") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// OTHERBRIDGE is a free data retrieval call binding the contract method 0x7f46ddb2. +// +// Solidity: function OTHER_BRIDGE() view returns(address) +func (_L1StandardBridge *L1StandardBridgeSession) OTHERBRIDGE() (common.Address, error) { + return _L1StandardBridge.Contract.OTHERBRIDGE(&_L1StandardBridge.CallOpts) +} + +// OTHERBRIDGE is a free data retrieval call binding the contract method 0x7f46ddb2. +// +// Solidity: function OTHER_BRIDGE() view returns(address) +func (_L1StandardBridge *L1StandardBridgeCallerSession) OTHERBRIDGE() (common.Address, error) { + return _L1StandardBridge.Contract.OTHERBRIDGE(&_L1StandardBridge.CallOpts) +} + +// Deposits is a free data retrieval call binding the contract method 0x8f601f66. +// +// Solidity: function deposits(address , address ) view returns(uint256) +func (_L1StandardBridge *L1StandardBridgeCaller) Deposits(opts *bind.CallOpts, arg0 common.Address, arg1 common.Address) (*big.Int, error) { + var out []interface{} + err := _L1StandardBridge.contract.Call(opts, &out, "deposits", arg0, arg1) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// Deposits is a free data retrieval call binding the contract method 0x8f601f66. +// +// Solidity: function deposits(address , address ) view returns(uint256) +func (_L1StandardBridge *L1StandardBridgeSession) Deposits(arg0 common.Address, arg1 common.Address) (*big.Int, error) { + return _L1StandardBridge.Contract.Deposits(&_L1StandardBridge.CallOpts, arg0, arg1) +} + +// Deposits is a free data retrieval call binding the contract method 0x8f601f66. +// +// Solidity: function deposits(address , address ) view returns(uint256) +func (_L1StandardBridge *L1StandardBridgeCallerSession) Deposits(arg0 common.Address, arg1 common.Address) (*big.Int, error) { + return _L1StandardBridge.Contract.Deposits(&_L1StandardBridge.CallOpts, arg0, arg1) +} + +// L2TokenBridge is a free data retrieval call binding the contract method 0x91c49bf8. +// +// Solidity: function l2TokenBridge() view returns(address) +func (_L1StandardBridge *L1StandardBridgeCaller) L2TokenBridge(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _L1StandardBridge.contract.Call(opts, &out, "l2TokenBridge") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// L2TokenBridge is a free data retrieval call binding the contract method 0x91c49bf8. +// +// Solidity: function l2TokenBridge() view returns(address) +func (_L1StandardBridge *L1StandardBridgeSession) L2TokenBridge() (common.Address, error) { + return _L1StandardBridge.Contract.L2TokenBridge(&_L1StandardBridge.CallOpts) +} + +// L2TokenBridge is a free data retrieval call binding the contract method 0x91c49bf8. +// +// Solidity: function l2TokenBridge() view returns(address) +func (_L1StandardBridge *L1StandardBridgeCallerSession) L2TokenBridge() (common.Address, error) { + return _L1StandardBridge.Contract.L2TokenBridge(&_L1StandardBridge.CallOpts) +} + +// Messenger is a free data retrieval call binding the contract method 0x3cb747bf. +// +// Solidity: function messenger() view returns(address) +func (_L1StandardBridge *L1StandardBridgeCaller) Messenger(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _L1StandardBridge.contract.Call(opts, &out, "messenger") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Messenger is a free data retrieval call binding the contract method 0x3cb747bf. +// +// Solidity: function messenger() view returns(address) +func (_L1StandardBridge *L1StandardBridgeSession) Messenger() (common.Address, error) { + return _L1StandardBridge.Contract.Messenger(&_L1StandardBridge.CallOpts) +} + +// Messenger is a free data retrieval call binding the contract method 0x3cb747bf. +// +// Solidity: function messenger() view returns(address) +func (_L1StandardBridge *L1StandardBridgeCallerSession) Messenger() (common.Address, error) { + return _L1StandardBridge.Contract.Messenger(&_L1StandardBridge.CallOpts) +} + +// OtherBridge is a free data retrieval call binding the contract method 0xc89701a2. +// +// Solidity: function otherBridge() view returns(address) +func (_L1StandardBridge *L1StandardBridgeCaller) OtherBridge(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _L1StandardBridge.contract.Call(opts, &out, "otherBridge") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// OtherBridge is a free data retrieval call binding the contract method 0xc89701a2. +// +// Solidity: function otherBridge() view returns(address) +func (_L1StandardBridge *L1StandardBridgeSession) OtherBridge() (common.Address, error) { + return _L1StandardBridge.Contract.OtherBridge(&_L1StandardBridge.CallOpts) +} + +// OtherBridge is a free data retrieval call binding the contract method 0xc89701a2. +// +// Solidity: function otherBridge() view returns(address) +func (_L1StandardBridge *L1StandardBridgeCallerSession) OtherBridge() (common.Address, error) { + return _L1StandardBridge.Contract.OtherBridge(&_L1StandardBridge.CallOpts) +} + +// Paused is a free data retrieval call binding the contract method 0x5c975abb. +// +// Solidity: function paused() view returns(bool) +func (_L1StandardBridge *L1StandardBridgeCaller) Paused(opts *bind.CallOpts) (bool, error) { + var out []interface{} + err := _L1StandardBridge.contract.Call(opts, &out, "paused") + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// Paused is a free data retrieval call binding the contract method 0x5c975abb. +// +// Solidity: function paused() view returns(bool) +func (_L1StandardBridge *L1StandardBridgeSession) Paused() (bool, error) { + return _L1StandardBridge.Contract.Paused(&_L1StandardBridge.CallOpts) +} + +// Paused is a free data retrieval call binding the contract method 0x5c975abb. +// +// Solidity: function paused() view returns(bool) +func (_L1StandardBridge *L1StandardBridgeCallerSession) Paused() (bool, error) { + return _L1StandardBridge.Contract.Paused(&_L1StandardBridge.CallOpts) +} + +// SuperchainConfig is a free data retrieval call binding the contract method 0x35e80ab3. +// +// Solidity: function superchainConfig() view returns(address) +func (_L1StandardBridge *L1StandardBridgeCaller) SuperchainConfig(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _L1StandardBridge.contract.Call(opts, &out, "superchainConfig") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// SuperchainConfig is a free data retrieval call binding the contract method 0x35e80ab3. +// +// Solidity: function superchainConfig() view returns(address) +func (_L1StandardBridge *L1StandardBridgeSession) SuperchainConfig() (common.Address, error) { + return _L1StandardBridge.Contract.SuperchainConfig(&_L1StandardBridge.CallOpts) +} + +// SuperchainConfig is a free data retrieval call binding the contract method 0x35e80ab3. +// +// Solidity: function superchainConfig() view returns(address) +func (_L1StandardBridge *L1StandardBridgeCallerSession) SuperchainConfig() (common.Address, error) { + return _L1StandardBridge.Contract.SuperchainConfig(&_L1StandardBridge.CallOpts) +} + +// SystemConfig is a free data retrieval call binding the contract method 0x33d7e2bd. +// +// Solidity: function systemConfig() view returns(address) +func (_L1StandardBridge *L1StandardBridgeCaller) SystemConfig(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _L1StandardBridge.contract.Call(opts, &out, "systemConfig") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// SystemConfig is a free data retrieval call binding the contract method 0x33d7e2bd. +// +// Solidity: function systemConfig() view returns(address) +func (_L1StandardBridge *L1StandardBridgeSession) SystemConfig() (common.Address, error) { + return _L1StandardBridge.Contract.SystemConfig(&_L1StandardBridge.CallOpts) +} + +// SystemConfig is a free data retrieval call binding the contract method 0x33d7e2bd. +// +// Solidity: function systemConfig() view returns(address) +func (_L1StandardBridge *L1StandardBridgeCallerSession) SystemConfig() (common.Address, error) { + return _L1StandardBridge.Contract.SystemConfig(&_L1StandardBridge.CallOpts) +} + +// Version is a free data retrieval call binding the contract method 0x54fd4d50. +// +// Solidity: function version() view returns(string) +func (_L1StandardBridge *L1StandardBridgeCaller) Version(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _L1StandardBridge.contract.Call(opts, &out, "version") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +// Version is a free data retrieval call binding the contract method 0x54fd4d50. +// +// Solidity: function version() view returns(string) +func (_L1StandardBridge *L1StandardBridgeSession) Version() (string, error) { + return _L1StandardBridge.Contract.Version(&_L1StandardBridge.CallOpts) +} + +// Version is a free data retrieval call binding the contract method 0x54fd4d50. +// +// Solidity: function version() view returns(string) +func (_L1StandardBridge *L1StandardBridgeCallerSession) Version() (string, error) { + return _L1StandardBridge.Contract.Version(&_L1StandardBridge.CallOpts) +} + +// BridgeERC20 is a paid mutator transaction binding the contract method 0x87087623. +// +// Solidity: function bridgeERC20(address _localToken, address _remoteToken, uint256 _amount, uint32 _minGasLimit, bytes _extraData) returns() +func (_L1StandardBridge *L1StandardBridgeTransactor) BridgeERC20(opts *bind.TransactOpts, _localToken common.Address, _remoteToken common.Address, _amount *big.Int, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.contract.Transact(opts, "bridgeERC20", _localToken, _remoteToken, _amount, _minGasLimit, _extraData) +} + +// BridgeERC20 is a paid mutator transaction binding the contract method 0x87087623. +// +// Solidity: function bridgeERC20(address _localToken, address _remoteToken, uint256 _amount, uint32 _minGasLimit, bytes _extraData) returns() +func (_L1StandardBridge *L1StandardBridgeSession) BridgeERC20(_localToken common.Address, _remoteToken common.Address, _amount *big.Int, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.BridgeERC20(&_L1StandardBridge.TransactOpts, _localToken, _remoteToken, _amount, _minGasLimit, _extraData) +} + +// BridgeERC20 is a paid mutator transaction binding the contract method 0x87087623. +// +// Solidity: function bridgeERC20(address _localToken, address _remoteToken, uint256 _amount, uint32 _minGasLimit, bytes _extraData) returns() +func (_L1StandardBridge *L1StandardBridgeTransactorSession) BridgeERC20(_localToken common.Address, _remoteToken common.Address, _amount *big.Int, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.BridgeERC20(&_L1StandardBridge.TransactOpts, _localToken, _remoteToken, _amount, _minGasLimit, _extraData) +} + +// BridgeERC20To is a paid mutator transaction binding the contract method 0x540abf73. +// +// Solidity: function bridgeERC20To(address _localToken, address _remoteToken, address _to, uint256 _amount, uint32 _minGasLimit, bytes _extraData) returns() +func (_L1StandardBridge *L1StandardBridgeTransactor) BridgeERC20To(opts *bind.TransactOpts, _localToken common.Address, _remoteToken common.Address, _to common.Address, _amount *big.Int, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.contract.Transact(opts, "bridgeERC20To", _localToken, _remoteToken, _to, _amount, _minGasLimit, _extraData) +} + +// BridgeERC20To is a paid mutator transaction binding the contract method 0x540abf73. +// +// Solidity: function bridgeERC20To(address _localToken, address _remoteToken, address _to, uint256 _amount, uint32 _minGasLimit, bytes _extraData) returns() +func (_L1StandardBridge *L1StandardBridgeSession) BridgeERC20To(_localToken common.Address, _remoteToken common.Address, _to common.Address, _amount *big.Int, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.BridgeERC20To(&_L1StandardBridge.TransactOpts, _localToken, _remoteToken, _to, _amount, _minGasLimit, _extraData) +} + +// BridgeERC20To is a paid mutator transaction binding the contract method 0x540abf73. +// +// Solidity: function bridgeERC20To(address _localToken, address _remoteToken, address _to, uint256 _amount, uint32 _minGasLimit, bytes _extraData) returns() +func (_L1StandardBridge *L1StandardBridgeTransactorSession) BridgeERC20To(_localToken common.Address, _remoteToken common.Address, _to common.Address, _amount *big.Int, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.BridgeERC20To(&_L1StandardBridge.TransactOpts, _localToken, _remoteToken, _to, _amount, _minGasLimit, _extraData) +} + +// BridgeETH is a paid mutator transaction binding the contract method 0x09fc8843. +// +// Solidity: function bridgeETH(uint32 _minGasLimit, bytes _extraData) payable returns() +func (_L1StandardBridge *L1StandardBridgeTransactor) BridgeETH(opts *bind.TransactOpts, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.contract.Transact(opts, "bridgeETH", _minGasLimit, _extraData) +} + +// BridgeETH is a paid mutator transaction binding the contract method 0x09fc8843. +// +// Solidity: function bridgeETH(uint32 _minGasLimit, bytes _extraData) payable returns() +func (_L1StandardBridge *L1StandardBridgeSession) BridgeETH(_minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.BridgeETH(&_L1StandardBridge.TransactOpts, _minGasLimit, _extraData) +} + +// BridgeETH is a paid mutator transaction binding the contract method 0x09fc8843. +// +// Solidity: function bridgeETH(uint32 _minGasLimit, bytes _extraData) payable returns() +func (_L1StandardBridge *L1StandardBridgeTransactorSession) BridgeETH(_minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.BridgeETH(&_L1StandardBridge.TransactOpts, _minGasLimit, _extraData) +} + +// BridgeETHTo is a paid mutator transaction binding the contract method 0xe11013dd. +// +// Solidity: function bridgeETHTo(address _to, uint32 _minGasLimit, bytes _extraData) payable returns() +func (_L1StandardBridge *L1StandardBridgeTransactor) BridgeETHTo(opts *bind.TransactOpts, _to common.Address, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.contract.Transact(opts, "bridgeETHTo", _to, _minGasLimit, _extraData) +} + +// BridgeETHTo is a paid mutator transaction binding the contract method 0xe11013dd. +// +// Solidity: function bridgeETHTo(address _to, uint32 _minGasLimit, bytes _extraData) payable returns() +func (_L1StandardBridge *L1StandardBridgeSession) BridgeETHTo(_to common.Address, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.BridgeETHTo(&_L1StandardBridge.TransactOpts, _to, _minGasLimit, _extraData) +} + +// BridgeETHTo is a paid mutator transaction binding the contract method 0xe11013dd. +// +// Solidity: function bridgeETHTo(address _to, uint32 _minGasLimit, bytes _extraData) payable returns() +func (_L1StandardBridge *L1StandardBridgeTransactorSession) BridgeETHTo(_to common.Address, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.BridgeETHTo(&_L1StandardBridge.TransactOpts, _to, _minGasLimit, _extraData) +} + +// DepositERC20 is a paid mutator transaction binding the contract method 0x58a997f6. +// +// Solidity: function depositERC20(address _l1Token, address _l2Token, uint256 _amount, uint32 _minGasLimit, bytes _extraData) returns() +func (_L1StandardBridge *L1StandardBridgeTransactor) DepositERC20(opts *bind.TransactOpts, _l1Token common.Address, _l2Token common.Address, _amount *big.Int, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.contract.Transact(opts, "depositERC20", _l1Token, _l2Token, _amount, _minGasLimit, _extraData) +} + +// DepositERC20 is a paid mutator transaction binding the contract method 0x58a997f6. +// +// Solidity: function depositERC20(address _l1Token, address _l2Token, uint256 _amount, uint32 _minGasLimit, bytes _extraData) returns() +func (_L1StandardBridge *L1StandardBridgeSession) DepositERC20(_l1Token common.Address, _l2Token common.Address, _amount *big.Int, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.DepositERC20(&_L1StandardBridge.TransactOpts, _l1Token, _l2Token, _amount, _minGasLimit, _extraData) +} + +// DepositERC20 is a paid mutator transaction binding the contract method 0x58a997f6. +// +// Solidity: function depositERC20(address _l1Token, address _l2Token, uint256 _amount, uint32 _minGasLimit, bytes _extraData) returns() +func (_L1StandardBridge *L1StandardBridgeTransactorSession) DepositERC20(_l1Token common.Address, _l2Token common.Address, _amount *big.Int, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.DepositERC20(&_L1StandardBridge.TransactOpts, _l1Token, _l2Token, _amount, _minGasLimit, _extraData) +} + +// DepositERC20To is a paid mutator transaction binding the contract method 0x838b2520. +// +// Solidity: function depositERC20To(address _l1Token, address _l2Token, address _to, uint256 _amount, uint32 _minGasLimit, bytes _extraData) returns() +func (_L1StandardBridge *L1StandardBridgeTransactor) DepositERC20To(opts *bind.TransactOpts, _l1Token common.Address, _l2Token common.Address, _to common.Address, _amount *big.Int, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.contract.Transact(opts, "depositERC20To", _l1Token, _l2Token, _to, _amount, _minGasLimit, _extraData) +} + +// DepositERC20To is a paid mutator transaction binding the contract method 0x838b2520. +// +// Solidity: function depositERC20To(address _l1Token, address _l2Token, address _to, uint256 _amount, uint32 _minGasLimit, bytes _extraData) returns() +func (_L1StandardBridge *L1StandardBridgeSession) DepositERC20To(_l1Token common.Address, _l2Token common.Address, _to common.Address, _amount *big.Int, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.DepositERC20To(&_L1StandardBridge.TransactOpts, _l1Token, _l2Token, _to, _amount, _minGasLimit, _extraData) +} + +// DepositERC20To is a paid mutator transaction binding the contract method 0x838b2520. +// +// Solidity: function depositERC20To(address _l1Token, address _l2Token, address _to, uint256 _amount, uint32 _minGasLimit, bytes _extraData) returns() +func (_L1StandardBridge *L1StandardBridgeTransactorSession) DepositERC20To(_l1Token common.Address, _l2Token common.Address, _to common.Address, _amount *big.Int, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.DepositERC20To(&_L1StandardBridge.TransactOpts, _l1Token, _l2Token, _to, _amount, _minGasLimit, _extraData) +} + +// DepositETH is a paid mutator transaction binding the contract method 0xb1a1a882. +// +// Solidity: function depositETH(uint32 _minGasLimit, bytes _extraData) payable returns() +func (_L1StandardBridge *L1StandardBridgeTransactor) DepositETH(opts *bind.TransactOpts, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.contract.Transact(opts, "depositETH", _minGasLimit, _extraData) +} + +// DepositETH is a paid mutator transaction binding the contract method 0xb1a1a882. +// +// Solidity: function depositETH(uint32 _minGasLimit, bytes _extraData) payable returns() +func (_L1StandardBridge *L1StandardBridgeSession) DepositETH(_minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.DepositETH(&_L1StandardBridge.TransactOpts, _minGasLimit, _extraData) +} + +// DepositETH is a paid mutator transaction binding the contract method 0xb1a1a882. +// +// Solidity: function depositETH(uint32 _minGasLimit, bytes _extraData) payable returns() +func (_L1StandardBridge *L1StandardBridgeTransactorSession) DepositETH(_minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.DepositETH(&_L1StandardBridge.TransactOpts, _minGasLimit, _extraData) +} + +// DepositETHTo is a paid mutator transaction binding the contract method 0x9a2ac6d5. +// +// Solidity: function depositETHTo(address _to, uint32 _minGasLimit, bytes _extraData) payable returns() +func (_L1StandardBridge *L1StandardBridgeTransactor) DepositETHTo(opts *bind.TransactOpts, _to common.Address, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.contract.Transact(opts, "depositETHTo", _to, _minGasLimit, _extraData) +} + +// DepositETHTo is a paid mutator transaction binding the contract method 0x9a2ac6d5. +// +// Solidity: function depositETHTo(address _to, uint32 _minGasLimit, bytes _extraData) payable returns() +func (_L1StandardBridge *L1StandardBridgeSession) DepositETHTo(_to common.Address, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.DepositETHTo(&_L1StandardBridge.TransactOpts, _to, _minGasLimit, _extraData) +} + +// DepositETHTo is a paid mutator transaction binding the contract method 0x9a2ac6d5. +// +// Solidity: function depositETHTo(address _to, uint32 _minGasLimit, bytes _extraData) payable returns() +func (_L1StandardBridge *L1StandardBridgeTransactorSession) DepositETHTo(_to common.Address, _minGasLimit uint32, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.DepositETHTo(&_L1StandardBridge.TransactOpts, _to, _minGasLimit, _extraData) +} + +// FinalizeBridgeERC20 is a paid mutator transaction binding the contract method 0x0166a07a. +// +// Solidity: function finalizeBridgeERC20(address _localToken, address _remoteToken, address _from, address _to, uint256 _amount, bytes _extraData) returns() +func (_L1StandardBridge *L1StandardBridgeTransactor) FinalizeBridgeERC20(opts *bind.TransactOpts, _localToken common.Address, _remoteToken common.Address, _from common.Address, _to common.Address, _amount *big.Int, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.contract.Transact(opts, "finalizeBridgeERC20", _localToken, _remoteToken, _from, _to, _amount, _extraData) +} + +// FinalizeBridgeERC20 is a paid mutator transaction binding the contract method 0x0166a07a. +// +// Solidity: function finalizeBridgeERC20(address _localToken, address _remoteToken, address _from, address _to, uint256 _amount, bytes _extraData) returns() +func (_L1StandardBridge *L1StandardBridgeSession) FinalizeBridgeERC20(_localToken common.Address, _remoteToken common.Address, _from common.Address, _to common.Address, _amount *big.Int, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.FinalizeBridgeERC20(&_L1StandardBridge.TransactOpts, _localToken, _remoteToken, _from, _to, _amount, _extraData) +} + +// FinalizeBridgeERC20 is a paid mutator transaction binding the contract method 0x0166a07a. +// +// Solidity: function finalizeBridgeERC20(address _localToken, address _remoteToken, address _from, address _to, uint256 _amount, bytes _extraData) returns() +func (_L1StandardBridge *L1StandardBridgeTransactorSession) FinalizeBridgeERC20(_localToken common.Address, _remoteToken common.Address, _from common.Address, _to common.Address, _amount *big.Int, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.FinalizeBridgeERC20(&_L1StandardBridge.TransactOpts, _localToken, _remoteToken, _from, _to, _amount, _extraData) +} + +// FinalizeBridgeETH is a paid mutator transaction binding the contract method 0x1635f5fd. +// +// Solidity: function finalizeBridgeETH(address _from, address _to, uint256 _amount, bytes _extraData) payable returns() +func (_L1StandardBridge *L1StandardBridgeTransactor) FinalizeBridgeETH(opts *bind.TransactOpts, _from common.Address, _to common.Address, _amount *big.Int, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.contract.Transact(opts, "finalizeBridgeETH", _from, _to, _amount, _extraData) +} + +// FinalizeBridgeETH is a paid mutator transaction binding the contract method 0x1635f5fd. +// +// Solidity: function finalizeBridgeETH(address _from, address _to, uint256 _amount, bytes _extraData) payable returns() +func (_L1StandardBridge *L1StandardBridgeSession) FinalizeBridgeETH(_from common.Address, _to common.Address, _amount *big.Int, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.FinalizeBridgeETH(&_L1StandardBridge.TransactOpts, _from, _to, _amount, _extraData) +} + +// FinalizeBridgeETH is a paid mutator transaction binding the contract method 0x1635f5fd. +// +// Solidity: function finalizeBridgeETH(address _from, address _to, uint256 _amount, bytes _extraData) payable returns() +func (_L1StandardBridge *L1StandardBridgeTransactorSession) FinalizeBridgeETH(_from common.Address, _to common.Address, _amount *big.Int, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.FinalizeBridgeETH(&_L1StandardBridge.TransactOpts, _from, _to, _amount, _extraData) +} + +// FinalizeERC20Withdrawal is a paid mutator transaction binding the contract method 0xa9f9e675. +// +// Solidity: function finalizeERC20Withdrawal(address _l1Token, address _l2Token, address _from, address _to, uint256 _amount, bytes _extraData) returns() +func (_L1StandardBridge *L1StandardBridgeTransactor) FinalizeERC20Withdrawal(opts *bind.TransactOpts, _l1Token common.Address, _l2Token common.Address, _from common.Address, _to common.Address, _amount *big.Int, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.contract.Transact(opts, "finalizeERC20Withdrawal", _l1Token, _l2Token, _from, _to, _amount, _extraData) +} + +// FinalizeERC20Withdrawal is a paid mutator transaction binding the contract method 0xa9f9e675. +// +// Solidity: function finalizeERC20Withdrawal(address _l1Token, address _l2Token, address _from, address _to, uint256 _amount, bytes _extraData) returns() +func (_L1StandardBridge *L1StandardBridgeSession) FinalizeERC20Withdrawal(_l1Token common.Address, _l2Token common.Address, _from common.Address, _to common.Address, _amount *big.Int, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.FinalizeERC20Withdrawal(&_L1StandardBridge.TransactOpts, _l1Token, _l2Token, _from, _to, _amount, _extraData) +} + +// FinalizeERC20Withdrawal is a paid mutator transaction binding the contract method 0xa9f9e675. +// +// Solidity: function finalizeERC20Withdrawal(address _l1Token, address _l2Token, address _from, address _to, uint256 _amount, bytes _extraData) returns() +func (_L1StandardBridge *L1StandardBridgeTransactorSession) FinalizeERC20Withdrawal(_l1Token common.Address, _l2Token common.Address, _from common.Address, _to common.Address, _amount *big.Int, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.FinalizeERC20Withdrawal(&_L1StandardBridge.TransactOpts, _l1Token, _l2Token, _from, _to, _amount, _extraData) +} + +// FinalizeETHWithdrawal is a paid mutator transaction binding the contract method 0x1532ec34. +// +// Solidity: function finalizeETHWithdrawal(address _from, address _to, uint256 _amount, bytes _extraData) payable returns() +func (_L1StandardBridge *L1StandardBridgeTransactor) FinalizeETHWithdrawal(opts *bind.TransactOpts, _from common.Address, _to common.Address, _amount *big.Int, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.contract.Transact(opts, "finalizeETHWithdrawal", _from, _to, _amount, _extraData) +} + +// FinalizeETHWithdrawal is a paid mutator transaction binding the contract method 0x1532ec34. +// +// Solidity: function finalizeETHWithdrawal(address _from, address _to, uint256 _amount, bytes _extraData) payable returns() +func (_L1StandardBridge *L1StandardBridgeSession) FinalizeETHWithdrawal(_from common.Address, _to common.Address, _amount *big.Int, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.FinalizeETHWithdrawal(&_L1StandardBridge.TransactOpts, _from, _to, _amount, _extraData) +} + +// FinalizeETHWithdrawal is a paid mutator transaction binding the contract method 0x1532ec34. +// +// Solidity: function finalizeETHWithdrawal(address _from, address _to, uint256 _amount, bytes _extraData) payable returns() +func (_L1StandardBridge *L1StandardBridgeTransactorSession) FinalizeETHWithdrawal(_from common.Address, _to common.Address, _amount *big.Int, _extraData []byte) (*types.Transaction, error) { + return _L1StandardBridge.Contract.FinalizeETHWithdrawal(&_L1StandardBridge.TransactOpts, _from, _to, _amount, _extraData) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc0c53b8b. +// +// Solidity: function initialize(address _messenger, address _superchainConfig, address _systemConfig) returns() +func (_L1StandardBridge *L1StandardBridgeTransactor) Initialize(opts *bind.TransactOpts, _messenger common.Address, _superchainConfig common.Address, _systemConfig common.Address) (*types.Transaction, error) { + return _L1StandardBridge.contract.Transact(opts, "initialize", _messenger, _superchainConfig, _systemConfig) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc0c53b8b. +// +// Solidity: function initialize(address _messenger, address _superchainConfig, address _systemConfig) returns() +func (_L1StandardBridge *L1StandardBridgeSession) Initialize(_messenger common.Address, _superchainConfig common.Address, _systemConfig common.Address) (*types.Transaction, error) { + return _L1StandardBridge.Contract.Initialize(&_L1StandardBridge.TransactOpts, _messenger, _superchainConfig, _systemConfig) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc0c53b8b. +// +// Solidity: function initialize(address _messenger, address _superchainConfig, address _systemConfig) returns() +func (_L1StandardBridge *L1StandardBridgeTransactorSession) Initialize(_messenger common.Address, _superchainConfig common.Address, _systemConfig common.Address) (*types.Transaction, error) { + return _L1StandardBridge.Contract.Initialize(&_L1StandardBridge.TransactOpts, _messenger, _superchainConfig, _systemConfig) +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_L1StandardBridge *L1StandardBridgeTransactor) Receive(opts *bind.TransactOpts) (*types.Transaction, error) { + return _L1StandardBridge.contract.RawTransact(opts, nil) // calldata is disallowed for receive function +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_L1StandardBridge *L1StandardBridgeSession) Receive() (*types.Transaction, error) { + return _L1StandardBridge.Contract.Receive(&_L1StandardBridge.TransactOpts) +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_L1StandardBridge *L1StandardBridgeTransactorSession) Receive() (*types.Transaction, error) { + return _L1StandardBridge.Contract.Receive(&_L1StandardBridge.TransactOpts) +} + +// L1StandardBridgeERC20BridgeFinalizedIterator is returned from FilterERC20BridgeFinalized and is used to iterate over the raw logs and unpacked data for ERC20BridgeFinalized events raised by the L1StandardBridge contract. +type L1StandardBridgeERC20BridgeFinalizedIterator struct { + Event *L1StandardBridgeERC20BridgeFinalized // 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 *L1StandardBridgeERC20BridgeFinalizedIterator) 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(L1StandardBridgeERC20BridgeFinalized) + 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(L1StandardBridgeERC20BridgeFinalized) + 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 *L1StandardBridgeERC20BridgeFinalizedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *L1StandardBridgeERC20BridgeFinalizedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// L1StandardBridgeERC20BridgeFinalized represents a ERC20BridgeFinalized event raised by the L1StandardBridge contract. +type L1StandardBridgeERC20BridgeFinalized struct { + LocalToken common.Address + RemoteToken common.Address + From common.Address + To common.Address + Amount *big.Int + ExtraData []byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterERC20BridgeFinalized is a free log retrieval operation binding the contract event 0xd59c65b35445225835c83f50b6ede06a7be047d22e357073e250d9af537518cd. +// +// Solidity: event ERC20BridgeFinalized(address indexed localToken, address indexed remoteToken, address indexed from, address to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) FilterERC20BridgeFinalized(opts *bind.FilterOpts, localToken []common.Address, remoteToken []common.Address, from []common.Address) (*L1StandardBridgeERC20BridgeFinalizedIterator, error) { + + var localTokenRule []interface{} + for _, localTokenItem := range localToken { + localTokenRule = append(localTokenRule, localTokenItem) + } + var remoteTokenRule []interface{} + for _, remoteTokenItem := range remoteToken { + remoteTokenRule = append(remoteTokenRule, remoteTokenItem) + } + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + + logs, sub, err := _L1StandardBridge.contract.FilterLogs(opts, "ERC20BridgeFinalized", localTokenRule, remoteTokenRule, fromRule) + if err != nil { + return nil, err + } + return &L1StandardBridgeERC20BridgeFinalizedIterator{contract: _L1StandardBridge.contract, event: "ERC20BridgeFinalized", logs: logs, sub: sub}, nil +} + +// WatchERC20BridgeFinalized is a free log subscription operation binding the contract event 0xd59c65b35445225835c83f50b6ede06a7be047d22e357073e250d9af537518cd. +// +// Solidity: event ERC20BridgeFinalized(address indexed localToken, address indexed remoteToken, address indexed from, address to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) WatchERC20BridgeFinalized(opts *bind.WatchOpts, sink chan<- *L1StandardBridgeERC20BridgeFinalized, localToken []common.Address, remoteToken []common.Address, from []common.Address) (event.Subscription, error) { + + var localTokenRule []interface{} + for _, localTokenItem := range localToken { + localTokenRule = append(localTokenRule, localTokenItem) + } + var remoteTokenRule []interface{} + for _, remoteTokenItem := range remoteToken { + remoteTokenRule = append(remoteTokenRule, remoteTokenItem) + } + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + + logs, sub, err := _L1StandardBridge.contract.WatchLogs(opts, "ERC20BridgeFinalized", localTokenRule, remoteTokenRule, fromRule) + 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(L1StandardBridgeERC20BridgeFinalized) + if err := _L1StandardBridge.contract.UnpackLog(event, "ERC20BridgeFinalized", 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 +} + +// ParseERC20BridgeFinalized is a log parse operation binding the contract event 0xd59c65b35445225835c83f50b6ede06a7be047d22e357073e250d9af537518cd. +// +// Solidity: event ERC20BridgeFinalized(address indexed localToken, address indexed remoteToken, address indexed from, address to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) ParseERC20BridgeFinalized(log types.Log) (*L1StandardBridgeERC20BridgeFinalized, error) { + event := new(L1StandardBridgeERC20BridgeFinalized) + if err := _L1StandardBridge.contract.UnpackLog(event, "ERC20BridgeFinalized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// L1StandardBridgeERC20BridgeInitiatedIterator is returned from FilterERC20BridgeInitiated and is used to iterate over the raw logs and unpacked data for ERC20BridgeInitiated events raised by the L1StandardBridge contract. +type L1StandardBridgeERC20BridgeInitiatedIterator struct { + Event *L1StandardBridgeERC20BridgeInitiated // 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 *L1StandardBridgeERC20BridgeInitiatedIterator) 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(L1StandardBridgeERC20BridgeInitiated) + 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(L1StandardBridgeERC20BridgeInitiated) + 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 *L1StandardBridgeERC20BridgeInitiatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *L1StandardBridgeERC20BridgeInitiatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// L1StandardBridgeERC20BridgeInitiated represents a ERC20BridgeInitiated event raised by the L1StandardBridge contract. +type L1StandardBridgeERC20BridgeInitiated struct { + LocalToken common.Address + RemoteToken common.Address + From common.Address + To common.Address + Amount *big.Int + ExtraData []byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterERC20BridgeInitiated is a free log retrieval operation binding the contract event 0x7ff126db8024424bbfd9826e8ab82ff59136289ea440b04b39a0df1b03b9cabf. +// +// Solidity: event ERC20BridgeInitiated(address indexed localToken, address indexed remoteToken, address indexed from, address to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) FilterERC20BridgeInitiated(opts *bind.FilterOpts, localToken []common.Address, remoteToken []common.Address, from []common.Address) (*L1StandardBridgeERC20BridgeInitiatedIterator, error) { + + var localTokenRule []interface{} + for _, localTokenItem := range localToken { + localTokenRule = append(localTokenRule, localTokenItem) + } + var remoteTokenRule []interface{} + for _, remoteTokenItem := range remoteToken { + remoteTokenRule = append(remoteTokenRule, remoteTokenItem) + } + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + + logs, sub, err := _L1StandardBridge.contract.FilterLogs(opts, "ERC20BridgeInitiated", localTokenRule, remoteTokenRule, fromRule) + if err != nil { + return nil, err + } + return &L1StandardBridgeERC20BridgeInitiatedIterator{contract: _L1StandardBridge.contract, event: "ERC20BridgeInitiated", logs: logs, sub: sub}, nil +} + +// WatchERC20BridgeInitiated is a free log subscription operation binding the contract event 0x7ff126db8024424bbfd9826e8ab82ff59136289ea440b04b39a0df1b03b9cabf. +// +// Solidity: event ERC20BridgeInitiated(address indexed localToken, address indexed remoteToken, address indexed from, address to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) WatchERC20BridgeInitiated(opts *bind.WatchOpts, sink chan<- *L1StandardBridgeERC20BridgeInitiated, localToken []common.Address, remoteToken []common.Address, from []common.Address) (event.Subscription, error) { + + var localTokenRule []interface{} + for _, localTokenItem := range localToken { + localTokenRule = append(localTokenRule, localTokenItem) + } + var remoteTokenRule []interface{} + for _, remoteTokenItem := range remoteToken { + remoteTokenRule = append(remoteTokenRule, remoteTokenItem) + } + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + + logs, sub, err := _L1StandardBridge.contract.WatchLogs(opts, "ERC20BridgeInitiated", localTokenRule, remoteTokenRule, fromRule) + 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(L1StandardBridgeERC20BridgeInitiated) + if err := _L1StandardBridge.contract.UnpackLog(event, "ERC20BridgeInitiated", 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 +} + +// ParseERC20BridgeInitiated is a log parse operation binding the contract event 0x7ff126db8024424bbfd9826e8ab82ff59136289ea440b04b39a0df1b03b9cabf. +// +// Solidity: event ERC20BridgeInitiated(address indexed localToken, address indexed remoteToken, address indexed from, address to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) ParseERC20BridgeInitiated(log types.Log) (*L1StandardBridgeERC20BridgeInitiated, error) { + event := new(L1StandardBridgeERC20BridgeInitiated) + if err := _L1StandardBridge.contract.UnpackLog(event, "ERC20BridgeInitiated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// L1StandardBridgeERC20DepositInitiatedIterator is returned from FilterERC20DepositInitiated and is used to iterate over the raw logs and unpacked data for ERC20DepositInitiated events raised by the L1StandardBridge contract. +type L1StandardBridgeERC20DepositInitiatedIterator struct { + Event *L1StandardBridgeERC20DepositInitiated // 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 *L1StandardBridgeERC20DepositInitiatedIterator) 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(L1StandardBridgeERC20DepositInitiated) + 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(L1StandardBridgeERC20DepositInitiated) + 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 *L1StandardBridgeERC20DepositInitiatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *L1StandardBridgeERC20DepositInitiatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// L1StandardBridgeERC20DepositInitiated represents a ERC20DepositInitiated event raised by the L1StandardBridge contract. +type L1StandardBridgeERC20DepositInitiated struct { + L1Token common.Address + L2Token common.Address + From common.Address + To common.Address + Amount *big.Int + ExtraData []byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterERC20DepositInitiated is a free log retrieval operation binding the contract event 0x718594027abd4eaed59f95162563e0cc6d0e8d5b86b1c7be8b1b0ac3343d0396. +// +// Solidity: event ERC20DepositInitiated(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) FilterERC20DepositInitiated(opts *bind.FilterOpts, l1Token []common.Address, l2Token []common.Address, from []common.Address) (*L1StandardBridgeERC20DepositInitiatedIterator, error) { + + var l1TokenRule []interface{} + for _, l1TokenItem := range l1Token { + l1TokenRule = append(l1TokenRule, l1TokenItem) + } + var l2TokenRule []interface{} + for _, l2TokenItem := range l2Token { + l2TokenRule = append(l2TokenRule, l2TokenItem) + } + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + + logs, sub, err := _L1StandardBridge.contract.FilterLogs(opts, "ERC20DepositInitiated", l1TokenRule, l2TokenRule, fromRule) + if err != nil { + return nil, err + } + return &L1StandardBridgeERC20DepositInitiatedIterator{contract: _L1StandardBridge.contract, event: "ERC20DepositInitiated", logs: logs, sub: sub}, nil +} + +// WatchERC20DepositInitiated is a free log subscription operation binding the contract event 0x718594027abd4eaed59f95162563e0cc6d0e8d5b86b1c7be8b1b0ac3343d0396. +// +// Solidity: event ERC20DepositInitiated(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) WatchERC20DepositInitiated(opts *bind.WatchOpts, sink chan<- *L1StandardBridgeERC20DepositInitiated, l1Token []common.Address, l2Token []common.Address, from []common.Address) (event.Subscription, error) { + + var l1TokenRule []interface{} + for _, l1TokenItem := range l1Token { + l1TokenRule = append(l1TokenRule, l1TokenItem) + } + var l2TokenRule []interface{} + for _, l2TokenItem := range l2Token { + l2TokenRule = append(l2TokenRule, l2TokenItem) + } + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + + logs, sub, err := _L1StandardBridge.contract.WatchLogs(opts, "ERC20DepositInitiated", l1TokenRule, l2TokenRule, fromRule) + 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(L1StandardBridgeERC20DepositInitiated) + if err := _L1StandardBridge.contract.UnpackLog(event, "ERC20DepositInitiated", 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 +} + +// ParseERC20DepositInitiated is a log parse operation binding the contract event 0x718594027abd4eaed59f95162563e0cc6d0e8d5b86b1c7be8b1b0ac3343d0396. +// +// Solidity: event ERC20DepositInitiated(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) ParseERC20DepositInitiated(log types.Log) (*L1StandardBridgeERC20DepositInitiated, error) { + event := new(L1StandardBridgeERC20DepositInitiated) + if err := _L1StandardBridge.contract.UnpackLog(event, "ERC20DepositInitiated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// L1StandardBridgeERC20WithdrawalFinalizedIterator is returned from FilterERC20WithdrawalFinalized and is used to iterate over the raw logs and unpacked data for ERC20WithdrawalFinalized events raised by the L1StandardBridge contract. +type L1StandardBridgeERC20WithdrawalFinalizedIterator struct { + Event *L1StandardBridgeERC20WithdrawalFinalized // 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 *L1StandardBridgeERC20WithdrawalFinalizedIterator) 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(L1StandardBridgeERC20WithdrawalFinalized) + 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(L1StandardBridgeERC20WithdrawalFinalized) + 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 *L1StandardBridgeERC20WithdrawalFinalizedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *L1StandardBridgeERC20WithdrawalFinalizedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// L1StandardBridgeERC20WithdrawalFinalized represents a ERC20WithdrawalFinalized event raised by the L1StandardBridge contract. +type L1StandardBridgeERC20WithdrawalFinalized struct { + L1Token common.Address + L2Token common.Address + From common.Address + To common.Address + Amount *big.Int + ExtraData []byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterERC20WithdrawalFinalized is a free log retrieval operation binding the contract event 0x3ceee06c1e37648fcbb6ed52e17b3e1f275a1f8c7b22a84b2b84732431e046b3. +// +// Solidity: event ERC20WithdrawalFinalized(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) FilterERC20WithdrawalFinalized(opts *bind.FilterOpts, l1Token []common.Address, l2Token []common.Address, from []common.Address) (*L1StandardBridgeERC20WithdrawalFinalizedIterator, error) { + + var l1TokenRule []interface{} + for _, l1TokenItem := range l1Token { + l1TokenRule = append(l1TokenRule, l1TokenItem) + } + var l2TokenRule []interface{} + for _, l2TokenItem := range l2Token { + l2TokenRule = append(l2TokenRule, l2TokenItem) + } + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + + logs, sub, err := _L1StandardBridge.contract.FilterLogs(opts, "ERC20WithdrawalFinalized", l1TokenRule, l2TokenRule, fromRule) + if err != nil { + return nil, err + } + return &L1StandardBridgeERC20WithdrawalFinalizedIterator{contract: _L1StandardBridge.contract, event: "ERC20WithdrawalFinalized", logs: logs, sub: sub}, nil +} + +// WatchERC20WithdrawalFinalized is a free log subscription operation binding the contract event 0x3ceee06c1e37648fcbb6ed52e17b3e1f275a1f8c7b22a84b2b84732431e046b3. +// +// Solidity: event ERC20WithdrawalFinalized(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) WatchERC20WithdrawalFinalized(opts *bind.WatchOpts, sink chan<- *L1StandardBridgeERC20WithdrawalFinalized, l1Token []common.Address, l2Token []common.Address, from []common.Address) (event.Subscription, error) { + + var l1TokenRule []interface{} + for _, l1TokenItem := range l1Token { + l1TokenRule = append(l1TokenRule, l1TokenItem) + } + var l2TokenRule []interface{} + for _, l2TokenItem := range l2Token { + l2TokenRule = append(l2TokenRule, l2TokenItem) + } + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + + logs, sub, err := _L1StandardBridge.contract.WatchLogs(opts, "ERC20WithdrawalFinalized", l1TokenRule, l2TokenRule, fromRule) + 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(L1StandardBridgeERC20WithdrawalFinalized) + if err := _L1StandardBridge.contract.UnpackLog(event, "ERC20WithdrawalFinalized", 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 +} + +// ParseERC20WithdrawalFinalized is a log parse operation binding the contract event 0x3ceee06c1e37648fcbb6ed52e17b3e1f275a1f8c7b22a84b2b84732431e046b3. +// +// Solidity: event ERC20WithdrawalFinalized(address indexed l1Token, address indexed l2Token, address indexed from, address to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) ParseERC20WithdrawalFinalized(log types.Log) (*L1StandardBridgeERC20WithdrawalFinalized, error) { + event := new(L1StandardBridgeERC20WithdrawalFinalized) + if err := _L1StandardBridge.contract.UnpackLog(event, "ERC20WithdrawalFinalized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// L1StandardBridgeETHBridgeFinalizedIterator is returned from FilterETHBridgeFinalized and is used to iterate over the raw logs and unpacked data for ETHBridgeFinalized events raised by the L1StandardBridge contract. +type L1StandardBridgeETHBridgeFinalizedIterator struct { + Event *L1StandardBridgeETHBridgeFinalized // 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 *L1StandardBridgeETHBridgeFinalizedIterator) 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(L1StandardBridgeETHBridgeFinalized) + 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(L1StandardBridgeETHBridgeFinalized) + 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 *L1StandardBridgeETHBridgeFinalizedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *L1StandardBridgeETHBridgeFinalizedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// L1StandardBridgeETHBridgeFinalized represents a ETHBridgeFinalized event raised by the L1StandardBridge contract. +type L1StandardBridgeETHBridgeFinalized struct { + From common.Address + To common.Address + Amount *big.Int + ExtraData []byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterETHBridgeFinalized is a free log retrieval operation binding the contract event 0x31b2166ff604fc5672ea5df08a78081d2bc6d746cadce880747f3643d819e83d. +// +// Solidity: event ETHBridgeFinalized(address indexed from, address indexed to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) FilterETHBridgeFinalized(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*L1StandardBridgeETHBridgeFinalizedIterator, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _L1StandardBridge.contract.FilterLogs(opts, "ETHBridgeFinalized", fromRule, toRule) + if err != nil { + return nil, err + } + return &L1StandardBridgeETHBridgeFinalizedIterator{contract: _L1StandardBridge.contract, event: "ETHBridgeFinalized", logs: logs, sub: sub}, nil +} + +// WatchETHBridgeFinalized is a free log subscription operation binding the contract event 0x31b2166ff604fc5672ea5df08a78081d2bc6d746cadce880747f3643d819e83d. +// +// Solidity: event ETHBridgeFinalized(address indexed from, address indexed to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) WatchETHBridgeFinalized(opts *bind.WatchOpts, sink chan<- *L1StandardBridgeETHBridgeFinalized, from []common.Address, to []common.Address) (event.Subscription, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _L1StandardBridge.contract.WatchLogs(opts, "ETHBridgeFinalized", fromRule, toRule) + 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(L1StandardBridgeETHBridgeFinalized) + if err := _L1StandardBridge.contract.UnpackLog(event, "ETHBridgeFinalized", 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 +} + +// ParseETHBridgeFinalized is a log parse operation binding the contract event 0x31b2166ff604fc5672ea5df08a78081d2bc6d746cadce880747f3643d819e83d. +// +// Solidity: event ETHBridgeFinalized(address indexed from, address indexed to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) ParseETHBridgeFinalized(log types.Log) (*L1StandardBridgeETHBridgeFinalized, error) { + event := new(L1StandardBridgeETHBridgeFinalized) + if err := _L1StandardBridge.contract.UnpackLog(event, "ETHBridgeFinalized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// L1StandardBridgeETHBridgeInitiatedIterator is returned from FilterETHBridgeInitiated and is used to iterate over the raw logs and unpacked data for ETHBridgeInitiated events raised by the L1StandardBridge contract. +type L1StandardBridgeETHBridgeInitiatedIterator struct { + Event *L1StandardBridgeETHBridgeInitiated // 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 *L1StandardBridgeETHBridgeInitiatedIterator) 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(L1StandardBridgeETHBridgeInitiated) + 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(L1StandardBridgeETHBridgeInitiated) + 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 *L1StandardBridgeETHBridgeInitiatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *L1StandardBridgeETHBridgeInitiatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// L1StandardBridgeETHBridgeInitiated represents a ETHBridgeInitiated event raised by the L1StandardBridge contract. +type L1StandardBridgeETHBridgeInitiated struct { + From common.Address + To common.Address + Amount *big.Int + ExtraData []byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterETHBridgeInitiated is a free log retrieval operation binding the contract event 0x2849b43074093a05396b6f2a937dee8565b15a48a7b3d4bffb732a5017380af5. +// +// Solidity: event ETHBridgeInitiated(address indexed from, address indexed to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) FilterETHBridgeInitiated(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*L1StandardBridgeETHBridgeInitiatedIterator, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _L1StandardBridge.contract.FilterLogs(opts, "ETHBridgeInitiated", fromRule, toRule) + if err != nil { + return nil, err + } + return &L1StandardBridgeETHBridgeInitiatedIterator{contract: _L1StandardBridge.contract, event: "ETHBridgeInitiated", logs: logs, sub: sub}, nil +} + +// WatchETHBridgeInitiated is a free log subscription operation binding the contract event 0x2849b43074093a05396b6f2a937dee8565b15a48a7b3d4bffb732a5017380af5. +// +// Solidity: event ETHBridgeInitiated(address indexed from, address indexed to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) WatchETHBridgeInitiated(opts *bind.WatchOpts, sink chan<- *L1StandardBridgeETHBridgeInitiated, from []common.Address, to []common.Address) (event.Subscription, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _L1StandardBridge.contract.WatchLogs(opts, "ETHBridgeInitiated", fromRule, toRule) + 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(L1StandardBridgeETHBridgeInitiated) + if err := _L1StandardBridge.contract.UnpackLog(event, "ETHBridgeInitiated", 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 +} + +// ParseETHBridgeInitiated is a log parse operation binding the contract event 0x2849b43074093a05396b6f2a937dee8565b15a48a7b3d4bffb732a5017380af5. +// +// Solidity: event ETHBridgeInitiated(address indexed from, address indexed to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) ParseETHBridgeInitiated(log types.Log) (*L1StandardBridgeETHBridgeInitiated, error) { + event := new(L1StandardBridgeETHBridgeInitiated) + if err := _L1StandardBridge.contract.UnpackLog(event, "ETHBridgeInitiated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// L1StandardBridgeETHDepositInitiatedIterator is returned from FilterETHDepositInitiated and is used to iterate over the raw logs and unpacked data for ETHDepositInitiated events raised by the L1StandardBridge contract. +type L1StandardBridgeETHDepositInitiatedIterator struct { + Event *L1StandardBridgeETHDepositInitiated // 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 *L1StandardBridgeETHDepositInitiatedIterator) 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(L1StandardBridgeETHDepositInitiated) + 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(L1StandardBridgeETHDepositInitiated) + 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 *L1StandardBridgeETHDepositInitiatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *L1StandardBridgeETHDepositInitiatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// L1StandardBridgeETHDepositInitiated represents a ETHDepositInitiated event raised by the L1StandardBridge contract. +type L1StandardBridgeETHDepositInitiated struct { + From common.Address + To common.Address + Amount *big.Int + ExtraData []byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterETHDepositInitiated is a free log retrieval operation binding the contract event 0x35d79ab81f2b2017e19afb5c5571778877782d7a8786f5907f93b0f4702f4f23. +// +// Solidity: event ETHDepositInitiated(address indexed from, address indexed to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) FilterETHDepositInitiated(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*L1StandardBridgeETHDepositInitiatedIterator, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _L1StandardBridge.contract.FilterLogs(opts, "ETHDepositInitiated", fromRule, toRule) + if err != nil { + return nil, err + } + return &L1StandardBridgeETHDepositInitiatedIterator{contract: _L1StandardBridge.contract, event: "ETHDepositInitiated", logs: logs, sub: sub}, nil +} + +// WatchETHDepositInitiated is a free log subscription operation binding the contract event 0x35d79ab81f2b2017e19afb5c5571778877782d7a8786f5907f93b0f4702f4f23. +// +// Solidity: event ETHDepositInitiated(address indexed from, address indexed to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) WatchETHDepositInitiated(opts *bind.WatchOpts, sink chan<- *L1StandardBridgeETHDepositInitiated, from []common.Address, to []common.Address) (event.Subscription, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _L1StandardBridge.contract.WatchLogs(opts, "ETHDepositInitiated", fromRule, toRule) + 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(L1StandardBridgeETHDepositInitiated) + if err := _L1StandardBridge.contract.UnpackLog(event, "ETHDepositInitiated", 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 +} + +// ParseETHDepositInitiated is a log parse operation binding the contract event 0x35d79ab81f2b2017e19afb5c5571778877782d7a8786f5907f93b0f4702f4f23. +// +// Solidity: event ETHDepositInitiated(address indexed from, address indexed to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) ParseETHDepositInitiated(log types.Log) (*L1StandardBridgeETHDepositInitiated, error) { + event := new(L1StandardBridgeETHDepositInitiated) + if err := _L1StandardBridge.contract.UnpackLog(event, "ETHDepositInitiated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// L1StandardBridgeETHWithdrawalFinalizedIterator is returned from FilterETHWithdrawalFinalized and is used to iterate over the raw logs and unpacked data for ETHWithdrawalFinalized events raised by the L1StandardBridge contract. +type L1StandardBridgeETHWithdrawalFinalizedIterator struct { + Event *L1StandardBridgeETHWithdrawalFinalized // 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 *L1StandardBridgeETHWithdrawalFinalizedIterator) 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(L1StandardBridgeETHWithdrawalFinalized) + 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(L1StandardBridgeETHWithdrawalFinalized) + 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 *L1StandardBridgeETHWithdrawalFinalizedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *L1StandardBridgeETHWithdrawalFinalizedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// L1StandardBridgeETHWithdrawalFinalized represents a ETHWithdrawalFinalized event raised by the L1StandardBridge contract. +type L1StandardBridgeETHWithdrawalFinalized struct { + From common.Address + To common.Address + Amount *big.Int + ExtraData []byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterETHWithdrawalFinalized is a free log retrieval operation binding the contract event 0x2ac69ee804d9a7a0984249f508dfab7cb2534b465b6ce1580f99a38ba9c5e631. +// +// Solidity: event ETHWithdrawalFinalized(address indexed from, address indexed to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) FilterETHWithdrawalFinalized(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*L1StandardBridgeETHWithdrawalFinalizedIterator, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _L1StandardBridge.contract.FilterLogs(opts, "ETHWithdrawalFinalized", fromRule, toRule) + if err != nil { + return nil, err + } + return &L1StandardBridgeETHWithdrawalFinalizedIterator{contract: _L1StandardBridge.contract, event: "ETHWithdrawalFinalized", logs: logs, sub: sub}, nil +} + +// WatchETHWithdrawalFinalized is a free log subscription operation binding the contract event 0x2ac69ee804d9a7a0984249f508dfab7cb2534b465b6ce1580f99a38ba9c5e631. +// +// Solidity: event ETHWithdrawalFinalized(address indexed from, address indexed to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) WatchETHWithdrawalFinalized(opts *bind.WatchOpts, sink chan<- *L1StandardBridgeETHWithdrawalFinalized, from []common.Address, to []common.Address) (event.Subscription, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _L1StandardBridge.contract.WatchLogs(opts, "ETHWithdrawalFinalized", fromRule, toRule) + 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(L1StandardBridgeETHWithdrawalFinalized) + if err := _L1StandardBridge.contract.UnpackLog(event, "ETHWithdrawalFinalized", 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 +} + +// ParseETHWithdrawalFinalized is a log parse operation binding the contract event 0x2ac69ee804d9a7a0984249f508dfab7cb2534b465b6ce1580f99a38ba9c5e631. +// +// Solidity: event ETHWithdrawalFinalized(address indexed from, address indexed to, uint256 amount, bytes extraData) +func (_L1StandardBridge *L1StandardBridgeFilterer) ParseETHWithdrawalFinalized(log types.Log) (*L1StandardBridgeETHWithdrawalFinalized, error) { + event := new(L1StandardBridgeETHWithdrawalFinalized) + if err := _L1StandardBridge.contract.UnpackLog(event, "ETHWithdrawalFinalized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// L1StandardBridgeInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the L1StandardBridge contract. +type L1StandardBridgeInitializedIterator struct { + Event *L1StandardBridgeInitialized // 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 *L1StandardBridgeInitializedIterator) 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(L1StandardBridgeInitialized) + 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(L1StandardBridgeInitialized) + 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 *L1StandardBridgeInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *L1StandardBridgeInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// L1StandardBridgeInitialized represents a Initialized event raised by the L1StandardBridge contract. +type L1StandardBridgeInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_L1StandardBridge *L1StandardBridgeFilterer) FilterInitialized(opts *bind.FilterOpts) (*L1StandardBridgeInitializedIterator, error) { + + logs, sub, err := _L1StandardBridge.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &L1StandardBridgeInitializedIterator{contract: _L1StandardBridge.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_L1StandardBridge *L1StandardBridgeFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *L1StandardBridgeInitialized) (event.Subscription, error) { + + logs, sub, err := _L1StandardBridge.contract.WatchLogs(opts, "Initialized") + 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(L1StandardBridgeInitialized) + if err := _L1StandardBridge.contract.UnpackLog(event, "Initialized", 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 +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_L1StandardBridge *L1StandardBridgeFilterer) ParseInitialized(log types.Log) (*L1StandardBridgeInitialized, error) { + event := new(L1StandardBridgeInitialized) + if err := _L1StandardBridge.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +func CreateL1StandardBridgeDeploymentCommand() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc string + var gasLimit uint64 + var simulate bool + var timeout uint + var safeAddress, safeApi, safeCreateCall, safeSaltRaw, safeNonceRaw string + var safeOperationType uint8 + var salt [32]byte + var predictAddress bool + var safeNonce *big.Int + var calldata bool + + cmd := &cobra.Command{ + Use: "deploy", + Short: "Deploy a new L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + + if !calldata { + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if safeCreateCall == "" { + fmt.Println("--safe-create-call not specified, using default (0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4)") + safeCreateCall = "0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4" + } + if !common.IsHexAddress(safeCreateCall) { + return fmt.Errorf("--safe-create-call is not a valid Ethereum address") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeSaltRaw == "" { + fmt.Println("--safe-salt not specified, generating random salt") + _, err := rand.Read(salt[:]) + if err != nil { + return fmt.Errorf("failed to generate random salt: %v", err) + } + // prompt user to accept random salt + fmt.Println("Generated salt:", common.Bytes2Hex(salt[:])) + fmt.Println("Please check the salt and confirm (y/n)") + var confirm string + fmt.Scanln(&confirm) + if confirm != "y" && confirm != "Y" && confirm != "\n" && confirm != "" { + return fmt.Errorf("salt not accepted, please specify a valid salt") + } + } else { + copy(salt[:], safeSaltRaw) + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + // Generate deploy bytecode with constructor arguments + deployCalldata, err := generateL1StandardBridgeDeployBytecode() + if err != nil { + return fmt.Errorf("failed to generate deploy bytecode: %v", err) + } + + if calldata { + deployCalldataHex := hex.EncodeToString(deployCalldata) + cmd.Println(deployCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + if safeAddress != "" { + // Create Safe proposal for deployment + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + if predictAddress { + fmt.Println("Predicting deployment address...") + from := common.HexToAddress(safeAddress) + if safeOperationType == 0 { + from = common.HexToAddress(safeCreateCall) + } + deploymentAddress, err := PredictDeploymentAddressSafe(from, salt, deployCalldata) + if err != nil { + return fmt.Errorf("failed to predict deployment address: %v", err) + } + fmt.Println("Predicted deployment address:", deploymentAddress.Hex()) + return nil + } else { + fmt.Println("Creating Safe proposal...") + err = DeployWithSafe(client, key, common.HexToAddress(safeAddress), common.HexToAddress(safeCreateCall), value, safeApi, deployCalldata, SafeOperationType(safeOperationType), salt, safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + } + + return nil + } + + address, deploymentTransaction, _, deploymentErr := DeployL1StandardBridge( + transactionOpts, + client, + ) + if deploymentErr != nil { + return deploymentErr + } + + cmd.Printf("Transaction hash: %s\nContract address: %s\n", deploymentTransaction.Hash().Hex(), address.Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + Data: deploymentTransaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := deploymentTransaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().StringVar(&safeCreateCall, "safe-create-call", "", "Address of the CreateCall contract (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 1, "Safe operation type: 0 (Call) or 1 (DelegateCall) - default is 1") + cmd.Flags().StringVar(&safeSaltRaw, "safe-salt", "", "Salt to use for the Safe transaction") + cmd.Flags().BoolVar(&predictAddress, "safe-predict-address", false, "Predict the deployment address (only works for Safe transactions)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + return cmd +} + +func generateL1StandardBridgeDeployBytecode() ([]byte, error) { + abiPacked, err := L1StandardBridgeMetaData.GetAbi() + if err != nil { + return nil, fmt.Errorf("failed to get ABI: %v", err) + } + + constructorArguments, err := abiPacked.Pack("") + if err != nil { + return nil, fmt.Errorf("failed to pack constructor arguments: %v", err) + } + + deployBytecode := append(common.FromHex(L1StandardBridgeMetaData.Bin), constructorArguments...) + return deployBytecode, nil +} + +func CreateDepositsCommand() *cobra.Command { + var contractAddressRaw, rpc string + var contractAddress common.Address + var timeout uint + + var blockNumberRaw, fromAddressRaw string + var pending bool + + var arg0 common.Address + var arg0Raw string + var arg1 common.Address + var arg1Raw string + + var capture0 *big.Int + + cmd := &cobra.Command{ + Use: "deposits", + Short: "Call the Deposits view method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + if arg0Raw == "" { + return fmt.Errorf("--arg-0 argument not specified") + } else if !common.IsHexAddress(arg0Raw) { + return fmt.Errorf("--arg-0 argument is not a valid Ethereum address") + } + arg0 = common.HexToAddress(arg0Raw) + + if arg1Raw == "" { + return fmt.Errorf("--arg-1 argument not specified") + } else if !common.IsHexAddress(arg1Raw) { + return fmt.Errorf("--arg-1 argument is not a valid Ethereum address") + } + arg1 = common.HexToAddress(arg1Raw) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + callOpts := bind.CallOpts{} + SetCallParametersFromArgs(&callOpts, pending, fromAddressRaw, blockNumberRaw) + + session := L1StandardBridgeCallerSession{ + Contract: &contract.L1StandardBridgeCaller, + CallOpts: callOpts, + } + + var callErr error + capture0, callErr = session.Deposits( + arg0, + arg1, + ) + if callErr != nil { + return callErr + } + + cmd.Printf("0: %s\n", capture0.String()) + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&blockNumberRaw, "block", "", "Block number at which to call the view method") + cmd.Flags().BoolVar(&pending, "pending", false, "Set this flag if it's ok to call the view method against pending state") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&fromAddressRaw, "from", "", "Optional address for caller of the view method") + + cmd.Flags().StringVar(&arg0Raw, "arg-0", "", "arg-0 argument (common.Address)") + cmd.Flags().StringVar(&arg1Raw, "arg-1", "", "arg-1 argument (common.Address)") + + return cmd +} +func CreateL2TokenBridgeCommand() *cobra.Command { + var contractAddressRaw, rpc string + var contractAddress common.Address + var timeout uint + + var blockNumberRaw, fromAddressRaw string + var pending bool + + var capture0 common.Address + + cmd := &cobra.Command{ + Use: "l-2-token-bridge", + Short: "Call the L2TokenBridge view method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + callOpts := bind.CallOpts{} + SetCallParametersFromArgs(&callOpts, pending, fromAddressRaw, blockNumberRaw) + + session := L1StandardBridgeCallerSession{ + Contract: &contract.L1StandardBridgeCaller, + CallOpts: callOpts, + } + + var callErr error + capture0, callErr = session.L2TokenBridge() + if callErr != nil { + return callErr + } + + cmd.Printf("0: %s\n", capture0.Hex()) + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&blockNumberRaw, "block", "", "Block number at which to call the view method") + cmd.Flags().BoolVar(&pending, "pending", false, "Set this flag if it's ok to call the view method against pending state") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&fromAddressRaw, "from", "", "Optional address for caller of the view method") + + return cmd +} +func CreateMessengerCommand() *cobra.Command { + var contractAddressRaw, rpc string + var contractAddress common.Address + var timeout uint + + var blockNumberRaw, fromAddressRaw string + var pending bool + + var capture0 common.Address + + cmd := &cobra.Command{ + Use: "messenger", + Short: "Call the MESSENGER view method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + callOpts := bind.CallOpts{} + SetCallParametersFromArgs(&callOpts, pending, fromAddressRaw, blockNumberRaw) + + session := L1StandardBridgeCallerSession{ + Contract: &contract.L1StandardBridgeCaller, + CallOpts: callOpts, + } + + var callErr error + capture0, callErr = session.MESSENGER() + if callErr != nil { + return callErr + } + + cmd.Printf("0: %s\n", capture0.Hex()) + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&blockNumberRaw, "block", "", "Block number at which to call the view method") + cmd.Flags().BoolVar(&pending, "pending", false, "Set this flag if it's ok to call the view method against pending state") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&fromAddressRaw, "from", "", "Optional address for caller of the view method") + + return cmd +} + +func CreateOtherbridgeCommand() *cobra.Command { + var contractAddressRaw, rpc string + var contractAddress common.Address + var timeout uint + + var blockNumberRaw, fromAddressRaw string + var pending bool + + var capture0 common.Address + + cmd := &cobra.Command{ + Use: "otherbridge", + Short: "Call the OTHERBRIDGE view method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + callOpts := bind.CallOpts{} + SetCallParametersFromArgs(&callOpts, pending, fromAddressRaw, blockNumberRaw) + + session := L1StandardBridgeCallerSession{ + Contract: &contract.L1StandardBridgeCaller, + CallOpts: callOpts, + } + + var callErr error + capture0, callErr = session.OTHERBRIDGE() + if callErr != nil { + return callErr + } + + cmd.Printf("0: %s\n", capture0.Hex()) + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&blockNumberRaw, "block", "", "Block number at which to call the view method") + cmd.Flags().BoolVar(&pending, "pending", false, "Set this flag if it's ok to call the view method against pending state") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&fromAddressRaw, "from", "", "Optional address for caller of the view method") + + return cmd +} +func CreateOtherBridgeCommand() *cobra.Command { + var contractAddressRaw, rpc string + var contractAddress common.Address + var timeout uint + + var blockNumberRaw, fromAddressRaw string + var pending bool + + var capture0 common.Address + + cmd := &cobra.Command{ + Use: "other-bridge", + Short: "Call the OtherBridge view method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + callOpts := bind.CallOpts{} + SetCallParametersFromArgs(&callOpts, pending, fromAddressRaw, blockNumberRaw) + + session := L1StandardBridgeCallerSession{ + Contract: &contract.L1StandardBridgeCaller, + CallOpts: callOpts, + } + + var callErr error + capture0, callErr = session.OtherBridge() + if callErr != nil { + return callErr + } + + cmd.Printf("0: %s\n", capture0.Hex()) + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&blockNumberRaw, "block", "", "Block number at which to call the view method") + cmd.Flags().BoolVar(&pending, "pending", false, "Set this flag if it's ok to call the view method against pending state") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&fromAddressRaw, "from", "", "Optional address for caller of the view method") + + return cmd +} +func CreatePausedCommand() *cobra.Command { + var contractAddressRaw, rpc string + var contractAddress common.Address + var timeout uint + + var blockNumberRaw, fromAddressRaw string + var pending bool + + var capture0 bool + + cmd := &cobra.Command{ + Use: "paused", + Short: "Call the Paused view method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + callOpts := bind.CallOpts{} + SetCallParametersFromArgs(&callOpts, pending, fromAddressRaw, blockNumberRaw) + + session := L1StandardBridgeCallerSession{ + Contract: &contract.L1StandardBridgeCaller, + CallOpts: callOpts, + } + + var callErr error + capture0, callErr = session.Paused() + if callErr != nil { + return callErr + } + + cmd.Printf("0: %t\n", capture0) + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&blockNumberRaw, "block", "", "Block number at which to call the view method") + cmd.Flags().BoolVar(&pending, "pending", false, "Set this flag if it's ok to call the view method against pending state") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&fromAddressRaw, "from", "", "Optional address for caller of the view method") + + return cmd +} +func CreateSuperchainConfigCommand() *cobra.Command { + var contractAddressRaw, rpc string + var contractAddress common.Address + var timeout uint + + var blockNumberRaw, fromAddressRaw string + var pending bool + + var capture0 common.Address + + cmd := &cobra.Command{ + Use: "superchain-config", + Short: "Call the SuperchainConfig view method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + callOpts := bind.CallOpts{} + SetCallParametersFromArgs(&callOpts, pending, fromAddressRaw, blockNumberRaw) + + session := L1StandardBridgeCallerSession{ + Contract: &contract.L1StandardBridgeCaller, + CallOpts: callOpts, + } + + var callErr error + capture0, callErr = session.SuperchainConfig() + if callErr != nil { + return callErr + } + + cmd.Printf("0: %s\n", capture0.Hex()) + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&blockNumberRaw, "block", "", "Block number at which to call the view method") + cmd.Flags().BoolVar(&pending, "pending", false, "Set this flag if it's ok to call the view method against pending state") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&fromAddressRaw, "from", "", "Optional address for caller of the view method") + + return cmd +} +func CreateSystemConfigCommand() *cobra.Command { + var contractAddressRaw, rpc string + var contractAddress common.Address + var timeout uint + + var blockNumberRaw, fromAddressRaw string + var pending bool + + var capture0 common.Address + + cmd := &cobra.Command{ + Use: "system-config", + Short: "Call the SystemConfig view method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + callOpts := bind.CallOpts{} + SetCallParametersFromArgs(&callOpts, pending, fromAddressRaw, blockNumberRaw) + + session := L1StandardBridgeCallerSession{ + Contract: &contract.L1StandardBridgeCaller, + CallOpts: callOpts, + } + + var callErr error + capture0, callErr = session.SystemConfig() + if callErr != nil { + return callErr + } + + cmd.Printf("0: %s\n", capture0.Hex()) + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&blockNumberRaw, "block", "", "Block number at which to call the view method") + cmd.Flags().BoolVar(&pending, "pending", false, "Set this flag if it's ok to call the view method against pending state") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&fromAddressRaw, "from", "", "Optional address for caller of the view method") + + return cmd +} +func CreateVersionCommand() *cobra.Command { + var contractAddressRaw, rpc string + var contractAddress common.Address + var timeout uint + + var blockNumberRaw, fromAddressRaw string + var pending bool + + var capture0 string + + cmd := &cobra.Command{ + Use: "version", + Short: "Call the Version view method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + callOpts := bind.CallOpts{} + SetCallParametersFromArgs(&callOpts, pending, fromAddressRaw, blockNumberRaw) + + session := L1StandardBridgeCallerSession{ + Contract: &contract.L1StandardBridgeCaller, + CallOpts: callOpts, + } + + var callErr error + capture0, callErr = session.Version() + if callErr != nil { + return callErr + } + + cmd.Printf("0: %s\n", capture0) + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&blockNumberRaw, "block", "", "Block number at which to call the view method") + cmd.Flags().BoolVar(&pending, "pending", false, "Set this flag if it's ok to call the view method against pending state") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&fromAddressRaw, "from", "", "Optional address for caller of the view method") + + return cmd +} + +func CreateBridgeErc20Command() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc, contractAddressRaw, safeFunction, safeNonceRaw string + var gasLimit uint64 + var simulate bool + var timeout uint + var contractAddress common.Address + var safeAddress, safeApi string + var safeOperationType uint8 + var safeNonce *big.Int + var calldata bool + + var localToken common.Address + var localTokenRaw string + var remoteToken common.Address + var remoteTokenRaw string + var amount *big.Int + var amountRaw string + var minGasLimit uint32 + + var extraData []byte + var extraDataRaw string + + cmd := &cobra.Command{ + Use: "bridge-erc-20", + Short: "Execute the BridgeERC20 method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if !calldata { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + if localTokenRaw == "" { + return fmt.Errorf("--local-token argument not specified") + } else if !common.IsHexAddress(localTokenRaw) { + return fmt.Errorf("--local-token argument is not a valid Ethereum address") + } + localToken = common.HexToAddress(localTokenRaw) + + if remoteTokenRaw == "" { + return fmt.Errorf("--remote-token argument not specified") + } else if !common.IsHexAddress(remoteTokenRaw) { + return fmt.Errorf("--remote-token argument is not a valid Ethereum address") + } + remoteToken = common.HexToAddress(remoteTokenRaw) + + if amountRaw == "" { + return fmt.Errorf("--amount argument not specified") + } + amount = new(big.Int) + amount.SetString(amountRaw, 0) + + var extraDataIntermediate []byte + + var extraDataIntermediateHexDecodeErr error + extraDataIntermediate, extraDataIntermediateHexDecodeErr = hex.DecodeString(extraDataRaw) + if extraDataIntermediateHexDecodeErr != nil { + return extraDataIntermediateHexDecodeErr + } + + copy(extraData[:], extraDataIntermediate) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + abi, err := L1StandardBridgeMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + // Generate transaction data (override method name if safe function is specified) + methodName := "bridgeErc20" + if safeFunction != "" { + methodName = safeFunction + } + + txCalldata, err := abi.Pack( + methodName, + localToken, + remoteToken, + amount, + minGasLimit, + extraData, + ) + + if err != nil { + return err + } + + if calldata { + txCalldataHex := hex.EncodeToString(txCalldata) + cmd.Println(txCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + session := L1StandardBridgeTransactorSession{ + Contract: &contract.L1StandardBridgeTransactor, + TransactOpts: *transactionOpts, + } + + if safeAddress != "" { + // Create Safe proposal for transaction + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + err = CreateSafeProposal(client, key, common.HexToAddress(safeAddress), contractAddress, txCalldata, value, safeApi, SafeOperationType(safeOperationType), safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + + return nil + } + + transaction, err := session.BridgeERC20( + + localToken, + remoteToken, + amount, + minGasLimit, + extraData, + ) + if err != nil { + return err + } + + cmd.Printf("Transaction hash: %s\n", transaction.Hash().Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + To: &contractAddress, + Data: transaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := transaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 0, "Safe operation type: 0 (Call) or 1 (DelegateCall)") + cmd.Flags().StringVar(&safeFunction, "safe-function", "", "Safe function overrider to use for the transaction (optional)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + cmd.Flags().StringVar(&localTokenRaw, "local-token", "", "local-token argument (common.Address)") + cmd.Flags().StringVar(&remoteTokenRaw, "remote-token", "", "remote-token argument (common.Address)") + cmd.Flags().StringVar(&amountRaw, "amount", "", "amount argument") + cmd.Flags().Uint32Var(&minGasLimit, "min-gas-limit", 0, "min-gas-limit argument") + cmd.Flags().StringVar(&extraDataRaw, "extra-data", "", "extra-data argument ([]byte)") + + return cmd +} +func CreateBridgeErc20ToCommand() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc, contractAddressRaw, safeFunction, safeNonceRaw string + var gasLimit uint64 + var simulate bool + var timeout uint + var contractAddress common.Address + var safeAddress, safeApi string + var safeOperationType uint8 + var safeNonce *big.Int + var calldata bool + + var localToken common.Address + var localTokenRaw string + var remoteToken common.Address + var remoteTokenRaw string + var _to0 common.Address + var _to0Raw string + var amount *big.Int + var amountRaw string + var minGasLimit uint32 + + var extraData []byte + var extraDataRaw string + + cmd := &cobra.Command{ + Use: "bridge-erc-20-to", + Short: "Execute the BridgeERC20To method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if !calldata { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + if localTokenRaw == "" { + return fmt.Errorf("--local-token argument not specified") + } else if !common.IsHexAddress(localTokenRaw) { + return fmt.Errorf("--local-token argument is not a valid Ethereum address") + } + localToken = common.HexToAddress(localTokenRaw) + + if remoteTokenRaw == "" { + return fmt.Errorf("--remote-token argument not specified") + } else if !common.IsHexAddress(remoteTokenRaw) { + return fmt.Errorf("--remote-token argument is not a valid Ethereum address") + } + remoteToken = common.HexToAddress(remoteTokenRaw) + + if _to0Raw == "" { + return fmt.Errorf("---to-0 argument not specified") + } else if !common.IsHexAddress(_to0Raw) { + return fmt.Errorf("---to-0 argument is not a valid Ethereum address") + } + _to0 = common.HexToAddress(_to0Raw) + + if amountRaw == "" { + return fmt.Errorf("--amount argument not specified") + } + amount = new(big.Int) + amount.SetString(amountRaw, 0) + + var extraDataIntermediate []byte + + var extraDataIntermediateHexDecodeErr error + extraDataIntermediate, extraDataIntermediateHexDecodeErr = hex.DecodeString(extraDataRaw) + if extraDataIntermediateHexDecodeErr != nil { + return extraDataIntermediateHexDecodeErr + } + + copy(extraData[:], extraDataIntermediate) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + abi, err := L1StandardBridgeMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + // Generate transaction data (override method name if safe function is specified) + methodName := "bridgeErc20To" + if safeFunction != "" { + methodName = safeFunction + } + + txCalldata, err := abi.Pack( + methodName, + localToken, + remoteToken, + _to0, + amount, + minGasLimit, + extraData, + ) + + if err != nil { + return err + } + + if calldata { + txCalldataHex := hex.EncodeToString(txCalldata) + cmd.Println(txCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + session := L1StandardBridgeTransactorSession{ + Contract: &contract.L1StandardBridgeTransactor, + TransactOpts: *transactionOpts, + } + + if safeAddress != "" { + // Create Safe proposal for transaction + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + err = CreateSafeProposal(client, key, common.HexToAddress(safeAddress), contractAddress, txCalldata, value, safeApi, SafeOperationType(safeOperationType), safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + + return nil + } + + transaction, err := session.BridgeERC20To( + + localToken, + remoteToken, + _to0, + amount, + minGasLimit, + extraData, + ) + if err != nil { + return err + } + + cmd.Printf("Transaction hash: %s\n", transaction.Hash().Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + To: &contractAddress, + Data: transaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := transaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 0, "Safe operation type: 0 (Call) or 1 (DelegateCall)") + cmd.Flags().StringVar(&safeFunction, "safe-function", "", "Safe function overrider to use for the transaction (optional)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + cmd.Flags().StringVar(&localTokenRaw, "local-token", "", "local-token argument (common.Address)") + cmd.Flags().StringVar(&remoteTokenRaw, "remote-token", "", "remote-token argument (common.Address)") + cmd.Flags().StringVar(&_to0Raw, "-to-0", "", "-to-0 argument (common.Address)") + cmd.Flags().StringVar(&amountRaw, "amount", "", "amount argument") + cmd.Flags().Uint32Var(&minGasLimit, "min-gas-limit", 0, "min-gas-limit argument") + cmd.Flags().StringVar(&extraDataRaw, "extra-data", "", "extra-data argument ([]byte)") + + return cmd +} +func CreateBridgeEthCommand() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc, contractAddressRaw, safeFunction, safeNonceRaw string + var gasLimit uint64 + var simulate bool + var timeout uint + var contractAddress common.Address + var safeAddress, safeApi string + var safeOperationType uint8 + var safeNonce *big.Int + var calldata bool + + var minGasLimit uint32 + + var extraData []byte + var extraDataRaw string + + cmd := &cobra.Command{ + Use: "bridge-eth", + Short: "Execute the BridgeETH method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if !calldata { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + var extraDataIntermediate []byte + + var extraDataIntermediateHexDecodeErr error + extraDataIntermediate, extraDataIntermediateHexDecodeErr = hex.DecodeString(extraDataRaw) + if extraDataIntermediateHexDecodeErr != nil { + return extraDataIntermediateHexDecodeErr + } + + copy(extraData[:], extraDataIntermediate) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + abi, err := L1StandardBridgeMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + // Generate transaction data (override method name if safe function is specified) + methodName := "bridgeEth" + if safeFunction != "" { + methodName = safeFunction + } + + txCalldata, err := abi.Pack( + methodName, + minGasLimit, + extraData, + ) + + if err != nil { + return err + } + + if calldata { + txCalldataHex := hex.EncodeToString(txCalldata) + cmd.Println(txCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + session := L1StandardBridgeTransactorSession{ + Contract: &contract.L1StandardBridgeTransactor, + TransactOpts: *transactionOpts, + } + + if safeAddress != "" { + // Create Safe proposal for transaction + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + err = CreateSafeProposal(client, key, common.HexToAddress(safeAddress), contractAddress, txCalldata, value, safeApi, SafeOperationType(safeOperationType), safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + + return nil + } + + transaction, err := session.BridgeETH( + + minGasLimit, + extraData, + ) + if err != nil { + return err + } + + cmd.Printf("Transaction hash: %s\n", transaction.Hash().Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + To: &contractAddress, + Data: transaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := transaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 0, "Safe operation type: 0 (Call) or 1 (DelegateCall)") + cmd.Flags().StringVar(&safeFunction, "safe-function", "", "Safe function overrider to use for the transaction (optional)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + cmd.Flags().Uint32Var(&minGasLimit, "min-gas-limit", 0, "min-gas-limit argument") + cmd.Flags().StringVar(&extraDataRaw, "extra-data", "", "extra-data argument ([]byte)") + + return cmd +} +func CreateBridgeEthtoCommand() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc, contractAddressRaw, safeFunction, safeNonceRaw string + var gasLimit uint64 + var simulate bool + var timeout uint + var contractAddress common.Address + var safeAddress, safeApi string + var safeOperationType uint8 + var safeNonce *big.Int + var calldata bool + + var _to0 common.Address + var _to0Raw string + var minGasLimit uint32 + + var extraData []byte + var extraDataRaw string + + cmd := &cobra.Command{ + Use: "bridge-eth-to", + Short: "Execute the BridgeETHTo method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if !calldata { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + if _to0Raw == "" { + return fmt.Errorf("---to-0 argument not specified") + } else if !common.IsHexAddress(_to0Raw) { + return fmt.Errorf("---to-0 argument is not a valid Ethereum address") + } + _to0 = common.HexToAddress(_to0Raw) + + var extraDataIntermediate []byte + + var extraDataIntermediateHexDecodeErr error + extraDataIntermediate, extraDataIntermediateHexDecodeErr = hex.DecodeString(extraDataRaw) + if extraDataIntermediateHexDecodeErr != nil { + return extraDataIntermediateHexDecodeErr + } + + copy(extraData[:], extraDataIntermediate) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + abi, err := L1StandardBridgeMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + // Generate transaction data (override method name if safe function is specified) + methodName := "bridgeEthto" + if safeFunction != "" { + methodName = safeFunction + } + + txCalldata, err := abi.Pack( + methodName, + _to0, + minGasLimit, + extraData, + ) + + if err != nil { + return err + } + + if calldata { + txCalldataHex := hex.EncodeToString(txCalldata) + cmd.Println(txCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + session := L1StandardBridgeTransactorSession{ + Contract: &contract.L1StandardBridgeTransactor, + TransactOpts: *transactionOpts, + } + + if safeAddress != "" { + // Create Safe proposal for transaction + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + err = CreateSafeProposal(client, key, common.HexToAddress(safeAddress), contractAddress, txCalldata, value, safeApi, SafeOperationType(safeOperationType), safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + + return nil + } + + transaction, err := session.BridgeETHTo( + + _to0, + minGasLimit, + extraData, + ) + if err != nil { + return err + } + + cmd.Printf("Transaction hash: %s\n", transaction.Hash().Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + To: &contractAddress, + Data: transaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := transaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 0, "Safe operation type: 0 (Call) or 1 (DelegateCall)") + cmd.Flags().StringVar(&safeFunction, "safe-function", "", "Safe function overrider to use for the transaction (optional)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + cmd.Flags().StringVar(&_to0Raw, "-to-0", "", "-to-0 argument (common.Address)") + cmd.Flags().Uint32Var(&minGasLimit, "min-gas-limit", 0, "min-gas-limit argument") + cmd.Flags().StringVar(&extraDataRaw, "extra-data", "", "extra-data argument ([]byte)") + + return cmd +} +func CreateDepositErc20Command() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc, contractAddressRaw, safeFunction, safeNonceRaw string + var gasLimit uint64 + var simulate bool + var timeout uint + var contractAddress common.Address + var safeAddress, safeApi string + var safeOperationType uint8 + var safeNonce *big.Int + var calldata bool + + var l1Token common.Address + var l1TokenRaw string + var l2Token common.Address + var l2TokenRaw string + var amount *big.Int + var amountRaw string + var minGasLimit uint32 + + var extraData []byte + var extraDataRaw string + + cmd := &cobra.Command{ + Use: "deposit-erc-20", + Short: "Execute the DepositERC20 method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if !calldata { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + if l1TokenRaw == "" { + return fmt.Errorf("--l-1-token argument not specified") + } else if !common.IsHexAddress(l1TokenRaw) { + return fmt.Errorf("--l-1-token argument is not a valid Ethereum address") + } + l1Token = common.HexToAddress(l1TokenRaw) + + if l2TokenRaw == "" { + return fmt.Errorf("--l-2-token argument not specified") + } else if !common.IsHexAddress(l2TokenRaw) { + return fmt.Errorf("--l-2-token argument is not a valid Ethereum address") + } + l2Token = common.HexToAddress(l2TokenRaw) + + if amountRaw == "" { + return fmt.Errorf("--amount argument not specified") + } + amount = new(big.Int) + amount.SetString(amountRaw, 0) + + var extraDataIntermediate []byte + + var extraDataIntermediateHexDecodeErr error + extraDataIntermediate, extraDataIntermediateHexDecodeErr = hex.DecodeString(extraDataRaw) + if extraDataIntermediateHexDecodeErr != nil { + return extraDataIntermediateHexDecodeErr + } + + copy(extraData[:], extraDataIntermediate) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + abi, err := L1StandardBridgeMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + // Generate transaction data (override method name if safe function is specified) + methodName := "depositErc20" + if safeFunction != "" { + methodName = safeFunction + } + + txCalldata, err := abi.Pack( + methodName, + l1Token, + l2Token, + amount, + minGasLimit, + extraData, + ) + + if err != nil { + return err + } + + if calldata { + txCalldataHex := hex.EncodeToString(txCalldata) + cmd.Println(txCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + session := L1StandardBridgeTransactorSession{ + Contract: &contract.L1StandardBridgeTransactor, + TransactOpts: *transactionOpts, + } + + if safeAddress != "" { + // Create Safe proposal for transaction + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + err = CreateSafeProposal(client, key, common.HexToAddress(safeAddress), contractAddress, txCalldata, value, safeApi, SafeOperationType(safeOperationType), safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + + return nil + } + + transaction, err := session.DepositERC20( + + l1Token, + l2Token, + amount, + minGasLimit, + extraData, + ) + if err != nil { + return err + } + + cmd.Printf("Transaction hash: %s\n", transaction.Hash().Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + To: &contractAddress, + Data: transaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := transaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 0, "Safe operation type: 0 (Call) or 1 (DelegateCall)") + cmd.Flags().StringVar(&safeFunction, "safe-function", "", "Safe function overrider to use for the transaction (optional)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + cmd.Flags().StringVar(&l1TokenRaw, "l-1-token", "", "l-1-token argument (common.Address)") + cmd.Flags().StringVar(&l2TokenRaw, "l-2-token", "", "l-2-token argument (common.Address)") + cmd.Flags().StringVar(&amountRaw, "amount", "", "amount argument") + cmd.Flags().Uint32Var(&minGasLimit, "min-gas-limit", 0, "min-gas-limit argument") + cmd.Flags().StringVar(&extraDataRaw, "extra-data", "", "extra-data argument ([]byte)") + + return cmd +} +func CreateDepositErc20ToCommand() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc, contractAddressRaw, safeFunction, safeNonceRaw string + var gasLimit uint64 + var simulate bool + var timeout uint + var contractAddress common.Address + var safeAddress, safeApi string + var safeOperationType uint8 + var safeNonce *big.Int + var calldata bool + + var l1Token common.Address + var l1TokenRaw string + var l2Token common.Address + var l2TokenRaw string + var _to0 common.Address + var _to0Raw string + var amount *big.Int + var amountRaw string + var minGasLimit uint32 + + var extraData []byte + var extraDataRaw string + + cmd := &cobra.Command{ + Use: "deposit-erc-20-to", + Short: "Execute the DepositERC20To method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if !calldata { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + if l1TokenRaw == "" { + return fmt.Errorf("--l-1-token argument not specified") + } else if !common.IsHexAddress(l1TokenRaw) { + return fmt.Errorf("--l-1-token argument is not a valid Ethereum address") + } + l1Token = common.HexToAddress(l1TokenRaw) + + if l2TokenRaw == "" { + return fmt.Errorf("--l-2-token argument not specified") + } else if !common.IsHexAddress(l2TokenRaw) { + return fmt.Errorf("--l-2-token argument is not a valid Ethereum address") + } + l2Token = common.HexToAddress(l2TokenRaw) + + if _to0Raw == "" { + return fmt.Errorf("---to-0 argument not specified") + } else if !common.IsHexAddress(_to0Raw) { + return fmt.Errorf("---to-0 argument is not a valid Ethereum address") + } + _to0 = common.HexToAddress(_to0Raw) + + if amountRaw == "" { + return fmt.Errorf("--amount argument not specified") + } + amount = new(big.Int) + amount.SetString(amountRaw, 0) + + var extraDataIntermediate []byte + + var extraDataIntermediateHexDecodeErr error + extraDataIntermediate, extraDataIntermediateHexDecodeErr = hex.DecodeString(extraDataRaw) + if extraDataIntermediateHexDecodeErr != nil { + return extraDataIntermediateHexDecodeErr + } + + copy(extraData[:], extraDataIntermediate) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + abi, err := L1StandardBridgeMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + // Generate transaction data (override method name if safe function is specified) + methodName := "depositErc20To" + if safeFunction != "" { + methodName = safeFunction + } + + txCalldata, err := abi.Pack( + methodName, + l1Token, + l2Token, + _to0, + amount, + minGasLimit, + extraData, + ) + + if err != nil { + return err + } + + if calldata { + txCalldataHex := hex.EncodeToString(txCalldata) + cmd.Println(txCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + session := L1StandardBridgeTransactorSession{ + Contract: &contract.L1StandardBridgeTransactor, + TransactOpts: *transactionOpts, + } + + if safeAddress != "" { + // Create Safe proposal for transaction + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + err = CreateSafeProposal(client, key, common.HexToAddress(safeAddress), contractAddress, txCalldata, value, safeApi, SafeOperationType(safeOperationType), safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + + return nil + } + + transaction, err := session.DepositERC20To( + + l1Token, + l2Token, + _to0, + amount, + minGasLimit, + extraData, + ) + if err != nil { + return err + } + + cmd.Printf("Transaction hash: %s\n", transaction.Hash().Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + To: &contractAddress, + Data: transaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := transaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 0, "Safe operation type: 0 (Call) or 1 (DelegateCall)") + cmd.Flags().StringVar(&safeFunction, "safe-function", "", "Safe function overrider to use for the transaction (optional)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + cmd.Flags().StringVar(&l1TokenRaw, "l-1-token", "", "l-1-token argument (common.Address)") + cmd.Flags().StringVar(&l2TokenRaw, "l-2-token", "", "l-2-token argument (common.Address)") + cmd.Flags().StringVar(&_to0Raw, "-to-0", "", "-to-0 argument (common.Address)") + cmd.Flags().StringVar(&amountRaw, "amount", "", "amount argument") + cmd.Flags().Uint32Var(&minGasLimit, "min-gas-limit", 0, "min-gas-limit argument") + cmd.Flags().StringVar(&extraDataRaw, "extra-data", "", "extra-data argument ([]byte)") + + return cmd +} +func CreateDepositEthCommand() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc, contractAddressRaw, safeFunction, safeNonceRaw string + var gasLimit uint64 + var simulate bool + var timeout uint + var contractAddress common.Address + var safeAddress, safeApi string + var safeOperationType uint8 + var safeNonce *big.Int + var calldata bool + + var minGasLimit uint32 + + var extraData []byte + var extraDataRaw string + + cmd := &cobra.Command{ + Use: "deposit-eth", + Short: "Execute the DepositETH method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if !calldata { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + var extraDataIntermediate []byte + + var extraDataIntermediateHexDecodeErr error + extraDataIntermediate, extraDataIntermediateHexDecodeErr = hex.DecodeString(extraDataRaw) + if extraDataIntermediateHexDecodeErr != nil { + return extraDataIntermediateHexDecodeErr + } + + copy(extraData[:], extraDataIntermediate) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + abi, err := L1StandardBridgeMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + // Generate transaction data (override method name if safe function is specified) + methodName := "depositEth" + if safeFunction != "" { + methodName = safeFunction + } + + txCalldata, err := abi.Pack( + methodName, + minGasLimit, + extraData, + ) + + if err != nil { + return err + } + + if calldata { + txCalldataHex := hex.EncodeToString(txCalldata) + cmd.Println(txCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + session := L1StandardBridgeTransactorSession{ + Contract: &contract.L1StandardBridgeTransactor, + TransactOpts: *transactionOpts, + } + + if safeAddress != "" { + // Create Safe proposal for transaction + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + err = CreateSafeProposal(client, key, common.HexToAddress(safeAddress), contractAddress, txCalldata, value, safeApi, SafeOperationType(safeOperationType), safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + + return nil + } + + transaction, err := session.DepositETH( + + minGasLimit, + extraData, + ) + if err != nil { + return err + } + + cmd.Printf("Transaction hash: %s\n", transaction.Hash().Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + To: &contractAddress, + Data: transaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := transaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 0, "Safe operation type: 0 (Call) or 1 (DelegateCall)") + cmd.Flags().StringVar(&safeFunction, "safe-function", "", "Safe function overrider to use for the transaction (optional)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + cmd.Flags().Uint32Var(&minGasLimit, "min-gas-limit", 0, "min-gas-limit argument") + cmd.Flags().StringVar(&extraDataRaw, "extra-data", "", "extra-data argument ([]byte)") + + return cmd +} +func CreateDepositEthtoCommand() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc, contractAddressRaw, safeFunction, safeNonceRaw string + var gasLimit uint64 + var simulate bool + var timeout uint + var contractAddress common.Address + var safeAddress, safeApi string + var safeOperationType uint8 + var safeNonce *big.Int + var calldata bool + + var _to0 common.Address + var _to0Raw string + var minGasLimit uint32 + + var extraData []byte + var extraDataRaw string + + cmd := &cobra.Command{ + Use: "deposit-eth-to", + Short: "Execute the DepositETHTo method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if !calldata { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + if _to0Raw == "" { + return fmt.Errorf("---to-0 argument not specified") + } else if !common.IsHexAddress(_to0Raw) { + return fmt.Errorf("---to-0 argument is not a valid Ethereum address") + } + _to0 = common.HexToAddress(_to0Raw) + + var extraDataIntermediate []byte + + var extraDataIntermediateHexDecodeErr error + extraDataIntermediate, extraDataIntermediateHexDecodeErr = hex.DecodeString(extraDataRaw) + if extraDataIntermediateHexDecodeErr != nil { + return extraDataIntermediateHexDecodeErr + } + + copy(extraData[:], extraDataIntermediate) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + abi, err := L1StandardBridgeMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + // Generate transaction data (override method name if safe function is specified) + methodName := "depositEthto" + if safeFunction != "" { + methodName = safeFunction + } + + txCalldata, err := abi.Pack( + methodName, + _to0, + minGasLimit, + extraData, + ) + + if err != nil { + return err + } + + if calldata { + txCalldataHex := hex.EncodeToString(txCalldata) + cmd.Println(txCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + session := L1StandardBridgeTransactorSession{ + Contract: &contract.L1StandardBridgeTransactor, + TransactOpts: *transactionOpts, + } + + if safeAddress != "" { + // Create Safe proposal for transaction + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + err = CreateSafeProposal(client, key, common.HexToAddress(safeAddress), contractAddress, txCalldata, value, safeApi, SafeOperationType(safeOperationType), safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + + return nil + } + + transaction, err := session.DepositETHTo( + + _to0, + minGasLimit, + extraData, + ) + if err != nil { + return err + } + + cmd.Printf("Transaction hash: %s\n", transaction.Hash().Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + To: &contractAddress, + Data: transaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := transaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 0, "Safe operation type: 0 (Call) or 1 (DelegateCall)") + cmd.Flags().StringVar(&safeFunction, "safe-function", "", "Safe function overrider to use for the transaction (optional)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + cmd.Flags().StringVar(&_to0Raw, "-to-0", "", "-to-0 argument (common.Address)") + cmd.Flags().Uint32Var(&minGasLimit, "min-gas-limit", 0, "min-gas-limit argument") + cmd.Flags().StringVar(&extraDataRaw, "extra-data", "", "extra-data argument ([]byte)") + + return cmd +} +func CreateFinalizeBridgeErc20Command() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc, contractAddressRaw, safeFunction, safeNonceRaw string + var gasLimit uint64 + var simulate bool + var timeout uint + var contractAddress common.Address + var safeAddress, safeApi string + var safeOperationType uint8 + var safeNonce *big.Int + var calldata bool + + var localToken common.Address + var localTokenRaw string + var remoteToken common.Address + var remoteTokenRaw string + var _from0 common.Address + var _from0Raw string + var _to0 common.Address + var _to0Raw string + var amount *big.Int + var amountRaw string + var extraData []byte + var extraDataRaw string + + cmd := &cobra.Command{ + Use: "finalize-bridge-erc-20", + Short: "Execute the FinalizeBridgeERC20 method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if !calldata { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + if localTokenRaw == "" { + return fmt.Errorf("--local-token argument not specified") + } else if !common.IsHexAddress(localTokenRaw) { + return fmt.Errorf("--local-token argument is not a valid Ethereum address") + } + localToken = common.HexToAddress(localTokenRaw) + + if remoteTokenRaw == "" { + return fmt.Errorf("--remote-token argument not specified") + } else if !common.IsHexAddress(remoteTokenRaw) { + return fmt.Errorf("--remote-token argument is not a valid Ethereum address") + } + remoteToken = common.HexToAddress(remoteTokenRaw) + + if _from0Raw == "" { + return fmt.Errorf("---from-0 argument not specified") + } else if !common.IsHexAddress(_from0Raw) { + return fmt.Errorf("---from-0 argument is not a valid Ethereum address") + } + _from0 = common.HexToAddress(_from0Raw) + + if _to0Raw == "" { + return fmt.Errorf("---to-0 argument not specified") + } else if !common.IsHexAddress(_to0Raw) { + return fmt.Errorf("---to-0 argument is not a valid Ethereum address") + } + _to0 = common.HexToAddress(_to0Raw) + + if amountRaw == "" { + return fmt.Errorf("--amount argument not specified") + } + amount = new(big.Int) + amount.SetString(amountRaw, 0) + + var extraDataIntermediate []byte + + var extraDataIntermediateHexDecodeErr error + extraDataIntermediate, extraDataIntermediateHexDecodeErr = hex.DecodeString(extraDataRaw) + if extraDataIntermediateHexDecodeErr != nil { + return extraDataIntermediateHexDecodeErr + } + + copy(extraData[:], extraDataIntermediate) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + abi, err := L1StandardBridgeMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + // Generate transaction data (override method name if safe function is specified) + methodName := "finalizeBridgeErc20" + if safeFunction != "" { + methodName = safeFunction + } + + txCalldata, err := abi.Pack( + methodName, + localToken, + remoteToken, + _from0, + _to0, + amount, + extraData, + ) + + if err != nil { + return err + } + + if calldata { + txCalldataHex := hex.EncodeToString(txCalldata) + cmd.Println(txCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + session := L1StandardBridgeTransactorSession{ + Contract: &contract.L1StandardBridgeTransactor, + TransactOpts: *transactionOpts, + } + + if safeAddress != "" { + // Create Safe proposal for transaction + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + err = CreateSafeProposal(client, key, common.HexToAddress(safeAddress), contractAddress, txCalldata, value, safeApi, SafeOperationType(safeOperationType), safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + + return nil + } + + transaction, err := session.FinalizeBridgeERC20( + + localToken, + remoteToken, + _from0, + _to0, + amount, + extraData, + ) + if err != nil { + return err + } + + cmd.Printf("Transaction hash: %s\n", transaction.Hash().Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + To: &contractAddress, + Data: transaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := transaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 0, "Safe operation type: 0 (Call) or 1 (DelegateCall)") + cmd.Flags().StringVar(&safeFunction, "safe-function", "", "Safe function overrider to use for the transaction (optional)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + cmd.Flags().StringVar(&localTokenRaw, "local-token", "", "local-token argument (common.Address)") + cmd.Flags().StringVar(&remoteTokenRaw, "remote-token", "", "remote-token argument (common.Address)") + cmd.Flags().StringVar(&_from0Raw, "-from-0", "", "-from-0 argument (common.Address)") + cmd.Flags().StringVar(&_to0Raw, "-to-0", "", "-to-0 argument (common.Address)") + cmd.Flags().StringVar(&amountRaw, "amount", "", "amount argument") + cmd.Flags().StringVar(&extraDataRaw, "extra-data", "", "extra-data argument ([]byte)") + + return cmd +} +func CreateFinalizeBridgeEthCommand() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc, contractAddressRaw, safeFunction, safeNonceRaw string + var gasLimit uint64 + var simulate bool + var timeout uint + var contractAddress common.Address + var safeAddress, safeApi string + var safeOperationType uint8 + var safeNonce *big.Int + var calldata bool + + var _from0 common.Address + var _from0Raw string + var _to0 common.Address + var _to0Raw string + var amount *big.Int + var amountRaw string + var extraData []byte + var extraDataRaw string + + cmd := &cobra.Command{ + Use: "finalize-bridge-eth", + Short: "Execute the FinalizeBridgeETH method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if !calldata { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + if _from0Raw == "" { + return fmt.Errorf("---from-0 argument not specified") + } else if !common.IsHexAddress(_from0Raw) { + return fmt.Errorf("---from-0 argument is not a valid Ethereum address") + } + _from0 = common.HexToAddress(_from0Raw) + + if _to0Raw == "" { + return fmt.Errorf("---to-0 argument not specified") + } else if !common.IsHexAddress(_to0Raw) { + return fmt.Errorf("---to-0 argument is not a valid Ethereum address") + } + _to0 = common.HexToAddress(_to0Raw) + + if amountRaw == "" { + return fmt.Errorf("--amount argument not specified") + } + amount = new(big.Int) + amount.SetString(amountRaw, 0) + + var extraDataIntermediate []byte + + var extraDataIntermediateHexDecodeErr error + extraDataIntermediate, extraDataIntermediateHexDecodeErr = hex.DecodeString(extraDataRaw) + if extraDataIntermediateHexDecodeErr != nil { + return extraDataIntermediateHexDecodeErr + } + + copy(extraData[:], extraDataIntermediate) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + abi, err := L1StandardBridgeMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + // Generate transaction data (override method name if safe function is specified) + methodName := "finalizeBridgeEth" + if safeFunction != "" { + methodName = safeFunction + } + + txCalldata, err := abi.Pack( + methodName, + _from0, + _to0, + amount, + extraData, + ) + + if err != nil { + return err + } + + if calldata { + txCalldataHex := hex.EncodeToString(txCalldata) + cmd.Println(txCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + session := L1StandardBridgeTransactorSession{ + Contract: &contract.L1StandardBridgeTransactor, + TransactOpts: *transactionOpts, + } + + if safeAddress != "" { + // Create Safe proposal for transaction + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + err = CreateSafeProposal(client, key, common.HexToAddress(safeAddress), contractAddress, txCalldata, value, safeApi, SafeOperationType(safeOperationType), safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + + return nil + } + + transaction, err := session.FinalizeBridgeETH( + + _from0, + _to0, + amount, + extraData, + ) + if err != nil { + return err + } + + cmd.Printf("Transaction hash: %s\n", transaction.Hash().Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + To: &contractAddress, + Data: transaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := transaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 0, "Safe operation type: 0 (Call) or 1 (DelegateCall)") + cmd.Flags().StringVar(&safeFunction, "safe-function", "", "Safe function overrider to use for the transaction (optional)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + cmd.Flags().StringVar(&_from0Raw, "-from-0", "", "-from-0 argument (common.Address)") + cmd.Flags().StringVar(&_to0Raw, "-to-0", "", "-to-0 argument (common.Address)") + cmd.Flags().StringVar(&amountRaw, "amount", "", "amount argument") + cmd.Flags().StringVar(&extraDataRaw, "extra-data", "", "extra-data argument ([]byte)") + + return cmd +} +func CreateFinalizeErc20WithdrawalCommand() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc, contractAddressRaw, safeFunction, safeNonceRaw string + var gasLimit uint64 + var simulate bool + var timeout uint + var contractAddress common.Address + var safeAddress, safeApi string + var safeOperationType uint8 + var safeNonce *big.Int + var calldata bool + + var l1Token common.Address + var l1TokenRaw string + var l2Token common.Address + var l2TokenRaw string + var _from0 common.Address + var _from0Raw string + var _to0 common.Address + var _to0Raw string + var amount *big.Int + var amountRaw string + var extraData []byte + var extraDataRaw string + + cmd := &cobra.Command{ + Use: "finalize-erc-20-withdrawal", + Short: "Execute the FinalizeERC20Withdrawal method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if !calldata { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + if l1TokenRaw == "" { + return fmt.Errorf("--l-1-token argument not specified") + } else if !common.IsHexAddress(l1TokenRaw) { + return fmt.Errorf("--l-1-token argument is not a valid Ethereum address") + } + l1Token = common.HexToAddress(l1TokenRaw) + + if l2TokenRaw == "" { + return fmt.Errorf("--l-2-token argument not specified") + } else if !common.IsHexAddress(l2TokenRaw) { + return fmt.Errorf("--l-2-token argument is not a valid Ethereum address") + } + l2Token = common.HexToAddress(l2TokenRaw) + + if _from0Raw == "" { + return fmt.Errorf("---from-0 argument not specified") + } else if !common.IsHexAddress(_from0Raw) { + return fmt.Errorf("---from-0 argument is not a valid Ethereum address") + } + _from0 = common.HexToAddress(_from0Raw) + + if _to0Raw == "" { + return fmt.Errorf("---to-0 argument not specified") + } else if !common.IsHexAddress(_to0Raw) { + return fmt.Errorf("---to-0 argument is not a valid Ethereum address") + } + _to0 = common.HexToAddress(_to0Raw) + + if amountRaw == "" { + return fmt.Errorf("--amount argument not specified") + } + amount = new(big.Int) + amount.SetString(amountRaw, 0) + + var extraDataIntermediate []byte + + var extraDataIntermediateHexDecodeErr error + extraDataIntermediate, extraDataIntermediateHexDecodeErr = hex.DecodeString(extraDataRaw) + if extraDataIntermediateHexDecodeErr != nil { + return extraDataIntermediateHexDecodeErr + } + + copy(extraData[:], extraDataIntermediate) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + abi, err := L1StandardBridgeMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + // Generate transaction data (override method name if safe function is specified) + methodName := "finalizeErc20Withdrawal" + if safeFunction != "" { + methodName = safeFunction + } + + txCalldata, err := abi.Pack( + methodName, + l1Token, + l2Token, + _from0, + _to0, + amount, + extraData, + ) + + if err != nil { + return err + } + + if calldata { + txCalldataHex := hex.EncodeToString(txCalldata) + cmd.Println(txCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + session := L1StandardBridgeTransactorSession{ + Contract: &contract.L1StandardBridgeTransactor, + TransactOpts: *transactionOpts, + } + + if safeAddress != "" { + // Create Safe proposal for transaction + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + err = CreateSafeProposal(client, key, common.HexToAddress(safeAddress), contractAddress, txCalldata, value, safeApi, SafeOperationType(safeOperationType), safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + + return nil + } + + transaction, err := session.FinalizeERC20Withdrawal( + + l1Token, + l2Token, + _from0, + _to0, + amount, + extraData, + ) + if err != nil { + return err + } + + cmd.Printf("Transaction hash: %s\n", transaction.Hash().Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + To: &contractAddress, + Data: transaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := transaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 0, "Safe operation type: 0 (Call) or 1 (DelegateCall)") + cmd.Flags().StringVar(&safeFunction, "safe-function", "", "Safe function overrider to use for the transaction (optional)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + cmd.Flags().StringVar(&l1TokenRaw, "l-1-token", "", "l-1-token argument (common.Address)") + cmd.Flags().StringVar(&l2TokenRaw, "l-2-token", "", "l-2-token argument (common.Address)") + cmd.Flags().StringVar(&_from0Raw, "-from-0", "", "-from-0 argument (common.Address)") + cmd.Flags().StringVar(&_to0Raw, "-to-0", "", "-to-0 argument (common.Address)") + cmd.Flags().StringVar(&amountRaw, "amount", "", "amount argument") + cmd.Flags().StringVar(&extraDataRaw, "extra-data", "", "extra-data argument ([]byte)") + + return cmd +} +func CreateFinalizeEthwithdrawalCommand() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc, contractAddressRaw, safeFunction, safeNonceRaw string + var gasLimit uint64 + var simulate bool + var timeout uint + var contractAddress common.Address + var safeAddress, safeApi string + var safeOperationType uint8 + var safeNonce *big.Int + var calldata bool + + var _from0 common.Address + var _from0Raw string + var _to0 common.Address + var _to0Raw string + var amount *big.Int + var amountRaw string + var extraData []byte + var extraDataRaw string + + cmd := &cobra.Command{ + Use: "finalize-eth-withdrawal", + Short: "Execute the FinalizeETHWithdrawal method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if !calldata { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + if _from0Raw == "" { + return fmt.Errorf("---from-0 argument not specified") + } else if !common.IsHexAddress(_from0Raw) { + return fmt.Errorf("---from-0 argument is not a valid Ethereum address") + } + _from0 = common.HexToAddress(_from0Raw) + + if _to0Raw == "" { + return fmt.Errorf("---to-0 argument not specified") + } else if !common.IsHexAddress(_to0Raw) { + return fmt.Errorf("---to-0 argument is not a valid Ethereum address") + } + _to0 = common.HexToAddress(_to0Raw) + + if amountRaw == "" { + return fmt.Errorf("--amount argument not specified") + } + amount = new(big.Int) + amount.SetString(amountRaw, 0) + + var extraDataIntermediate []byte + + var extraDataIntermediateHexDecodeErr error + extraDataIntermediate, extraDataIntermediateHexDecodeErr = hex.DecodeString(extraDataRaw) + if extraDataIntermediateHexDecodeErr != nil { + return extraDataIntermediateHexDecodeErr + } + + copy(extraData[:], extraDataIntermediate) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + abi, err := L1StandardBridgeMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + // Generate transaction data (override method name if safe function is specified) + methodName := "finalizeEthwithdrawal" + if safeFunction != "" { + methodName = safeFunction + } + + txCalldata, err := abi.Pack( + methodName, + _from0, + _to0, + amount, + extraData, + ) + + if err != nil { + return err + } + + if calldata { + txCalldataHex := hex.EncodeToString(txCalldata) + cmd.Println(txCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + session := L1StandardBridgeTransactorSession{ + Contract: &contract.L1StandardBridgeTransactor, + TransactOpts: *transactionOpts, + } + + if safeAddress != "" { + // Create Safe proposal for transaction + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + err = CreateSafeProposal(client, key, common.HexToAddress(safeAddress), contractAddress, txCalldata, value, safeApi, SafeOperationType(safeOperationType), safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + + return nil + } + + transaction, err := session.FinalizeETHWithdrawal( + + _from0, + _to0, + amount, + extraData, + ) + if err != nil { + return err + } + + cmd.Printf("Transaction hash: %s\n", transaction.Hash().Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + To: &contractAddress, + Data: transaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := transaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 0, "Safe operation type: 0 (Call) or 1 (DelegateCall)") + cmd.Flags().StringVar(&safeFunction, "safe-function", "", "Safe function overrider to use for the transaction (optional)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + cmd.Flags().StringVar(&_from0Raw, "-from-0", "", "-from-0 argument (common.Address)") + cmd.Flags().StringVar(&_to0Raw, "-to-0", "", "-to-0 argument (common.Address)") + cmd.Flags().StringVar(&amountRaw, "amount", "", "amount argument") + cmd.Flags().StringVar(&extraDataRaw, "extra-data", "", "extra-data argument ([]byte)") + + return cmd +} +func CreateInitializeCommand() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc, contractAddressRaw, safeFunction, safeNonceRaw string + var gasLimit uint64 + var simulate bool + var timeout uint + var contractAddress common.Address + var safeAddress, safeApi string + var safeOperationType uint8 + var safeNonce *big.Int + var calldata bool + + var messenger common.Address + var messengerRaw string + var superchainConfig common.Address + var superchainConfigRaw string + var systemConfig common.Address + var systemConfigRaw string + + cmd := &cobra.Command{ + Use: "initialize", + Short: "Execute the Initialize method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if !calldata { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + if messengerRaw == "" { + return fmt.Errorf("--messenger argument not specified") + } else if !common.IsHexAddress(messengerRaw) { + return fmt.Errorf("--messenger argument is not a valid Ethereum address") + } + messenger = common.HexToAddress(messengerRaw) + + if superchainConfigRaw == "" { + return fmt.Errorf("--superchain-config argument not specified") + } else if !common.IsHexAddress(superchainConfigRaw) { + return fmt.Errorf("--superchain-config argument is not a valid Ethereum address") + } + superchainConfig = common.HexToAddress(superchainConfigRaw) + + if systemConfigRaw == "" { + return fmt.Errorf("--system-config argument not specified") + } else if !common.IsHexAddress(systemConfigRaw) { + return fmt.Errorf("--system-config argument is not a valid Ethereum address") + } + systemConfig = common.HexToAddress(systemConfigRaw) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + abi, err := L1StandardBridgeMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + // Generate transaction data (override method name if safe function is specified) + methodName := "initialize" + if safeFunction != "" { + methodName = safeFunction + } + + txCalldata, err := abi.Pack( + methodName, + messenger, + superchainConfig, + systemConfig, + ) + + if err != nil { + return err + } + + if calldata { + txCalldataHex := hex.EncodeToString(txCalldata) + cmd.Println(txCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + session := L1StandardBridgeTransactorSession{ + Contract: &contract.L1StandardBridgeTransactor, + TransactOpts: *transactionOpts, + } + + if safeAddress != "" { + // Create Safe proposal for transaction + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + err = CreateSafeProposal(client, key, common.HexToAddress(safeAddress), contractAddress, txCalldata, value, safeApi, SafeOperationType(safeOperationType), safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + + return nil + } + + transaction, err := session.Initialize( + + messenger, + superchainConfig, + systemConfig, + ) + if err != nil { + return err + } + + cmd.Printf("Transaction hash: %s\n", transaction.Hash().Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + To: &contractAddress, + Data: transaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := transaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 0, "Safe operation type: 0 (Call) or 1 (DelegateCall)") + cmd.Flags().StringVar(&safeFunction, "safe-function", "", "Safe function overrider to use for the transaction (optional)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + cmd.Flags().StringVar(&messengerRaw, "messenger", "", "messenger argument (common.Address)") + cmd.Flags().StringVar(&superchainConfigRaw, "superchain-config", "", "superchain-config argument (common.Address)") + cmd.Flags().StringVar(&systemConfigRaw, "system-config", "", "system-config argument (common.Address)") + + return cmd +} +func CreateReceiveCommand() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc, contractAddressRaw, safeFunction, safeNonceRaw string + var gasLimit uint64 + var simulate bool + var timeout uint + var contractAddress common.Address + var safeAddress, safeApi string + var safeOperationType uint8 + var safeNonce *big.Int + var calldata bool + + cmd := &cobra.Command{ + Use: "receive", + Short: "Execute the Receive method on a L1StandardBridge contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if !calldata { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + abi, err := L1StandardBridgeMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + // Generate transaction data (override method name if safe function is specified) + methodName := "receive" + if safeFunction != "" { + methodName = safeFunction + } + + txCalldata, err := abi.Pack( + methodName, + ) + + if err != nil { + return err + } + + if calldata { + txCalldataHex := hex.EncodeToString(txCalldata) + cmd.Println(txCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + contract, contractErr := NewL1StandardBridge(contractAddress, client) + if contractErr != nil { + return contractErr + } + + session := L1StandardBridgeTransactorSession{ + Contract: &contract.L1StandardBridgeTransactor, + TransactOpts: *transactionOpts, + } + + if safeAddress != "" { + // Create Safe proposal for transaction + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + err = CreateSafeProposal(client, key, common.HexToAddress(safeAddress), contractAddress, txCalldata, value, safeApi, SafeOperationType(safeOperationType), safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + + return nil + } + + transaction, err := session.Receive() + if err != nil { + return err + } + + cmd.Printf("Transaction hash: %s\n", transaction.Hash().Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + To: &contractAddress, + Data: transaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := transaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 0, "Safe operation type: 0 (Call) or 1 (DelegateCall)") + cmd.Flags().StringVar(&safeFunction, "safe-function", "", "Safe function overrider to use for the transaction (optional)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + return cmd +} + +var ErrNoRPCURL error = errors.New("no RPC URL provided -- please pass an RPC URL from the command line or set the L_1_STANDARD_BRIDGE_RPC_URL environment variable") + +// Generates an Ethereum client to the JSONRPC API at the given URL. If rpcURL is empty, then it +// attempts to read the RPC URL from the L_1_STANDARD_BRIDGE_RPC_URL environment variable. If that is empty, +// too, then it returns an error. +func NewClient(rpcURL string) (*ethclient.Client, error) { + if rpcURL == "" { + rpcURL = os.Getenv("L_1_STANDARD_BRIDGE_RPC_URL") + } + + if rpcURL == "" { + return nil, ErrNoRPCURL + } + + client, err := ethclient.Dial(rpcURL) + return client, err +} + +// Creates a new context to be used when interacting with the chain client. +func NewChainContext(timeout uint) (context.Context, context.CancelFunc) { + baseCtx := context.Background() + parsedTimeout := time.Duration(timeout) * time.Second + ctx, cancel := context.WithTimeout(baseCtx, parsedTimeout) + return ctx, cancel +} + +// Unlocks a key from a keystore (byte contents of a keystore file) with the given password. +func UnlockKeystore(keystoreData []byte, password string) (*keystore.Key, error) { + key, err := keystore.DecryptKey(keystoreData, password) + return key, err +} + +// Loads a key from file, prompting the user for the password if it is not provided as a function argument. +func KeyFromFile(keystoreFile string, password string) (*keystore.Key, error) { + var emptyKey *keystore.Key + keystoreContent, readErr := os.ReadFile(keystoreFile) + if readErr != nil { + return emptyKey, readErr + } + + // If password is "", prompt user for password. + if password == "" { + fmt.Printf("Please provide a password for keystore (%s): ", keystoreFile) + passwordRaw, inputErr := term.ReadPassword(int(os.Stdin.Fd())) + if inputErr != nil { + return emptyKey, fmt.Errorf("error reading password: %s", inputErr.Error()) + } + fmt.Print("\n") + password = string(passwordRaw) + } + + key, err := UnlockKeystore(keystoreContent, password) + return key, err +} + +// This method is used to set the parameters on a view call from command line arguments (represented mostly as +// strings). +func SetCallParametersFromArgs(opts *bind.CallOpts, pending bool, fromAddress, blockNumber string) { + if pending { + opts.Pending = true + } + + if fromAddress != "" { + opts.From = common.HexToAddress(fromAddress) + } + + if blockNumber != "" { + opts.BlockNumber = new(big.Int) + opts.BlockNumber.SetString(blockNumber, 0) + } +} + +// This method is used to set the parameters on a transaction from command line arguments (represented mostly as +// strings). +func SetTransactionParametersFromArgs(opts *bind.TransactOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas string, gasLimit uint64, noSend bool) { + if nonce != "" { + opts.Nonce = new(big.Int) + opts.Nonce.SetString(nonce, 0) + } + + if value != "" { + opts.Value = new(big.Int) + opts.Value.SetString(value, 0) + } + + if gasPrice != "" { + opts.GasPrice = new(big.Int) + opts.GasPrice.SetString(gasPrice, 0) + } + + if maxFeePerGas != "" { + opts.GasFeeCap = new(big.Int) + opts.GasFeeCap.SetString(maxFeePerGas, 0) + } + + if maxPriorityFeePerGas != "" { + opts.GasTipCap = new(big.Int) + opts.GasTipCap.SetString(maxPriorityFeePerGas, 0) + } + + if gasLimit != 0 { + opts.GasLimit = gasLimit + } + + opts.NoSend = noSend +} + +func CreateL1StandardBridgeCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "l-1-standard-bridge", + Short: "Interact with the L1StandardBridge contract", + Run: func(cmd *cobra.Command, args []string) { + cmd.Help() + }, + } + + cmd.SetOut(os.Stdout) + + DeployGroup := &cobra.Group{ + ID: "deploy", Title: "Commands which deploy contracts", + } + cmd.AddGroup(DeployGroup) + ViewGroup := &cobra.Group{ + ID: "view", Title: "Commands which view contract state", + } + TransactGroup := &cobra.Group{ + ID: "transact", Title: "Commands which submit transactions", + } + cmd.AddGroup(ViewGroup, TransactGroup) + + cmdDeployL1StandardBridge := CreateL1StandardBridgeDeploymentCommand() + cmdDeployL1StandardBridge.GroupID = DeployGroup.ID + cmd.AddCommand(cmdDeployL1StandardBridge) + + cmdViewDeposits := CreateDepositsCommand() + cmdViewDeposits.GroupID = ViewGroup.ID + cmd.AddCommand(cmdViewDeposits) + cmdViewL2TokenBridge := CreateL2TokenBridgeCommand() + cmdViewL2TokenBridge.GroupID = ViewGroup.ID + cmd.AddCommand(cmdViewL2TokenBridge) + cmdViewMESSENGER := CreateMessengerCommand() + cmdViewMESSENGER.GroupID = ViewGroup.ID + cmd.AddCommand(cmdViewMESSENGER) + cmdViewMessenger := CreateMessengerCommand() + cmdViewMessenger.GroupID = ViewGroup.ID + cmd.AddCommand(cmdViewMessenger) + cmdViewOTHERBRIDGE := CreateOtherbridgeCommand() + cmdViewOTHERBRIDGE.GroupID = ViewGroup.ID + cmd.AddCommand(cmdViewOTHERBRIDGE) + cmdViewOtherBridge := CreateOtherBridgeCommand() + cmdViewOtherBridge.GroupID = ViewGroup.ID + cmd.AddCommand(cmdViewOtherBridge) + cmdViewPaused := CreatePausedCommand() + cmdViewPaused.GroupID = ViewGroup.ID + cmd.AddCommand(cmdViewPaused) + cmdViewSuperchainConfig := CreateSuperchainConfigCommand() + cmdViewSuperchainConfig.GroupID = ViewGroup.ID + cmd.AddCommand(cmdViewSuperchainConfig) + cmdViewSystemConfig := CreateSystemConfigCommand() + cmdViewSystemConfig.GroupID = ViewGroup.ID + cmd.AddCommand(cmdViewSystemConfig) + cmdViewVersion := CreateVersionCommand() + cmdViewVersion.GroupID = ViewGroup.ID + cmd.AddCommand(cmdViewVersion) + + cmdTransactBridgeERC20 := CreateBridgeErc20Command() + cmdTransactBridgeERC20.GroupID = TransactGroup.ID + cmd.AddCommand(cmdTransactBridgeERC20) + cmdTransactBridgeERC20To := CreateBridgeErc20ToCommand() + cmdTransactBridgeERC20To.GroupID = TransactGroup.ID + cmd.AddCommand(cmdTransactBridgeERC20To) + cmdTransactBridgeETH := CreateBridgeEthCommand() + cmdTransactBridgeETH.GroupID = TransactGroup.ID + cmd.AddCommand(cmdTransactBridgeETH) + cmdTransactBridgeETHTo := CreateBridgeEthtoCommand() + cmdTransactBridgeETHTo.GroupID = TransactGroup.ID + cmd.AddCommand(cmdTransactBridgeETHTo) + cmdTransactDepositERC20 := CreateDepositErc20Command() + cmdTransactDepositERC20.GroupID = TransactGroup.ID + cmd.AddCommand(cmdTransactDepositERC20) + cmdTransactDepositERC20To := CreateDepositErc20ToCommand() + cmdTransactDepositERC20To.GroupID = TransactGroup.ID + cmd.AddCommand(cmdTransactDepositERC20To) + cmdTransactDepositETH := CreateDepositEthCommand() + cmdTransactDepositETH.GroupID = TransactGroup.ID + cmd.AddCommand(cmdTransactDepositETH) + cmdTransactDepositETHTo := CreateDepositEthtoCommand() + cmdTransactDepositETHTo.GroupID = TransactGroup.ID + cmd.AddCommand(cmdTransactDepositETHTo) + cmdTransactFinalizeBridgeERC20 := CreateFinalizeBridgeErc20Command() + cmdTransactFinalizeBridgeERC20.GroupID = TransactGroup.ID + cmd.AddCommand(cmdTransactFinalizeBridgeERC20) + cmdTransactFinalizeBridgeETH := CreateFinalizeBridgeEthCommand() + cmdTransactFinalizeBridgeETH.GroupID = TransactGroup.ID + cmd.AddCommand(cmdTransactFinalizeBridgeETH) + cmdTransactFinalizeERC20Withdrawal := CreateFinalizeErc20WithdrawalCommand() + cmdTransactFinalizeERC20Withdrawal.GroupID = TransactGroup.ID + cmd.AddCommand(cmdTransactFinalizeERC20Withdrawal) + cmdTransactFinalizeETHWithdrawal := CreateFinalizeEthwithdrawalCommand() + cmdTransactFinalizeETHWithdrawal.GroupID = TransactGroup.ID + cmd.AddCommand(cmdTransactFinalizeETHWithdrawal) + cmdTransactInitialize := CreateInitializeCommand() + cmdTransactInitialize.GroupID = TransactGroup.ID + cmd.AddCommand(cmdTransactInitialize) + cmdTransactReceive := CreateReceiveCommand() + cmdTransactReceive.GroupID = TransactGroup.ID + cmd.AddCommand(cmdTransactReceive) + + return cmd +} + +// SafeOperationType represents the type of operation for a Safe transaction +type SafeOperationType uint8 + +const ( + Call SafeOperationType = 0 + DelegateCall SafeOperationType = 1 +) + +// String returns the string representation of the SafeOperationType +func (o SafeOperationType) String() string { + switch o { + case Call: + return "Call" + case DelegateCall: + return "DelegateCall" + default: + return "Unknown" + } +} + +// SafeTransactionData represents the data for a Safe transaction +type SafeTransactionData struct { + To string `json:"to"` + Value string `json:"value"` + Data string `json:"data"` + Operation SafeOperationType `json:"operation"` + SafeTxGas uint64 `json:"safeTxGas"` + BaseGas uint64 `json:"baseGas"` + GasPrice string `json:"gasPrice"` + GasToken string `json:"gasToken"` + RefundReceiver string `json:"refundReceiver"` + Nonce *big.Int `json:"nonce"` + SafeTxHash string `json:"safeTxHash"` + Sender string `json:"sender"` + Signature string `json:"signature"` + Origin string `json:"origin"` +} + +const ( + NativeTokenAddress = "0x0000000000000000000000000000000000000000" +) + +func DeployWithSafe(client *ethclient.Client, key *keystore.Key, safeAddress common.Address, factoryAddress common.Address, value *big.Int, safeApi string, deployBytecode []byte, safeOperationType SafeOperationType, salt [32]byte, safeNonce *big.Int) error { + abi, err := CreateCall.CreateCallMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + safeCreateCallTxData, err := abi.Pack("performCreate2", value, deployBytecode, salt) + if err != nil { + return fmt.Errorf("failed to pack performCreate2 transaction: %v", err) + } + + return CreateSafeProposal(client, key, safeAddress, factoryAddress, safeCreateCallTxData, value, safeApi, SafeOperationType(safeOperationType), safeNonce) +} + +func PredictDeploymentAddressSafe(from common.Address, salt [32]byte, deployBytecode []byte) (common.Address, error) { + // Calculate the hash of the init code (deployment bytecode) + initCodeHash := crypto.Keccak256(deployBytecode) + + // Calculate the CREATE2 address + deployedAddress := crypto.CreateAddress2(from, salt, initCodeHash) + + return deployedAddress, nil +} + +func CreateSafeProposal(client *ethclient.Client, key *keystore.Key, safeAddress common.Address, to common.Address, data []byte, value *big.Int, safeApi string, safeOperationType SafeOperationType, safeNonce *big.Int) error { + chainID, err := client.ChainID(context.Background()) + if err != nil { + return fmt.Errorf("failed to get chain ID: %v", err) + } + + // Create a new instance of the GnosisSafe contract + safeInstance, err := GnosisSafe.NewGnosisSafe(safeAddress, client) + if err != nil { + return fmt.Errorf("failed to create GnosisSafe instance: %v", err) + } + + nonce := safeNonce + if safeNonce == nil { + // Fetch the current nonce from the Safe contract + fetchedNonce, err := safeInstance.Nonce(&bind.CallOpts{}) + if err != nil { + return fmt.Errorf("failed to fetch nonce from Safe contract: %v", err) + } + nonce = fetchedNonce + } else { + nonce = safeNonce + } + + safeTransactionData := SafeTransactionData{ + To: to.Hex(), + Value: value.String(), + Data: common.Bytes2Hex(data), + Operation: safeOperationType, + SafeTxGas: 0, + BaseGas: 0, + GasPrice: "0", + GasToken: NativeTokenAddress, + RefundReceiver: NativeTokenAddress, + Nonce: nonce, + } + + // Calculate SafeTxHash + safeTxHash, err := CalculateSafeTxHash(safeAddress, safeTransactionData, chainID) + if err != nil { + return fmt.Errorf("failed to calculate SafeTxHash: %v", err) + } + + // Sign the SafeTxHash + signature, err := crypto.Sign(safeTxHash.Bytes(), key.PrivateKey) + if err != nil { + return fmt.Errorf("failed to sign SafeTxHash: %v", err) + } + + // Adjust V value for Ethereum's replay protection + signature[64] += 27 + + // Convert signature to hex + senderSignature := "0x" + common.Bytes2Hex(signature) + + // Prepare the request body + requestBody := map[string]interface{}{ + "to": safeTransactionData.To, + "value": safeTransactionData.Value, + "data": "0x" + safeTransactionData.Data, + "operation": int(safeTransactionData.Operation), + "safeTxGas": fmt.Sprintf("%d", safeTransactionData.SafeTxGas), + "baseGas": fmt.Sprintf("%d", safeTransactionData.BaseGas), + "gasPrice": safeTransactionData.GasPrice, + "gasToken": safeTransactionData.GasToken, + "refundReceiver": safeTransactionData.RefundReceiver, + "nonce": fmt.Sprintf("%d", safeTransactionData.Nonce), + "safeTxHash": safeTxHash.Hex(), + "sender": key.Address.Hex(), + "signature": senderSignature, + "origin": fmt.Sprintf("{\"url\":\"%s\",\"name\":\"TokenSender Deployment\"}", safeApi), + } + + // Marshal the request body to JSON + jsonBody, err := json.Marshal(requestBody) + if err != nil { + return fmt.Errorf("failed to marshal request body: %v", err) + } + + // Send the request to the Safe Transaction Service + req, err := http.NewRequest("POST", safeApi, bytes.NewBuffer(jsonBody)) + if err != nil { + return fmt.Errorf("failed to create request: %v", err) + } + + req.Header.Set("Content-Type", "application/json") + + httpClient := &http.Client{} + resp, err := httpClient.Do(req) + if err != nil { + return fmt.Errorf("failed to send request: %v", err) + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated { + return fmt.Errorf("unexpected status code: %d", resp.StatusCode) + } + + fmt.Println("Safe proposal created successfully") + return nil +} + +func CalculateSafeTxHash(safeAddress common.Address, txData SafeTransactionData, chainID *big.Int) (common.Hash, error) { + domainSeparator := apitypes.TypedDataDomain{ + ChainId: (*math.HexOrDecimal256)(chainID), + VerifyingContract: safeAddress.Hex(), + } + + typedData := apitypes.TypedData{ + Types: apitypes.Types{ + "EIP712Domain": []apitypes.Type{ + {Name: "chainId", Type: "uint256"}, + {Name: "verifyingContract", Type: "address"}, + }, + "SafeTx": []apitypes.Type{ + {Name: "to", Type: "address"}, + {Name: "value", Type: "uint256"}, + {Name: "data", Type: "bytes"}, + {Name: "operation", Type: "uint8"}, + {Name: "safeTxGas", Type: "uint256"}, + {Name: "baseGas", Type: "uint256"}, + {Name: "gasPrice", Type: "uint256"}, + {Name: "gasToken", Type: "address"}, + {Name: "refundReceiver", Type: "address"}, + {Name: "nonce", Type: "uint256"}, + }, + }, + Domain: domainSeparator, + PrimaryType: "SafeTx", + Message: apitypes.TypedDataMessage{ + "to": txData.To, + "value": txData.Value, + "data": "0x" + txData.Data, + "operation": fmt.Sprintf("%d", txData.Operation), + "safeTxGas": fmt.Sprintf("%d", txData.SafeTxGas), + "baseGas": fmt.Sprintf("%d", txData.BaseGas), + "gasPrice": txData.GasPrice, + "gasToken": txData.GasToken, + "refundReceiver": txData.RefundReceiver, + "nonce": fmt.Sprintf("%d", txData.Nonce), + }, + } + + typedDataHash, _, err := apitypes.TypedDataAndHash(typedData) + if err != nil { + return common.Hash{}, fmt.Errorf("failed to hash typed data: %v", err) + } + + return common.BytesToHash(typedDataHash), nil +} diff --git a/bindings/OptimismMintableERC20Factory/OptimismMintableERC20Factory.go b/bindings/OptimismMintableERC20Factory/OptimismMintableERC20Factory.go new file mode 100644 index 0000000..ecf020c --- /dev/null +++ b/bindings/OptimismMintableERC20Factory/OptimismMintableERC20Factory.go @@ -0,0 +1,2479 @@ +// This file was generated by seer: https://github.com/G7DAO/seer. +// seer version: 0.3.15 +// seer command: seer evm generate --package OptimismMintableERC20Factory --cli --foundry ../../base-org/optimism/packages/contracts-bedrock/forge-artifacts/OptimismMintableERC20Factory.sol/OptimismMintableERC20Factory.json --struct OptimismMintableERC20Factory --output bindings/OptimismMintableERC20Factory/OptimismMintableERC20Factory.go +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package OptimismMintableERC20Factory + +import ( + "bytes" + "crypto/rand" + "errors" + "math/big" + "net/http" + "strings" + + "context" + + 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" + "github.com/ethereum/go-ethereum/signer/core/apitypes" + + // Reference imports to suppress errors if they are not otherwise used. + "encoding/hex" + "encoding/json" + "fmt" + "os" + "time" + + "github.com/G7DAO/seer/bindings/CreateCall" + "github.com/G7DAO/seer/bindings/GnosisSafe" + "github.com/ethereum/go-ethereum/accounts/keystore" + "github.com/ethereum/go-ethereum/ethclient" + "github.com/spf13/cobra" + "golang.org/x/term" + + // OptimismMintableERC20FactoryMetaData contains all meta data concerning the OptimismMintableERC20Factory contract. + "github.com/ethereum/go-ethereum/common/math" + "github.com/ethereum/go-ethereum/crypto" +) + +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +var OptimismMintableERC20FactoryMetaData = &bind.MetaData{ + ABI: "[{\"type\":\"constructor\",\"inputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"BRIDGE\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"bridge\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"createOptimismMintableERC20\",\"inputs\":[{\"name\":\"_remoteToken\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_name\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"_symbol\",\"type\":\"string\",\"internalType\":\"string\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"createOptimismMintableERC20WithDecimals\",\"inputs\":[{\"name\":\"_remoteToken\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_name\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"_symbol\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"_decimals\",\"type\":\"uint8\",\"internalType\":\"uint8\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"createStandardL2Token\",\"inputs\":[{\"name\":\"_remoteToken\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"_name\",\"type\":\"string\",\"internalType\":\"string\"},{\"name\":\"_symbol\",\"type\":\"string\",\"internalType\":\"string\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"initialize\",\"inputs\":[{\"name\":\"_bridge\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"function\",\"name\":\"version\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"string\",\"internalType\":\"string\"}],\"stateMutability\":\"view\"},{\"type\":\"event\",\"name\":\"Initialized\",\"inputs\":[{\"name\":\"version\",\"type\":\"uint8\",\"indexed\":false,\"internalType\":\"uint8\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OptimismMintableERC20Created\",\"inputs\":[{\"name\":\"localToken\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"remoteToken\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"deployer\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"StandardL2TokenCreated\",\"inputs\":[{\"name\":\"remoteToken\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"localToken\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"}],\"anonymous\":false}]", + Bin: "0x608060405234801561001057600080fd5b5061001b6000610020565b610169565b600054610100900460ff16158080156100405750600054600160ff909116105b8061006b57506100593061015a60201b61059d1760201c565b15801561006b575060005460ff166001145b6100d25760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b6000805460ff1916600117905580156100f5576000805461ff0019166101001790555b600180546001600160a01b0319166001600160a01b0384161790558015610156576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b6001600160a01b03163b151590565b6120e5806101786000396000f3fe60806040523480156200001157600080fd5b5060043610620000875760003560e01c8063c4d66de81162000062578063c4d66de81462000135578063ce5ac90f146200014e578063e78cea921462000165578063ee9a31a2146200018657600080fd5b806354fd4d50146200008c578063896f93d114620000e15780638cf0629c146200011e575b600080fd5b620000c96040518060400160405280600581526020017f312e392e3000000000000000000000000000000000000000000000000000000081525081565b604051620000d8919062000635565b60405180910390f35b620000f8620000f23660046200075d565b620001a5565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001620000d8565b620000f86200012f366004620007da565b620001bc565b6200014c6200014636600462000871565b620003ba565b005b620000f86200015f3660046200075d565b6200058c565b600154620000f89073ffffffffffffffffffffffffffffffffffffffff1681565b60015473ffffffffffffffffffffffffffffffffffffffff16620000f8565b6000620001b48484846200058c565b949350505050565b600073ffffffffffffffffffffffffffffffffffffffff851662000267576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603f60248201527f4f7074696d69736d4d696e7461626c654552433230466163746f72793a206d7560448201527f73742070726f766964652072656d6f746520746f6b656e20616464726573730060648201526084015b60405180910390fd5b6000858585856040516020016200028294939291906200088f565b604051602081830303815290604052805190602001209050600081600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1688888888604051620002d290620005b9565b620002e2959493929190620008e9565b8190604051809103906000f590508015801562000303573d6000803e3d6000fd5b5090508073ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167fceeb8e7d520d7f3b65fc11a262b91066940193b05d4f93df07cfdced0eb551cf60405160405180910390a360405133815273ffffffffffffffffffffffffffffffffffffffff80891691908316907f52fe89dd5930f343d25650b62fd367bae47088bcddffd2a88350a6ecdd620cdb9060200160405180910390a39695505050505050565b600054610100900460ff1615808015620003db5750600054600160ff909116105b80620003f75750303b158015620003f7575060005460ff166001145b62000485576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016200025e565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790558015620004e457600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff841617905580156200058857600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b6000620001b48484846012620001bc565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b61178a806200094f83390190565b6000815180845260005b81811015620005ef57602081850181015186830182015201620005d1565b8181111562000602576000602083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006200064a6020830184620005c7565b9392505050565b803573ffffffffffffffffffffffffffffffffffffffff811681146200067657600080fd5b919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f830112620006bc57600080fd5b813567ffffffffffffffff80821115620006da57620006da6200067b565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156200072357620007236200067b565b816040528381528660208588010111156200073d57600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000606084860312156200077357600080fd5b6200077e8462000651565b9250602084013567ffffffffffffffff808211156200079c57600080fd5b620007aa87838801620006aa565b93506040860135915080821115620007c157600080fd5b50620007d086828701620006aa565b9150509250925092565b60008060008060808587031215620007f157600080fd5b620007fc8562000651565b9350602085013567ffffffffffffffff808211156200081a57600080fd5b6200082888838901620006aa565b945060408701359150808211156200083f57600080fd5b506200084e87828801620006aa565b925050606085013560ff811681146200086657600080fd5b939692955090935050565b6000602082840312156200088457600080fd5b6200064a8262000651565b73ffffffffffffffffffffffffffffffffffffffff85168152608060208201526000620008c06080830186620005c7565b8281036040840152620008d48186620005c7565b91505060ff8316606083015295945050505050565b600073ffffffffffffffffffffffffffffffffffffffff808816835280871660208401525060a060408301526200092460a0830186620005c7565b8281036060840152620009388186620005c7565b91505060ff83166080830152969550505050505056fe60e06040523480156200001157600080fd5b506040516200178a3803806200178a833981016040819052620000349162000163565b828260036200004483826200029e565b5060046200005382826200029e565b5050506001600160a01b039384166080529390921660a052505060ff1660c0526200036a565b80516001600160a01b03811681146200009157600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620000be57600080fd5b81516001600160401b0380821115620000db57620000db62000096565b604051601f8301601f19908116603f0116810190828211818310171562000106576200010662000096565b816040528381526020925086838588010111156200012357600080fd5b600091505b8382101562000147578582018301518183018401529082019062000128565b83821115620001595760008385830101525b9695505050505050565b600080600080600060a086880312156200017c57600080fd5b620001878662000079565b9450620001976020870162000079565b60408701519094506001600160401b0380821115620001b557600080fd5b620001c389838a01620000ac565b94506060880151915080821115620001da57600080fd5b50620001e988828901620000ac565b925050608086015160ff811681146200020157600080fd5b809150509295509295909350565b600181811c908216806200022457607f821691505b6020821081036200024557634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200029957600081815260208120601f850160051c81016020861015620002745750805b601f850160051c820191505b81811015620002955782815560010162000280565b5050505b505050565b81516001600160401b03811115620002ba57620002ba62000096565b620002d281620002cb84546200020f565b846200024b565b602080601f8311600181146200030a5760008415620002f15750858301515b600019600386901b1c1916600185901b17855562000295565b600085815260208120601f198616915b828110156200033b578886015182559484019460019091019084016200031a565b50858210156200035a5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a05160c0516113d4620003b6600039600061024401526000818161034b015281816103e001528181610625015261075c0152600081816101a9015261037101526113d46000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063ae1f6aaf1161008c578063dd62ed3e11610066578063dd62ed3e14610395578063e78cea9214610349578063ee9a31a2146103db57600080fd5b8063ae1f6aaf14610349578063c01e1bd61461036f578063d6c0b2c41461036f57600080fd5b80639dc29fac116100bd5780639dc29fac14610310578063a457c2d714610323578063a9059cbb1461033657600080fd5b806370a08231146102d257806395d89b411461030857600080fd5b806323b872dd1161012f5780633950935111610114578063395093511461026e57806340c10f191461028157806354fd4d501461029657600080fd5b806323b872dd1461022a578063313ce5671461023d57600080fd5b806306fdde031161016057806306fdde03146101f0578063095ea7b31461020557806318160ddd1461021857600080fd5b806301ffc9a71461017c578063033964be146101a4575b600080fd5b61018f61018a36600461117d565b610402565b60405190151581526020015b60405180910390f35b6101cb7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161019b565b6101f86104f3565b60405161019b91906111c6565b61018f610213366004611262565b610585565b6002545b60405190815260200161019b565b61018f61023836600461128c565b61059d565b60405160ff7f000000000000000000000000000000000000000000000000000000000000000016815260200161019b565b61018f61027c366004611262565b6105c1565b61029461028f366004611262565b61060d565b005b6101f86040518060400160405280600581526020017f312e332e3000000000000000000000000000000000000000000000000000000081525081565b61021c6102e03660046112c8565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6101f8610735565b61029461031e366004611262565b610744565b61018f610331366004611262565b61085b565b61018f610344366004611262565b61092c565b7f00000000000000000000000000000000000000000000000000000000000000006101cb565b7f00000000000000000000000000000000000000000000000000000000000000006101cb565b61021c6103a33660046112e3565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101cb7f000000000000000000000000000000000000000000000000000000000000000081565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007f1d1d8b63000000000000000000000000000000000000000000000000000000007fec4fc8e3000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000085168314806104bb57507fffffffff00000000000000000000000000000000000000000000000000000000858116908316145b806104ea57507fffffffff00000000000000000000000000000000000000000000000000000000858116908216145b95945050505050565b60606003805461050290611316565b80601f016020809104026020016040519081016040528092919081815260200182805461052e90611316565b801561057b5780601f106105505761010080835404028352916020019161057b565b820191906000526020600020905b81548152906001019060200180831161055e57829003601f168201915b5050505050905090565b60003361059381858561093a565b5060019392505050565b6000336105ab858285610aee565b6105b6858585610bc5565b506001949350505050565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091906105939082908690610608908790611398565b61093a565b3373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016146106d7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603460248201527f4f7074696d69736d4d696e7461626c6545524332303a206f6e6c79206272696460448201527f67652063616e206d696e7420616e64206275726e00000000000000000000000060648201526084015b60405180910390fd5b6106e18282610e78565b8173ffffffffffffffffffffffffffffffffffffffff167f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d41213968858260405161072991815260200190565b60405180910390a25050565b60606004805461050290611316565b3373ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610809576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603460248201527f4f7074696d69736d4d696e7461626c6545524332303a206f6e6c79206272696460448201527f67652063616e206d696e7420616e64206275726e00000000000000000000000060648201526084016106ce565b6108138282610f98565b8173ffffffffffffffffffffffffffffffffffffffff167fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca58260405161072991815260200190565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff871684529091528120549091908381101561091f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f00000000000000000000000000000000000000000000000000000060648201526084016106ce565b6105b6828686840361093a565b600033610593818585610bc5565b73ffffffffffffffffffffffffffffffffffffffff83166109dc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016106ce565b73ffffffffffffffffffffffffffffffffffffffff8216610a7f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f737300000000000000000000000000000000000000000000000000000000000060648201526084016106ce565b73ffffffffffffffffffffffffffffffffffffffff83811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610bbf5781811015610bb2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e636500000060448201526064016106ce565b610bbf848484840361093a565b50505050565b73ffffffffffffffffffffffffffffffffffffffff8316610c68576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f647265737300000000000000000000000000000000000000000000000000000060648201526084016106ce565b73ffffffffffffffffffffffffffffffffffffffff8216610d0b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f657373000000000000000000000000000000000000000000000000000000000060648201526084016106ce565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015610dc1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e6365000000000000000000000000000000000000000000000000000060648201526084016106ce565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260208190526040808220858503905591851681529081208054849290610e05908490611398565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610e6b91815260200190565b60405180910390a3610bbf565b73ffffffffffffffffffffffffffffffffffffffff8216610ef5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016106ce565b8060026000828254610f079190611398565b909155505073ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604081208054839290610f41908490611398565b909155505060405181815273ffffffffffffffffffffffffffffffffffffffff8316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b73ffffffffffffffffffffffffffffffffffffffff821661103b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f730000000000000000000000000000000000000000000000000000000000000060648201526084016106ce565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260208190526040902054818110156110f1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f636500000000000000000000000000000000000000000000000000000000000060648201526084016106ce565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260208190526040812083830390556002805484929061112d9084906113b0565b909155505060405182815260009073ffffffffffffffffffffffffffffffffffffffff8516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602001610ae1565b60006020828403121561118f57600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146111bf57600080fd5b9392505050565b600060208083528351808285015260005b818110156111f3578581018301518582016040015282016111d7565b81811115611205576000604083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016929092016040019392505050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461125d57600080fd5b919050565b6000806040838503121561127557600080fd5b61127e83611239565b946020939093013593505050565b6000806000606084860312156112a157600080fd5b6112aa84611239565b92506112b860208501611239565b9150604084013590509250925092565b6000602082840312156112da57600080fd5b6111bf82611239565b600080604083850312156112f657600080fd5b6112ff83611239565b915061130d60208401611239565b90509250929050565b600181811c9082168061132a57607f821691505b602082108103611363577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082198211156113ab576113ab611369565b500190565b6000828210156113c2576113c2611369565b50039056fea164736f6c634300080f000aa164736f6c634300080f000a", +} + +// OptimismMintableERC20FactoryABI is the input ABI used to generate the binding from. +// Deprecated: Use OptimismMintableERC20FactoryMetaData.ABI instead. +var OptimismMintableERC20FactoryABI = OptimismMintableERC20FactoryMetaData.ABI + +// OptimismMintableERC20FactoryBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use OptimismMintableERC20FactoryMetaData.Bin instead. +var OptimismMintableERC20FactoryBin = OptimismMintableERC20FactoryMetaData.Bin + +// DeployOptimismMintableERC20Factory deploys a new Ethereum contract, binding an instance of OptimismMintableERC20Factory to it. +func DeployOptimismMintableERC20Factory(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *OptimismMintableERC20Factory, error) { + parsed, err := OptimismMintableERC20FactoryMetaData.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(OptimismMintableERC20FactoryBin), backend) + if err != nil { + return common.Address{}, nil, nil, err + } + return address, tx, &OptimismMintableERC20Factory{OptimismMintableERC20FactoryCaller: OptimismMintableERC20FactoryCaller{contract: contract}, OptimismMintableERC20FactoryTransactor: OptimismMintableERC20FactoryTransactor{contract: contract}, OptimismMintableERC20FactoryFilterer: OptimismMintableERC20FactoryFilterer{contract: contract}}, nil +} + +// OptimismMintableERC20Factory is an auto generated Go binding around an Ethereum contract. +type OptimismMintableERC20Factory struct { + OptimismMintableERC20FactoryCaller // Read-only binding to the contract + OptimismMintableERC20FactoryTransactor // Write-only binding to the contract + OptimismMintableERC20FactoryFilterer // Log filterer for contract events +} + +// OptimismMintableERC20FactoryCaller is an auto generated read-only Go binding around an Ethereum contract. +type OptimismMintableERC20FactoryCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// OptimismMintableERC20FactoryTransactor is an auto generated write-only Go binding around an Ethereum contract. +type OptimismMintableERC20FactoryTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// OptimismMintableERC20FactoryFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type OptimismMintableERC20FactoryFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// OptimismMintableERC20FactorySession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type OptimismMintableERC20FactorySession struct { + Contract *OptimismMintableERC20Factory // 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 +} + +// OptimismMintableERC20FactoryCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type OptimismMintableERC20FactoryCallerSession struct { + Contract *OptimismMintableERC20FactoryCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// OptimismMintableERC20FactoryTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type OptimismMintableERC20FactoryTransactorSession struct { + Contract *OptimismMintableERC20FactoryTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// OptimismMintableERC20FactoryRaw is an auto generated low-level Go binding around an Ethereum contract. +type OptimismMintableERC20FactoryRaw struct { + Contract *OptimismMintableERC20Factory // Generic contract binding to access the raw methods on +} + +// OptimismMintableERC20FactoryCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type OptimismMintableERC20FactoryCallerRaw struct { + Contract *OptimismMintableERC20FactoryCaller // Generic read-only contract binding to access the raw methods on +} + +// OptimismMintableERC20FactoryTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type OptimismMintableERC20FactoryTransactorRaw struct { + Contract *OptimismMintableERC20FactoryTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewOptimismMintableERC20Factory creates a new instance of OptimismMintableERC20Factory, bound to a specific deployed contract. +func NewOptimismMintableERC20Factory(address common.Address, backend bind.ContractBackend) (*OptimismMintableERC20Factory, error) { + contract, err := bindOptimismMintableERC20Factory(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &OptimismMintableERC20Factory{OptimismMintableERC20FactoryCaller: OptimismMintableERC20FactoryCaller{contract: contract}, OptimismMintableERC20FactoryTransactor: OptimismMintableERC20FactoryTransactor{contract: contract}, OptimismMintableERC20FactoryFilterer: OptimismMintableERC20FactoryFilterer{contract: contract}}, nil +} + +// NewOptimismMintableERC20FactoryCaller creates a new read-only instance of OptimismMintableERC20Factory, bound to a specific deployed contract. +func NewOptimismMintableERC20FactoryCaller(address common.Address, caller bind.ContractCaller) (*OptimismMintableERC20FactoryCaller, error) { + contract, err := bindOptimismMintableERC20Factory(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &OptimismMintableERC20FactoryCaller{contract: contract}, nil +} + +// NewOptimismMintableERC20FactoryTransactor creates a new write-only instance of OptimismMintableERC20Factory, bound to a specific deployed contract. +func NewOptimismMintableERC20FactoryTransactor(address common.Address, transactor bind.ContractTransactor) (*OptimismMintableERC20FactoryTransactor, error) { + contract, err := bindOptimismMintableERC20Factory(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &OptimismMintableERC20FactoryTransactor{contract: contract}, nil +} + +// NewOptimismMintableERC20FactoryFilterer creates a new log filterer instance of OptimismMintableERC20Factory, bound to a specific deployed contract. +func NewOptimismMintableERC20FactoryFilterer(address common.Address, filterer bind.ContractFilterer) (*OptimismMintableERC20FactoryFilterer, error) { + contract, err := bindOptimismMintableERC20Factory(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &OptimismMintableERC20FactoryFilterer{contract: contract}, nil +} + +// bindOptimismMintableERC20Factory binds a generic wrapper to an already deployed contract. +func bindOptimismMintableERC20Factory(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := OptimismMintableERC20FactoryMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _OptimismMintableERC20Factory.Contract.OptimismMintableERC20FactoryCaller.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 (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _OptimismMintableERC20Factory.Contract.OptimismMintableERC20FactoryTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _OptimismMintableERC20Factory.Contract.OptimismMintableERC20FactoryTransactor.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 (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _OptimismMintableERC20Factory.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 (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _OptimismMintableERC20Factory.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _OptimismMintableERC20Factory.Contract.contract.Transact(opts, method, params...) +} + +// BRIDGE is a free data retrieval call binding the contract method 0xee9a31a2. +// +// Solidity: function BRIDGE() view returns(address) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryCaller) BRIDGE(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _OptimismMintableERC20Factory.contract.Call(opts, &out, "BRIDGE") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// BRIDGE is a free data retrieval call binding the contract method 0xee9a31a2. +// +// Solidity: function BRIDGE() view returns(address) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactorySession) BRIDGE() (common.Address, error) { + return _OptimismMintableERC20Factory.Contract.BRIDGE(&_OptimismMintableERC20Factory.CallOpts) +} + +// BRIDGE is a free data retrieval call binding the contract method 0xee9a31a2. +// +// Solidity: function BRIDGE() view returns(address) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryCallerSession) BRIDGE() (common.Address, error) { + return _OptimismMintableERC20Factory.Contract.BRIDGE(&_OptimismMintableERC20Factory.CallOpts) +} + +// Bridge is a free data retrieval call binding the contract method 0xe78cea92. +// +// Solidity: function bridge() view returns(address) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryCaller) Bridge(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _OptimismMintableERC20Factory.contract.Call(opts, &out, "bridge") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Bridge is a free data retrieval call binding the contract method 0xe78cea92. +// +// Solidity: function bridge() view returns(address) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactorySession) Bridge() (common.Address, error) { + return _OptimismMintableERC20Factory.Contract.Bridge(&_OptimismMintableERC20Factory.CallOpts) +} + +// Bridge is a free data retrieval call binding the contract method 0xe78cea92. +// +// Solidity: function bridge() view returns(address) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryCallerSession) Bridge() (common.Address, error) { + return _OptimismMintableERC20Factory.Contract.Bridge(&_OptimismMintableERC20Factory.CallOpts) +} + +// Version is a free data retrieval call binding the contract method 0x54fd4d50. +// +// Solidity: function version() view returns(string) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryCaller) Version(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _OptimismMintableERC20Factory.contract.Call(opts, &out, "version") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +// Version is a free data retrieval call binding the contract method 0x54fd4d50. +// +// Solidity: function version() view returns(string) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactorySession) Version() (string, error) { + return _OptimismMintableERC20Factory.Contract.Version(&_OptimismMintableERC20Factory.CallOpts) +} + +// Version is a free data retrieval call binding the contract method 0x54fd4d50. +// +// Solidity: function version() view returns(string) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryCallerSession) Version() (string, error) { + return _OptimismMintableERC20Factory.Contract.Version(&_OptimismMintableERC20Factory.CallOpts) +} + +// CreateOptimismMintableERC20 is a paid mutator transaction binding the contract method 0xce5ac90f. +// +// Solidity: function createOptimismMintableERC20(address _remoteToken, string _name, string _symbol) returns(address) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryTransactor) CreateOptimismMintableERC20(opts *bind.TransactOpts, _remoteToken common.Address, _name string, _symbol string) (*types.Transaction, error) { + return _OptimismMintableERC20Factory.contract.Transact(opts, "createOptimismMintableERC20", _remoteToken, _name, _symbol) +} + +// CreateOptimismMintableERC20 is a paid mutator transaction binding the contract method 0xce5ac90f. +// +// Solidity: function createOptimismMintableERC20(address _remoteToken, string _name, string _symbol) returns(address) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactorySession) CreateOptimismMintableERC20(_remoteToken common.Address, _name string, _symbol string) (*types.Transaction, error) { + return _OptimismMintableERC20Factory.Contract.CreateOptimismMintableERC20(&_OptimismMintableERC20Factory.TransactOpts, _remoteToken, _name, _symbol) +} + +// CreateOptimismMintableERC20 is a paid mutator transaction binding the contract method 0xce5ac90f. +// +// Solidity: function createOptimismMintableERC20(address _remoteToken, string _name, string _symbol) returns(address) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryTransactorSession) CreateOptimismMintableERC20(_remoteToken common.Address, _name string, _symbol string) (*types.Transaction, error) { + return _OptimismMintableERC20Factory.Contract.CreateOptimismMintableERC20(&_OptimismMintableERC20Factory.TransactOpts, _remoteToken, _name, _symbol) +} + +// CreateOptimismMintableERC20WithDecimals is a paid mutator transaction binding the contract method 0x8cf0629c. +// +// Solidity: function createOptimismMintableERC20WithDecimals(address _remoteToken, string _name, string _symbol, uint8 _decimals) returns(address) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryTransactor) CreateOptimismMintableERC20WithDecimals(opts *bind.TransactOpts, _remoteToken common.Address, _name string, _symbol string, _decimals uint8) (*types.Transaction, error) { + return _OptimismMintableERC20Factory.contract.Transact(opts, "createOptimismMintableERC20WithDecimals", _remoteToken, _name, _symbol, _decimals) +} + +// CreateOptimismMintableERC20WithDecimals is a paid mutator transaction binding the contract method 0x8cf0629c. +// +// Solidity: function createOptimismMintableERC20WithDecimals(address _remoteToken, string _name, string _symbol, uint8 _decimals) returns(address) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactorySession) CreateOptimismMintableERC20WithDecimals(_remoteToken common.Address, _name string, _symbol string, _decimals uint8) (*types.Transaction, error) { + return _OptimismMintableERC20Factory.Contract.CreateOptimismMintableERC20WithDecimals(&_OptimismMintableERC20Factory.TransactOpts, _remoteToken, _name, _symbol, _decimals) +} + +// CreateOptimismMintableERC20WithDecimals is a paid mutator transaction binding the contract method 0x8cf0629c. +// +// Solidity: function createOptimismMintableERC20WithDecimals(address _remoteToken, string _name, string _symbol, uint8 _decimals) returns(address) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryTransactorSession) CreateOptimismMintableERC20WithDecimals(_remoteToken common.Address, _name string, _symbol string, _decimals uint8) (*types.Transaction, error) { + return _OptimismMintableERC20Factory.Contract.CreateOptimismMintableERC20WithDecimals(&_OptimismMintableERC20Factory.TransactOpts, _remoteToken, _name, _symbol, _decimals) +} + +// CreateStandardL2Token is a paid mutator transaction binding the contract method 0x896f93d1. +// +// Solidity: function createStandardL2Token(address _remoteToken, string _name, string _symbol) returns(address) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryTransactor) CreateStandardL2Token(opts *bind.TransactOpts, _remoteToken common.Address, _name string, _symbol string) (*types.Transaction, error) { + return _OptimismMintableERC20Factory.contract.Transact(opts, "createStandardL2Token", _remoteToken, _name, _symbol) +} + +// CreateStandardL2Token is a paid mutator transaction binding the contract method 0x896f93d1. +// +// Solidity: function createStandardL2Token(address _remoteToken, string _name, string _symbol) returns(address) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactorySession) CreateStandardL2Token(_remoteToken common.Address, _name string, _symbol string) (*types.Transaction, error) { + return _OptimismMintableERC20Factory.Contract.CreateStandardL2Token(&_OptimismMintableERC20Factory.TransactOpts, _remoteToken, _name, _symbol) +} + +// CreateStandardL2Token is a paid mutator transaction binding the contract method 0x896f93d1. +// +// Solidity: function createStandardL2Token(address _remoteToken, string _name, string _symbol) returns(address) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryTransactorSession) CreateStandardL2Token(_remoteToken common.Address, _name string, _symbol string) (*types.Transaction, error) { + return _OptimismMintableERC20Factory.Contract.CreateStandardL2Token(&_OptimismMintableERC20Factory.TransactOpts, _remoteToken, _name, _symbol) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _bridge) returns() +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryTransactor) Initialize(opts *bind.TransactOpts, _bridge common.Address) (*types.Transaction, error) { + return _OptimismMintableERC20Factory.contract.Transact(opts, "initialize", _bridge) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _bridge) returns() +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactorySession) Initialize(_bridge common.Address) (*types.Transaction, error) { + return _OptimismMintableERC20Factory.Contract.Initialize(&_OptimismMintableERC20Factory.TransactOpts, _bridge) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _bridge) returns() +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryTransactorSession) Initialize(_bridge common.Address) (*types.Transaction, error) { + return _OptimismMintableERC20Factory.Contract.Initialize(&_OptimismMintableERC20Factory.TransactOpts, _bridge) +} + +// OptimismMintableERC20FactoryInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the OptimismMintableERC20Factory contract. +type OptimismMintableERC20FactoryInitializedIterator struct { + Event *OptimismMintableERC20FactoryInitialized // 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 *OptimismMintableERC20FactoryInitializedIterator) 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(OptimismMintableERC20FactoryInitialized) + 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(OptimismMintableERC20FactoryInitialized) + 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 *OptimismMintableERC20FactoryInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *OptimismMintableERC20FactoryInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// OptimismMintableERC20FactoryInitialized represents a Initialized event raised by the OptimismMintableERC20Factory contract. +type OptimismMintableERC20FactoryInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryFilterer) FilterInitialized(opts *bind.FilterOpts) (*OptimismMintableERC20FactoryInitializedIterator, error) { + + logs, sub, err := _OptimismMintableERC20Factory.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &OptimismMintableERC20FactoryInitializedIterator{contract: _OptimismMintableERC20Factory.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *OptimismMintableERC20FactoryInitialized) (event.Subscription, error) { + + logs, sub, err := _OptimismMintableERC20Factory.contract.WatchLogs(opts, "Initialized") + 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(OptimismMintableERC20FactoryInitialized) + if err := _OptimismMintableERC20Factory.contract.UnpackLog(event, "Initialized", 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 +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryFilterer) ParseInitialized(log types.Log) (*OptimismMintableERC20FactoryInitialized, error) { + event := new(OptimismMintableERC20FactoryInitialized) + if err := _OptimismMintableERC20Factory.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// OptimismMintableERC20FactoryOptimismMintableERC20CreatedIterator is returned from FilterOptimismMintableERC20Created and is used to iterate over the raw logs and unpacked data for OptimismMintableERC20Created events raised by the OptimismMintableERC20Factory contract. +type OptimismMintableERC20FactoryOptimismMintableERC20CreatedIterator struct { + Event *OptimismMintableERC20FactoryOptimismMintableERC20Created // 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 *OptimismMintableERC20FactoryOptimismMintableERC20CreatedIterator) 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(OptimismMintableERC20FactoryOptimismMintableERC20Created) + 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(OptimismMintableERC20FactoryOptimismMintableERC20Created) + 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 *OptimismMintableERC20FactoryOptimismMintableERC20CreatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *OptimismMintableERC20FactoryOptimismMintableERC20CreatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// OptimismMintableERC20FactoryOptimismMintableERC20Created represents a OptimismMintableERC20Created event raised by the OptimismMintableERC20Factory contract. +type OptimismMintableERC20FactoryOptimismMintableERC20Created struct { + LocalToken common.Address + RemoteToken common.Address + Deployer common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOptimismMintableERC20Created is a free log retrieval operation binding the contract event 0x52fe89dd5930f343d25650b62fd367bae47088bcddffd2a88350a6ecdd620cdb. +// +// Solidity: event OptimismMintableERC20Created(address indexed localToken, address indexed remoteToken, address deployer) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryFilterer) FilterOptimismMintableERC20Created(opts *bind.FilterOpts, localToken []common.Address, remoteToken []common.Address) (*OptimismMintableERC20FactoryOptimismMintableERC20CreatedIterator, error) { + + var localTokenRule []interface{} + for _, localTokenItem := range localToken { + localTokenRule = append(localTokenRule, localTokenItem) + } + var remoteTokenRule []interface{} + for _, remoteTokenItem := range remoteToken { + remoteTokenRule = append(remoteTokenRule, remoteTokenItem) + } + + logs, sub, err := _OptimismMintableERC20Factory.contract.FilterLogs(opts, "OptimismMintableERC20Created", localTokenRule, remoteTokenRule) + if err != nil { + return nil, err + } + return &OptimismMintableERC20FactoryOptimismMintableERC20CreatedIterator{contract: _OptimismMintableERC20Factory.contract, event: "OptimismMintableERC20Created", logs: logs, sub: sub}, nil +} + +// WatchOptimismMintableERC20Created is a free log subscription operation binding the contract event 0x52fe89dd5930f343d25650b62fd367bae47088bcddffd2a88350a6ecdd620cdb. +// +// Solidity: event OptimismMintableERC20Created(address indexed localToken, address indexed remoteToken, address deployer) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryFilterer) WatchOptimismMintableERC20Created(opts *bind.WatchOpts, sink chan<- *OptimismMintableERC20FactoryOptimismMintableERC20Created, localToken []common.Address, remoteToken []common.Address) (event.Subscription, error) { + + var localTokenRule []interface{} + for _, localTokenItem := range localToken { + localTokenRule = append(localTokenRule, localTokenItem) + } + var remoteTokenRule []interface{} + for _, remoteTokenItem := range remoteToken { + remoteTokenRule = append(remoteTokenRule, remoteTokenItem) + } + + logs, sub, err := _OptimismMintableERC20Factory.contract.WatchLogs(opts, "OptimismMintableERC20Created", localTokenRule, remoteTokenRule) + 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(OptimismMintableERC20FactoryOptimismMintableERC20Created) + if err := _OptimismMintableERC20Factory.contract.UnpackLog(event, "OptimismMintableERC20Created", 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 +} + +// ParseOptimismMintableERC20Created is a log parse operation binding the contract event 0x52fe89dd5930f343d25650b62fd367bae47088bcddffd2a88350a6ecdd620cdb. +// +// Solidity: event OptimismMintableERC20Created(address indexed localToken, address indexed remoteToken, address deployer) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryFilterer) ParseOptimismMintableERC20Created(log types.Log) (*OptimismMintableERC20FactoryOptimismMintableERC20Created, error) { + event := new(OptimismMintableERC20FactoryOptimismMintableERC20Created) + if err := _OptimismMintableERC20Factory.contract.UnpackLog(event, "OptimismMintableERC20Created", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// OptimismMintableERC20FactoryStandardL2TokenCreatedIterator is returned from FilterStandardL2TokenCreated and is used to iterate over the raw logs and unpacked data for StandardL2TokenCreated events raised by the OptimismMintableERC20Factory contract. +type OptimismMintableERC20FactoryStandardL2TokenCreatedIterator struct { + Event *OptimismMintableERC20FactoryStandardL2TokenCreated // 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 *OptimismMintableERC20FactoryStandardL2TokenCreatedIterator) 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(OptimismMintableERC20FactoryStandardL2TokenCreated) + 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(OptimismMintableERC20FactoryStandardL2TokenCreated) + 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 *OptimismMintableERC20FactoryStandardL2TokenCreatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *OptimismMintableERC20FactoryStandardL2TokenCreatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// OptimismMintableERC20FactoryStandardL2TokenCreated represents a StandardL2TokenCreated event raised by the OptimismMintableERC20Factory contract. +type OptimismMintableERC20FactoryStandardL2TokenCreated struct { + RemoteToken common.Address + LocalToken common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterStandardL2TokenCreated is a free log retrieval operation binding the contract event 0xceeb8e7d520d7f3b65fc11a262b91066940193b05d4f93df07cfdced0eb551cf. +// +// Solidity: event StandardL2TokenCreated(address indexed remoteToken, address indexed localToken) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryFilterer) FilterStandardL2TokenCreated(opts *bind.FilterOpts, remoteToken []common.Address, localToken []common.Address) (*OptimismMintableERC20FactoryStandardL2TokenCreatedIterator, error) { + + var remoteTokenRule []interface{} + for _, remoteTokenItem := range remoteToken { + remoteTokenRule = append(remoteTokenRule, remoteTokenItem) + } + var localTokenRule []interface{} + for _, localTokenItem := range localToken { + localTokenRule = append(localTokenRule, localTokenItem) + } + + logs, sub, err := _OptimismMintableERC20Factory.contract.FilterLogs(opts, "StandardL2TokenCreated", remoteTokenRule, localTokenRule) + if err != nil { + return nil, err + } + return &OptimismMintableERC20FactoryStandardL2TokenCreatedIterator{contract: _OptimismMintableERC20Factory.contract, event: "StandardL2TokenCreated", logs: logs, sub: sub}, nil +} + +// WatchStandardL2TokenCreated is a free log subscription operation binding the contract event 0xceeb8e7d520d7f3b65fc11a262b91066940193b05d4f93df07cfdced0eb551cf. +// +// Solidity: event StandardL2TokenCreated(address indexed remoteToken, address indexed localToken) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryFilterer) WatchStandardL2TokenCreated(opts *bind.WatchOpts, sink chan<- *OptimismMintableERC20FactoryStandardL2TokenCreated, remoteToken []common.Address, localToken []common.Address) (event.Subscription, error) { + + var remoteTokenRule []interface{} + for _, remoteTokenItem := range remoteToken { + remoteTokenRule = append(remoteTokenRule, remoteTokenItem) + } + var localTokenRule []interface{} + for _, localTokenItem := range localToken { + localTokenRule = append(localTokenRule, localTokenItem) + } + + logs, sub, err := _OptimismMintableERC20Factory.contract.WatchLogs(opts, "StandardL2TokenCreated", remoteTokenRule, localTokenRule) + 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(OptimismMintableERC20FactoryStandardL2TokenCreated) + if err := _OptimismMintableERC20Factory.contract.UnpackLog(event, "StandardL2TokenCreated", 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 +} + +// ParseStandardL2TokenCreated is a log parse operation binding the contract event 0xceeb8e7d520d7f3b65fc11a262b91066940193b05d4f93df07cfdced0eb551cf. +// +// Solidity: event StandardL2TokenCreated(address indexed remoteToken, address indexed localToken) +func (_OptimismMintableERC20Factory *OptimismMintableERC20FactoryFilterer) ParseStandardL2TokenCreated(log types.Log) (*OptimismMintableERC20FactoryStandardL2TokenCreated, error) { + event := new(OptimismMintableERC20FactoryStandardL2TokenCreated) + if err := _OptimismMintableERC20Factory.contract.UnpackLog(event, "StandardL2TokenCreated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +func CreateOptimismMintableERC20FactoryDeploymentCommand() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc string + var gasLimit uint64 + var simulate bool + var timeout uint + var safeAddress, safeApi, safeCreateCall, safeSaltRaw, safeNonceRaw string + var safeOperationType uint8 + var salt [32]byte + var predictAddress bool + var safeNonce *big.Int + var calldata bool + + cmd := &cobra.Command{ + Use: "deploy", + Short: "Deploy a new OptimismMintableERC20Factory contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + + if !calldata { + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if safeCreateCall == "" { + fmt.Println("--safe-create-call not specified, using default (0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4)") + safeCreateCall = "0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4" + } + if !common.IsHexAddress(safeCreateCall) { + return fmt.Errorf("--safe-create-call is not a valid Ethereum address") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeSaltRaw == "" { + fmt.Println("--safe-salt not specified, generating random salt") + _, err := rand.Read(salt[:]) + if err != nil { + return fmt.Errorf("failed to generate random salt: %v", err) + } + // prompt user to accept random salt + fmt.Println("Generated salt:", common.Bytes2Hex(salt[:])) + fmt.Println("Please check the salt and confirm (y/n)") + var confirm string + fmt.Scanln(&confirm) + if confirm != "y" && confirm != "Y" && confirm != "\n" && confirm != "" { + return fmt.Errorf("salt not accepted, please specify a valid salt") + } + } else { + copy(salt[:], safeSaltRaw) + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + // Generate deploy bytecode with constructor arguments + deployCalldata, err := generateOptimismMintableERC20FactoryDeployBytecode() + if err != nil { + return fmt.Errorf("failed to generate deploy bytecode: %v", err) + } + + if calldata { + deployCalldataHex := hex.EncodeToString(deployCalldata) + cmd.Println(deployCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + if safeAddress != "" { + // Create Safe proposal for deployment + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + if predictAddress { + fmt.Println("Predicting deployment address...") + from := common.HexToAddress(safeAddress) + if safeOperationType == 0 { + from = common.HexToAddress(safeCreateCall) + } + deploymentAddress, err := PredictDeploymentAddressSafe(from, salt, deployCalldata) + if err != nil { + return fmt.Errorf("failed to predict deployment address: %v", err) + } + fmt.Println("Predicted deployment address:", deploymentAddress.Hex()) + return nil + } else { + fmt.Println("Creating Safe proposal...") + err = DeployWithSafe(client, key, common.HexToAddress(safeAddress), common.HexToAddress(safeCreateCall), value, safeApi, deployCalldata, SafeOperationType(safeOperationType), salt, safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + } + + return nil + } + + address, deploymentTransaction, _, deploymentErr := DeployOptimismMintableERC20Factory( + transactionOpts, + client, + ) + if deploymentErr != nil { + return deploymentErr + } + + cmd.Printf("Transaction hash: %s\nContract address: %s\n", deploymentTransaction.Hash().Hex(), address.Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + Data: deploymentTransaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := deploymentTransaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().StringVar(&safeCreateCall, "safe-create-call", "", "Address of the CreateCall contract (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 1, "Safe operation type: 0 (Call) or 1 (DelegateCall) - default is 1") + cmd.Flags().StringVar(&safeSaltRaw, "safe-salt", "", "Salt to use for the Safe transaction") + cmd.Flags().BoolVar(&predictAddress, "safe-predict-address", false, "Predict the deployment address (only works for Safe transactions)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + return cmd +} + +func generateOptimismMintableERC20FactoryDeployBytecode() ([]byte, error) { + abiPacked, err := OptimismMintableERC20FactoryMetaData.GetAbi() + if err != nil { + return nil, fmt.Errorf("failed to get ABI: %v", err) + } + + constructorArguments, err := abiPacked.Pack("") + if err != nil { + return nil, fmt.Errorf("failed to pack constructor arguments: %v", err) + } + + deployBytecode := append(common.FromHex(OptimismMintableERC20FactoryMetaData.Bin), constructorArguments...) + return deployBytecode, nil +} + +func CreateBridgeCommand() *cobra.Command { + var contractAddressRaw, rpc string + var contractAddress common.Address + var timeout uint + + var blockNumberRaw, fromAddressRaw string + var pending bool + + var capture0 common.Address + + cmd := &cobra.Command{ + Use: "bridge", + Short: "Call the Bridge view method on a OptimismMintableERC20Factory contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + contract, contractErr := NewOptimismMintableERC20Factory(contractAddress, client) + if contractErr != nil { + return contractErr + } + + callOpts := bind.CallOpts{} + SetCallParametersFromArgs(&callOpts, pending, fromAddressRaw, blockNumberRaw) + + session := OptimismMintableERC20FactoryCallerSession{ + Contract: &contract.OptimismMintableERC20FactoryCaller, + CallOpts: callOpts, + } + + var callErr error + capture0, callErr = session.Bridge() + if callErr != nil { + return callErr + } + + cmd.Printf("0: %s\n", capture0.Hex()) + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&blockNumberRaw, "block", "", "Block number at which to call the view method") + cmd.Flags().BoolVar(&pending, "pending", false, "Set this flag if it's ok to call the view method against pending state") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&fromAddressRaw, "from", "", "Optional address for caller of the view method") + + return cmd +} +func CreateVersionCommand() *cobra.Command { + var contractAddressRaw, rpc string + var contractAddress common.Address + var timeout uint + + var blockNumberRaw, fromAddressRaw string + var pending bool + + var capture0 string + + cmd := &cobra.Command{ + Use: "version", + Short: "Call the Version view method on a OptimismMintableERC20Factory contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + contract, contractErr := NewOptimismMintableERC20Factory(contractAddress, client) + if contractErr != nil { + return contractErr + } + + callOpts := bind.CallOpts{} + SetCallParametersFromArgs(&callOpts, pending, fromAddressRaw, blockNumberRaw) + + session := OptimismMintableERC20FactoryCallerSession{ + Contract: &contract.OptimismMintableERC20FactoryCaller, + CallOpts: callOpts, + } + + var callErr error + capture0, callErr = session.Version() + if callErr != nil { + return callErr + } + + cmd.Printf("0: %s\n", capture0) + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&blockNumberRaw, "block", "", "Block number at which to call the view method") + cmd.Flags().BoolVar(&pending, "pending", false, "Set this flag if it's ok to call the view method against pending state") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&fromAddressRaw, "from", "", "Optional address for caller of the view method") + + return cmd +} + +func CreateCreateOptimismMintableErc20Command() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc, contractAddressRaw, safeFunction, safeNonceRaw string + var gasLimit uint64 + var simulate bool + var timeout uint + var contractAddress common.Address + var safeAddress, safeApi string + var safeOperationType uint8 + var safeNonce *big.Int + var calldata bool + + var remoteToken common.Address + var remoteTokenRaw string + var _name0 string + + var symbol string + + cmd := &cobra.Command{ + Use: "create-optimism-mintable-erc-20", + Short: "Execute the CreateOptimismMintableERC20 method on a OptimismMintableERC20Factory contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if !calldata { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + if remoteTokenRaw == "" { + return fmt.Errorf("--remote-token argument not specified") + } else if !common.IsHexAddress(remoteTokenRaw) { + return fmt.Errorf("--remote-token argument is not a valid Ethereum address") + } + remoteToken = common.HexToAddress(remoteTokenRaw) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + abi, err := OptimismMintableERC20FactoryMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + // Generate transaction data (override method name if safe function is specified) + methodName := "createOptimismMintableErc20" + if safeFunction != "" { + methodName = safeFunction + } + + txCalldata, err := abi.Pack( + methodName, + remoteToken, + _name0, + symbol, + ) + + if err != nil { + return err + } + + if calldata { + txCalldataHex := hex.EncodeToString(txCalldata) + cmd.Println(txCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + contract, contractErr := NewOptimismMintableERC20Factory(contractAddress, client) + if contractErr != nil { + return contractErr + } + + session := OptimismMintableERC20FactoryTransactorSession{ + Contract: &contract.OptimismMintableERC20FactoryTransactor, + TransactOpts: *transactionOpts, + } + + if safeAddress != "" { + // Create Safe proposal for transaction + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + err = CreateSafeProposal(client, key, common.HexToAddress(safeAddress), contractAddress, txCalldata, value, safeApi, SafeOperationType(safeOperationType), safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + + return nil + } + + transaction, err := session.CreateOptimismMintableERC20( + + remoteToken, + _name0, + symbol, + ) + if err != nil { + return err + } + + cmd.Printf("Transaction hash: %s\n", transaction.Hash().Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + To: &contractAddress, + Data: transaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := transaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 0, "Safe operation type: 0 (Call) or 1 (DelegateCall)") + cmd.Flags().StringVar(&safeFunction, "safe-function", "", "Safe function overrider to use for the transaction (optional)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + cmd.Flags().StringVar(&remoteTokenRaw, "remote-token", "", "remote-token argument (common.Address)") + cmd.Flags().StringVar(&_name0, "name-0", "", "name-0 argument") + cmd.Flags().StringVar(&symbol, "symbol", "", "symbol argument") + + return cmd +} +func CreateCreateOptimismMintableErc20WithDecimalsCommand() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc, contractAddressRaw, safeFunction, safeNonceRaw string + var gasLimit uint64 + var simulate bool + var timeout uint + var contractAddress common.Address + var safeAddress, safeApi string + var safeOperationType uint8 + var safeNonce *big.Int + var calldata bool + + var remoteToken common.Address + var remoteTokenRaw string + var _name0 string + + var symbol string + + var decimals uint8 + + cmd := &cobra.Command{ + Use: "create-optimism-mintable-erc-20-with-decimals", + Short: "Execute the CreateOptimismMintableERC20WithDecimals method on a OptimismMintableERC20Factory contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if !calldata { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + if remoteTokenRaw == "" { + return fmt.Errorf("--remote-token argument not specified") + } else if !common.IsHexAddress(remoteTokenRaw) { + return fmt.Errorf("--remote-token argument is not a valid Ethereum address") + } + remoteToken = common.HexToAddress(remoteTokenRaw) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + abi, err := OptimismMintableERC20FactoryMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + // Generate transaction data (override method name if safe function is specified) + methodName := "createOptimismMintableErc20WithDecimals" + if safeFunction != "" { + methodName = safeFunction + } + + txCalldata, err := abi.Pack( + methodName, + remoteToken, + _name0, + symbol, + decimals, + ) + + if err != nil { + return err + } + + if calldata { + txCalldataHex := hex.EncodeToString(txCalldata) + cmd.Println(txCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + contract, contractErr := NewOptimismMintableERC20Factory(contractAddress, client) + if contractErr != nil { + return contractErr + } + + session := OptimismMintableERC20FactoryTransactorSession{ + Contract: &contract.OptimismMintableERC20FactoryTransactor, + TransactOpts: *transactionOpts, + } + + if safeAddress != "" { + // Create Safe proposal for transaction + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + err = CreateSafeProposal(client, key, common.HexToAddress(safeAddress), contractAddress, txCalldata, value, safeApi, SafeOperationType(safeOperationType), safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + + return nil + } + + transaction, err := session.CreateOptimismMintableERC20WithDecimals( + + remoteToken, + _name0, + symbol, + decimals, + ) + if err != nil { + return err + } + + cmd.Printf("Transaction hash: %s\n", transaction.Hash().Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + To: &contractAddress, + Data: transaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := transaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 0, "Safe operation type: 0 (Call) or 1 (DelegateCall)") + cmd.Flags().StringVar(&safeFunction, "safe-function", "", "Safe function overrider to use for the transaction (optional)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + cmd.Flags().StringVar(&remoteTokenRaw, "remote-token", "", "remote-token argument (common.Address)") + cmd.Flags().StringVar(&_name0, "name-0", "", "name-0 argument") + cmd.Flags().StringVar(&symbol, "symbol", "", "symbol argument") + cmd.Flags().Uint8Var(&decimals, "decimals", 0, "decimals argument") + + return cmd +} +func CreateCreateStandardL2TokenCommand() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc, contractAddressRaw, safeFunction, safeNonceRaw string + var gasLimit uint64 + var simulate bool + var timeout uint + var contractAddress common.Address + var safeAddress, safeApi string + var safeOperationType uint8 + var safeNonce *big.Int + var calldata bool + + var remoteToken common.Address + var remoteTokenRaw string + var _name0 string + + var symbol string + + cmd := &cobra.Command{ + Use: "create-standard-l-2-token", + Short: "Execute the CreateStandardL2Token method on a OptimismMintableERC20Factory contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if !calldata { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + if remoteTokenRaw == "" { + return fmt.Errorf("--remote-token argument not specified") + } else if !common.IsHexAddress(remoteTokenRaw) { + return fmt.Errorf("--remote-token argument is not a valid Ethereum address") + } + remoteToken = common.HexToAddress(remoteTokenRaw) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + abi, err := OptimismMintableERC20FactoryMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + // Generate transaction data (override method name if safe function is specified) + methodName := "createStandardL2Token" + if safeFunction != "" { + methodName = safeFunction + } + + txCalldata, err := abi.Pack( + methodName, + remoteToken, + _name0, + symbol, + ) + + if err != nil { + return err + } + + if calldata { + txCalldataHex := hex.EncodeToString(txCalldata) + cmd.Println(txCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + contract, contractErr := NewOptimismMintableERC20Factory(contractAddress, client) + if contractErr != nil { + return contractErr + } + + session := OptimismMintableERC20FactoryTransactorSession{ + Contract: &contract.OptimismMintableERC20FactoryTransactor, + TransactOpts: *transactionOpts, + } + + if safeAddress != "" { + // Create Safe proposal for transaction + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + err = CreateSafeProposal(client, key, common.HexToAddress(safeAddress), contractAddress, txCalldata, value, safeApi, SafeOperationType(safeOperationType), safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + + return nil + } + + transaction, err := session.CreateStandardL2Token( + + remoteToken, + _name0, + symbol, + ) + if err != nil { + return err + } + + cmd.Printf("Transaction hash: %s\n", transaction.Hash().Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + To: &contractAddress, + Data: transaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := transaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 0, "Safe operation type: 0 (Call) or 1 (DelegateCall)") + cmd.Flags().StringVar(&safeFunction, "safe-function", "", "Safe function overrider to use for the transaction (optional)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + cmd.Flags().StringVar(&remoteTokenRaw, "remote-token", "", "remote-token argument (common.Address)") + cmd.Flags().StringVar(&_name0, "name-0", "", "name-0 argument") + cmd.Flags().StringVar(&symbol, "symbol", "", "symbol argument") + + return cmd +} +func CreateInitializeCommand() *cobra.Command { + var keyfile, nonce, password, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, rpc, contractAddressRaw, safeFunction, safeNonceRaw string + var gasLimit uint64 + var simulate bool + var timeout uint + var contractAddress common.Address + var safeAddress, safeApi string + var safeOperationType uint8 + var safeNonce *big.Int + var calldata bool + + var bridge common.Address + var bridgeRaw string + + cmd := &cobra.Command{ + Use: "initialize", + Short: "Execute the Initialize method on a OptimismMintableERC20Factory contract", + PreRunE: func(cmd *cobra.Command, args []string) error { + if !calldata { + if contractAddressRaw == "" { + return fmt.Errorf("--contract not specified") + } else if !common.IsHexAddress(contractAddressRaw) { + return fmt.Errorf("--contract is not a valid Ethereum address") + } + contractAddress = common.HexToAddress(contractAddressRaw) + + if keyfile == "" { + return fmt.Errorf("--keystore not specified (this should be a path to an Ethereum account keystore file)") + } + + if rpc == "" { + return fmt.Errorf("--rpc not specified (this should be a URL to an Ethereum JSONRPC API)") + } + } + + if safeAddress != "" { + if !common.IsHexAddress(safeAddress) { + return fmt.Errorf("--safe is not a valid Ethereum address") + } + if safeApi == "" { + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + safeApi = fmt.Sprintf("https://safe-client.safe.global/v1/chains/%s/transactions/%s/propose", chainID.String(), safeAddress) + fmt.Println("--safe-api not specified, using default (", safeApi, ")") + } + + if SafeOperationType(safeOperationType).String() == "Unknown" { + return fmt.Errorf("--safe-operation must be 0 (Call) or 1 (DelegateCall)") + } + + if safeNonceRaw == "" { + fmt.Println("--safe-nonce not specified, fetching nonce from Safe contract") + } else { + safeNonce = new(big.Int) + _, ok := safeNonce.SetString(safeNonceRaw, 0) + if !ok { + return fmt.Errorf("--safe-nonce is not a valid big integer") + } + } + } + + if bridgeRaw == "" { + return fmt.Errorf("--bridge argument not specified") + } else if !common.IsHexAddress(bridgeRaw) { + return fmt.Errorf("--bridge argument is not a valid Ethereum address") + } + bridge = common.HexToAddress(bridgeRaw) + + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + abi, err := OptimismMintableERC20FactoryMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + // Generate transaction data (override method name if safe function is specified) + methodName := "initialize" + if safeFunction != "" { + methodName = safeFunction + } + + txCalldata, err := abi.Pack( + methodName, + bridge, + ) + + if err != nil { + return err + } + + if calldata { + txCalldataHex := hex.EncodeToString(txCalldata) + cmd.Println(txCalldataHex) + return nil + } + + client, clientErr := NewClient(rpc) + if clientErr != nil { + return clientErr + } + + key, keyErr := KeyFromFile(keyfile, password) + if keyErr != nil { + return keyErr + } + + chainIDCtx, cancelChainIDCtx := NewChainContext(timeout) + defer cancelChainIDCtx() + chainID, chainIDErr := client.ChainID(chainIDCtx) + if chainIDErr != nil { + return chainIDErr + } + + transactionOpts, transactionOptsErr := bind.NewKeyedTransactorWithChainID(key.PrivateKey, chainID) + if transactionOptsErr != nil { + return transactionOptsErr + } + + SetTransactionParametersFromArgs(transactionOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas, gasLimit, simulate) + + contract, contractErr := NewOptimismMintableERC20Factory(contractAddress, client) + if contractErr != nil { + return contractErr + } + + session := OptimismMintableERC20FactoryTransactorSession{ + Contract: &contract.OptimismMintableERC20FactoryTransactor, + TransactOpts: *transactionOpts, + } + + if safeAddress != "" { + // Create Safe proposal for transaction + value := transactionOpts.Value + if value == nil { + value = big.NewInt(0) + } + + err = CreateSafeProposal(client, key, common.HexToAddress(safeAddress), contractAddress, txCalldata, value, safeApi, SafeOperationType(safeOperationType), safeNonce) + if err != nil { + return fmt.Errorf("failed to create Safe proposal: %v", err) + } + + return nil + } + + transaction, err := session.Initialize( + + bridge, + ) + if err != nil { + return err + } + + cmd.Printf("Transaction hash: %s\n", transaction.Hash().Hex()) + if transactionOpts.NoSend { + estimationMessage := ethereum.CallMsg{ + From: transactionOpts.From, + To: &contractAddress, + Data: transaction.Data(), + } + + gasEstimationCtx, cancelGasEstimationCtx := NewChainContext(timeout) + defer cancelGasEstimationCtx() + + gasEstimate, gasEstimateErr := client.EstimateGas(gasEstimationCtx, estimationMessage) + if gasEstimateErr != nil { + return gasEstimateErr + } + + transactionBinary, transactionBinaryErr := transaction.MarshalBinary() + if transactionBinaryErr != nil { + return transactionBinaryErr + } + transactionBinaryHex := hex.EncodeToString(transactionBinary) + + cmd.Printf("Transaction: %s\nEstimated gas: %d\n", transactionBinaryHex, gasEstimate) + } else { + cmd.Println("Transaction submitted") + } + + return nil + }, + } + + cmd.Flags().StringVar(&rpc, "rpc", "", "URL of the JSONRPC API to use") + cmd.Flags().StringVar(&keyfile, "keyfile", "", "Path to the keystore file to use for the transaction") + cmd.Flags().StringVar(&password, "password", "", "Password to use to unlock the keystore (if not specified, you will be prompted for the password when the command executes)") + cmd.Flags().StringVar(&nonce, "nonce", "", "Nonce to use for the transaction") + cmd.Flags().StringVar(&value, "value", "", "Value to send with the transaction") + cmd.Flags().StringVar(&gasPrice, "gas-price", "", "Gas price to use for the transaction") + cmd.Flags().StringVar(&maxFeePerGas, "max-fee-per-gas", "", "Maximum fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().StringVar(&maxPriorityFeePerGas, "max-priority-fee-per-gas", "", "Maximum priority fee per gas to use for the (EIP-1559) transaction") + cmd.Flags().Uint64Var(&gasLimit, "gas-limit", 0, "Gas limit for the transaction") + cmd.Flags().BoolVar(&simulate, "simulate", false, "Simulate the transaction without sending it") + cmd.Flags().UintVar(&timeout, "timeout", 60, "Timeout (in seconds) for interactions with the JSONRPC API") + cmd.Flags().StringVar(&contractAddressRaw, "contract", "", "Address of the contract to interact with") + cmd.Flags().StringVar(&safeAddress, "safe", "", "Address of the Safe contract") + cmd.Flags().StringVar(&safeApi, "safe-api", "", "Safe API for the Safe Transaction Service (optional)") + cmd.Flags().Uint8Var(&safeOperationType, "safe-operation", 0, "Safe operation type: 0 (Call) or 1 (DelegateCall)") + cmd.Flags().StringVar(&safeFunction, "safe-function", "", "Safe function overrider to use for the transaction (optional)") + cmd.Flags().StringVar(&safeNonceRaw, "safe-nonce", "", "Safe nonce overrider for the transaction (optional)") + cmd.Flags().BoolVar(&calldata, "calldata", false, "Set this flag if want to return the calldata instead of sending the transaction") + + cmd.Flags().StringVar(&bridgeRaw, "bridge", "", "bridge argument (common.Address)") + + return cmd +} + +var ErrNoRPCURL error = errors.New("no RPC URL provided -- please pass an RPC URL from the command line or set the OPTIMISM_MINTABLE_ERC_20_FACTORY_RPC_URL environment variable") + +// Generates an Ethereum client to the JSONRPC API at the given URL. If rpcURL is empty, then it +// attempts to read the RPC URL from the OPTIMISM_MINTABLE_ERC_20_FACTORY_RPC_URL environment variable. If that is empty, +// too, then it returns an error. +func NewClient(rpcURL string) (*ethclient.Client, error) { + if rpcURL == "" { + rpcURL = os.Getenv("OPTIMISM_MINTABLE_ERC_20_FACTORY_RPC_URL") + } + + if rpcURL == "" { + return nil, ErrNoRPCURL + } + + client, err := ethclient.Dial(rpcURL) + return client, err +} + +// Creates a new context to be used when interacting with the chain client. +func NewChainContext(timeout uint) (context.Context, context.CancelFunc) { + baseCtx := context.Background() + parsedTimeout := time.Duration(timeout) * time.Second + ctx, cancel := context.WithTimeout(baseCtx, parsedTimeout) + return ctx, cancel +} + +// Unlocks a key from a keystore (byte contents of a keystore file) with the given password. +func UnlockKeystore(keystoreData []byte, password string) (*keystore.Key, error) { + key, err := keystore.DecryptKey(keystoreData, password) + return key, err +} + +// Loads a key from file, prompting the user for the password if it is not provided as a function argument. +func KeyFromFile(keystoreFile string, password string) (*keystore.Key, error) { + var emptyKey *keystore.Key + keystoreContent, readErr := os.ReadFile(keystoreFile) + if readErr != nil { + return emptyKey, readErr + } + + // If password is "", prompt user for password. + if password == "" { + fmt.Printf("Please provide a password for keystore (%s): ", keystoreFile) + passwordRaw, inputErr := term.ReadPassword(int(os.Stdin.Fd())) + if inputErr != nil { + return emptyKey, fmt.Errorf("error reading password: %s", inputErr.Error()) + } + fmt.Print("\n") + password = string(passwordRaw) + } + + key, err := UnlockKeystore(keystoreContent, password) + return key, err +} + +// This method is used to set the parameters on a view call from command line arguments (represented mostly as +// strings). +func SetCallParametersFromArgs(opts *bind.CallOpts, pending bool, fromAddress, blockNumber string) { + if pending { + opts.Pending = true + } + + if fromAddress != "" { + opts.From = common.HexToAddress(fromAddress) + } + + if blockNumber != "" { + opts.BlockNumber = new(big.Int) + opts.BlockNumber.SetString(blockNumber, 0) + } +} + +// This method is used to set the parameters on a transaction from command line arguments (represented mostly as +// strings). +func SetTransactionParametersFromArgs(opts *bind.TransactOpts, nonce, value, gasPrice, maxFeePerGas, maxPriorityFeePerGas string, gasLimit uint64, noSend bool) { + if nonce != "" { + opts.Nonce = new(big.Int) + opts.Nonce.SetString(nonce, 0) + } + + if value != "" { + opts.Value = new(big.Int) + opts.Value.SetString(value, 0) + } + + if gasPrice != "" { + opts.GasPrice = new(big.Int) + opts.GasPrice.SetString(gasPrice, 0) + } + + if maxFeePerGas != "" { + opts.GasFeeCap = new(big.Int) + opts.GasFeeCap.SetString(maxFeePerGas, 0) + } + + if maxPriorityFeePerGas != "" { + opts.GasTipCap = new(big.Int) + opts.GasTipCap.SetString(maxPriorityFeePerGas, 0) + } + + if gasLimit != 0 { + opts.GasLimit = gasLimit + } + + opts.NoSend = noSend +} + +func CreateOptimismMintableERC20FactoryCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "optimism-mintable-erc-20-factory", + Short: "Interact with the OptimismMintableERC20Factory contract", + Run: func(cmd *cobra.Command, args []string) { + cmd.Help() + }, + } + + cmd.SetOut(os.Stdout) + + DeployGroup := &cobra.Group{ + ID: "deploy", Title: "Commands which deploy contracts", + } + cmd.AddGroup(DeployGroup) + ViewGroup := &cobra.Group{ + ID: "view", Title: "Commands which view contract state", + } + TransactGroup := &cobra.Group{ + ID: "transact", Title: "Commands which submit transactions", + } + cmd.AddGroup(ViewGroup, TransactGroup) + + cmdDeployOptimismMintableERC20Factory := CreateOptimismMintableERC20FactoryDeploymentCommand() + cmdDeployOptimismMintableERC20Factory.GroupID = DeployGroup.ID + cmd.AddCommand(cmdDeployOptimismMintableERC20Factory) + + cmdViewBRIDGE := CreateBridgeCommand() + cmdViewBRIDGE.GroupID = ViewGroup.ID + cmd.AddCommand(cmdViewBRIDGE) + cmdViewBridge := CreateBridgeCommand() + cmdViewBridge.GroupID = ViewGroup.ID + cmd.AddCommand(cmdViewBridge) + cmdViewVersion := CreateVersionCommand() + cmdViewVersion.GroupID = ViewGroup.ID + cmd.AddCommand(cmdViewVersion) + + cmdTransactCreateOptimismMintableERC20 := CreateCreateOptimismMintableErc20Command() + cmdTransactCreateOptimismMintableERC20.GroupID = TransactGroup.ID + cmd.AddCommand(cmdTransactCreateOptimismMintableERC20) + cmdTransactCreateOptimismMintableERC20WithDecimals := CreateCreateOptimismMintableErc20WithDecimalsCommand() + cmdTransactCreateOptimismMintableERC20WithDecimals.GroupID = TransactGroup.ID + cmd.AddCommand(cmdTransactCreateOptimismMintableERC20WithDecimals) + cmdTransactCreateStandardL2Token := CreateCreateStandardL2TokenCommand() + cmdTransactCreateStandardL2Token.GroupID = TransactGroup.ID + cmd.AddCommand(cmdTransactCreateStandardL2Token) + cmdTransactInitialize := CreateInitializeCommand() + cmdTransactInitialize.GroupID = TransactGroup.ID + cmd.AddCommand(cmdTransactInitialize) + + return cmd +} + +// SafeOperationType represents the type of operation for a Safe transaction +type SafeOperationType uint8 + +const ( + Call SafeOperationType = 0 + DelegateCall SafeOperationType = 1 +) + +// String returns the string representation of the SafeOperationType +func (o SafeOperationType) String() string { + switch o { + case Call: + return "Call" + case DelegateCall: + return "DelegateCall" + default: + return "Unknown" + } +} + +// SafeTransactionData represents the data for a Safe transaction +type SafeTransactionData struct { + To string `json:"to"` + Value string `json:"value"` + Data string `json:"data"` + Operation SafeOperationType `json:"operation"` + SafeTxGas uint64 `json:"safeTxGas"` + BaseGas uint64 `json:"baseGas"` + GasPrice string `json:"gasPrice"` + GasToken string `json:"gasToken"` + RefundReceiver string `json:"refundReceiver"` + Nonce *big.Int `json:"nonce"` + SafeTxHash string `json:"safeTxHash"` + Sender string `json:"sender"` + Signature string `json:"signature"` + Origin string `json:"origin"` +} + +const ( + NativeTokenAddress = "0x0000000000000000000000000000000000000000" +) + +func DeployWithSafe(client *ethclient.Client, key *keystore.Key, safeAddress common.Address, factoryAddress common.Address, value *big.Int, safeApi string, deployBytecode []byte, safeOperationType SafeOperationType, salt [32]byte, safeNonce *big.Int) error { + abi, err := CreateCall.CreateCallMetaData.GetAbi() + if err != nil { + return fmt.Errorf("failed to get ABI: %v", err) + } + + safeCreateCallTxData, err := abi.Pack("performCreate2", value, deployBytecode, salt) + if err != nil { + return fmt.Errorf("failed to pack performCreate2 transaction: %v", err) + } + + return CreateSafeProposal(client, key, safeAddress, factoryAddress, safeCreateCallTxData, value, safeApi, SafeOperationType(safeOperationType), safeNonce) +} + +func PredictDeploymentAddressSafe(from common.Address, salt [32]byte, deployBytecode []byte) (common.Address, error) { + // Calculate the hash of the init code (deployment bytecode) + initCodeHash := crypto.Keccak256(deployBytecode) + + // Calculate the CREATE2 address + deployedAddress := crypto.CreateAddress2(from, salt, initCodeHash) + + return deployedAddress, nil +} + +func CreateSafeProposal(client *ethclient.Client, key *keystore.Key, safeAddress common.Address, to common.Address, data []byte, value *big.Int, safeApi string, safeOperationType SafeOperationType, safeNonce *big.Int) error { + chainID, err := client.ChainID(context.Background()) + if err != nil { + return fmt.Errorf("failed to get chain ID: %v", err) + } + + // Create a new instance of the GnosisSafe contract + safeInstance, err := GnosisSafe.NewGnosisSafe(safeAddress, client) + if err != nil { + return fmt.Errorf("failed to create GnosisSafe instance: %v", err) + } + + nonce := safeNonce + if safeNonce == nil { + // Fetch the current nonce from the Safe contract + fetchedNonce, err := safeInstance.Nonce(&bind.CallOpts{}) + if err != nil { + return fmt.Errorf("failed to fetch nonce from Safe contract: %v", err) + } + nonce = fetchedNonce + } else { + nonce = safeNonce + } + + safeTransactionData := SafeTransactionData{ + To: to.Hex(), + Value: value.String(), + Data: common.Bytes2Hex(data), + Operation: safeOperationType, + SafeTxGas: 0, + BaseGas: 0, + GasPrice: "0", + GasToken: NativeTokenAddress, + RefundReceiver: NativeTokenAddress, + Nonce: nonce, + } + + // Calculate SafeTxHash + safeTxHash, err := CalculateSafeTxHash(safeAddress, safeTransactionData, chainID) + if err != nil { + return fmt.Errorf("failed to calculate SafeTxHash: %v", err) + } + + // Sign the SafeTxHash + signature, err := crypto.Sign(safeTxHash.Bytes(), key.PrivateKey) + if err != nil { + return fmt.Errorf("failed to sign SafeTxHash: %v", err) + } + + // Adjust V value for Ethereum's replay protection + signature[64] += 27 + + // Convert signature to hex + senderSignature := "0x" + common.Bytes2Hex(signature) + + // Prepare the request body + requestBody := map[string]interface{}{ + "to": safeTransactionData.To, + "value": safeTransactionData.Value, + "data": "0x" + safeTransactionData.Data, + "operation": int(safeTransactionData.Operation), + "safeTxGas": fmt.Sprintf("%d", safeTransactionData.SafeTxGas), + "baseGas": fmt.Sprintf("%d", safeTransactionData.BaseGas), + "gasPrice": safeTransactionData.GasPrice, + "gasToken": safeTransactionData.GasToken, + "refundReceiver": safeTransactionData.RefundReceiver, + "nonce": fmt.Sprintf("%d", safeTransactionData.Nonce), + "safeTxHash": safeTxHash.Hex(), + "sender": key.Address.Hex(), + "signature": senderSignature, + "origin": fmt.Sprintf("{\"url\":\"%s\",\"name\":\"TokenSender Deployment\"}", safeApi), + } + + // Marshal the request body to JSON + jsonBody, err := json.Marshal(requestBody) + if err != nil { + return fmt.Errorf("failed to marshal request body: %v", err) + } + + // Send the request to the Safe Transaction Service + req, err := http.NewRequest("POST", safeApi, bytes.NewBuffer(jsonBody)) + if err != nil { + return fmt.Errorf("failed to create request: %v", err) + } + + req.Header.Set("Content-Type", "application/json") + + httpClient := &http.Client{} + resp, err := httpClient.Do(req) + if err != nil { + return fmt.Errorf("failed to send request: %v", err) + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated { + return fmt.Errorf("unexpected status code: %d", resp.StatusCode) + } + + fmt.Println("Safe proposal created successfully") + return nil +} + +func CalculateSafeTxHash(safeAddress common.Address, txData SafeTransactionData, chainID *big.Int) (common.Hash, error) { + domainSeparator := apitypes.TypedDataDomain{ + ChainId: (*math.HexOrDecimal256)(chainID), + VerifyingContract: safeAddress.Hex(), + } + + typedData := apitypes.TypedData{ + Types: apitypes.Types{ + "EIP712Domain": []apitypes.Type{ + {Name: "chainId", Type: "uint256"}, + {Name: "verifyingContract", Type: "address"}, + }, + "SafeTx": []apitypes.Type{ + {Name: "to", Type: "address"}, + {Name: "value", Type: "uint256"}, + {Name: "data", Type: "bytes"}, + {Name: "operation", Type: "uint8"}, + {Name: "safeTxGas", Type: "uint256"}, + {Name: "baseGas", Type: "uint256"}, + {Name: "gasPrice", Type: "uint256"}, + {Name: "gasToken", Type: "address"}, + {Name: "refundReceiver", Type: "address"}, + {Name: "nonce", Type: "uint256"}, + }, + }, + Domain: domainSeparator, + PrimaryType: "SafeTx", + Message: apitypes.TypedDataMessage{ + "to": txData.To, + "value": txData.Value, + "data": "0x" + txData.Data, + "operation": fmt.Sprintf("%d", txData.Operation), + "safeTxGas": fmt.Sprintf("%d", txData.SafeTxGas), + "baseGas": fmt.Sprintf("%d", txData.BaseGas), + "gasPrice": txData.GasPrice, + "gasToken": txData.GasToken, + "refundReceiver": txData.RefundReceiver, + "nonce": fmt.Sprintf("%d", txData.Nonce), + }, + } + + typedDataHash, _, err := apitypes.TypedDataAndHash(typedData) + if err != nil { + return common.Hash{}, fmt.Errorf("failed to hash typed data: %v", err) + } + + return common.BytesToHash(typedDataHash), nil +} diff --git a/cmd/base/base.go b/cmd/base/base.go new file mode 100644 index 0000000..d01fc0d --- /dev/null +++ b/cmd/base/base.go @@ -0,0 +1,24 @@ +package base + +import ( + "github.com/G7DAO/bifrost/bindings/L1StandardBridge" + "github.com/G7DAO/bifrost/bindings/OptimismMintableERC20Factory" + "github.com/spf13/cobra" +) + +func CreateBaseCommand() *cobra.Command { + baseCmd := &cobra.Command{ + Use: "base", + Short: "Base commands", + Run: func(cmd *cobra.Command, args []string) { + cmd.Help() + }, + } + + l1StandardBridgeCmd := L1StandardBridge.CreateL1StandardBridgeCommand() + optimismMintableERC20FactoryCmd := OptimismMintableERC20Factory.CreateOptimismMintableERC20FactoryCommand() + + baseCmd.AddCommand(l1StandardBridgeCmd, optimismMintableERC20FactoryCmd) + + return baseCmd +} diff --git a/cmd/cmd.go b/cmd/cmd.go index e866093..c03663a 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -4,6 +4,7 @@ import ( "os" arbitrum_bifrost "github.com/G7DAO/bifrost/cmd/arbitrum" + "github.com/G7DAO/bifrost/cmd/base" "github.com/G7DAO/bifrost/cmd/cctp" "github.com/G7DAO/bifrost/cmd/version" "github.com/spf13/cobra" @@ -24,8 +25,9 @@ func CreateRootCommand() *cobra.Command { arbitrumCmd := arbitrum_bifrost.CreateArbitrumCommand() cctpCmd := cctp.CreateCctpCommand() + baseCmd := base.CreateBaseCommand() - rootCmd.AddCommand(completionCmd, versionCmd, arbitrumCmd, cctpCmd) + rootCmd.AddCommand(completionCmd, versionCmd, arbitrumCmd, cctpCmd, baseCmd) // By default, cobra Command objects write to stderr. We have to forcibly set them to output to // stdout. diff --git a/docs/base.md b/docs/base.md new file mode 100644 index 0000000..e937a0e --- /dev/null +++ b/docs/base.md @@ -0,0 +1,34 @@ +# Setup Base bifrost and call + +This checklist describes how to deploy a ERC20 token on Base and bridge it to Ethereum using the Optimism Canonical Bridge + +## Deploy a ERC20 token on Base + +```bash +bin/bifrost base optimism-mintable-erc-20-factory create-standard-l-2-token \ + --keyfile $WB_WALLET \ + --rpc $BASE_SEPOLIA_RPC \ + --name-0 $NAME \ + --symbol $SYMBOL \ + --contract $OPTIMISM_ERC20_FACTORY_BASE_SEPOLIA \ + --remote-token $TOKEN_ON_ETHEREUM \ +``` + +Output: Transaction Hash + + +## Bridge a ERC20 token from Base to Ethereum + +```bash +bin/bifrost base l-1-standard-bridge bridge-erc-20 \ + --keyfile $WB_WALLET \ + --rpc $BASE_RPC \ + --contract $L1_STANDARD_BRIDGE_BASE \ + --local-token $TOKEN_ON_ETHEREUM \ + --remote-token $TOKEN_ON_BASE \ + --amount $AMOUNT \ + --min-gas-limit $MIN_GAS_LIMIT \ + --extra-data $EXTRA_DATA +``` + +Output: Transaction Hash \ No newline at end of file