From 378aec67eb0c53ae54b9c99f66188ca8f76a5d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDiga=20Kokelj?= Date: Fri, 24 Nov 2023 10:17:31 +0100 Subject: [PATCH 1/5] Use eth sign typed data v4 in gateway (#1643) --- design/ux/Obscuro_Gateway.md | 36 ++++- go/common/viewingkey/viewing_key.go | 133 ++++++++++++++++++ go/enclave/enclave.go | 24 ++-- go/enclave/events/subscription_manager.go | 6 +- go/enclave/vkhandler/vk_handler.go | 38 ++--- go/enclave/vkhandler/vk_handler_test.go | 42 ++++-- .../obscurogateway/obscurogateway_test.go | 1 + tools/walletextension/api/routes.go | 14 +- .../api/staticOG/javascript.js | 82 +++++++---- tools/walletextension/common/common.go | 29 ---- tools/walletextension/common/constants.go | 2 +- tools/walletextension/config/config.go | 1 + .../container/walletextension_container.go | 2 +- tools/walletextension/lib/client_lib.go | 19 ++- tools/walletextension/main/cli.go | 6 + .../storage/database/001_init.sql | 4 +- .../storage/database/sqlite.go | 4 +- tools/walletextension/test/apis.go | 3 +- tools/walletextension/wallet_extension.go | 74 ++-------- 19 files changed, 326 insertions(+), 194 deletions(-) diff --git a/design/ux/Obscuro_Gateway.md b/design/ux/Obscuro_Gateway.md index 6c58a31d28..6dad2356f3 100644 --- a/design/ux/Obscuro_Gateway.md +++ b/design/ux/Obscuro_Gateway.md @@ -112,7 +112,7 @@ group Second click end group Third click - Alice -> MM: Automatically open MM with request to \nsign over "Register $UserId for $Acct" + Alice -> MM: Automatically open MM with request to \nsign over EIP-712 formatted message note right This text will be sent as is accompanied by the signature and @@ -129,7 +129,33 @@ Alice -> OG: All further Ten interactions will be to\nhttps://gateway.ten.org/v1 The onboarding should be done in 3 clicks. 1. The user goes to a website (like "ten.org"), where she clicks "Join Ten". This will add a network to their wallet. 2. User connects the wallet to the page. -3. In the wallet popup, the user has to sign over a message: "Register $UserId for $ACCT" +3. In the wallet popup, the user has to sign over EIP-712 formatted message. + +Format of EIP-712 message used for signing viewing keys is: + +``` +types: { + EIP712Domain: [ + { name: "name", type: "string" }, + { name: "version", type: "string" }, + { name: "chainId", type: "uint256" }, + ], + Authentication: [ + { name: "Encryption Token", type: "address" }, + ], + }, + primaryType: "Authentication", + domain: { + name: "Ten", + version: "1.0", + chainId: obscuroChainIDDecimal, + }, + message: { + "Encryption Token": "0x"+userID + }, + }; + +``` ##### Click 1 1. Behind the scenes, a js functions calls "gateway.ten.org/v1/join" where it will generate a VK and send back the hash of the Public key. This is the "UserId" @@ -139,7 +165,7 @@ Notice that the UserId has to be included as a query parameter because it must b ##### Click 2 After these actions are complete, the same page will now ask the user to connect the wallet and switch to Ten. -Automatically the page will open metamask and ask the user to sign over a text "Register $UserId for $ACCT", where ACCT is the current account selected in metamask. +Automatically, the page will open metamask and ask the user to sign over an EIP-712 formatted message as described above. ##### Click 3 Once signed, this will be submitted in the background to: "https://gateway.ten.org/v1?u=$UserId&action=register" @@ -149,8 +175,6 @@ Note: Any further accounts will be registered similarly for the same UserId. Note: The user must guard the UserId. Anyone who can read it, will be able to read the data of this user. -The ultimate goal of this protocol is to submit the "Register $UserId for $ACCT" text to the gateway, which is required by an Ten node to authenticate viewing keys per address. - Note: Alternative UXes that achieve the same goal are ok. @@ -193,7 +217,7 @@ This endpoints responds a json of true or false if the address "a" is already re ### Authenticate address - POST "/authenticate?u=$UserId" JSON Fields: -- text +- address - signature This call will be made by a javascript function after it has collected the signed text containing the UserId and the Address from the wallet. diff --git a/go/common/viewingkey/viewing_key.go b/go/common/viewingkey/viewing_key.go index b5c740774d..7fb8d12b19 100644 --- a/go/common/viewingkey/viewing_key.go +++ b/go/common/viewingkey/viewing_key.go @@ -1,14 +1,19 @@ package viewingkey import ( + "bytes" "crypto/ecdsa" "encoding/hex" + "errors" "fmt" + "math/big" "strings" "github.com/ethereum/go-ethereum/accounts" + "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/ecies" + "github.com/ethereum/go-ethereum/signer/core/apitypes" "github.com/ten-protocol/go-ten/go/wallet" gethcommon "github.com/ethereum/go-ethereum/common" @@ -22,6 +27,18 @@ import ( // signed as-is. const SignedMsgPrefix = "vk" +const ( + EIP712Domain = "EIP712Domain" + EIP712Type = "Authentication" + EIP712DomainName = "name" + EIP712DomainVersion = "version" + EIP712DomainChainID = "chainId" + EIP712EncryptionToken = "Encryption Token" + EIP712DomainNameValue = "Ten" + EIP712DomainVersionValue = "1.0" + UserIDHexLength = 40 +) + // ViewingKey encapsulates the signed viewing key for an account for use in encrypted communication with an enclave type ViewingKey struct { Account *gethcommon.Address // Account address that this Viewing Key is bound to - Users Pubkey address @@ -109,3 +126,119 @@ func GenerateSignMessageOG(vkPubKey []byte, addr *gethcommon.Address) string { userID := crypto.Keccak256Hash(vkPubKey).Bytes() return fmt.Sprintf("Register %s for %s", hex.EncodeToString(userID), strings.ToLower(addr.Hex())) } + +// GenerateAuthenticationEIP712RawData generates raw data (bytes) +// for an EIP-712 message used to authenticate an address with user +func GenerateAuthenticationEIP712RawData(userID string, chainID int64) ([]byte, error) { + if len(userID) != UserIDHexLength { + return nil, fmt.Errorf("userID hex length must be %d, received %d", UserIDHexLength, len(userID)) + } + encryptionToken := "0x" + userID + + types := apitypes.Types{ + EIP712Domain: { + {Name: EIP712DomainName, Type: "string"}, + {Name: EIP712DomainVersion, Type: "string"}, + {Name: EIP712DomainChainID, Type: "uint256"}, + }, + EIP712Type: { + {Name: EIP712EncryptionToken, Type: "address"}, + }, + } + + domain := apitypes.TypedDataDomain{ + Name: EIP712DomainNameValue, + Version: EIP712DomainVersionValue, + ChainId: (*math.HexOrDecimal256)(big.NewInt(chainID)), + } + + message := map[string]interface{}{ + EIP712EncryptionToken: encryptionToken, + } + + typedData := apitypes.TypedData{ + Types: types, + PrimaryType: EIP712Type, + Domain: domain, + Message: message, + } + + // Now we need to create EIP-712 compliant hash. + // It involves hashing the message with its structure, hashing domain separator, + // and then encoding both hashes with specific EIP-712 bytes to construct the final message format. + + // Hash the EIP-712 message using its type and content + typedDataHash, err := typedData.HashStruct(typedData.PrimaryType, typedData.Message) + if err != nil { + return nil, err + } + // Create the domain separator hash for EIP-712 message context + domainSeparator, err := typedData.HashStruct(EIP712Domain, typedData.Domain.Map()) + if err != nil { + return nil, err + } + // Prefix domain and message hashes with EIP-712 version and encoding bytes + rawData := append([]byte("\x19\x01"), append(domainSeparator, typedDataHash...)...) + return rawData, nil +} + +// CalculateUserIDHex CalculateUserID calculates userID from a public key +// (we truncate it, because we want it to have length 20) and encode to hex strings +func CalculateUserIDHex(publicKeyBytes []byte) string { + return hex.EncodeToString(CalculateUserID(publicKeyBytes)) +} + +// CalculateUserID calculates userID from a public key (we truncate it, because we want it to have length 20) +func CalculateUserID(publicKeyBytes []byte) []byte { + return crypto.Keccak256Hash(publicKeyBytes).Bytes()[:20] +} + +func VerifySignatureEIP712(userID string, address *gethcommon.Address, signature []byte, chainID int64) (bool, error) { + // get raw data for structured message + rawData, err := GenerateAuthenticationEIP712RawData(userID, chainID) + if err != nil { + return false, err + } + + // create a hash of structured message (needed for signature verification) + hashBytes := crypto.Keccak256(rawData) + hash := gethcommon.BytesToHash(hashBytes) + + if len(signature) != 65 { + return false, fmt.Errorf("invalid signature length: %d", len(signature)) + } + + // We transform the V from 27/28 to 0/1. This same change is made in Geth internals, for legacy reasons to be able + // to recover the address: https://github.com/ethereum/go-ethereum/blob/55599ee95d4151a2502465e0afc7c47bd1acba77/internal/ethapi/api.go#L452-L459 + if signature[64] == 27 || signature[64] == 28 { + signature[64] -= 27 + } + + pubKeyBytes, err := crypto.Ecrecover(hash[:], signature) + if err != nil { + return false, fmt.Errorf("invalid signature: %w", err) + } + + pubKey, err := crypto.UnmarshalPubkey(pubKeyBytes) + if err != nil { + return false, fmt.Errorf("cannot unmarshal public key: %w", err) + } + + recoveredAddr := crypto.PubkeyToAddress(*pubKey) + + if !bytes.Equal(recoveredAddr.Bytes(), address.Bytes()) { + return false, errors.New("address from signature not the same as expected") + } + + r := new(big.Int).SetBytes(signature[:32]) + s := new(big.Int).SetBytes(signature[32:64]) + + // Verify the signature + isValid := ecdsa.Verify(pubKey, hashBytes, r, s) + + if !isValid { + return false, errors.New("signature is not valid") + } + + return true, nil +} diff --git a/go/enclave/enclave.go b/go/enclave/enclave.go index 2cc0fedab8..f0f7b37385 100644 --- a/go/enclave/enclave.go +++ b/go/enclave/enclave.go @@ -180,7 +180,7 @@ func NewEnclave( crossChainProcessors := crosschain.New(&config.MessageBusAddress, storage, big.NewInt(config.ObscuroChainID), logger) - subscriptionManager := events.NewSubscriptionManager(&rpcEncryptionManager, storage, logger) + subscriptionManager := events.NewSubscriptionManager(&rpcEncryptionManager, storage, config.ObscuroChainID, logger) gasOracle := gas.NewGasOracle() blockProcessor := components.NewBlockProcessor(storage, crossChainProcessors, gasOracle, logger) @@ -491,7 +491,7 @@ func (e *enclaveImpl) SubmitTx(tx common.EncryptedTx) (*responses.RawTx, common. } // extract, create and validate the VK encryption handler - vkHandler, err := createVKHandler(&viewingKeyAddress, paramList[0]) + vkHandler, err := createVKHandler(&viewingKeyAddress, paramList[0], e.config.ObscuroChainID) if err != nil { return responses.AsPlaintextError(fmt.Errorf("unable to create VK encryptor - %w", err)), nil } @@ -629,7 +629,7 @@ func (e *enclaveImpl) ObsCall(encryptedParams common.EncryptedParamsCall) (*resp } // extract, create and validate the VK encryption handler - vkHandler, err := createVKHandler(apiArgs.From, paramList[0]) + vkHandler, err := createVKHandler(apiArgs.From, paramList[0], e.config.ObscuroChainID) if err != nil { return responses.AsPlaintextError(fmt.Errorf("unable to create VK encryptor - %w", err)), nil } @@ -689,7 +689,7 @@ func (e *enclaveImpl) GetTransactionCount(encryptedParams common.EncryptedParams address := gethcommon.HexToAddress(addressStr) // extract, create and validate the VK encryption handler - vkHandler, err := createVKHandler(&address, paramList[0]) + vkHandler, err := createVKHandler(&address, paramList[0], e.config.ObscuroChainID) if err != nil { return responses.AsPlaintextError(fmt.Errorf("unable to create VK encryptor - %w", err)), nil } @@ -748,7 +748,7 @@ func (e *enclaveImpl) GetTransaction(encryptedParams common.EncryptedParamsGetTx } // extract, create and validate the VK encryption handler - vkHandler, err := createVKHandler(&viewingKeyAddress, paramList[0]) + vkHandler, err := createVKHandler(&viewingKeyAddress, paramList[0], e.config.ObscuroChainID) if err != nil { return responses.AsPlaintextError(fmt.Errorf("unable to create VK encryptor - %w", err)), nil } @@ -803,7 +803,7 @@ func (e *enclaveImpl) GetTransactionReceipt(encryptedParams common.EncryptedPara } // extract, create and validate the VK encryption handler - vkHandler, err := createVKHandler(&sender, paramList[0]) + vkHandler, err := createVKHandler(&sender, paramList[0], e.config.ObscuroChainID) if err != nil { e.logger.Trace("error getting the vk ", "txHash", txHash, log.ErrKey, err) return responses.AsPlaintextError(fmt.Errorf("unable to create VK encryptor - %w", err)), nil @@ -920,7 +920,7 @@ func (e *enclaveImpl) GetBalance(encryptedParams common.EncryptedParamsGetBalanc } // extract, create and validate the VK encryption handler - vkHandler, err := createVKHandler(encryptAddress, paramList[0]) + vkHandler, err := createVKHandler(encryptAddress, paramList[0], e.config.ObscuroChainID) if err != nil { return responses.AsPlaintextError(fmt.Errorf("unable to create VK encryptor - %w", err)), nil } @@ -1015,7 +1015,7 @@ func (e *enclaveImpl) EstimateGas(encryptedParams common.EncryptedParamsEstimate } // extract, create and validate the VK encryption handler - vkHandler, err := createVKHandler(callMsg.From, paramList[0]) + vkHandler, err := createVKHandler(callMsg.From, paramList[0], e.config.ObscuroChainID) if err != nil { return responses.AsPlaintextError(fmt.Errorf("unable to create VK encryptor - %w", err)), nil } @@ -1069,7 +1069,7 @@ func (e *enclaveImpl) GetLogs(encryptedParams common.EncryptedParamsGetLogs) (*r } // extract, create and validate the VK encryption handler - vkHandler, err := createVKHandler(forAddress, paramList[0]) + vkHandler, err := createVKHandler(forAddress, paramList[0], e.config.ObscuroChainID) if err != nil { return responses.AsPlaintextError(fmt.Errorf("unable to create VK encryptor - %w", err)), nil } @@ -1333,7 +1333,7 @@ func (e *enclaveImpl) GetCustomQuery(encryptedParams common.EncryptedParamsGetSt } // extract, create and validate the VK encryption handler - vkHandler, err := createVKHandler(&privateCustomQuery.Address, paramList[0]) + vkHandler, err := createVKHandler(&privateCustomQuery.Address, paramList[0], e.config.ObscuroChainID) if err != nil { return responses.AsPlaintextError(fmt.Errorf("unable to create VK encryptor - %w", err)), nil } @@ -1593,13 +1593,13 @@ func replayBatchesToValidState(storage storage.Storage, registry components.Batc return nil } -func createVKHandler(address *gethcommon.Address, vkIntf interface{}) (*vkhandler.VKHandler, error) { +func createVKHandler(address *gethcommon.Address, vkIntf interface{}, chainID int64) (*vkhandler.VKHandler, error) { vkPubKeyHexBytes, accountSignatureHexBytes, err := gethencoding.ExtractViewingKey(vkIntf) if err != nil { return nil, fmt.Errorf("unable to decode viewing key - %w", err) } - encryptor, err := vkhandler.New(address, vkPubKeyHexBytes, accountSignatureHexBytes) + encryptor, err := vkhandler.New(address, vkPubKeyHexBytes, accountSignatureHexBytes, chainID) if err != nil { return nil, fmt.Errorf("unable to create vk encryption for request - %w", err) } diff --git a/go/enclave/events/subscription_manager.go b/go/enclave/events/subscription_manager.go index 47625eb32d..170f4f980d 100644 --- a/go/enclave/events/subscription_manager.go +++ b/go/enclave/events/subscription_manager.go @@ -34,17 +34,19 @@ type SubscriptionManager struct { storage storage.Storage subscriptions map[gethrpc.ID]*common.LogSubscription + chainID int64 subscriptionMutex *sync.RWMutex // the mutex guards the subscriptions/lastHead pair logger gethlog.Logger } -func NewSubscriptionManager(rpcEncryptionManager *rpc.EncryptionManager, storage storage.Storage, logger gethlog.Logger) *SubscriptionManager { +func NewSubscriptionManager(rpcEncryptionManager *rpc.EncryptionManager, storage storage.Storage, chainID int64, logger gethlog.Logger) *SubscriptionManager { return &SubscriptionManager{ rpcEncryptionManager: rpcEncryptionManager, storage: storage, subscriptions: map[gethrpc.ID]*common.LogSubscription{}, + chainID: chainID, subscriptionMutex: &sync.RWMutex{}, logger: logger, } @@ -64,7 +66,7 @@ func (s *SubscriptionManager) AddSubscription(id gethrpc.ID, encryptedSubscripti } // create viewing key encryption handler for pushing future logs - encryptor, err := vkhandler.New(subscription.Account, subscription.PublicViewingKey, subscription.Signature) + encryptor, err := vkhandler.New(subscription.Account, subscription.PublicViewingKey, subscription.Signature, s.chainID) if err != nil { return fmt.Errorf("unable to create vk encryption for request - %w", err) } diff --git a/go/enclave/vkhandler/vk_handler.go b/go/enclave/vkhandler/vk_handler.go index bae8416548..9c4cd4e1a6 100644 --- a/go/enclave/vkhandler/vk_handler.go +++ b/go/enclave/vkhandler/vk_handler.go @@ -5,11 +5,11 @@ import ( "fmt" "github.com/ethereum/go-ethereum/accounts" + gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/crypto/ecies" "github.com/ten-protocol/go-ten/go/common/viewingkey" - gethcommon "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto/ecies" ) var ErrInvalidAddressSignature = fmt.Errorf("invalid viewing key signature for requested address") @@ -22,23 +22,24 @@ type VKHandler struct { publicViewingKey *ecies.PublicKey } -// New creates a new viewing key handler -// checks if the signature is valid -// as well if signature matches account address -// todo (@ziga) - function now accepts both old and new messages -func New(requestedAddr *gethcommon.Address, vkPubKeyBytes, accountSignatureHexBytes []byte) (*VKHandler, error) { - // Recalculate the message signed by MetaMask. - msgToSign := viewingkey.GenerateSignMessageOG(vkPubKeyBytes, requestedAddr) +// VKHandler is responsible for: +// - checking if received signature of a provided viewing key is signed by provided address +// - encrypting payloads with a viewing key (public key) that can only be decrypted by private key signed owned by an address signing it - // We recover the key based on the signed message and the signature. - recoveredAccountPublicKey, err := crypto.SigToPub(accounts.TextHash([]byte(msgToSign)), accountSignatureHexBytes) - if err != nil { - return nil, fmt.Errorf("viewing key but could not validate its signature - %w", err) - } - recoveredAccountAddress := crypto.PubkeyToAddress(*recoveredAccountPublicKey) +// New creates a new viewing key handler if signature is valid and was produced by given address +// It receives address, viewing key and a signature over viewing key. +// In order to check signature validity, we need to reproduce a message that was originally signed +func New(requestedAddr *gethcommon.Address, vkPubKeyBytes, accountSignatureHexBytes []byte, chainID int64) (*VKHandler, error) { + // get userID from viewingKey public key + userID := viewingkey.CalculateUserIDHex(vkPubKeyBytes) + + // check if the signature is valid + // TODO: @ziga - after removing old wallet extension signatures we can return if the signature is invalid + isValidSignature, _ := viewingkey.VerifySignatureEIP712(userID, requestedAddr, accountSignatureHexBytes, chainID) + // Old wallet extension message format // We recover the key based on the signed message and the signature (same as before, but with legacy message format "vk"+" - // todo (@ziga) remove this once old WE message format is deprecated + // todo (@ziga) remove support of old message format when removing old wallet extension endpoints (#2134) msgToSignLegacy := viewingkey.GenerateSignMessage(vkPubKeyBytes) recoveredAccountPublicKeyLegacy, err := crypto.SigToPub(accounts.TextHash([]byte(msgToSignLegacy)), accountSignatureHexBytes) if err != nil { @@ -47,9 +48,8 @@ func New(requestedAddr *gethcommon.Address, vkPubKeyBytes, accountSignatureHexBy recoveredAccountAddressLegacy := crypto.PubkeyToAddress(*recoveredAccountPublicKeyLegacy) // is the requested account address the same as the address recovered from the signature - // todo (@ziga) - we currently check also for legacy address and allow both (remove this after transition period) - if requestedAddr.Hash() != recoveredAccountAddress.Hash() && - requestedAddr.Hash() != recoveredAccountAddressLegacy.Hash() { + if requestedAddr.Hash() != recoveredAccountAddressLegacy.Hash() && + !isValidSignature { return nil, ErrInvalidAddressSignature } diff --git a/go/enclave/vkhandler/vk_handler_test.go b/go/enclave/vkhandler/vk_handler_test.go index bfd1bb9501..a86e6ee74d 100644 --- a/go/enclave/vkhandler/vk_handler_test.go +++ b/go/enclave/vkhandler/vk_handler_test.go @@ -10,6 +10,8 @@ import ( "github.com/ten-protocol/go-ten/go/common/viewingkey" ) +const chainID = 443 + func TestVKHandler(t *testing.T) { // generate user private Key userPrivKey, err := crypto.GenerateKey() @@ -24,19 +26,26 @@ func TestVKHandler(t *testing.T) { t.Fatalf(err.Error()) } vkPubKeyBytes := crypto.CompressPubkey(ecies.ImportECDSAPublic(&vkPrivKey.PublicKey).ExportECDSA()) + userID := viewingkey.CalculateUserIDHex(vkPubKeyBytes) + WEMessageFormatTestHash := accounts.TextHash([]byte(viewingkey.GenerateSignMessage(vkPubKeyBytes))) + EIP712MessageData, err := viewingkey.GenerateAuthenticationEIP712RawData(userID, chainID) + if err != nil { + t.Fatalf(err.Error()) + } + EIP712MessageFormatTestHash := crypto.Keccak256(EIP712MessageData) - tests := map[string]string{ - "WEMessageFormatTest": viewingkey.GenerateSignMessage(vkPubKeyBytes), - "OGMessageFormatTest": viewingkey.GenerateSignMessageOG(vkPubKeyBytes, &userAddr), + tests := map[string][]byte{ + "WEMessageFormatTest": WEMessageFormatTestHash, + "EIP712MessageFormatTest": EIP712MessageFormatTestHash, } - for testName, msgToSign := range tests { + for testName, msgHashToSign := range tests { t.Run(testName, func(t *testing.T) { - signature, err := crypto.Sign(accounts.TextHash([]byte(msgToSign)), userPrivKey) + signature, err := crypto.Sign(msgHashToSign, userPrivKey) assert.NoError(t, err) // Create a new vk Handler - _, err = New(&userAddr, vkPubKeyBytes, signature) + _, err = New(&userAddr, vkPubKeyBytes, signature, chainID) assert.NoError(t, err) }) } @@ -56,25 +65,32 @@ func TestSignAndCheckSignature(t *testing.T) { t.Fatalf(err.Error()) } vkPubKeyBytes := crypto.CompressPubkey(ecies.ImportECDSAPublic(&vkPrivKey.PublicKey).ExportECDSA()) + userID := viewingkey.CalculateUserIDHex(vkPubKeyBytes) + WEMessageFormatTestHash := accounts.TextHash([]byte(viewingkey.GenerateSignMessage(vkPubKeyBytes))) + EIP712MessageData, err := viewingkey.GenerateAuthenticationEIP712RawData(userID, chainID) + if err != nil { + t.Fatalf(err.Error()) + } + EIP712MessageFormatTestHash := crypto.Keccak256(EIP712MessageData) - tests := map[string]string{ - "WEMessageFormatTest": viewingkey.GenerateSignMessage(vkPubKeyBytes), - "OGMessageFormatTest": viewingkey.GenerateSignMessageOG(vkPubKeyBytes, &userAddr), + tests := map[string][]byte{ + "WEMessageFormatTest": WEMessageFormatTestHash, + "EIP712MessageFormatTest": EIP712MessageFormatTestHash, } - for testName, msgToSign := range tests { + for testName, msgHashToSign := range tests { t.Run(testName, func(t *testing.T) { // sign the message - signature, err := crypto.Sign(accounts.TextHash([]byte(msgToSign)), userPrivKey) + signature, err := crypto.Sign(msgHashToSign, userPrivKey) assert.NoError(t, err) // Recover the key based on the signed message and the signature. - recoveredAccountPublicKey, err := crypto.SigToPub(accounts.TextHash([]byte(msgToSign)), signature) + recoveredAccountPublicKey, err := crypto.SigToPub(msgHashToSign, signature) assert.NoError(t, err) recoveredAccountAddress := crypto.PubkeyToAddress(*recoveredAccountPublicKey) if recoveredAccountAddress.Hex() != userAddr.Hex() { - t.Errorf("unable to recover user address from signature") + t.Fatalf("Expected user address %s, got %s", userAddr.Hex(), recoveredAccountAddress.Hex()) } _, err = crypto.DecompressPubkey(vkPubKeyBytes) diff --git a/integration/obscurogateway/obscurogateway_test.go b/integration/obscurogateway/obscurogateway_test.go index 65f0391997..70091d1ac1 100644 --- a/integration/obscurogateway/obscurogateway_test.go +++ b/integration/obscurogateway/obscurogateway_test.go @@ -63,6 +63,7 @@ func TestObscuroGateway(t *testing.T) { LogPath: "sys_out", VerboseFlag: false, DBType: "sqlite", + TenChainID: 443, } obscuroGwContainer := container.NewWalletExtensionContainerFromConfig(obscuroGatewayConf, testlog.Logger()) diff --git a/tools/walletextension/api/routes.go b/tools/walletextension/api/routes.go index a9ebfd7973..a933874fcf 100644 --- a/tools/walletextension/api/routes.go +++ b/tools/walletextension/api/routes.go @@ -301,25 +301,25 @@ func authenticateRequestHandler(walletExt *walletextension.WalletExtension, conn return } - // get message from the request - message, ok := reqJSONMap[common.JSONKeyMessage] - if !ok || message == "" { - handleError(conn, walletExt.Logger(), fmt.Errorf("unable to read message field from the request")) + // get address from the request + address, ok := reqJSONMap[common.JSONKeyAddress] + if !ok || address == "" { + handleError(conn, walletExt.Logger(), fmt.Errorf("unable to read address field from the request")) return } // read userID from query params hexUserID, err := getUserID(conn, 2) if err != nil { - handleError(conn, walletExt.Logger(), fmt.Errorf("malformed query: 'u' required - representing userID - %w", err)) + handleError(conn, walletExt.Logger(), fmt.Errorf("malformed query: 'u' required - representing encryption token - %w", err)) return } // check signature and add address and signature for that user - err = walletExt.AddAddressToUser(hexUserID, message, signature) + err = walletExt.AddAddressToUser(hexUserID, address, signature) if err != nil { handleError(conn, walletExt.Logger(), fmt.Errorf("internal error")) - walletExt.Logger().Error("error adding address to user with message", "message", message, log.ErrKey, err) + walletExt.Logger().Error(fmt.Sprintf("error adding address: %s to user: %s with signature: %s", address, hexUserID, signature)) return } err = conn.WriteResponse([]byte(common.SuccessMsg)) diff --git a/tools/walletextension/api/staticOG/javascript.js b/tools/walletextension/api/staticOG/javascript.js index 538f85b9d5..69e869d078 100644 --- a/tools/walletextension/api/staticOG/javascript.js +++ b/tools/walletextension/api/staticOG/javascript.js @@ -19,6 +19,7 @@ const pathQuery = obscuroGatewayVersion + "/query/"; const pathRevoke = obscuroGatewayVersion + "/revoke/"; const pathVersion = "/version/"; const obscuroChainIDDecimal = 443; +const userIDHexLength = 40; const methodPost = "post"; const methodGet = "get"; const jsonHeaders = { @@ -30,7 +31,7 @@ const metamaskPersonalSign = "personal_sign"; const obscuroChainIDHex = "0x" + obscuroChainIDDecimal.toString(16); // Convert to hexadecimal and prefix with '0x' function isValidUserIDFormat(value) { - return typeof value === "string" && value.length === 64; + return typeof value === "string" && value.length === userIDHexLength; } let obscuroGatewayAddress = @@ -118,39 +119,58 @@ async function addNetworkToMetaMask(ethereum, userID, chainIDDecimal) { return true; } -async function authenticateAccountWithObscuroGateway( - ethereum, - account, - userID -) { - const isAuthenticated = await accountIsAuthenticated(account, userID); - if (isAuthenticated) { - return "Account is already authenticated"; - } +async function authenticateAccountWithObscuroGatewayEIP712(ethereum, account, userID) { + const isAuthenticated = await accountIsAuthenticated(account, userID) - const textToSign = "Register " + userID + " for " + account.toLowerCase(); - const signature = await ethereum - .request({ - method: metamaskPersonalSign, - params: [textToSign, account], - }) - .catch((_) => { - return -1; - }); - if (signature === -1) { - return "Signing failed"; + if (isAuthenticated) { + return "Account is already authenticated" } - const authenticateUserURL = pathAuthenticate + "?u=" + userID; - const authenticateFields = { signature: signature, message: textToSign }; - const authenticateResp = await fetch(authenticateUserURL, { - method: methodPost, - headers: jsonHeaders, - body: JSON.stringify(authenticateFields), + const typedData = { + types: { + EIP712Domain: [ + { name: "name", type: "string" }, + { name: "version", type: "string" }, + { name: "chainId", type: "uint256" }, + ], + Authentication: [ + { name: "Encryption Token", type: "address" }, + ], + }, + primaryType: "Authentication", + domain: { + name: "Ten", + version: "1.0", + chainId: obscuroChainIDDecimal, + }, + message: { + "Encryption Token": "0x"+userID + }, + }; + + const data = JSON.stringify(typedData); + const signature = await ethereum.request({ + method: "eth_signTypedData_v4", + params: [account, data], + }).catch(_ => { + console.log("signing failed!") + return -1; }); - return await authenticateResp.text(); + + + const authenticateUserURL = pathAuthenticate+"?u="+userID + const authenticateFields = {"signature": signature, "address": account } + const authenticateResp = await fetch( + authenticateUserURL, { + method: methodPost, + headers: jsonHeaders, + body: JSON.stringify(authenticateFields) + } + ); + return await authenticateResp.text() } + async function accountIsAuthenticated(account, userID) { const queryAccountUserID = pathQuery + "?u=" + userID + "&a=" + account; const isAuthenticatedResponse = await fetch(queryAccountUserID, { @@ -275,7 +295,7 @@ async function populateAccountsTable(document, tableBody, userID) { connectButton.style.cursor = "pointer"; connectButton.addEventListener("click", async (event) => { event.preventDefault(); - await authenticateAccountWithObscuroGateway(ethereum, account, userID); + await authenticateAccountWithObscuroGatewayEIP712(ethereum, account, userID); }); statusCell.appendChild(connectButton); } @@ -435,7 +455,7 @@ const initialize = async () => { beginBox.style.visibility = "hidden"; spinner.style.visibility = "visible"; for (const account of accounts) { - await authenticateAccountWithObscuroGateway(ethereum, account, userID); + await authenticateAccountWithObscuroGatewayEIP712(ethereum, account, userID); accountsTable.style.display = "block"; await populateAccountsTable(document, tableBody, userID); } @@ -445,7 +465,7 @@ const initialize = async () => { if (isValidUserIDFormat(await getUserID())) { userID = await getUserID(); for (const account of accounts) { - await authenticateAccountWithObscuroGateway( + await authenticateAccountWithObscuroGatewayEIP712( ethereum, account, userID diff --git a/tools/walletextension/common/common.go b/tools/walletextension/common/common.go index 4a3698d945..d2e974beec 100644 --- a/tools/walletextension/common/common.go +++ b/tools/walletextension/common/common.go @@ -1,12 +1,9 @@ package common import ( - "crypto/ecdsa" "encoding/hex" "encoding/json" - "errors" "fmt" - "regexp" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/ecies" @@ -17,8 +14,6 @@ import ( gethlog "github.com/ethereum/go-ethereum/log" ) -var authenticateMessageRegex = regexp.MustCompile(MessageFormatRegex) - // PrivateKeyToCompressedPubKey converts *ecies.PrivateKey to compressed PubKey ([]byte with length 33) func PrivateKeyToCompressedPubKey(prvKey *ecies.PrivateKey) []byte { ecdsaPublicKey := prvKey.PublicKey.ExportECDSA() @@ -37,30 +32,6 @@ func BytesToPrivateKey(keyBytes []byte) (*ecies.PrivateKey, error) { return eciesPrivateKey, nil } -// CalculateUserID calculates userID from a public key -func CalculateUserID(publicKeyBytes []byte) []byte { - return crypto.Keccak256Hash(publicKeyBytes).Bytes() -} - -// GetUserIDAndAddressFromMessage checks if message is in correct format and extracts userID and address from it -func GetUserIDAndAddressFromMessage(message string) (string, string, error) { - if authenticateMessageRegex.MatchString(message) { - params := authenticateMessageRegex.FindStringSubmatch(message) - return params[1], params[2], nil - } - return "", "", errors.New("invalid message format") -} - -// GetAddressAndPubKeyFromSignature gets an address that was used to sign given signature -func GetAddressAndPubKeyFromSignature(messageHash []byte, signature []byte) (gethcommon.Address, *ecdsa.PublicKey, error) { - pubKey, err := crypto.SigToPub(messageHash, signature) - if err != nil { - return gethcommon.Address{}, nil, err - } - - return crypto.PubkeyToAddress(*pubKey), pubKey, nil -} - // GetUserIDbyte converts userID from string to correct byte format func GetUserIDbyte(userID string) ([]byte, error) { return hex.DecodeString(userID) diff --git a/tools/walletextension/common/constants.go b/tools/walletextension/common/constants.go index f7ab956396..ee62e18742 100644 --- a/tools/walletextension/common/constants.go +++ b/tools/walletextension/common/constants.go @@ -40,7 +40,7 @@ const ( UserQueryParameter = "u" AddressQueryParameter = "a" MessageFormatRegex = `^Register\s(\w+)\sfor\s(\w+)$` - MessageUserIDLen = 64 + MessageUserIDLen = 40 SignatureLen = 65 EthereumAddressLen = 42 PersonalSignMessagePrefix = "\x19Ethereum Signed Message:\n%d%s" diff --git a/tools/walletextension/config/config.go b/tools/walletextension/config/config.go index 2ee16d3b65..0914a93fe4 100644 --- a/tools/walletextension/config/config.go +++ b/tools/walletextension/config/config.go @@ -12,4 +12,5 @@ type Config struct { VerboseFlag bool DBType string DBConnectionURL string + TenChainID int } diff --git a/tools/walletextension/container/walletextension_container.go b/tools/walletextension/container/walletextension_container.go index 3e2ebc94c4..65ee6f3144 100644 --- a/tools/walletextension/container/walletextension_container.go +++ b/tools/walletextension/container/walletextension_container.go @@ -70,7 +70,7 @@ func NewWalletExtensionContainerFromConfig(config config.Config, logger gethlog. } stopControl := stopcontrol.New() - walletExt := walletextension.New(hostRPCBindAddr, &userAccountManager, databaseStorage, stopControl, version, logger) + walletExt := walletextension.New(hostRPCBindAddr, &userAccountManager, databaseStorage, stopControl, version, logger, &config) httpRoutes := api.NewHTTPRoutes(walletExt) httpServer := api.NewHTTPServer(fmt.Sprintf("%s:%d", config.WalletExtensionHost, config.WalletExtensionPortHTTP), httpRoutes) diff --git a/tools/walletextension/lib/client_lib.go b/tools/walletextension/lib/client_lib.go index c0a3d5c390..be93d990ec 100644 --- a/tools/walletextension/lib/client_lib.go +++ b/tools/walletextension/lib/client_lib.go @@ -9,9 +9,11 @@ import ( "net/http" "strings" + "github.com/ten-protocol/go-ten/integration" + gethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - "github.com/ten-protocol/go-ten/tools/walletextension/common" + "github.com/ten-protocol/go-ten/go/common/viewingkey" "github.com/valyala/fasthttp" ) @@ -44,17 +46,19 @@ func (o *OGLib) Join() error { func (o *OGLib) RegisterAccount(pk *ecdsa.PrivateKey, addr gethcommon.Address) error { // create the registration message - message := fmt.Sprintf("Register %s for %s", o.userID, strings.ToLower(addr.Hex())) - prefixedMessage := fmt.Sprintf(common.PersonalSignMessagePrefix, len(message), message) + rawMessage, err := viewingkey.GenerateAuthenticationEIP712RawData(string(o.userID), integration.ObscuroChainID) + if err != nil { + return err + } - messageHash := crypto.Keccak256([]byte(prefixedMessage)) + messageHash := crypto.Keccak256(rawMessage) sig, err := crypto.Sign(messageHash, pk) if err != nil { return fmt.Errorf("failed to sign message: %w", err) } sig[64] += 27 signature := "0x" + hex.EncodeToString(sig) - payload := fmt.Sprintf("{\"signature\": \"%s\", \"message\": \"%s\"}", signature, message) + payload := fmt.Sprintf("{\"signature\": \"%s\", \"address\": \"%s\"}", signature, addr.Hex()) // issue the registration message req, err := http.NewRequestWithContext( @@ -76,10 +80,13 @@ func (o *OGLib) RegisterAccount(pk *ecdsa.PrivateKey, addr gethcommon.Address) e } defer response.Body.Close() - _, err = io.ReadAll(response.Body) + r, err := io.ReadAll(response.Body) if err != nil { return fmt.Errorf("unable to read response - %w", err) } + if string(r) != "success" { + return fmt.Errorf("expected success, got %s", string(r)) + } return nil } diff --git a/tools/walletextension/main/cli.go b/tools/walletextension/main/cli.go index b79b7c2625..119a4b9289 100644 --- a/tools/walletextension/main/cli.go +++ b/tools/walletextension/main/cli.go @@ -51,6 +51,10 @@ const ( dbConnectionURLFlagName = "dbConnectionURL" dbConnectionURLFlagDefault = "" dbConnectionURLFlagUsage = "If dbType is set to mariaDB, this must be set. ex: obscurouser:password@tcp(127.0.0.1:3306)/ogdb" + + tenChainIDName = "tenChainID" + tenChainIDDefault = 443 + tenChainIDFlagUsage = "ChainID of Ten network that the gateway is communicating with" ) func parseCLIArgs() config.Config { @@ -65,6 +69,7 @@ func parseCLIArgs() config.Config { verboseFlag := flag.Bool(verboseFlagName, verboseFlagDefault, verboseFlagUsage) dbType := flag.String(dbTypeFlagName, dbTypeFlagDefault, dbTypeFlagUsage) dbConnectionURL := flag.String(dbConnectionURLFlagName, dbConnectionURLFlagDefault, dbConnectionURLFlagUsage) + tenChainID := flag.Int(tenChainIDName, tenChainIDDefault, tenChainIDFlagUsage) flag.Parse() return config.Config{ @@ -78,5 +83,6 @@ func parseCLIArgs() config.Config { VerboseFlag: *verboseFlag, DBType: *dbType, DBConnectionURL: *dbConnectionURL, + TenChainID: *tenChainID, } } diff --git a/tools/walletextension/storage/database/001_init.sql b/tools/walletextension/storage/database/001_init.sql index 20087a4c5a..9cf37e7a17 100644 --- a/tools/walletextension/storage/database/001_init.sql +++ b/tools/walletextension/storage/database/001_init.sql @@ -5,11 +5,11 @@ USE ogdb; GRANT SELECT, INSERT, UPDATE, DELETE ON ogdb.* TO 'obscurouser'; CREATE TABLE IF NOT EXISTS ogdb.users ( - user_id varbinary(32) PRIMARY KEY, + user_id varbinary(20) PRIMARY KEY, private_key varbinary(32) ); CREATE TABLE IF NOT EXISTS ogdb.accounts ( - user_id varbinary(32), + user_id varbinary(20), account_address varbinary(20), signature varbinary(65), FOREIGN KEY(user_id) REFERENCES users(user_id) ON DELETE CASCADE diff --git a/tools/walletextension/storage/database/sqlite.go b/tools/walletextension/storage/database/sqlite.go index 1b0b0c5a12..0140d99470 100644 --- a/tools/walletextension/storage/database/sqlite.go +++ b/tools/walletextension/storage/database/sqlite.go @@ -39,7 +39,7 @@ func NewSqliteDatabase(dbPath string) (*SqliteDatabase, error) { // create users table _, err = db.Exec(`CREATE TABLE IF NOT EXISTS users ( - user_id binary(32) PRIMARY KEY, + user_id binary(20) PRIMARY KEY, private_key binary(32) );`) @@ -49,7 +49,7 @@ func NewSqliteDatabase(dbPath string) (*SqliteDatabase, error) { // create accounts table _, err = db.Exec(`CREATE TABLE IF NOT EXISTS accounts ( - user_id binary(32), + user_id binary(20), account_address binary(20), signature binary(65), FOREIGN KEY(user_id) REFERENCES users(user_id) ON DELETE CASCADE diff --git a/tools/walletextension/test/apis.go b/tools/walletextension/test/apis.go index 81138b4dc6..746563a937 100644 --- a/tools/walletextension/test/apis.go +++ b/tools/walletextension/test/apis.go @@ -23,6 +23,7 @@ import ( const ( l2ChainIDHex = "0x309" + l2ChainIDDecimal = 443 enclavePrivateKeyHex = "81acce9620f0adf1728cb8df7f6b8b8df857955eb9e8b7aed6ef8390c09fc207" ) @@ -171,7 +172,7 @@ func (api *DummyAPI) reEncryptParams(encryptedParams []byte) (*responses.Enclave return responses.AsEmptyResponse(), fmt.Errorf("could not decrypt params with enclave private key. Cause: %w", err) } - encryptor, err := vkhandler.New(api.address, api.viewingKey, api.signature) + encryptor, err := vkhandler.New(api.address, api.viewingKey, api.signature, l2ChainIDDecimal) if err != nil { return nil, fmt.Errorf("unable to create vk encryption for request - %w", err) } diff --git a/tools/walletextension/wallet_extension.go b/tools/walletextension/wallet_extension.go index eb3b9aaf26..2920933d8d 100644 --- a/tools/walletextension/wallet_extension.go +++ b/tools/walletextension/wallet_extension.go @@ -2,11 +2,11 @@ package walletextension import ( "bytes" - "crypto/ecdsa" "encoding/hex" "errors" "fmt" - "math/big" + + "github.com/ten-protocol/go-ten/tools/walletextension/config" "github.com/ten-protocol/go-ten/go/common/log" @@ -35,6 +35,7 @@ type WalletExtension struct { logger gethlog.Logger stopControl *stopcontrol.StopControl version string + config *config.Config } func New( @@ -44,6 +45,7 @@ func New( stopControl *stopcontrol.StopControl, version string, logger gethlog.Logger, + config *config.Config, ) *WalletExtension { return &WalletExtension{ hostAddr: hostAddr, @@ -53,6 +55,7 @@ func New( logger: logger, stopControl: stopControl, version: version, + config: config, } } @@ -188,7 +191,7 @@ func (w *WalletExtension) GenerateAndStoreNewUser() (string, error) { } // create UserID and store it in the database with the private key - userID := common.CalculateUserID(common.PrivateKeyToCompressedPubKey(viewingPrivateKeyEcies)) + userID := viewingkey.CalculateUserID(common.PrivateKeyToCompressedPubKey(viewingPrivateKeyEcies)) err = w.storage.AddUser(userID, crypto.FromECDSA(viewingPrivateKeyEcies.ExportECDSA())) if err != nil { w.Logger().Error(fmt.Sprintf("failed to save user to the database: %s", err)) @@ -202,28 +205,13 @@ func (w *WalletExtension) GenerateAndStoreNewUser() (string, error) { return hexUserID, nil } -// AddAddressToUser checks if message is in correct format and if signature is valid. If all checks pass we save address and signature against userID -func (w *WalletExtension) AddAddressToUser(hexUserID string, message string, signature []byte) error { - // parse the message to get userID and account address - messageUserID, messageAddressHex, err := common.GetUserIDAndAddressFromMessage(message) - if err != nil { - w.Logger().Error(fmt.Errorf("submitted message (%s) is not in the correct format", message).Error()) - return err - } - - // check if userID corresponds to the one in the message and check if the length of hex encoded userID is correct - if hexUserID != messageUserID || len(messageUserID) != common.MessageUserIDLen { - w.Logger().Error(fmt.Errorf("submitted message (%s) is not in the correct format", message).Error()) - return errors.New("userID from message does not match userID from request") - } - - addressFromMessage := gethcommon.HexToAddress(messageAddressHex) - - // check if message was signed by the correct address and if signature is valid - valid, err := verifySignature(message, signature, addressFromMessage) +// AddAddressToUser checks if a message is in correct format and if signature is valid. If all checks pass we save address and signature against userID +func (w *WalletExtension) AddAddressToUser(hexUserID string, address string, signature []byte) error { + addressFromMessage := gethcommon.HexToAddress(address) + // check if a message was signed by the correct address and if the signature is valid + valid, err := viewingkey.VerifySignatureEIP712(hexUserID, &addressFromMessage, signature, int64(w.config.TenChainID)) if !valid && err != nil { - w.Logger().Error(fmt.Errorf("error: signature is not valid: %s", string(signature)).Error()) - return err + return fmt.Errorf("signature is not valid: %w", err) } // register the account for that viewing key @@ -328,44 +316,6 @@ func (w *WalletExtension) UserExists(hexUserID string) bool { return len(key) > 0 } -// verifySignature checks if a message was signed by the correct address and if signature is valid -func verifySignature(message string, signature []byte, address gethcommon.Address) (bool, error) { - // prefix the message like in the personal_sign method - prefixedMessage := fmt.Sprintf(common.PersonalSignMessagePrefix, len(message), message) - messageHash := crypto.Keccak256([]byte(prefixedMessage)) - - // check if the signature length is correct - if len(signature) != common.SignatureLen { - return false, errors.New("incorrect signature length") - } - - // We transform the V from 27/28 to 0/1. This same change is made in Geth internals, for legacy reasons to be able - // to recover the address: https://github.com/ethereum/go-ethereum/blob/55599ee95d4151a2502465e0afc7c47bd1acba77/internal/ethapi/api.go#L452-L459 - signature[64] -= 27 - - addressFromSignature, pubKeyFromSignature, err := common.GetAddressAndPubKeyFromSignature(messageHash, signature) - if err != nil { - return false, err - } - - if !bytes.Equal(addressFromSignature.Bytes(), address.Bytes()) { - return false, errors.New("address from signature not the same as expected") - } - - // Split signature into r, s - r := new(big.Int).SetBytes(signature[:32]) - s := new(big.Int).SetBytes(signature[32:64]) - - // Verify the signature - isValid := ecdsa.Verify(pubKeyFromSignature, messageHash, r, s) - - if !isValid { - return false, errors.New("signature is not valid") - } - - return true, nil -} - func adjustStateRoot(rpcResp interface{}, respMap map[string]interface{}) { if resultMap, ok := rpcResp.(map[string]interface{}); ok { if val, foundRoot := resultMap[common.JSONKeyRoot]; foundRoot { From 3af59e7626909f2d110a3d9874adf9aa1499821c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDiga=20Kokelj?= Date: Mon, 27 Nov 2023 10:51:37 +0100 Subject: [PATCH 2/5] add default user for old endpoints (#1665) --- tools/walletextension/api/routes.go | 6 +-- .../container/walletextension_container.go | 43 ++++++++++++++++++- .../test/wallet_extension_test.go | 2 +- tools/walletextension/wallet_extension.go | 11 +++++ 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/tools/walletextension/api/routes.go b/tools/walletextension/api/routes.go index a933874fcf..00f1745adb 100644 --- a/tools/walletextension/api/routes.go +++ b/tools/walletextension/api/routes.go @@ -162,7 +162,7 @@ func ethRequestHandler(walletExt *walletextension.WalletExtension, conn userconn // Get userID hexUserID, err := getUserID(conn, 1) if err != nil || !walletExt.UserExists(hexUserID) { - walletExt.Logger().Error("user not found in the query params: %w. Using the default user", log.ErrKey, err) + walletExt.Logger().Info("user not found in the query params: %w. Using the default user", log.ErrKey, err) hexUserID = hex.EncodeToString([]byte(common.DefaultUser)) // todo (@ziga) - this can be removed once old WE endpoints are removed } @@ -342,7 +342,7 @@ func queryRequestHandler(walletExt *walletextension.WalletExtension, conn userco hexUserID, err := getUserID(conn, 2) if err != nil { handleError(conn, walletExt.Logger(), fmt.Errorf("user ('u') not found in query parameters")) - walletExt.Logger().Error("user not found in the query params", log.ErrKey, err) + walletExt.Logger().Info("user not found in the query params", log.ErrKey, err) return } address, err := getQueryParameter(conn.ReadRequestParams(), common.AddressQueryParameter) @@ -394,7 +394,7 @@ func revokeRequestHandler(walletExt *walletextension.WalletExtension, conn userc hexUserID, err := getUserID(conn, 2) if err != nil { handleError(conn, walletExt.Logger(), fmt.Errorf("user ('u') not found in query parameters")) - walletExt.Logger().Error("user not found in the query params", log.ErrKey, err) + walletExt.Logger().Info("user not found in the query params", log.ErrKey, err) return } diff --git a/tools/walletextension/container/walletextension_container.go b/tools/walletextension/container/walletextension_container.go index 65ee6f3144..0214b6cf72 100644 --- a/tools/walletextension/container/walletextension_container.go +++ b/tools/walletextension/container/walletextension_container.go @@ -1,12 +1,17 @@ package container import ( + "bytes" "encoding/hex" "errors" "fmt" "net/http" "os" + "github.com/ethereum/go-ethereum/common" + + "github.com/ethereum/go-ethereum/crypto" + "github.com/ten-protocol/go-ten/go/common/log" "github.com/ten-protocol/go-ten/go/common/stopcontrol" "github.com/ten-protocol/go-ten/go/rpc" @@ -49,18 +54,52 @@ func NewWalletExtensionContainerFromConfig(config config.Config, logger gethlog. userAccountManager := useraccountmanager.NewUserAccountManager(unAuthedClient, logger, databaseStorage, hostRPCBindAddr) // add default user (when no UserID is provided in the query parameter - for WE endpoints) - userAccountManager.AddAndReturnAccountManager(hex.EncodeToString([]byte(wecommon.DefaultUser))) + defaultUserAccountManager := userAccountManager.AddAndReturnAccountManager(hex.EncodeToString([]byte(wecommon.DefaultUser))) + + // add default user to the database (temporary fix before removing wallet extension endpoints) + accountPrivateKey, err := crypto.GenerateKey() + if err != nil { + logger.Error("Unable to generate key pair for default user", log.ErrKey, err) + os.Exit(1) + } // get all users and their private keys from the database allUsers, err := databaseStorage.GetAllUsers() if err != nil { logger.Error(fmt.Errorf("error getting all users from database, %w", err).Error()) + os.Exit(1) } - // iterate over users create accountManagers and add all accounts to them per user + // iterate over users create accountManagers and add all defaultUserAccounts to them per user for _, user := range allUsers { userAccountManager.AddAndReturnAccountManager(hex.EncodeToString(user.UserID)) logger.Info(fmt.Sprintf("account manager added for user: %s", hex.EncodeToString(user.UserID))) + + // to ensure backwards compatibility we want to load clients for the default user + // TODO @ziga - this code needs to be removed when removing old wallet extension endpoints + if bytes.Equal(user.UserID, []byte(wecommon.DefaultUser)) { + accounts, err := databaseStorage.GetAccounts(user.UserID) + if err != nil { + logger.Error(fmt.Errorf("error getting accounts for user: %s, %w", hex.EncodeToString(user.UserID), err).Error()) + os.Exit(1) + } + for _, account := range accounts { + encClient, err := wecommon.CreateEncClient(hostRPCBindAddr, account.AccountAddress, user.PrivateKey, account.Signature, logger) + if err != nil { + logger.Error(fmt.Errorf("error creating new client, %w", err).Error()) + os.Exit(1) + } + + // add a client to default user + defaultUserAccountManager.AddClient(common.BytesToAddress(account.AccountAddress), encClient) + } + } + } + // TODO @ziga - remove this when removing wallet extension endpoints + err = databaseStorage.AddUser([]byte(wecommon.DefaultUser), crypto.FromECDSA(accountPrivateKey)) + if err != nil { + logger.Error("Unable to save default user to the database", log.ErrKey, err) + os.Exit(1) } // captures version in the env vars diff --git a/tools/walletextension/test/wallet_extension_test.go b/tools/walletextension/test/wallet_extension_test.go index 1b811bc742..5ec9c7546e 100644 --- a/tools/walletextension/test/wallet_extension_test.go +++ b/tools/walletextension/test/wallet_extension_test.go @@ -294,7 +294,7 @@ func TestGetStorageAtForReturningUserID(t *testing.T) { } // make a request to GetStorageAt with correct parameters, but userID that is not present in the database - invalidUserID := "abc123" + invalidUserID := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" respBody2 := makeHTTPEthJSONReqWithUserID(walletHTTPPort, rpc.GetStorageAt, []interface{}{"getUserID", "0", nil}, invalidUserID) if !strings.Contains(string(respBody2), "method eth_getStorageAt cannot be called with an unauthorised client - no signed viewing keys found") { diff --git a/tools/walletextension/wallet_extension.go b/tools/walletextension/wallet_extension.go index 2920933d8d..eb71816728 100644 --- a/tools/walletextension/wallet_extension.go +++ b/tools/walletextension/wallet_extension.go @@ -6,6 +6,8 @@ import ( "errors" "fmt" + "github.com/ten-protocol/go-ten/tools/walletextension/accountmanager" + "github.com/ten-protocol/go-ten/tools/walletextension/config" "github.com/ten-protocol/go-ten/go/common/log" @@ -338,6 +340,15 @@ func (w *WalletExtension) getStorageAtInterceptor(request *common.RPCRequest, he return nil } + // check if we have default user (we don't want to send userID of it out) + if hexUserID == hex.EncodeToString([]byte(common.DefaultUser)) { + response := map[string]interface{}{} + response[common.JSONKeyRPCVersion] = jsonrpc.Version + response[common.JSONKeyID] = request.ID + response[common.JSONKeyResult] = fmt.Sprintf(accountmanager.ErrNoViewingKey, "eth_getStorageAt") + return response + } + _, err = w.storage.GetUserPrivateKey(userID) if err != nil { w.logger.Info("Trying to get userID, but it is not present in our database: ", log.ErrKey, err) From 34221a57c8f90f96af31c8a7d4f43663a5bc7424 Mon Sep 17 00:00:00 2001 From: Matt <98158711+BedrockSquirrel@users.noreply.github.com> Date: Mon, 27 Nov 2023 10:17:39 +0000 Subject: [PATCH 3/5] Local network: pass mgmt contract to l2 contract deploy script (#1664) Co-authored-by: Matt Curtis --- testnet/launcher/docker.go | 1 + testnet/launcher/l2contractdeployer/cmd/main.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/testnet/launcher/docker.go b/testnet/launcher/docker.go index 5fd7b02893..3b282a6fe6 100644 --- a/testnet/launcher/docker.go +++ b/testnet/launcher/docker.go @@ -124,6 +124,7 @@ func (t *Testnet) Start() error { l2cd.WithL2Host("sequencer-host"), l2cd.WithL2WSPort(81), l2cd.WithL1PrivateKey("f52e5418e349dccdda29b6ac8b0abe6576bb7713886aa85abea6181ba731f9bb"), + l2cd.WithManagementContractAddress("0xeDa66Cc53bd2f26896f6Ba6b736B1Ca325DE04eF"), l2cd.WithMessageBusContractAddress("0xFD03804faCA2538F4633B3EBdfEfc38adafa259B"), l2cd.WithL2PrivateKey("8dfb8083da6275ae3e4f41e3e8a8c19d028d32c9247e24530933782f2a05035b"), l2cd.WithHocPKString("6e384a07a01263518a09a5424c7b6bbfc3604ba7d93f47e3a455cbdd7f9f0682"), diff --git a/testnet/launcher/l2contractdeployer/cmd/main.go b/testnet/launcher/l2contractdeployer/cmd/main.go index 781857b7fb..531c1c82c9 100644 --- a/testnet/launcher/l2contractdeployer/cmd/main.go +++ b/testnet/launcher/l2contractdeployer/cmd/main.go @@ -16,7 +16,7 @@ func main() { l2cd.WithL2Host(cliConfig.l2Host), // "host" l2cd.WithL2WSPort(cliConfig.l2WSPort), // 81 l2cd.WithL1PrivateKey(cliConfig.privateKey), // "f52e5418e349dccdda29b6ac8b0abe6576bb7713886aa85abea6181ba731f9bb" - l2cd.WithManagementContractAddress(cliConfig.managementContractAddr), // + l2cd.WithManagementContractAddress(cliConfig.managementContractAddr), // "0xeDa66Cc53bd2f26896f6Ba6b736B1Ca325DE04eF" l2cd.WithMessageBusContractAddress(cliConfig.messageBusContractAddr), // "0xFD03804faCA2538F4633B3EBdfEfc38adafa259B" l2cd.WithL2PrivateKey(cliConfig.l2PrivateKey), // "8dfb8083da6275ae3e4f41e3e8a8c19d028d32c9247e24530933782f2a05035b" l2cd.WithHocPKString(cliConfig.l2HOCPrivateKey), // "6e384a07a01263518a09a5424c7b6bbfc3604ba7d93f47e3a455cbdd7f9f0682"), From f6c7c1b9f450ed919ad84370c00c842bb8f74ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDiga=20Kokelj?= Date: Mon, 27 Nov 2023 11:27:41 +0100 Subject: [PATCH 4/5] add token as query param (#1666) --- .../ux/{Obscuro_Gateway.md => Ten_Gateway.md} | 107 +++++++++--------- integration/constants.go | 30 ++--- .../contract_deployer_test.go | 12 +- integration/faucet/faucet_test.go | 6 +- integration/manualtests/connection_test.go | 2 +- .../networktest/actions/setup_actions.go | 2 +- integration/networktest/env/testnet.go | 4 +- .../networktest/userwallet/userwallet.go | 4 +- integration/obscurogateway/gateway_user.go | 14 +-- ...curogateway_test.go => tengateway_test.go} | 82 +++++++------- integration/obscuroscan/obscuroscan_test.go | 8 +- integration/simulation/devnetwork/config.go | 4 +- .../simulation/devnetwork/dev_network.go | 2 +- integration/simulation/devnetwork/node.go | 4 +- .../simulation/network/network_utils.go | 2 +- .../simulation_full_network_test.go | 2 +- .../simulation/simulation_geth_in_mem_test.go | 2 +- .../simulation/simulation_in_mem_test.go | 2 +- tools/gateway-js/gateway-lib/gateway.js | 6 +- tools/walletextension/README.md | 6 +- .../api/staticOG/javascript.js | 8 +- tools/walletextension/api/utils.go | 16 ++- tools/walletextension/common/constants.go | 4 +- tools/walletextension/lib/client_lib.go | 24 ++-- tools/walletextension/test/utils.go | 2 +- 25 files changed, 183 insertions(+), 172 deletions(-) rename design/ux/{Obscuro_Gateway.md => Ten_Gateway.md} (66%) rename integration/obscurogateway/{obscurogateway_test.go => tengateway_test.go} (89%) diff --git a/design/ux/Obscuro_Gateway.md b/design/ux/Ten_Gateway.md similarity index 66% rename from design/ux/Obscuro_Gateway.md rename to design/ux/Ten_Gateway.md index 6dad2356f3..9c7acf43bb 100644 --- a/design/ux/Obscuro_Gateway.md +++ b/design/ux/Ten_Gateway.md @@ -1,16 +1,16 @@ # The Ten Gateway - Design -The scope of this document is to design a hosted [Wallet Extension](wallet_extension.md) called the "Ten Gateway" (OG). +The scope of this document is to design a hosted [Wallet Extension](wallet_extension.md) called the "Ten Gateway" (TG). -The OG will be a superset of the WE functionality, so this document will only cover the additions. +The TG will be a superset of the WE functionality, so this document will only cover the additions. ## High level overview -The OG will be a [Confidential Web Service](https://medium.com/p/983a2a67fc08), running inside SGX. +The TG will be a [Confidential Web Service](https://medium.com/p/983a2a67fc08), running inside SGX. The current WE is designed to be used by a single user holding multiple addresses accross potentially multiple wallets. -The OG must support mutiple users, each with multiple addresses. It can be seen as offering a WE per user. +The TG must support mutiple users, each with multiple addresses. It can be seen as offering a WE per user. The Ten node has no concept of "User". It only authenticates based on the "blockchain address". It expects to be supplied with a signed viewing key per address, so that it can respond encrypted with that VK. @@ -22,7 +22,7 @@ The AVKs are stored on the local computer in a file. An AVK is a text containing the hash of the public viewing key signed with the "spending key" that controls a blockchain address. -The diagram below depicts the setup once the OG is implemented. +The diagram below depicts the setup once the TG is implemented. ![Architecture diagram](resources/og_arch.png) ```plantuml @startuml @@ -47,9 +47,9 @@ component "Bob's Computer"{ } component "Confidential Web Service"{ node "Ten Gateway" - database "OG Viewing Keys" + database "TG Viewing Keys" } -"OG Viewing Keys" <-> "Ten Gateway" +"TG Viewing Keys" <-> "Ten Gateway" Bob --> "Bob's MetaMask" "Bob's MetaMask" ---> "Ten Gateway" : HTTPS @@ -66,11 +66,11 @@ Charlie --> "Charlie's MetaMask" @enduml ``` -Notice that the OG is a multi-tenant WE running inside SGX and storing the authenticated viewing keys (and other information) in an encrypted database. +Notice that the TG is a multi-tenant WE running inside SGX and storing the authenticated viewing keys (and other information) in an encrypted database. ## User interactions -The key reason for the OG is to allow implementing a 3-click user onboarding process. +The key reason for the TG is to allow implementing a 3-click user onboarding process. ### User on-boarding @@ -86,25 +86,25 @@ autonumber actor "Alice's Browser" as Alice participant MetaMask as MM -participant "https://gateway.ten.org/v1" as OG +participant "https://gateway.ten.org/v1" as TG participant "https://ten.org" as ON group First click Alice -> ON: Join Ten - ON --> Alice: Redirect to OG + ON --> Alice: Redirect to TG note right The point of this sequence is to call the "Create User" - endpoint on the OG + endpoint on the TG end note - Alice -> OG: Create User\n(ajax call behind the scenes) - OG -> OG: Generate and record VK\nand record against UserId + Alice -> TG: Create User\n(ajax call behind the scenes) + TG -> TG: Generate and record VK\nand record against UserId note right The UserId is the hash of the Public Key of the VK end note - OG -> Alice: Send UserId - Alice -> MM: Automatically add "Ten" network with RPC\n"https://gateway.ten.org/v1?u=$UserId" + TG -> Alice: Send Encryption token + Alice -> MM: Automatically add "Ten" network with RPC\n"https://gateway.ten.org/v1?token=$EncryptionToken" end group Second click @@ -121,7 +121,7 @@ group Third click Alice -> MM : Confirm signature end -Alice -> OG: All further Ten interactions will be to\nhttps://gateway.ten.org/v1?u=$UserId +Alice -> TG: All further Ten interactions will be to\nhttps://gateway.ten.org/v1?token=$EncryptionToken @enduml ``` @@ -151,36 +151,36 @@ types: { chainId: obscuroChainIDDecimal, }, message: { - "Encryption Token": "0x"+userID + "Encryption Token": "0x"+encryptionToken }, }; ``` ##### Click 1 -1. Behind the scenes, a js functions calls "gateway.ten.org/v1/join" where it will generate a VK and send back the hash of the Public key. This is the "UserId" -2. After receiving the UserId, the js function will add a new network to the wallet. -The RPC URL of the new Ten network will include the userid: "https://gateway.ten.org/v1?u=$UserId". -Notice that the UserId has to be included as a query parameter because it must be encrypted by https, as it is secret. +1. Behind the scenes, a js functions calls "gateway.ten.org/v1/join" where it will generate a VK and send back the hash of the Public key. This is the "encryption token" +2. After receiving the Encryption token, the js function will add a new network to the wallet. +The RPC URL of the new Ten network will include the encryption token: "https://gateway.ten.org/v1?token=$EncryptionToken". +Notice that the encryption token has to be included as a query parameter because it must be encrypted by https, as it is secret. ##### Click 2 After these actions are complete, the same page will now ask the user to connect the wallet and switch to Ten. Automatically, the page will open metamask and ask the user to sign over an EIP-712 formatted message as described above. ##### Click 3 -Once signed, this will be submitted in the background to: "https://gateway.ten.org/v1?u=$UserId&action=register" +Once signed, this will be submitted in the background to: "https://gateway.ten.org/v1?token=$EncryptionToken&action=register" -Note: Any further accounts will be registered similarly for the same UserId. +Note: Any further accounts will be registered similarly for the same encryption token. -Note: The user must guard the UserId. Anyone who can read it, will be able to read the data of this user. +Note: The user must guard the encryption token. Anyone who can read it, will be able to read the data of this user. Note: Alternative UXes that achieve the same goal are ok. ### Register subsequent addresses -User Alice is onboarded already and has the Ten network configured in her wallet with a UserId. +User Alice is onboarded already and has the Ten network configured in her wallet with an encryption token. She has to go to the same landing page as above and connect her wallet, instead of hitting "Join". When connecting, she can choose a second account. @@ -192,51 +192,52 @@ After signing it will submit to the server The curent WE is single-tenant. It assumes that all registered blockchain addresses belong to the same user. -The OG will keep a many-to-one relationship between addresses and users. It will have multiple users, each with multiple addresses. +The TG will keep a many-to-one relationship between addresses and users. It will have multiple users, each with multiple addresses. -Each request to the OG (except "/join") must have the "u" query parameter. -The first thing, the WE will lookup the userId and then operate in "Wallet Extension" mode, after loading all addresses. +Each request to the TG (except "/join") must have the "u" query parameter. +The first thing, the WE will lookup the encryption token and then operate in "Wallet Extension" mode, after loading all addresses. -Note that the system considers the realm of a UserId as completely independent. Multiple users could register the same addrss, -if they somehow control the spending key. It shouldn't matter since they have different userIds +Note that the system considers the realm of an encryption token as completely independent. Multiple users could register the same addrss, +if they somehow control the spending key. +It shouldn't matter since they have different encryption tokens ## HTTP Endpoints ### Create User - GET "/join" - Generates a key-pair. -- Hashes the public key of the VK - this is the UserId. -- Stores in the db: UserId, PrivateKey -- Return UserId +- Hashes the public key of the VK - this is the encryption token. +- Stores in the db: EncryptionToken, PrivateKey +- Return encryption token Note: Has to be protected against DDOS attacks. -### Query address - Get "/query/address?u=$UserId&a=$Address" +### Query address - Get "/query/address?token=$EncryptionToken&a=$Address" This endpoints responds a json of true or false if the address "a" is already registered for user "u" -### Authenticate address - POST "/authenticate?u=$UserId" +### Authenticate address - POST "/authenticate?token=$EncryptionToken" JSON Fields: - address - signature -This call will be made by a javascript function after it has collected the signed text containing the UserId and the Address from the wallet. +This call will be made by a javascript function after it has collected the signed text containing the encryption token and the Address from the wallet. -This call is equivalent to the current: "submitviewingkey/", but instead it will save the information against the UserId. +This call is equivalent to the current: "submitviewingkey/", but instead it will save the information against the encryption token. Actions: -- check the text is well formed and extract the userId and address -- check the UserId corresponds to the one in the text +- check the text is well formed and extract the encryption token and address +- check the encryption token corresponds to the one in the text - check the signature corresponds to the address and is valid -- save the text+signature against the userId +- save the text+signature against the encryption token -### Revoke UserId - POST "/revoke?u=$UserId" +### Revoke Encryption token - POST "/revoke?t=$EncryptionToken" -When this endpoint is triggered, the userId with the authenticated viewing keys should be deleted. +When this endpoint is triggered, the encryption token with the authenticated viewing keys should be deleted. ### ETH RPC endpoints All the Eth RPC endpoints are implemented as they are now in the WE. -The difference is that the UserId must be checked before any logic, and the registered addresses for that user are loaded in context. +The difference is that the encryption token must be checked before any logic, and the registered addresses for that user are loaded in context. ## SGX @@ -253,7 +254,7 @@ Note that the current WE implements most of this flow. ## Upgradability -When the OG is upgraded, the database with viewing keys has to be handed over to the new version. +When the TG is upgraded, the database with viewing keys has to be handed over to the new version. The best mechanism is to use the transparent upgrading approval we have for the enclave based on an event from the Management Contract. @@ -268,17 +269,17 @@ I propose to start gradually by adding functionality that doesn't break the WE. The tests can use sqlite, same as we do for the enclave. And in the real setup it will be edgelessdb. This code can be extracted from the enclave and made reusable. -2. Store the VKs in the database against a hardcoded userId and create the logic to fetch them based on the hardcoded userId. +2. Store the VKs in the database against a hardcoded encryption token and create the logic to fetch them based on the hardcoded encryption token. Note: At this stage there is no functional change of the wallet extension. Just prepararation. -3. Add the UserId parameter in all request handlers. +3. Add the encryption token parameter in all request handlers. -Note: still no functional change, except that now all the rpc urls in the test need "?u=1" to work +Note: still no functional change, except that now all the rpc urls in the test need "?token1" to work 4. Change the format of the signed string and implement the authenticate endpoint. -5. Do the rest of the wiring of the userId +5. Do the rest of the wiring of the encryption token 6. Implement the "join" endpoint, and make sure everything works E2E @@ -295,7 +296,7 @@ Very simple interface to show that the 3-click approach is possible. # Advanced features -## Allowing users to create accounts on the OG +## Allowing users to create accounts on the TG Maybe using single-sign On. This will allow advanced features. @@ -304,14 +305,14 @@ This will allow advanced features. This could be used for tax purposes, or to prove holdings. -## Revocation of userId +## Revocation of encryption token Users might suspect someone else knows their UserdId. -Note: forgotten userIds are not a problem, because they have high enough entropy. +Note: forgotten encryption tokens are not a problem, because they have high enough entropy. There must be a UI which calls the revocation endpoint. -Note that if the OG operator comes into possession of a UserId, they can circumvent the revocation by launching the service +Note that if the TG operator comes into possession of an encryption token, they can circumvent the revocation by launching the service against a snapshot of the database. To prevent this, revocations could be published on ledger, and make them a first class citizen. diff --git a/integration/constants.go b/integration/constants.go index 1e9f85ed83..37dee9b2f0 100644 --- a/integration/constants.go +++ b/integration/constants.go @@ -12,24 +12,24 @@ const ( StartPortWalletExtensionUnitTest = 40000 StartPortFaucetUnitTest = 41000 StartPortFaucetHTTPUnitTest = 42000 - StartPortObscuroscanUnitTest = 43000 - StartPortObscuroGatewayUnitTest = 44000 + StartPortTenscanUnitTest = 43000 + StartPortTenGatewayUnitTest = 44000 - DefaultGethWSPortOffset = 100 - DefaultGethAUTHPortOffset = 200 - DefaultGethNetworkPortOffset = 300 - DefaultPrysmHTTPPortOffset = 400 - DefaultPrysmP2PPortOffset = 500 - DefaultHostP2pOffset = 600 // The default offset for the host P2p - DefaultEnclaveOffset = 700 // The default offset between a Geth nodes port and the enclave ports. Used in Socket Simulations. - DefaultHostRPCHTTPOffset = 800 // The default offset for the host's RPC HTTP port - DefaultHostRPCWSOffset = 900 // The default offset for the host's RPC websocket port - DefaultObscuroscanHTTPPortOffset = 910 - DefaultObscuroGatewayHTTPPortOffset = 930 - DefaultObscuroGatewayWSPortOffset = 940 + DefaultGethWSPortOffset = 100 + DefaultGethAUTHPortOffset = 200 + DefaultGethNetworkPortOffset = 300 + DefaultPrysmHTTPPortOffset = 400 + DefaultPrysmP2PPortOffset = 500 + DefaultHostP2pOffset = 600 // The default offset for the host P2p + DefaultEnclaveOffset = 700 // The default offset between a Geth nodes port and the enclave ports. Used in Socket Simulations. + DefaultHostRPCHTTPOffset = 800 // The default offset for the host's RPC HTTP port + DefaultHostRPCWSOffset = 900 // The default offset for the host's RPC websocket port + DefaultTenscanHTTPPortOffset = 910 + DefaultTenGatewayHTTPPortOffset = 930 + DefaultTenGatewayWSPortOffset = 940 ) const ( EthereumChainID = 1337 - ObscuroChainID = 443 + TenChainID = 443 ) diff --git a/integration/contractdeployer/contract_deployer_test.go b/integration/contractdeployer/contract_deployer_test.go index 423028caa1..93785918e7 100644 --- a/integration/contractdeployer/contract_deployer_test.go +++ b/integration/contractdeployer/contract_deployer_test.go @@ -56,7 +56,7 @@ func TestCanDeployLayer2ERC20Contract(t *testing.T) { NodePort: uint(hostWSPort), IsL1Deployment: false, PrivateKey: contractDeployerPrivateKeyHex, - ChainID: big.NewInt(integration.ObscuroChainID), + ChainID: big.NewInt(integration.TenChainID), ContractName: contractdeployer.Layer2Erc20Contract, ConstructorParams: []string{erc20ParamOne, erc20ParamTwo, erc20ParamThree}, } @@ -66,7 +66,7 @@ func TestCanDeployLayer2ERC20Contract(t *testing.T) { panic(err) } - contractDeployerWallet := wallet.NewInMemoryWalletFromConfig(contractDeployerPrivateKeyHex, integration.ObscuroChainID, testlog.Logger()) + contractDeployerWallet := wallet.NewInMemoryWalletFromConfig(contractDeployerPrivateKeyHex, integration.TenChainID, testlog.Logger()) contractDeployerClient := getClient(hostWSPort, contractDeployerWallet) var deployedCode string @@ -85,10 +85,10 @@ func TestFaucetSendsFundsOnlyIfNeeded(t *testing.T) { hostWSPort := startPort + integration.DefaultHostRPCWSOffset createObscuroNetwork(t, startPort) - faucetWallet := wallet.NewInMemoryWalletFromConfig(genesis.TestnetPrefundedPK, integration.ObscuroChainID, testlog.Logger()) + faucetWallet := wallet.NewInMemoryWalletFromConfig(genesis.TestnetPrefundedPK, integration.TenChainID, testlog.Logger()) faucetClient := getClient(hostWSPort, faucetWallet) - contractDeployerWallet := wallet.NewInMemoryWalletFromConfig(contractDeployerPrivateKeyHex, integration.ObscuroChainID, testlog.Logger()) + contractDeployerWallet := wallet.NewInMemoryWalletFromConfig(contractDeployerPrivateKeyHex, integration.TenChainID, testlog.Logger()) // We send more than enough to the contract deployer, to make sure prefunding won't be needed. excessivePrealloc := big.NewInt(contractdeployer.Prealloc * 3) testcommon.PrefundWallets(context.Background(), faucetWallet, obsclient.NewAuthObsClient(faucetClient), 0, []wallet.Wallet{contractDeployerWallet}, excessivePrealloc, receiptTimeout) @@ -106,7 +106,7 @@ func TestFaucetSendsFundsOnlyIfNeeded(t *testing.T) { NodePort: uint(startPort + integration.DefaultHostRPCWSOffset), IsL1Deployment: false, PrivateKey: contractDeployerPrivateKeyHex, - ChainID: big.NewInt(integration.ObscuroChainID), + ChainID: big.NewInt(integration.TenChainID), ContractName: contractdeployer.Layer2Erc20Contract, ConstructorParams: []string{erc20ParamOne, erc20ParamTwo, erc20ParamThree}, } @@ -133,7 +133,7 @@ func TestFaucetSendsFundsOnlyIfNeeded(t *testing.T) { func createObscuroNetwork(t *testing.T, startPort int) { // Create the Obscuro network. numberOfNodes := 1 - wallets := params.NewSimWallets(1, numberOfNodes, integration.EthereumChainID, integration.ObscuroChainID) + wallets := params.NewSimWallets(1, numberOfNodes, integration.EthereumChainID, integration.TenChainID) simParams := params.SimParams{ NumberOfNodes: numberOfNodes, AvgBlockDuration: 1 * time.Second, diff --git a/integration/faucet/faucet_test.go b/integration/faucet/faucet_test.go index a71826a515..f893510f51 100644 --- a/integration/faucet/faucet_test.go +++ b/integration/faucet/faucet_test.go @@ -52,7 +52,7 @@ func TestFaucet(t *testing.T) { HTTPPort: startPort + integration.DefaultHostRPCHTTPOffset, PK: "0x" + contractDeployerPrivateKeyHex, JWTSecret: "This_is_secret", - ChainID: big.NewInt(integration.ObscuroChainID), + ChainID: big.NewInt(integration.TenChainID), ServerPort: integration.StartPortFaucetHTTPUnitTest, DefaultFundAmount: new(big.Int).Mul(big.NewInt(100), big.NewInt(1e18)), } @@ -66,7 +66,7 @@ func TestFaucet(t *testing.T) { require.NoError(t, err) require.NotZero(t, initialFaucetBal) - rndWallet := datagenerator.RandomWallet(integration.ObscuroChainID) + rndWallet := datagenerator.RandomWallet(integration.TenChainID) err = fundWallet(faucetConfig.ServerPort, rndWallet) require.NoError(t, err) @@ -91,7 +91,7 @@ func TestFaucet(t *testing.T) { func createObscuroNetwork(t *testing.T, startPort int) { // Create the Obscuro network. numberOfNodes := 1 - wallets := params.NewSimWallets(1, numberOfNodes, integration.EthereumChainID, integration.ObscuroChainID) + wallets := params.NewSimWallets(1, numberOfNodes, integration.EthereumChainID, integration.TenChainID) simParams := params.SimParams{ NumberOfNodes: numberOfNodes, AvgBlockDuration: 1 * time.Second, diff --git a/integration/manualtests/connection_test.go b/integration/manualtests/connection_test.go index c307685c35..9935df547d 100644 --- a/integration/manualtests/connection_test.go +++ b/integration/manualtests/connection_test.go @@ -22,7 +22,7 @@ func TestSubscribeToOG(t *testing.T) { ogWSAddress := "wss://dev-testnet.obscu.ro:81" // ogWSAddress := "ws://51.132.131.47:81" - ogClient := lib.NewObscuroGatewayLibrary(ogHTTPAddress, ogWSAddress) + ogClient := lib.NewTenGatewayLibrary(ogHTTPAddress, ogWSAddress) // join the network err := ogClient.Join() diff --git a/integration/networktest/actions/setup_actions.go b/integration/networktest/actions/setup_actions.go index 9bef943c54..174a506403 100644 --- a/integration/networktest/actions/setup_actions.go +++ b/integration/networktest/actions/setup_actions.go @@ -21,7 +21,7 @@ func (c *CreateTestUser) String() string { func (c *CreateTestUser) Run(ctx context.Context, network networktest.NetworkConnector) (context.Context, error) { logger := testlog.Logger() - wal := datagenerator.RandomWallet(integration.ObscuroChainID) + wal := datagenerator.RandomWallet(integration.TenChainID) // traffic sim users are round robin-ed onto the validators for now (todo (@matt) - make that overridable) user := userwallet.NewUserWallet(wal.PrivateKey(), network.ValidatorRPCAddress(c.UserID%network.NumValidators()), logger) return storeTestUser(ctx, c.UserID, user), nil diff --git a/integration/networktest/env/testnet.go b/integration/networktest/env/testnet.go index 3f7001909a..7e0d9cb810 100644 --- a/integration/networktest/env/testnet.go +++ b/integration/networktest/env/testnet.go @@ -52,13 +52,13 @@ func NewTestnetConnectorWithFaucetAccount(seqRPCAddr string, validatorRPCAddress return &testnetConnector{ seqRPCAddress: seqRPCAddr, validatorRPCAddresses: validatorRPCAddressses, - faucetWallet: userwallet.NewUserWallet(ecdsaKey, validatorRPCAddressses[0], testlog.Logger(), userwallet.WithChainID(big.NewInt(integration.ObscuroChainID))), + faucetWallet: userwallet.NewUserWallet(ecdsaKey, validatorRPCAddressses[0], testlog.Logger(), userwallet.WithChainID(big.NewInt(integration.TenChainID))), l1RPCURL: l1RPCAddress, } } func (t *testnetConnector) ChainID() int64 { - return integration.ObscuroChainID + return integration.TenChainID } func (t *testnetConnector) AllocateFaucetFunds(ctx context.Context, account gethcommon.Address) error { diff --git a/integration/networktest/userwallet/userwallet.go b/integration/networktest/userwallet/userwallet.go index a1f2f8b2fb..aa580037b9 100644 --- a/integration/networktest/userwallet/userwallet.go +++ b/integration/networktest/userwallet/userwallet.go @@ -70,7 +70,7 @@ func NewUserWallet(pk *ecdsa.PrivateKey, rpcEndpoint string, logger gethlog.Logg privateKey: pk, publicKey: publicKeyECDSA, accountAddress: crypto.PubkeyToAddress(*publicKeyECDSA), - chainID: big.NewInt(integration.ObscuroChainID), // default, overridable using `WithChainID(...) opt` + chainID: big.NewInt(integration.TenChainID), // default, overridable using `WithChainID(...) opt` rpcEndpoint: rpcEndpoint, logger: logger, } @@ -82,7 +82,7 @@ func NewUserWallet(pk *ecdsa.PrivateKey, rpcEndpoint string, logger gethlog.Logg } func (s *UserWallet) ChainID() *big.Int { - return big.NewInt(integration.ObscuroChainID) + return big.NewInt(integration.TenChainID) } func (s *UserWallet) SendFunds(ctx context.Context, addr gethcommon.Address, value *big.Int, gas uint64) (*gethcommon.Hash, error) { diff --git a/integration/obscurogateway/gateway_user.go b/integration/obscurogateway/gateway_user.go index 9ea6fe699a..4820b32e97 100644 --- a/integration/obscurogateway/gateway_user.go +++ b/integration/obscurogateway/gateway_user.go @@ -16,11 +16,11 @@ type GatewayUser struct { Wallets []wallet.Wallet HTTPClient *ethclient.Client WSClient *ethclient.Client - ogClient *lib.OGLib + tgClient *lib.TGLib } func NewUser(wallets []wallet.Wallet, serverAddressHTTP string, serverAddressWS string) (*GatewayUser, error) { - ogClient := lib.NewObscuroGatewayLibrary(serverAddressHTTP, serverAddressWS) + ogClient := lib.NewTenGatewayLibrary(serverAddressHTTP, serverAddressWS) // automatically join err := ogClient.Join() @@ -29,11 +29,11 @@ func NewUser(wallets []wallet.Wallet, serverAddressHTTP string, serverAddressWS } // create clients - httpClient, err := ethclient.Dial(serverAddressHTTP + "/v1/" + "?u=" + ogClient.UserID()) + httpClient, err := ethclient.Dial(serverAddressHTTP + "/v1/" + "?token=" + ogClient.UserID()) if err != nil { return nil, err } - wsClient, err := ethclient.Dial(serverAddressWS + "/v1/" + "?u=" + ogClient.UserID()) + wsClient, err := ethclient.Dial(serverAddressWS + "/v1/" + "?token=" + ogClient.UserID()) if err != nil { return nil, err } @@ -42,17 +42,17 @@ func NewUser(wallets []wallet.Wallet, serverAddressHTTP string, serverAddressWS Wallets: wallets, HTTPClient: httpClient, WSClient: wsClient, - ogClient: ogClient, + tgClient: ogClient, }, nil } func (u GatewayUser) RegisterAccounts() error { for _, w := range u.Wallets { - err := u.ogClient.RegisterAccount(w.PrivateKey(), w.Address()) + err := u.tgClient.RegisterAccount(w.PrivateKey(), w.Address()) if err != nil { return err } - fmt.Printf("Successfully registered address %s for user: %s.\n", w.Address().Hex(), u.ogClient.UserID()) + fmt.Printf("Successfully registered address %s for user: %s.\n", w.Address().Hex(), u.tgClient.UserID()) } return nil diff --git a/integration/obscurogateway/obscurogateway_test.go b/integration/obscurogateway/tengateway_test.go similarity index 89% rename from integration/obscurogateway/obscurogateway_test.go rename to integration/obscurogateway/tengateway_test.go index 70091d1ac1..95c6a88ad0 100644 --- a/integration/obscurogateway/obscurogateway_test.go +++ b/integration/obscurogateway/tengateway_test.go @@ -40,24 +40,24 @@ import ( func init() { //nolint:gochecknoinits testlog.Setup(&testlog.Cfg{ LogDir: testLogs, - TestType: "obscurogateway", + TestType: "tengateway", TestSubtype: "test", LogLevel: log.LvlInfo, }) } const ( - testLogs = "../.build/obscurogateway/" + testLogs = "../.build/tengateway/" ) -func TestObscuroGateway(t *testing.T) { - startPort := integration.StartPortObscuroGatewayUnitTest - createObscuroNetwork(t, startPort) +func TestTenGateway(t *testing.T) { + startPort := integration.StartPortTenGatewayUnitTest + createTenNetwork(t, startPort) - obscuroGatewayConf := config.Config{ + tenGatewayConf := config.Config{ WalletExtensionHost: "127.0.0.1", - WalletExtensionPortHTTP: startPort + integration.DefaultObscuroGatewayHTTPPortOffset, - WalletExtensionPortWS: startPort + integration.DefaultObscuroGatewayWSPortOffset, + WalletExtensionPortHTTP: startPort + integration.DefaultTenGatewayHTTPPortOffset, + WalletExtensionPortWS: startPort + integration.DefaultTenGatewayWSPortOffset, NodeRPCHTTPAddress: fmt.Sprintf("127.0.0.1:%d", startPort+integration.DefaultHostRPCHTTPOffset), NodeRPCWebsocketAddress: fmt.Sprintf("127.0.0.1:%d", startPort+integration.DefaultHostRPCWSOffset), LogPath: "sys_out", @@ -66,9 +66,9 @@ func TestObscuroGateway(t *testing.T) { TenChainID: 443, } - obscuroGwContainer := container.NewWalletExtensionContainerFromConfig(obscuroGatewayConf, testlog.Logger()) + tenGwContainer := container.NewWalletExtensionContainerFromConfig(tenGatewayConf, testlog.Logger()) go func() { - err := obscuroGwContainer.Start() + err := tenGwContainer.Start() if err != nil { fmt.Printf("error stopping WE - %s", err) } @@ -78,15 +78,15 @@ func TestObscuroGateway(t *testing.T) { time.Sleep(5 * time.Second) // make sure the server is ready to receive requests - httpURL := fmt.Sprintf("http://%s:%d", obscuroGatewayConf.WalletExtensionHost, obscuroGatewayConf.WalletExtensionPortHTTP) - wsURL := fmt.Sprintf("ws://%s:%d", obscuroGatewayConf.WalletExtensionHost, obscuroGatewayConf.WalletExtensionPortWS) + httpURL := fmt.Sprintf("http://%s:%d", tenGatewayConf.WalletExtensionHost, tenGatewayConf.WalletExtensionPortHTTP) + wsURL := fmt.Sprintf("ws://%s:%d", tenGatewayConf.WalletExtensionHost, tenGatewayConf.WalletExtensionPortWS) // make sure the server is ready to receive requests err := waitServerIsReady(httpURL) require.NoError(t, err) // prefunded wallet - w := wallet.NewInMemoryWalletFromConfig(genesis.TestnetPrefundedPK, integration.ObscuroChainID, testlog.Logger()) + w := wallet.NewInMemoryWalletFromConfig(genesis.TestnetPrefundedPK, integration.TenChainID, testlog.Logger()) // run the tests against the exis for name, test := range map[string]func(*testing.T, string, string, wallet.Wallet){ @@ -103,22 +103,22 @@ func TestObscuroGateway(t *testing.T) { } // Gracefully shutdown - err = obscuroGwContainer.Stop() + err = tenGwContainer.Stop() assert.NoError(t, err) } func testMultipleAccountsSubscription(t *testing.T, httpURL, wsURL string, w wallet.Wallet) { user0, err := NewUser([]wallet.Wallet{w}, httpURL, wsURL) require.NoError(t, err) - fmt.Printf("Created user with UserID: %s\n", user0.ogClient.UserID()) + fmt.Printf("Created user with encryption token: %s\n", user0.tgClient.UserID()) - user1, err := NewUser([]wallet.Wallet{datagenerator.RandomWallet(integration.ObscuroChainID), datagenerator.RandomWallet(integration.ObscuroChainID)}, httpURL, wsURL) + user1, err := NewUser([]wallet.Wallet{datagenerator.RandomWallet(integration.TenChainID), datagenerator.RandomWallet(integration.TenChainID)}, httpURL, wsURL) require.NoError(t, err) - fmt.Printf("Created user with UserID: %s\n", user0.ogClient.UserID()) + fmt.Printf("Created user with encryption token: %s\n", user0.tgClient.UserID()) - user2, err := NewUser([]wallet.Wallet{datagenerator.RandomWallet(integration.ObscuroChainID), datagenerator.RandomWallet(integration.ObscuroChainID)}, httpURL, wsURL) + user2, err := NewUser([]wallet.Wallet{datagenerator.RandomWallet(integration.TenChainID), datagenerator.RandomWallet(integration.TenChainID)}, httpURL, wsURL) require.NoError(t, err) - fmt.Printf("Created user with UserID: %s\n", user0.ogClient.UserID()) + fmt.Printf("Created user with encryption token: %s\n", user0.tgClient.UserID()) // register all the accounts for that user err = user0.RegisterAccounts() @@ -190,7 +190,7 @@ func testMultipleAccountsSubscription(t *testing.T, httpURL, wsURL string, w wal subscribeToEvents([]gethcommon.Address{contractReceipt.ContractAddress}, nil, user2.WSClient, &user2logs) // user1 calls setMessage and setMessage2 on deployed smart contract with the account - // that was registered as the first in OG + // that was registered as the first in TG user1MessageValue := "user1PublicEvent" // interact with smart contract and cause events to be emitted _, err = integrationCommon.InteractWithSmartContract(user1.HTTPClient, user1.Wallets[0], eventsContractABI, "setMessage", "user1PrivateEvent", contractReceipt.ContractAddress) @@ -211,7 +211,7 @@ func testMultipleAccountsSubscription(t *testing.T, httpURL, wsURL string, w wal assert.Equal(t, user1MessageValue, resultMessage) // user2 calls setMessage and setMessage2 on deployed smart contract with the account - // that was registered as the second in OG + // that was registered as the second in TG user2MessageValue := "user2PublicEvent" // interact with smart contract and cause events to be emitted _, err = integrationCommon.InteractWithSmartContract(user2.HTTPClient, user2.Wallets[1], eventsContractABI, "setMessage", "user2PrivateEvent", contractReceipt.ContractAddress) @@ -243,8 +243,8 @@ func testMultipleAccountsSubscription(t *testing.T, httpURL, wsURL string, w wal } func testAreTxsMinted(t *testing.T, httpURL, wsURL string, w wallet.Wallet) { //nolint: unused - // set up the ogClient - ogClient := lib.NewObscuroGatewayLibrary(httpURL, wsURL) + // set up the tgClient + ogClient := lib.NewTenGatewayLibrary(httpURL, wsURL) // join + register against the og err := ogClient.Join() @@ -270,8 +270,8 @@ func testAreTxsMinted(t *testing.T, httpURL, wsURL string, w wallet.Wallet) { // } func testErrorHandling(t *testing.T, httpURL, wsURL string, w wallet.Wallet) { - // set up the ogClient - ogClient := lib.NewObscuroGatewayLibrary(httpURL, wsURL) + // set up the tgClient + ogClient := lib.NewTenGatewayLibrary(httpURL, wsURL) // join + register against the og err := ogClient.Join() @@ -301,7 +301,7 @@ func testErrorHandling(t *testing.T, httpURL, wsURL string, w wallet.Wallet) { require.NoError(t, err) // repeat the process for the gateway - _, response, err = httputil.PostDataJSON(fmt.Sprintf("http://localhost:%d", integration.StartPortObscuroGatewayUnitTest), []byte(req)) + _, response, err = httputil.PostDataJSON(fmt.Sprintf("http://localhost:%d", integration.StartPortTenGatewayUnitTest), []byte(req)) require.NoError(t, err) // we only care about format @@ -312,8 +312,8 @@ func testErrorHandling(t *testing.T, httpURL, wsURL string, w wallet.Wallet) { } func testErrorsRevertedArePassed(t *testing.T, httpURL, wsURL string, w wallet.Wallet) { - // set up the ogClient - ogClient := lib.NewObscuroGatewayLibrary(httpURL, wsURL) + // set up the tgClient + ogClient := lib.NewTenGatewayLibrary(httpURL, wsURL) // join + register against the og err := ogClient.Join() @@ -388,9 +388,9 @@ func testErrorsRevertedArePassed(t *testing.T, httpURL, wsURL string, w wallet.W func testUnsubscribe(t *testing.T, httpURL, wsURL string, w wallet.Wallet) { // create a user with multiple accounts - user, err := NewUser([]wallet.Wallet{w, datagenerator.RandomWallet(integration.ObscuroChainID)}, httpURL, wsURL) + user, err := NewUser([]wallet.Wallet{w, datagenerator.RandomWallet(integration.TenChainID)}, httpURL, wsURL) require.NoError(t, err) - fmt.Printf("Created user with UserID: %s\n", user.ogClient.UserID()) + fmt.Printf("Created user with encryption token: %s\n", user.tgClient.UserID()) // register all the accounts for the user err = user.RegisterAccounts() @@ -438,9 +438,9 @@ func testUnsubscribe(t *testing.T, httpURL, wsURL string, w wallet.Wallet) { func testClosingConnectionWhileSubscribed(t *testing.T, httpURL, wsURL string, w wallet.Wallet) { // create a user with multiple accounts - user, err := NewUser([]wallet.Wallet{w, datagenerator.RandomWallet(integration.ObscuroChainID)}, httpURL, wsURL) + user, err := NewUser([]wallet.Wallet{w, datagenerator.RandomWallet(integration.TenChainID)}, httpURL, wsURL) require.NoError(t, err) - fmt.Printf("Created user with UserID: %s\n", user.ogClient.UserID()) + fmt.Printf("Created user with encryption token: %s\n", user.tgClient.UserID()) // register all the accounts for the user err = user.RegisterAccounts() @@ -479,7 +479,7 @@ func testClosingConnectionWhileSubscribed(t *testing.T, httpURL, wsURL string, w assert.Equal(t, 0, len(userLogs)) // re-establish connection - wsClient, err := ethclient.Dial(wsURL + "/v1/" + "?u=" + user.ogClient.UserID()) + wsClient, err := ethclient.Dial(wsURL + "/v1/" + "?token=" + user.tgClient.UserID()) require.NoError(t, err) user.WSClient = wsClient @@ -525,11 +525,11 @@ func transferRandomAddr(t *testing.T, client *ethclient.Client, w wallet.Wallet) return signedTx.Hash() } -// Creates a single-node Obscuro network for testing. -func createObscuroNetwork(t *testing.T, startPort int) { - // Create the Obscuro network. +// Creates a single-node Ten network for testing. +func createTenNetwork(t *testing.T, startPort int) { + // Create the Ten network. numberOfNodes := 1 - wallets := params.NewSimWallets(1, numberOfNodes, integration.EthereumChainID, integration.ObscuroChainID) + wallets := params.NewSimWallets(1, numberOfNodes, integration.EthereumChainID, integration.TenChainID) simParams := params.SimParams{ NumberOfNodes: numberOfNodes, AvgBlockDuration: 1 * time.Second, @@ -540,11 +540,11 @@ func createObscuroNetwork(t *testing.T, startPort int) { WithPrefunding: true, } - obscuroNetwork := network.NewNetworkOfSocketNodes(wallets) - t.Cleanup(obscuroNetwork.TearDown) - _, err := obscuroNetwork.Create(&simParams, nil) + tenNetwork := network.NewNetworkOfSocketNodes(wallets) + t.Cleanup(tenNetwork.TearDown) + _, err := tenNetwork.Create(&simParams, nil) if err != nil { - panic(fmt.Sprintf("failed to create test Obscuro network. Cause: %s", err)) + panic(fmt.Sprintf("failed to create test Ten network. Cause: %s", err)) } } diff --git a/integration/obscuroscan/obscuroscan_test.go b/integration/obscuroscan/obscuroscan_test.go index b8feb958fe..a6424866e1 100644 --- a/integration/obscuroscan/obscuroscan_test.go +++ b/integration/obscuroscan/obscuroscan_test.go @@ -47,12 +47,12 @@ const ( ) func TestObscuroscan(t *testing.T) { - startPort := integration.StartPortObscuroscanUnitTest + startPort := integration.StartPortTenscanUnitTest createObscuroNetwork(t, startPort) obsScanConfig := &config.Config{ NodeHostAddress: fmt.Sprintf("http://127.0.0.1:%d", startPort+integration.DefaultHostRPCHTTPOffset), - ServerAddress: fmt.Sprintf("127.0.0.1:%d", startPort+integration.DefaultObscuroscanHTTPPortOffset), + ServerAddress: fmt.Sprintf("127.0.0.1:%d", startPort+integration.DefaultTenscanHTTPPortOffset), LogPath: "sys_out", } serverAddress := fmt.Sprintf("http://%s", obsScanConfig.ServerAddress) @@ -73,7 +73,7 @@ func TestObscuroscan(t *testing.T) { issueTransactions( t, fmt.Sprintf("ws://127.0.0.1:%d", startPort+integration.DefaultHostRPCWSOffset), - wallet.NewInMemoryWalletFromConfig(genesis.TestnetPrefundedPK, integration.ObscuroChainID, testlog.Logger()), + wallet.NewInMemoryWalletFromConfig(genesis.TestnetPrefundedPK, integration.TenChainID, testlog.Logger()), 5, ) @@ -203,7 +203,7 @@ func waitServerIsReady(serverAddr string) error { // Creates a single-node Obscuro network for testing. func createObscuroNetwork(t *testing.T, startPort int) { // Create the Obscuro network. - wallets := params.NewSimWallets(1, 1, integration.EthereumChainID, integration.ObscuroChainID) + wallets := params.NewSimWallets(1, 1, integration.EthereumChainID, integration.TenChainID) simParams := params.SimParams{ NumberOfNodes: 1, AvgBlockDuration: 1 * time.Second, diff --git a/integration/simulation/devnetwork/config.go b/integration/simulation/devnetwork/config.go index 140577b469..51a4998a5c 100644 --- a/integration/simulation/devnetwork/config.go +++ b/integration/simulation/devnetwork/config.go @@ -38,7 +38,7 @@ type ObscuroConfig struct { // DefaultDevNetwork provides an off-the-shelf default config for a sim network func DefaultDevNetwork() *InMemDevNetwork { numNodes := 4 // Default sim currently uses 4 L1 nodes. Obscuro nodes: 1 seq, 3 validators - networkWallets := params.NewSimWallets(0, numNodes, integration.EthereumChainID, integration.ObscuroChainID) + networkWallets := params.NewSimWallets(0, numNodes, integration.EthereumChainID, integration.TenChainID) l1Config := &L1Config{ PortStart: integration.StartPortSimulationFullNetwork, NumNodes: 4, @@ -71,7 +71,7 @@ func LiveL1DevNetwork(seqWallet wallet.Wallet, validatorWallets []wallet.Wallet, if err != nil { panic("could not initialise L2 faucet private key") } - l2FaucetWallet := wallet.NewInMemoryWalletFromPK(big.NewInt(integration.ObscuroChainID), l2FaucetPrivKey, testlog.Logger()) + l2FaucetWallet := wallet.NewInMemoryWalletFromPK(big.NewInt(integration.TenChainID), l2FaucetPrivKey, testlog.Logger()) networkWallets := ¶ms.SimWallets{ MCOwnerWallet: seqWallet, NodeWallets: append([]wallet.Wallet{seqWallet}, validatorWallets...), diff --git a/integration/simulation/devnetwork/dev_network.go b/integration/simulation/devnetwork/dev_network.go index 462bc26feb..ea85e7ed5d 100644 --- a/integration/simulation/devnetwork/dev_network.go +++ b/integration/simulation/devnetwork/dev_network.go @@ -59,7 +59,7 @@ func (s *InMemDevNetwork) GetMCOwnerWallet() (wallet.Wallet, error) { } func (s *InMemDevNetwork) ChainID() int64 { - return integration.ObscuroChainID + return integration.TenChainID } func (s *InMemDevNetwork) FaucetWallet() wallet.Wallet { diff --git a/integration/simulation/devnetwork/node.go b/integration/simulation/devnetwork/node.go index 071d2eb425..60e70c2dca 100644 --- a/integration/simulation/devnetwork/node.go +++ b/integration/simulation/devnetwork/node.go @@ -123,7 +123,7 @@ func (n *InMemNodeOperator) createHostContainer() *hostcontainer.HostContainer { ManagementContractAddress: n.l1Data.MgmtContractAddress, MessageBusAddress: n.l1Data.MessageBusAddr, L1ChainID: integration.EthereumChainID, - ObscuroChainID: integration.ObscuroChainID, + ObscuroChainID: integration.TenChainID, L1StartHash: n.l1Data.ObscuroStartBlock, SequencerID: n.config.SequencerID, UseInMemoryDB: false, @@ -167,7 +167,7 @@ func (n *InMemNodeOperator) createEnclaveContainer() *enclavecontainer.EnclaveCo Address: enclaveAddr, NodeType: n.nodeType, L1ChainID: integration.EthereumChainID, - ObscuroChainID: integration.ObscuroChainID, + ObscuroChainID: integration.TenChainID, ValidateL1Blocks: false, WillAttest: false, GenesisJSON: nil, diff --git a/integration/simulation/network/network_utils.go b/integration/simulation/network/network_utils.go index 399ea5668d..4633975fea 100644 --- a/integration/simulation/network/network_utils.go +++ b/integration/simulation/network/network_utils.go @@ -83,7 +83,7 @@ func createInMemObscuroNode( HostID: hostConfig.ID, NodeType: nodeType, L1ChainID: integration.EthereumChainID, - ObscuroChainID: integration.ObscuroChainID, + ObscuroChainID: integration.TenChainID, WillAttest: false, ValidateL1Blocks: validateBlocks, GenesisJSON: genesisJSON, diff --git a/integration/simulation/simulation_full_network_test.go b/integration/simulation/simulation_full_network_test.go index 3f56a64d66..926f736cd8 100644 --- a/integration/simulation/simulation_full_network_test.go +++ b/integration/simulation/simulation_full_network_test.go @@ -20,7 +20,7 @@ func TestFullNetworkMonteCarloSimulation(t *testing.T) { numberOfNodes := 5 numberOfSimWallets := 5 - wallets := params.NewSimWallets(numberOfSimWallets, numberOfNodes, integration.EthereumChainID, integration.ObscuroChainID) + wallets := params.NewSimWallets(numberOfSimWallets, numberOfNodes, integration.EthereumChainID, integration.TenChainID) simParams := ¶ms.SimParams{ NumberOfNodes: numberOfNodes, diff --git a/integration/simulation/simulation_geth_in_mem_test.go b/integration/simulation/simulation_geth_in_mem_test.go index 4c59b81f04..6f24453691 100644 --- a/integration/simulation/simulation_geth_in_mem_test.go +++ b/integration/simulation/simulation_geth_in_mem_test.go @@ -23,7 +23,7 @@ func TestGethSimulation(t *testing.T) { numberOfNodes := 5 numberOfSimWallets := 5 - wallets := params.NewSimWallets(numberOfSimWallets, numberOfNodes, integration.EthereumChainID, integration.ObscuroChainID) + wallets := params.NewSimWallets(numberOfSimWallets, numberOfNodes, integration.EthereumChainID, integration.TenChainID) simParams := ¶ms.SimParams{ NumberOfNodes: numberOfNodes, diff --git a/integration/simulation/simulation_in_mem_test.go b/integration/simulation/simulation_in_mem_test.go index c776360021..b29f057ab5 100644 --- a/integration/simulation/simulation_in_mem_test.go +++ b/integration/simulation/simulation_in_mem_test.go @@ -21,7 +21,7 @@ func TestInMemoryMonteCarloSimulation(t *testing.T) { // todo (#718) - try increasing this back to 7 once faster-finality model is optimised numberOfNodes := 5 numberOfSimWallets := 10 - wallets := params.NewSimWallets(numberOfSimWallets, numberOfNodes, integration.EthereumChainID, integration.ObscuroChainID) + wallets := params.NewSimWallets(numberOfSimWallets, numberOfNodes, integration.EthereumChainID, integration.TenChainID) simParams := params.SimParams{ NumberOfNodes: numberOfNodes, diff --git a/tools/gateway-js/gateway-lib/gateway.js b/tools/gateway-js/gateway-lib/gateway.js index 933355c6af..8d997dfe9e 100644 --- a/tools/gateway-js/gateway-lib/gateway.js +++ b/tools/gateway-js/gateway-lib/gateway.js @@ -44,7 +44,7 @@ class Gateway { } try { - const authenticateUserURL = pathAuthenticate+"?u="+this.userId + const authenticateUserURL = pathAuthenticate+"?token="+this.userId const authenticateFields = {"signature": signature, "message": message} const authenticateResp = await axios.post( authenticateUserURL, @@ -68,11 +68,11 @@ class Gateway { } http() { - return `${this.httpURL}/v1/?u=${this.userId}`; + return `${this.httpURL}/v1/?token=${this.userId}`; } ws() { - return `${this.wsURL}/v1/?u=${this.userId}`; + return `${this.wsURL}/v1/?token=${this.userId}`; } } diff --git a/tools/walletextension/README.md b/tools/walletextension/README.md index 0074b295bf..c7ef89fe32 100644 --- a/tools/walletextension/README.md +++ b/tools/walletextension/README.md @@ -38,16 +38,16 @@ For interacting with Ten Gateway, there are the following HTTP endpoints availab It generates and returns userID which needs to be added as a query parameter "u" to the URL in your Metamask (or another provider) as it identifies you. -- `POST /v1/authenticate?u=$UserId` +- `POST /v1/authenticate?token=$EncryptionToken` With this endpoint, you submit a signed message in the format `Register for ` from that account which proves that you hold private keys for it, and it links that account with your userID. -- `GET /v1/query/address?u=$UserId&a=$Address` +- `GET /v1/query/address?token=$EncryptionToken&a=$Address` This endpoint responds with a JSON of true or false if the address "a" is already registered for user "u" -- `POST "/v1/revoke?u=$UserId"` +- `POST "/v1/revoke?token=$EncryptionToken"` When this endpoint is triggered, the userId with the authenticated viewing keys should be deleted. diff --git a/tools/walletextension/api/staticOG/javascript.js b/tools/walletextension/api/staticOG/javascript.js index 69e869d078..51db8aec41 100644 --- a/tools/walletextension/api/staticOG/javascript.js +++ b/tools/walletextension/api/staticOG/javascript.js @@ -105,7 +105,7 @@ async function addNetworkToMetaMask(ethereum, userID, chainIDDecimal) { getRPCFromUrl(obscuroGatewayAddress) + "/" + obscuroGatewayVersion + - "/?u=" + + "/?token=" + userID, ], blockExplorerUrls: ["https://testnet.obscuroscan.io"], @@ -158,7 +158,7 @@ async function authenticateAccountWithObscuroGatewayEIP712(ethereum, account, us }); - const authenticateUserURL = pathAuthenticate+"?u="+userID + const authenticateUserURL = pathAuthenticate+"?token="+userID const authenticateFields = {"signature": signature, "address": account } const authenticateResp = await fetch( authenticateUserURL, { @@ -172,7 +172,7 @@ async function authenticateAccountWithObscuroGatewayEIP712(ethereum, account, us async function accountIsAuthenticated(account, userID) { - const queryAccountUserID = pathQuery + "?u=" + userID + "&a=" + account; + const queryAccountUserID = pathQuery + "?token=" + userID + "&a=" + account; const isAuthenticatedResponse = await fetch(queryAccountUserID, { method: methodGet, headers: jsonHeaders, @@ -183,7 +183,7 @@ async function accountIsAuthenticated(account, userID) { } async function revokeUserID(userID) { - const queryAccountUserID = pathRevoke + "?u=" + userID; + const queryAccountUserID = pathRevoke + "?token=" + userID; const revokeResponse = await fetch(queryAccountUserID, { method: methodGet, headers: jsonHeaders, diff --git a/tools/walletextension/api/utils.go b/tools/walletextension/api/utils.go index bd5eb96031..96f14038fa 100644 --- a/tools/walletextension/api/utils.go +++ b/tools/walletextension/api/utils.go @@ -51,9 +51,21 @@ func getQueryParameter(params map[string]string, selectedParameter string) (stri return value, nil } +// getUserID returns userID from query params / url of the URL +// it always first tries to get userID from a query parameter `u` or `token` (`u` parameter will become deprecated) +// if it fails to get userID from a query parameter it tries to get it from the URL and it needs position as the second parameter func getUserID(conn userconn.UserConn, userIDPosition int) (string, error) { - // try getting userID from query parameters and return it if successful - userID, err := getQueryParameter(conn.ReadRequestParams(), common.UserQueryParameter) + // try getting userID (`token`) from query parameters and return it if successful + userID, err := getQueryParameter(conn.ReadRequestParams(), common.EncryptedTokenQueryParameter) + if err == nil { + if len(userID) != common.MessageUserIDLen { + return "", fmt.Errorf(fmt.Sprintf("wrong length of userID from URL. Got: %d, Expected: %d", len(userID), common.MessageUserIDLen)) + } + return userID, err + } + + // try getting userID(`u`) from query parameters and return it if successful + userID, err = getQueryParameter(conn.ReadRequestParams(), common.UserQueryParameter) if err == nil { if len(userID) != common.MessageUserIDLen { return "", fmt.Errorf(fmt.Sprintf("wrong length of userID from URL. Got: %d, Expected: %d", len(userID), common.MessageUserIDLen)) diff --git a/tools/walletextension/common/constants.go b/tools/walletextension/common/constants.go index ee62e18742..6cca9175e0 100644 --- a/tools/walletextension/common/constants.go +++ b/tools/walletextension/common/constants.go @@ -38,12 +38,10 @@ const ( WSProtocol = "ws://" DefaultUser = "defaultUser" UserQueryParameter = "u" + EncryptedTokenQueryParameter = "token" AddressQueryParameter = "a" - MessageFormatRegex = `^Register\s(\w+)\sfor\s(\w+)$` MessageUserIDLen = 40 - SignatureLen = 65 EthereumAddressLen = 42 - PersonalSignMessagePrefix = "\x19Ethereum Signed Message:\n%d%s" GetStorageAtUserIDRequestMethodName = "getUserID" SuccessMsg = "success" APIVersion1 = "/v1" diff --git a/tools/walletextension/lib/client_lib.go b/tools/walletextension/lib/client_lib.go index be93d990ec..e79aa305d4 100644 --- a/tools/walletextension/lib/client_lib.go +++ b/tools/walletextension/lib/client_lib.go @@ -17,24 +17,24 @@ import ( "github.com/valyala/fasthttp" ) -type OGLib struct { +type TGLib struct { httpURL string wsURL string userID []byte } -func NewObscuroGatewayLibrary(httpURL, wsURL string) *OGLib { - return &OGLib{ +func NewTenGatewayLibrary(httpURL, wsURL string) *TGLib { + return &TGLib{ httpURL: httpURL, wsURL: wsURL, } } -func (o *OGLib) UserID() string { +func (o *TGLib) UserID() string { return string(o.userID) } -func (o *OGLib) Join() error { +func (o *TGLib) Join() error { // todo move this to stdlib statusCode, userID, err := fasthttp.Get(nil, fmt.Sprintf("%s/v1/join/", o.httpURL)) if err != nil || statusCode != 200 { @@ -44,9 +44,9 @@ func (o *OGLib) Join() error { return nil } -func (o *OGLib) RegisterAccount(pk *ecdsa.PrivateKey, addr gethcommon.Address) error { +func (o *TGLib) RegisterAccount(pk *ecdsa.PrivateKey, addr gethcommon.Address) error { // create the registration message - rawMessage, err := viewingkey.GenerateAuthenticationEIP712RawData(string(o.userID), integration.ObscuroChainID) + rawMessage, err := viewingkey.GenerateAuthenticationEIP712RawData(string(o.userID), integration.TenChainID) if err != nil { return err } @@ -64,7 +64,7 @@ func (o *OGLib) RegisterAccount(pk *ecdsa.PrivateKey, addr gethcommon.Address) e req, err := http.NewRequestWithContext( context.Background(), http.MethodPost, - o.httpURL+"/v1/authenticate/?u="+string(o.userID), + o.httpURL+"/v1/authenticate/?token="+string(o.userID), strings.NewReader(payload), ) if err != nil { @@ -90,10 +90,10 @@ func (o *OGLib) RegisterAccount(pk *ecdsa.PrivateKey, addr gethcommon.Address) e return nil } -func (o *OGLib) HTTP() string { - return fmt.Sprintf("%s/v1/?u=%s", o.httpURL, o.userID) +func (o *TGLib) HTTP() string { + return fmt.Sprintf("%s/v1/?token=%s", o.httpURL, o.userID) } -func (o *OGLib) WS() string { - return fmt.Sprintf("%s/v1/?u=%s", o.wsURL, o.userID) +func (o *TGLib) WS() string { + return fmt.Sprintf("%s/v1/?token=%s", o.wsURL, o.userID) } diff --git a/tools/walletextension/test/utils.go b/tools/walletextension/test/utils.go index b56b53cb3c..7c5d2420cd 100644 --- a/tools/walletextension/test/utils.go +++ b/tools/walletextension/test/utils.go @@ -126,7 +126,7 @@ func makeHTTPEthJSONReqWithPath(port int, path string) []byte { // Makes an Ethereum JSON RPC request over HTTP and returns the response body with userID query paremeter. func makeHTTPEthJSONReqWithUserID(port int, method string, params interface{}, userID string) []byte { //nolint: unparam reqBody := prepareRequestBody(method, params) - return makeRequestHTTP(fmt.Sprintf("http://%s:%d/v1/?u=%s", common.Localhost, port, userID), reqBody) + return makeRequestHTTP(fmt.Sprintf("http://%s:%d/v1/?token=%s", common.Localhost, port, userID), reqBody) } // Makes an Ethereum JSON RPC request over websockets and returns the response body. From 1d08a78b93b66dea399fdf3ffdcaf199851a2cf0 Mon Sep 17 00:00:00 2001 From: Stefan Iliev <46542846+StefanIliev545@users.noreply.github.com> Date: Mon, 27 Nov 2023 18:44:00 +0200 Subject: [PATCH 5/5] Proxy contracts deployment (#1663) * Minimal proxy deployment. * added a proxy for contract deployment. * Dumping progress. * Dump progress. * Working version of contract deployments through proxies. * Fix for hardhat tests. * Fix for sim tests. * Fixed linter issues. * waiting for receipt for initialization. * Use initializers. * Generated ABI bindings. --------- Co-authored-by: StefanIliev545 --- contracts/config/networks.json | 5 +- .../bridge/001_deploy_bridge.ts | 20 +++++++- .../core/001_deploy_management_contract.ts | 14 ++++++ .../funding/layer1/001_fund_accounts.ts | 3 +- .../funding/layer1/002_fund_faucet.ts | 6 +-- .../001_deploy_cross_chain_messenger.ts | 11 +++- .../001_deploy_cross_chain_messenger.ts | 20 +++++--- .../testing/001_gas_testing_deployment.ts | 7 ++- .../CrossChainMessenger.go | 29 +++++++++-- .../EthereumBridge/EthereumBridge.go | 50 +++++++++++++++++-- .../ManagementContract/ManagementContract.go | 25 +++++++++- .../generated/ObscuroBridge/ObscuroBridge.go | 50 +++++++++++++++++-- contracts/package.json | 2 +- contracts/src/bridge/L1/ObscuroBridge.sol | 5 +- contracts/src/bridge/L2/EthereumBridge.sol | 6 ++- .../src/management/ManagementContract.sol | 13 +++-- .../messenger/CrossChainEnabledObscuro.sol | 6 ++- .../messenger/CrossChainMessenger.sol | 11 ++-- contracts/test/bridge-test.ts | 14 ++++-- integration/simulation/network/geth_utils.go | 17 +++++++ testnet/launcher/docker.go | 4 +- testnet/launcher/l1contractdeployer/docker.go | 2 + 22 files changed, 268 insertions(+), 52 deletions(-) diff --git a/contracts/config/networks.json b/contracts/config/networks.json index 3d5c0f90b0..697b73f1c8 100644 --- a/contracts/config/networks.json +++ b/contracts/config/networks.json @@ -1,6 +1,6 @@ { "localGeth": { - "url": "http://127.0.0.1:37000", + "url": "http://127.0.0.1:8025", "deploy": [ "deployment_scripts/core/layer1/", "deployment_scripts/testnet/layer1/", @@ -14,11 +14,12 @@ "localObscuro": { "chainId": 443, "url": "http://127.0.0.1:3000/v1/", - "obscuroEncRpcUrl": "ws://127.0.0.1:37901", + "obscuroEncRpcUrl": "ws://127.0.0.1:13011", "companionNetworks" : { "layer1" : "localGeth" }, "deploy": [ + "deployment_scripts/core/", "deployment_scripts/funding/layer1", "deployment_scripts/messenger/layer1", "deployment_scripts/messenger/layer2", diff --git a/contracts/deployment_scripts/bridge/001_deploy_bridge.ts b/contracts/deployment_scripts/bridge/001_deploy_bridge.ts index c9df0e084f..e912483d60 100644 --- a/contracts/deployment_scripts/bridge/001_deploy_bridge.ts +++ b/contracts/deployment_scripts/bridge/001_deploy_bridge.ts @@ -24,8 +24,16 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // We deploy the layer 1 part of the bridge. const layer1BridgeDeployment = await hre.companionNetworks.layer1.deployments.deploy('ObscuroBridge', { from: accountsL1.deployer, - args: [ messengerL1.address ], log: true, + proxy: { + proxyContract: "OpenZeppelinTransparentProxy", + execute: { + init: { + methodName: "initialize", + args: [ messengerL1.address ] + } + } + } }); // get management contract and write the L1 bridge address to it @@ -44,8 +52,16 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // and be subordinate of the L1 ObscuroBridge const layer2BridgeDeployment = await deployments.deploy('EthereumBridge', { from: accountsL2.deployer, - args: [ messengerL2.address, layer1BridgeDeployment.address ], log: true, + proxy: { + proxyContract: "OpenZeppelinTransparentProxy", + execute: { + init: { + methodName: "initialize", + args: [ messengerL2.address, layer1BridgeDeployment.address ] + } + } + } }); await hre.companionNetworks.layer1.deployments.execute("ObscuroBridge", { diff --git a/contracts/deployment_scripts/core/001_deploy_management_contract.ts b/contracts/deployment_scripts/core/001_deploy_management_contract.ts index 502cb3950a..3e862202fd 100644 --- a/contracts/deployment_scripts/core/001_deploy_management_contract.ts +++ b/contracts/deployment_scripts/core/001_deploy_management_contract.ts @@ -23,9 +23,23 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { contract: contractArtifact, args: [], log: true, + proxy: { + proxyContract: "OpenZeppelinTransparentProxy", + execute: { + init: { + methodName: "initialize", + args: [] + } + } + } }); + const busAddress = await deployments.read('ManagementContract', 'messageBus'); + const busAddressImpl = await deployments.read('ManagementContract_Implementation', 'messageBus'); + console.log(`Implementation_MessageBus = ${busAddressImpl}`); + + console.log(`ManagementContractAddress= ${mgmtContractDeployment.address}`); // This is required in CI/CD - look at testnet-deploy-contracts.sh for more information. // depends on grep -e MessageBusAddress and a positional cut of the address console.log(`MessageBusAddress= ${busAddress}`); diff --git a/contracts/deployment_scripts/funding/layer1/001_fund_accounts.ts b/contracts/deployment_scripts/funding/layer1/001_fund_accounts.ts index 0c45d38bcd..24a286a9ec 100644 --- a/contracts/deployment_scripts/funding/layer1/001_fund_accounts.ts +++ b/contracts/deployment_scripts/funding/layer1/001_fund_accounts.ts @@ -16,8 +16,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { value: prefundAmount }); - - console.log(`Sending ${prefundAmount} to ${deployer}`); + console.log(`Sending ${prefundAmount} to ${deployer} through MessageBus ${messageBusAddress}`); const receipt = await layer1.deployments.rawTx({ from: l1Accs.deployer, diff --git a/contracts/deployment_scripts/funding/layer1/002_fund_faucet.ts b/contracts/deployment_scripts/funding/layer1/002_fund_faucet.ts index 4320d41cda..9eb5e56644 100644 --- a/contracts/deployment_scripts/funding/layer1/002_fund_faucet.ts +++ b/contracts/deployment_scripts/funding/layer1/002_fund_faucet.ts @@ -8,8 +8,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const {deployer} = await hre.getNamedAccounts(); const l1Accs = await layer1.getNamedAccounts(); - const messageBusAddress = process.env.MESSAGE_BUS_ADDRESS!! - const prefundAmountStr = process.env.PREFUND_FAUCET_AMOUNT!! + const messageBusAddress = process.env.MESSAGE_BUS_ADDRESS!!// || "0xFD03804faCA2538F4633B3EBdfEfc38adafa259B" + const prefundAmountStr = process.env.PREFUND_FAUCET_AMOUNT!!// || "1" if (prefundAmountStr == "0") { return; @@ -22,7 +22,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { }); - console.log(`Sending ${prefundAmount} to ${deployer}`); + console.log(`Sending ${prefundAmount} to ${deployer} through ${messageBusAddress}`); const receipt = await layer1.deployments.rawTx({ from: l1Accs.deployer, diff --git a/contracts/deployment_scripts/messenger/layer1/001_deploy_cross_chain_messenger.ts b/contracts/deployment_scripts/messenger/layer1/001_deploy_cross_chain_messenger.ts index cb55e27665..8311cf2227 100644 --- a/contracts/deployment_scripts/messenger/layer1/001_deploy_cross_chain_messenger.ts +++ b/contracts/deployment_scripts/messenger/layer1/001_deploy_cross_chain_messenger.ts @@ -16,13 +16,22 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // Use the contract addresses from the management contract deployment. const mgmtContractAddress = process.env.MGMT_CONTRACT_ADDRESS!! const messageBusAddress : string = process.env.MESSAGE_BUS_ADDRESS!! + console.log(`Management Contract address ${mgmtContractAddress}`); console.log(`Message Bus address ${messageBusAddress}`); // Setup the cross chain messenger and point it to the message bus from the management contract to be used for validation const crossChainDeployment = await deployments.deploy('CrossChainMessenger', { from: deployer, - args: [ messageBusAddress ], log: true, + proxy: { + proxyContract: "OpenZeppelinTransparentProxy", + execute: { + init: { + methodName: "initialize", + args: [ messageBusAddress ] + } + } + } }); // get management contract and write the cross chain messenger address to it diff --git a/contracts/deployment_scripts/messenger/layer2/001_deploy_cross_chain_messenger.ts b/contracts/deployment_scripts/messenger/layer2/001_deploy_cross_chain_messenger.ts index 864dfaebd1..b49c9d797a 100644 --- a/contracts/deployment_scripts/messenger/layer2/001_deploy_cross_chain_messenger.ts +++ b/contracts/deployment_scripts/messenger/layer2/001_deploy_cross_chain_messenger.ts @@ -17,20 +17,26 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // Get the prefunded L2 deployer account to use for deploying. const {deployer} = await getNamedAccounts(); - console.log(`Deployer acc ${deployer}`); + console.log(`Script: 001_deploy_cross_chain_messenger.ts - address used: ${deployer}`); // TODO: Remove hardcoded L2 message bus address when properly exposed. - const busAddress = hre.ethers.utils.getAddress("0x526c84529b2b8c11f57d93d3f5537aca3aecef9b") - - console.log(`Beginning deploy of cross chain messenger`); - + const messageBusAddress = hre.ethers.utils.getAddress("0x526c84529b2b8c11f57d93d3f5537aca3aecef9b"); // Deploy the L2 Cross chain messenger and use the L2 bus for validation await deployments.deploy('CrossChainMessenger', { from: deployer, - args: [ busAddress ], log: true, + proxy: { + proxyContract: "OpenZeppelinTransparentProxy", + execute: { + init: { + methodName: "initialize", + args: [ messageBusAddress ] + } + } + } }); + console.log("Deployed!") }; export default func; -func.tags = ['CrossChainMessenger', 'CrossChainMessenger_deploy']; \ No newline at end of file +func.tags = ['CrossChainMessenger', 'CrossChainMessenger_deploy']; diff --git a/contracts/deployment_scripts/testing/001_gas_testing_deployment.ts b/contracts/deployment_scripts/testing/001_gas_testing_deployment.ts index d577d4b145..56aa8b4d8b 100644 --- a/contracts/deployment_scripts/testing/001_gas_testing_deployment.ts +++ b/contracts/deployment_scripts/testing/001_gas_testing_deployment.ts @@ -14,11 +14,14 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const gasConsumerBalance = await hre.ethers.getContractAt("GasConsumerBalance", gcb.address) - const gasEstimation = await gasConsumerBalance.estimateGas.get_balance({from: deployer}); + const gasEstimation = await gasConsumerBalance.estimateGas.get_balance({ + from: deployer, + gasPrice: 2, + }); await hre.deployments.execute("GasConsumerBalance", { from: deployer, - gasLimit: gasEstimation.div(2), + gasLimit: gasEstimation, log: true }, "get_balance"); }; diff --git a/contracts/generated/CrossChainMessenger/CrossChainMessenger.go b/contracts/generated/CrossChainMessenger/CrossChainMessenger.go index d11e6976d5..eaffbf1dfb 100644 --- a/contracts/generated/CrossChainMessenger/CrossChainMessenger.go +++ b/contracts/generated/CrossChainMessenger/CrossChainMessenger.go @@ -41,8 +41,8 @@ type StructsCrossChainMessage struct { // CrossChainMessengerMetaData contains all meta data concerning the CrossChainMessenger contract. var CrossChainMessengerMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"messageBusAddr\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"error\",\"type\":\"bytes\"}],\"name\":\"CallFailed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"crossChainSender\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"payload\",\"type\":\"bytes\"}],\"name\":\"encodeCall\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"messageBus\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"sequence\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"nonce\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"topic\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"payload\",\"type\":\"bytes\"},{\"internalType\":\"uint8\",\"name\":\"consistencyLevel\",\"type\":\"uint8\"}],\"internalType\":\"structStructs.CrossChainMessage\",\"name\":\"message\",\"type\":\"tuple\"}],\"name\":\"relayMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x6080604052600180546001600160a01b031916905534801561002057600080fd5b506040516109ad3803806109ad83398101604081905261003f91610064565b600080546001600160a01b0319166001600160a01b0392909216919091179055610094565b60006020828403121561007657600080fd5b81516001600160a01b038116811461008d57600080fd5b9392505050565b61090a806100a36000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80635b76f28b1461005157806363012de51461007a5780639b7cf1ee146100a5578063a1a227fa146100ba575b600080fd5b61006461005f366004610425565b6100cb565b6040516100719190610504565b60405180910390f35b60015461008d906001600160a01b031681565b6040516001600160a01b039091168152602001610071565b6100b86100b336600461051e565b61014b565b005b6000546001600160a01b031661008d565b60606040518060600160405280856001600160a01b0316815260200184848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250938552505050602091820152604051610133929101610559565b60405160208183030381529060405290509392505050565b6101548161027d565b610161602082018261059e565b6001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055600061019d60808301836105b9565b8101906101aa9190610690565b905060008082600001516001600160a01b03165a84602001516040516101d09190610764565b60006040518083038160008787f1925050503d806000811461020e576040519150601f19603f3d011682016040523d82523d6000602084013e610213565b606091505b50915091508161025a57806040517fa5fa8d2b0000000000000000000000000000000000000000000000000000000081526004016102519190610504565b60405180910390fd5b50506001805473ffffffffffffffffffffffffffffffffffffffff191690555050565b6000546040517f33a88c720000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906333a88c72906102c69084906004016107ce565b60206040518083038186803b1580156102de57600080fd5b505afa1580156102f2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061031691906108b2565b6103625760405162461bcd60e51b815260206004820152601f60248201527f4d657373616765206e6f7420666f756e64206f722066696e616c697a65642e006044820152606401610251565b60008160405160200161037591906107ce565b60408051601f1981840301815291815281516020928301206000818152600290935291205490915060ff16156103ed5760405162461bcd60e51b815260206004820152601960248201527f4d65737361676520616c726561647920636f6e73756d65642e000000000000006044820152606401610251565b6000908152600260205260409020805460ff1916600117905550565b80356001600160a01b038116811461042057600080fd5b919050565b60008060006040848603121561043a57600080fd5b61044384610409565b9250602084013567ffffffffffffffff8082111561046057600080fd5b818601915086601f83011261047457600080fd5b81358181111561048357600080fd5b87602082850101111561049557600080fd5b6020830194508093505050509250925092565b60005b838110156104c35781810151838201526020016104ab565b838111156104d2576000848401525b50505050565b600081518084526104f08160208601602086016104a8565b601f01601f19169290920160200192915050565b60208152600061051760208301846104d8565b9392505050565b60006020828403121561053057600080fd5b813567ffffffffffffffff81111561054757600080fd5b820160c0818503121561051757600080fd5b602081526001600160a01b038251166020820152600060208301516060604084015261058860808401826104d8565b9050604084015160608401528091505092915050565b6000602082840312156105b057600080fd5b61051782610409565b6000808335601e198436030181126105d057600080fd5b83018035915067ffffffffffffffff8211156105eb57600080fd5b60200191503681900382131561060057600080fd5b9250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff8111828210171561065957610659610607565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561068857610688610607565b604052919050565b600060208083850312156106a357600080fd5b823567ffffffffffffffff808211156106bb57600080fd5b90840190606082870312156106cf57600080fd5b6106d7610636565b6106e083610409565b815283830135828111156106f357600080fd5b8301601f8101881361070457600080fd5b80358381111561071657610716610607565b610728601f8201601f1916870161065f565b9350808452888682840101111561073e57600080fd5b808683018786013760009084018601525092830152604090810135908201529392505050565b600082516107768184602087016104a8565b9190910192915050565b803563ffffffff8116811461042057600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b803560ff8116811461042057600080fd5b602081526001600160a01b036107e383610409565b1660208201526000602083013567ffffffffffffffff80821680831461080857600080fd5b8060408601525061081b60408601610780565b915063ffffffff80831660608601528061083760608801610780565b1660808601525060808501359150601e1985360301821261085757600080fd5b9084019081358181111561086a57600080fd5b80360386131561087957600080fd5b60c060a086015261089160e086018260208601610794565b925050506108a160a085016107bd565b60ff811660c0850152509392505050565b6000602082840312156108c457600080fd5b8151801515811461051757600080fdfea26469706673582212202090fa14d405733eeb20c7bd72003a0427e54bafa4f122140f5a19df921d92ea64736f6c63430008090033", + ABI: "[{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"error\",\"type\":\"bytes\"}],\"name\":\"CallFailed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"crossChainSender\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"target\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"payload\",\"type\":\"bytes\"}],\"name\":\"encodeCall\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"messageBusAddr\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"messageBus\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"sequence\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"nonce\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"topic\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"payload\",\"type\":\"bytes\"},{\"internalType\":\"uint8\",\"name\":\"consistencyLevel\",\"type\":\"uint8\"}],\"internalType\":\"structStructs.CrossChainMessage\",\"name\":\"message\",\"type\":\"tuple\"}],\"name\":\"relayMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x608060405234801561001057600080fd5b50610a61806100206000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c80639b7cf1ee116100505780639b7cf1ee146100c0578063a1a227fa146100d5578063c4d66de8146100ec57600080fd5b80635b76f28b1461006c57806363012de514610095575b600080fd5b61007f61007a36600461057c565b6100ff565b60405161008c919061065b565b60405180910390f35b6001546100a8906001600160a01b031681565b6040516001600160a01b03909116815260200161008c565b6100d36100ce366004610675565b61017f565b005b6000546201000090046001600160a01b03166100a8565b6100d36100fa3660046106b0565b6102b1565b60606040518060600160405280856001600160a01b0316815260200184848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509385525050506020918201526040516101679291016106cb565b60405160208183030381529060405290509392505050565b610188816103cf565b61019560208201826106b0565b6001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b039290921691909117905560006101d16080830183610710565b8101906101de91906107e7565b905060008082600001516001600160a01b03165a846020015160405161020491906108bb565b60006040518083038160008787f1925050503d8060008114610242576040519150601f19603f3d011682016040523d82523d6000602084013e610247565b606091505b50915091508161028e57806040517fa5fa8d2b000000000000000000000000000000000000000000000000000000008152600401610285919061065b565b60405180910390fd5b50506001805473ffffffffffffffffffffffffffffffffffffffff191690555050565b600054610100900460ff166102cc5760005460ff16156102d0565b303b155b6103425760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610285565b600054610100900460ff16158015610364576000805461ffff19166101011790555b600080547fffffffffffffffffffff0000000000000000000000000000000000000000ffff16620100006001600160a01b038516021790556001805473ffffffffffffffffffffffffffffffffffffffff1916905580156103cb576000805461ff00191690555b5050565b6000546040517f33a88c72000000000000000000000000000000000000000000000000000000008152620100009091046001600160a01b0316906333a88c729061041d908490600401610925565b60206040518083038186803b15801561043557600080fd5b505afa158015610449573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061046d9190610a09565b6104b95760405162461bcd60e51b815260206004820152601f60248201527f4d657373616765206e6f7420666f756e64206f722066696e616c697a65642e006044820152606401610285565b6000816040516020016104cc9190610925565b60408051601f1981840301815291815281516020928301206000818152600290935291205490915060ff16156105445760405162461bcd60e51b815260206004820152601960248201527f4d65737361676520616c726561647920636f6e73756d65642e000000000000006044820152606401610285565b6000908152600260205260409020805460ff1916600117905550565b80356001600160a01b038116811461057757600080fd5b919050565b60008060006040848603121561059157600080fd5b61059a84610560565b9250602084013567ffffffffffffffff808211156105b757600080fd5b818601915086601f8301126105cb57600080fd5b8135818111156105da57600080fd5b8760208285010111156105ec57600080fd5b6020830194508093505050509250925092565b60005b8381101561061a578181015183820152602001610602565b83811115610629576000848401525b50505050565b600081518084526106478160208601602086016105ff565b601f01601f19169290920160200192915050565b60208152600061066e602083018461062f565b9392505050565b60006020828403121561068757600080fd5b813567ffffffffffffffff81111561069e57600080fd5b820160c0818503121561066e57600080fd5b6000602082840312156106c257600080fd5b61066e82610560565b602081526001600160a01b03825116602082015260006020830151606060408401526106fa608084018261062f565b9050604084015160608401528091505092915050565b6000808335601e1984360301811261072757600080fd5b83018035915067ffffffffffffffff82111561074257600080fd5b60200191503681900382131561075757600080fd5b9250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff811182821017156107b0576107b061075e565b60405290565b604051601f8201601f1916810167ffffffffffffffff811182821017156107df576107df61075e565b604052919050565b600060208083850312156107fa57600080fd5b823567ffffffffffffffff8082111561081257600080fd5b908401906060828703121561082657600080fd5b61082e61078d565b61083783610560565b8152838301358281111561084a57600080fd5b8301601f8101881361085b57600080fd5b80358381111561086d5761086d61075e565b61087f601f8201601f191687016107b6565b9350808452888682840101111561089557600080fd5b808683018786013760009084018601525092830152604090810135908201529392505050565b600082516108cd8184602087016105ff565b9190910192915050565b803563ffffffff8116811461057757600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b803560ff8116811461057757600080fd5b602081526001600160a01b0361093a83610560565b1660208201526000602083013567ffffffffffffffff80821680831461095f57600080fd5b80604086015250610972604086016108d7565b915063ffffffff80831660608601528061098e606088016108d7565b1660808601525060808501359150601e198536030182126109ae57600080fd5b908401908135818111156109c157600080fd5b8036038613156109d057600080fd5b60c060a08601526109e860e0860182602086016108eb565b925050506109f860a08501610914565b60ff811660c0850152509392505050565b600060208284031215610a1b57600080fd5b8151801515811461066e57600080fdfea2646970667358221220bc0279585a1702d1ea9f6fb2a48e0fb555f801bbc52b59154651989fb7dea11364736f6c63430008090033", } // CrossChainMessengerABI is the input ABI used to generate the binding from. @@ -54,7 +54,7 @@ var CrossChainMessengerABI = CrossChainMessengerMetaData.ABI var CrossChainMessengerBin = CrossChainMessengerMetaData.Bin // DeployCrossChainMessenger deploys a new Ethereum contract, binding an instance of CrossChainMessenger to it. -func DeployCrossChainMessenger(auth *bind.TransactOpts, backend bind.ContractBackend, messageBusAddr common.Address) (common.Address, *types.Transaction, *CrossChainMessenger, error) { +func DeployCrossChainMessenger(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *CrossChainMessenger, error) { parsed, err := CrossChainMessengerMetaData.GetAbi() if err != nil { return common.Address{}, nil, nil, err @@ -63,7 +63,7 @@ func DeployCrossChainMessenger(auth *bind.TransactOpts, backend bind.ContractBac return common.Address{}, nil, nil, errors.New("GetABI returned nil") } - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(CrossChainMessengerBin), backend, messageBusAddr) + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(CrossChainMessengerBin), backend) if err != nil { return common.Address{}, nil, nil, err } @@ -305,6 +305,27 @@ func (_CrossChainMessenger *CrossChainMessengerCallerSession) MessageBus() (comm return _CrossChainMessenger.Contract.MessageBus(&_CrossChainMessenger.CallOpts) } +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address messageBusAddr) returns() +func (_CrossChainMessenger *CrossChainMessengerTransactor) Initialize(opts *bind.TransactOpts, messageBusAddr common.Address) (*types.Transaction, error) { + return _CrossChainMessenger.contract.Transact(opts, "initialize", messageBusAddr) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address messageBusAddr) returns() +func (_CrossChainMessenger *CrossChainMessengerSession) Initialize(messageBusAddr common.Address) (*types.Transaction, error) { + return _CrossChainMessenger.Contract.Initialize(&_CrossChainMessenger.TransactOpts, messageBusAddr) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address messageBusAddr) returns() +func (_CrossChainMessenger *CrossChainMessengerTransactorSession) Initialize(messageBusAddr common.Address) (*types.Transaction, error) { + return _CrossChainMessenger.Contract.Initialize(&_CrossChainMessenger.TransactOpts, messageBusAddr) +} + // RelayMessage is a paid mutator transaction binding the contract method 0x9b7cf1ee. // // Solidity: function relayMessage((address,uint64,uint32,uint32,bytes,uint8) message) returns() diff --git a/contracts/generated/EthereumBridge/EthereumBridge.go b/contracts/generated/EthereumBridge/EthereumBridge.go index e2d39edf5b..51007f553d 100644 --- a/contracts/generated/EthereumBridge/EthereumBridge.go +++ b/contracts/generated/EthereumBridge/EthereumBridge.go @@ -31,8 +31,8 @@ var ( // EthereumBridgeMetaData contains all meta data concerning the EthereumBridge contract. var EthereumBridgeMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"messenger\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"remoteBridge\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"remoteAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"localAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"}],\"name\":\"CreatedWrappedToken\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"wrappedToken\",\"type\":\"address\"}],\"name\":\"hasTokenMapping\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"localToRemoteToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"crossChainAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"}],\"name\":\"onCreateTokenCommand\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"receiveAssets\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"remoteToLocalToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"sendERC20\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"sendNative\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"wrappedTokens\",\"outputs\":[{\"internalType\":\"contractWrappedERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", - Bin: "0x60806040526001805463ffffffff60a01b191690553480156200002157600080fd5b5060405162002b7f38038062002b7f83398101604081905262000044916200012c565b600080546001600160a01b0319166001600160a01b038416908117909155604080516350d113fd60e11b8152905184929163a1a227fa916004808301926020929190829003018186803b1580156200009b57600080fd5b505afa158015620000b0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000d6919062000164565b600180546001600160a01b039283166001600160a01b031991821617909155600580549490921693169290921790915550620001899050565b80516001600160a01b03811681146200012757600080fd5b919050565b600080604083850312156200014057600080fd5b6200014b836200010f565b91506200015b602084016200010f565b90509250929050565b6000602082840312156200017757600080fd5b62000182826200010f565b9392505050565b6129e680620001996000396000f3fe6080604052600436106200008a5760003560e01c80639813c7b211620000555780639813c7b214620002065780639e405b711462000256578063a381c8e21462000290578063d5c6b50414620002b55762000103565b80628d48e3146200014c5780631888d71214620001a3578063458ffd6314620001bc57806383bece4d14620001e15762000103565b36620001035760405162461bcd60e51b815260206004820152602360248201527f436f6e747261637420646f6573206e6f7420737570706f72742072656365697660448201527f652829000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b60405162461bcd60e51b815260206004820152601d60248201527f66616c6c6261636b2829206d6574686f6420756e737570706f727465640000006044820152606401620000fa565b3480156200015957600080fd5b50620001866200016b36600462000c75565b6004602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b620001ba620001b436600462000c75565b620002ef565b005b348015620001c957600080fd5b50620001ba620001db36600462000ce8565b620004a0565b348015620001ee57600080fd5b50620001ba6200020036600462000d74565b620006be565b3480156200021357600080fd5b50620002456200022536600462000c75565b6001600160a01b0390811660009081526002602052604090205416151590565b60405190151581526020016200019a565b3480156200026357600080fd5b50620001866200027536600462000c75565b6003602052600090815260409020546001600160a01b031681565b3480156200029d57600080fd5b50620001ba620002af36600462000d74565b62000901565b348015620002c257600080fd5b5062000186620002d436600462000c75565b6002602052600090815260409020546001600160a01b031681565b60003411620003415760405162461bcd60e51b815260206004820152600d60248201527f4e6f7468696e672073656e742e000000000000000000000000000000000000006044820152606401620000fa565b6000805260026020527fac33ff75c19e70fe83507db0d683fd3465c996598dc972688b7ace676c89077b546001600160a01b0316620003c35760405162461bcd60e51b815260206004820152601560248201527f4e6f206d617070696e6720666f7220746f6b656e2e00000000000000000000006044820152606401620000fa565b600080805260036020527f3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff546040516001600160a01b03918216602482015234604482015290831660648201526383bece4d60e01b9060840160408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526005549091506200049c906001600160a01b03168260005b60008062000a90565b5050565b6005546000546001600160a01b0391821691163314620005295760405162461bcd60e51b815260206004820152603060248201527f436f6e74726163742063616c6c6572206973206e6f742074686520726567697360448201527f7465726564206d657373656e67657221000000000000000000000000000000006064820152608401620000fa565b806001600160a01b03166200053d62000bbe565b6001600160a01b031614620005bb5760405162461bcd60e51b815260206004820152603160248201527f43726f737320636861696e206d65737361676520636f6d696e672066726f6d2060448201527f696e636f72726563742073656e646572210000000000000000000000000000006064820152608401620000fa565b600085858585604051620005cf9062000c4e565b620005de949392919062000de4565b604051809103906000f080158015620005fb573d6000803e3d6000fd5b506001600160a01b03808216600081815260026020908152604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081168617909155600383528184208054968f169682168717905594835260049091529081902080549093169091179091555190915081907f30c05779f384e0ae9d43bbf7ec4417f28bdc53d02a35551b6eb270a9c4c71dca90620006ac908a9084908b908b908b908b9062000e1a565b60405180910390a15050505050505050565b6005546000546001600160a01b0391821691163314620007475760405162461bcd60e51b815260206004820152603060248201527f436f6e74726163742063616c6c6572206973206e6f742074686520726567697360448201527f7465726564206d657373656e67657221000000000000000000000000000000006064820152608401620000fa565b806001600160a01b03166200075b62000bbe565b6001600160a01b031614620007d95760405162461bcd60e51b815260206004820152603160248201527f43726f737320636861696e206d65737361676520636f6d696e672066726f6d2060448201527f696e636f72726563742073656e646572210000000000000000000000000000006064820152608401620000fa565b6001600160a01b038085166000908152600460209081526040808320548416808452600290925290912054909116806200087c5760405162461bcd60e51b815260206004820152602b60248201527f526563656976696e672061737365747320666f7220756e6b6e6f776e2077726160448201527f7070656420746f6b656e210000000000000000000000000000000000000000006064820152608401620000fa565b6040517f979005ad0000000000000000000000000000000000000000000000000000000081526001600160a01b0385811660048301526024820187905282169063979005ad90604401600060405180830381600087803b158015620008e057600080fd5b505af1158015620008f5573d6000803e3d6000fd5b50505050505050505050565b6001600160a01b03808416600090815260026020526040902054166200096a5760405162461bcd60e51b815260206004820152601560248201527f4e6f206d617070696e6720666f7220746f6b656e2e00000000000000000000006044820152606401620000fa565b6001600160a01b03838116600090815260026020526040908190205490517f1dd319cb000000000000000000000000000000000000000000000000000000008152336004820152602481018590529116908190631dd319cb90604401600060405180830381600087803b158015620009e157600080fd5b505af1158015620009f6573d6000803e3d6000fd5b505050506001600160a01b03848116600090815260036020908152604080832054815190851660248201526044810188905286851660648083019190915282518083039091018152608490910190915290810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166383bece4d60e01b179052600554909262000a8992911690839062000493565b5050505050565b60006040518060600160405280876001600160a01b031681526020018681526020018481525060405160200162000ac8919062000ebb565b60408051808303601f19018152919052600180549192506001600160a01b0382169163b1454caa917401000000000000000000000000000000000000000090910463ffffffff1690601462000b1d8362000f02565b91906101000a81548163ffffffff021916908363ffffffff1602179055508684866040518563ffffffff1660e01b815260040162000b5f949392919062000f4e565b602060405180830381600087803b15801562000b7a57600080fd5b505af115801562000b8f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000bb5919062000f8d565b50505050505050565b60008060009054906101000a90046001600160a01b03166001600160a01b03166363012de56040518163ffffffff1660e01b815260040160206040518083038186803b15801562000c0e57600080fd5b505afa15801562000c23573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000c49919062000fb9565b905090565b6119d78062000fda83390190565b6001600160a01b038116811462000c7257600080fd5b50565b60006020828403121562000c8857600080fd5b813562000c958162000c5c565b9392505050565b60008083601f84011262000caf57600080fd5b50813567ffffffffffffffff81111562000cc857600080fd5b60208301915083602082850101111562000ce157600080fd5b9250929050565b60008060008060006060868803121562000d0157600080fd5b853562000d0e8162000c5c565b9450602086013567ffffffffffffffff8082111562000d2c57600080fd5b62000d3a89838a0162000c9c565b9096509450604088013591508082111562000d5457600080fd5b5062000d638882890162000c9c565b969995985093965092949392505050565b60008060006060848603121562000d8a57600080fd5b833562000d978162000c5c565b925060208401359150604084013562000db08162000c5c565b809150509250925092565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60408152600062000dfa60408301868862000dbb565b828103602084015262000e0f81858762000dbb565b979650505050505050565b60006001600160a01b0380891683528088166020840152506080604083015262000e4960808301868862000dbb565b828103606084015262000e5e81858762000dbb565b9998505050505050505050565b6000815180845260005b8181101562000e935760208185018101518683018201520162000e75565b8181111562000ea6576000602083870101525b50601f01601f19169290920160200192915050565b602081526001600160a01b038251166020820152600060208301516060604084015262000eec608084018262000e6b565b9050604084015160608401528091505092915050565b600063ffffffff8083168181141562000f44577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6001019392505050565b600063ffffffff80871683528086166020840152506080604083015262000f79608083018562000e6b565b905060ff8316606083015295945050505050565b60006020828403121562000fa057600080fd5b815167ffffffffffffffff8116811462000c9557600080fd5b60006020828403121562000fcc57600080fd5b815162000c958162000c5c56fe6080604052600580546001600160a01b03191673deb34a740eca1ec42c8b8204cbec0ba34fdd27f31790553480156200003757600080fd5b50604051620019d7380380620019d78339810160408190526200005a91620002e3565b8181818181600390805190602001906200007692919062000170565b5080516200008c90600490602084019062000170565b5050505050620000c37fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177533620000cb60201b60201c565b50506200038a565b60008281526007602090815260408083206001600160a01b038516845290915290205460ff166200016c5760008281526007602090815260408083206001600160a01b03851684529091529020805460ff191660011790556200012b3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b8280546200017e906200034d565b90600052602060002090601f016020900481019282620001a25760008555620001ed565b82601f10620001bd57805160ff1916838001178555620001ed565b82800160010185558215620001ed579182015b82811115620001ed578251825591602001919060010190620001d0565b50620001fb929150620001ff565b5090565b5b80821115620001fb576000815560010162000200565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200023e57600080fd5b81516001600160401b03808211156200025b576200025b62000216565b604051601f8301601f19908116603f0116810190828211818310171562000286576200028662000216565b81604052838152602092508683858801011115620002a357600080fd5b600091505b83821015620002c75785820183015181830184015290820190620002a8565b83821115620002d95760008385830101525b9695505050505050565b60008060408385031215620002f757600080fd5b82516001600160401b03808211156200030f57600080fd5b6200031d868387016200022c565b935060208501519150808211156200033457600080fd5b5062000343858286016200022c565b9150509250929050565b600181811c908216806200036257607f821691505b602082108114156200038457634e487b7160e01b600052602260045260246000fd5b50919050565b61163d806200039a6000396000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806339509351116100d8578063979005ad1161008c578063a9059cbb11610066578063a9059cbb1461031a578063d547741f1461032d578063dd62ed3e1461034057600080fd5b8063979005ad146102ec578063a217fddf146102ff578063a457c2d71461030757600080fd5b806375b238fc116100bd57806375b238fc1461028457806391d14854146102ab57806395d89b41146102e457600080fd5b8063395093511461025e57806370a082311461027157600080fd5b806323b872dd1161012f5780632f2ff15d116101145780632f2ff15d14610229578063313ce5671461023c57806336568abe1461024b57600080fd5b806323b872dd146101f3578063248a9ca31461020657600080fd5b8063095ea7b311610160578063095ea7b3146101b957806318160ddd146101cc5780631dd319cb146101de57600080fd5b806301ffc9a71461017c57806306fdde03146101a4575b600080fd5b61018f61018a3660046112f7565b610353565b60405190151581526020015b60405180910390f35b6101ac6103ec565b60405161019b9190611365565b61018f6101c73660046113b4565b61047e565b6002545b60405190815260200161019b565b6101f16101ec3660046113b4565b610496565b005b61018f6102013660046113de565b61052d565b6101d061021436600461141a565b60009081526007602052604090206001015490565b6101f1610237366004611433565b610551565b6040516012815260200161019b565b6101f1610259366004611433565b610577565b61018f61026c3660046113b4565b610603565b6101d061027f36600461145f565b610642565b6101d07fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b61018f6102b9366004611433565b60009182526007602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6101ac6106ea565b6101f16102fa3660046113b4565b6106f9565b6101d0600081565b61018f6103153660046113b4565b61072e565b61018f6103283660046113b4565b6107d8565b6101f161033b366004611433565b6107e6565b6101d061034e36600461147a565b61080c565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806103e657507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b6060600380546103fb906114a4565b80601f0160208091040260200160405190810160405280929190818152602001828054610427906114a4565b80156104745780601f1061044957610100808354040283529160200191610474565b820191906000526020600020905b81548152906001019060200180831161045757829003601f168201915b5050505050905090565b60003361048c81858561091d565b5060019392505050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756104c18133610a75565b816104cb84610642565b101561051e5760405162461bcd60e51b815260206004820152601560248201527f496e73756666696369656e742062616c616e63652e000000000000000000000060448201526064015b60405180910390fd5b6105288383610af5565b505050565b60003361053b858285610c7a565b610546858585610cf4565b506001949350505050565b60008281526007602052604090206001015461056d8133610a75565b6105288383610f0b565b6001600160a01b03811633146105f55760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610515565b6105ff8282610fad565b5050565b3360008181526001602090815260408083206001600160a01b038716845290915281205490919061048c908290869061063d9087906114f5565b61091d565b6000326001600160a01b0383161415610673576001600160a01b0382166000908152602081905260409020546103e6565b336001600160a01b03831614156106a2576001600160a01b0382166000908152602081905260409020546103e6565b60405162461bcd60e51b815260206004820152601f60248201527f4e6f7420616c6c6f77656420746f2072656164207468652062616c616e6365006044820152606401610515565b6060600480546103fb906114a4565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756107248133610a75565b6105288383611030565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909190838110156107cb5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610515565b610546828686840361091d565b60003361048c818585610cf4565b6000828152600760205260409020600101546108028133610a75565b6105288383610fad565b6000326001600160a01b038416148061082d5750326001600160a01b038316145b15610860576001600160a01b038084166000908152600160209081526040808320938616835292905220545b90506103e6565b336001600160a01b038416148061087f5750336001600160a01b038316145b156108af576001600160a01b03808416600090815260016020908152604080832093861683529290522054610859565b60405162461bcd60e51b815260206004820152602160248201527f4e6f7420616c6c6f77656420746f20726561642074686520616c6c6f77616e6360448201527f65000000000000000000000000000000000000000000000000000000000000006064820152608401610515565b6001600160a01b0383166109985760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610515565b6001600160a01b038216610a145760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610515565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60008281526007602090815260408083206001600160a01b038516845290915290205460ff166105ff57610ab3816001600160a01b0316601461110f565b610abe83602061110f565b604051602001610acf92919061150d565b60408051601f198184030181529082905262461bcd60e51b825261051591600401611365565b6001600160a01b038216610b715760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610515565b6001600160a01b03821660009081526020819052604090205481811015610c005760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610515565b6001600160a01b0383166000908152602081905260408120838303905560028054849290610c2f90849061158e565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b6000610c86848461080c565b90506000198114610cee5781811015610ce15760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610515565b610cee848484840361091d565b50505050565b6001600160a01b038316610d705760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610515565b6001600160a01b038216610dec5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610515565b6001600160a01b03831660009081526020819052604090205481811015610e7b5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610515565b6001600160a01b03808516600090815260208190526040808220858503905591851681529081208054849290610eb29084906114f5565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610efe91815260200190565b60405180910390a3610cee565b60008281526007602090815260408083206001600160a01b038516845290915290205460ff166105ff5760008281526007602090815260408083206001600160a01b03851684529091529020805460ff19166001179055610f693390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526007602090815260408083206001600160a01b038516845290915290205460ff16156105ff5760008281526007602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001600160a01b0382166110865760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610515565b806002600082825461109891906114f5565b90915550506001600160a01b038216600090815260208190526040812080548392906110c59084906114f5565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6060600061111e8360026115a5565b6111299060026114f5565b67ffffffffffffffff811115611141576111416115c4565b6040519080825280601f01601f19166020018201604052801561116b576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106111a2576111a26115da565b60200101906001600160f81b031916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106111ed576111ed6115da565b60200101906001600160f81b031916908160001a90535060006112118460026115a5565b61121c9060016114f5565b90505b60018111156112a1577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061125d5761125d6115da565b1a60f81b828281518110611273576112736115da565b60200101906001600160f81b031916908160001a90535060049490941c9361129a816115f0565b905061121f565b5083156112f05760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610515565b9392505050565b60006020828403121561130957600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146112f057600080fd5b60005b8381101561135457818101518382015260200161133c565b83811115610cee5750506000910152565b6020815260008251806020840152611384816040850160208701611339565b601f01601f19169190910160400192915050565b80356001600160a01b03811681146113af57600080fd5b919050565b600080604083850312156113c757600080fd5b6113d083611398565b946020939093013593505050565b6000806000606084860312156113f357600080fd5b6113fc84611398565b925061140a60208501611398565b9150604084013590509250925092565b60006020828403121561142c57600080fd5b5035919050565b6000806040838503121561144657600080fd5b8235915061145660208401611398565b90509250929050565b60006020828403121561147157600080fd5b6112f082611398565b6000806040838503121561148d57600080fd5b61149683611398565b915061145660208401611398565b600181811c908216806114b857607f821691505b602082108114156114d957634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b60008219821115611508576115086114df565b500190565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351611545816017850160208801611339565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351611582816028840160208801611339565b01602801949350505050565b6000828210156115a0576115a06114df565b500390565b60008160001904831182151516156115bf576115bf6114df565b500290565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6000816115ff576115ff6114df565b50600019019056fea26469706673582212201c0c3a851d2bc9f4f94393362a160e99651c656d627113abd657cce4d7d8770964736f6c63430008090033a2646970667358221220f9825dd91174a15483717354b811471c21735f94eeeab98508c31c1e389d5d7164736f6c63430008090033", + ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"remoteAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"localAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"}],\"name\":\"CreatedWrappedToken\",\"type\":\"event\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"messengerAddress\",\"type\":\"address\"}],\"name\":\"configure\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"wrappedToken\",\"type\":\"address\"}],\"name\":\"hasTokenMapping\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"messenger\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"remoteBridge\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"localToRemoteToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"crossChainAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"}],\"name\":\"onCreateTokenCommand\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"receiveAssets\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"remoteToLocalToken\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"sendERC20\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"sendNative\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"wrappedTokens\",\"outputs\":[{\"internalType\":\"contractWrappedERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", + Bin: "0x60806040526001805463ffffffff60a01b1916905534801561002057600080fd5b50612d10806100306000396000f3fe608060405260043610620000c65760003560e01c806383bece4d11620000735780639e405b7111620000555780639e405b7114620002dc578063a381c8e21462000316578063d5c6b504146200033b576200013f565b806383bece4d14620002675780639813c7b2146200028c576200013f565b8063458ffd6311620000a9578063458ffd6314620001f8578063485cc955146200021d57806375cb26721462000242576200013f565b80628d48e314620001885780631888d71214620001df576200013f565b366200013f5760405162461bcd60e51b815260206004820152602360248201527f436f6e747261637420646f6573206e6f7420737570706f72742072656365697660448201527f652829000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b60405162461bcd60e51b815260206004820152601d60248201527f66616c6c6261636b2829206d6574686f6420756e737570706f72746564000000604482015260640162000136565b3480156200019557600080fd5b50620001c2620001a736600462000f61565b6004602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b620001f6620001f036600462000f61565b62000375565b005b3480156200020557600080fd5b50620001f66200021736600462000fd4565b62000526565b3480156200022a57600080fd5b50620001f66200023c36600462001060565b62000740565b3480156200024f57600080fd5b50620001f66200026136600462000f61565b62000843565b3480156200027457600080fd5b50620001f6620002863660046200109e565b620009a3565b3480156200029957600080fd5b50620002cb620002ab36600462000f61565b6001600160a01b0390811660009081526002602052604090205416151590565b6040519015158152602001620001d6565b348015620002e957600080fd5b50620001c2620002fb36600462000f61565b6003602052600090815260409020546001600160a01b031681565b3480156200032357600080fd5b50620001f6620003353660046200109e565b62000bed565b3480156200034857600080fd5b50620001c26200035a36600462000f61565b6002602052600090815260409020546001600160a01b031681565b60003411620003c75760405162461bcd60e51b815260206004820152600d60248201527f4e6f7468696e672073656e742e00000000000000000000000000000000000000604482015260640162000136565b6000805260026020527fac33ff75c19e70fe83507db0d683fd3465c996598dc972688b7ace676c89077b546001600160a01b0316620004495760405162461bcd60e51b815260206004820152601560248201527f4e6f206d617070696e6720666f7220746f6b656e2e0000000000000000000000604482015260640162000136565b600080805260036020527f3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff546040516001600160a01b03918216602482015234604482015290831660648201526383bece4d60e01b9060840160408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009093169290921790915260055490915062000522906001600160a01b03168260005b60008062000d7c565b5050565b6005546000546001600160a01b039182169162010000909104163314620005b65760405162461bcd60e51b815260206004820152603060248201527f436f6e74726163742063616c6c6572206973206e6f742074686520726567697360448201527f7465726564206d657373656e6765722100000000000000000000000000000000606482015260840162000136565b806001600160a01b0316620005ca62000eaa565b6001600160a01b031614620006485760405162461bcd60e51b815260206004820152603160248201527f43726f737320636861696e206d65737361676520636f6d696e672066726f6d2060448201527f696e636f72726563742073656e64657221000000000000000000000000000000606482015260840162000136565b6000858585856040516200065c9062000f3a565b6200066b94939291906200110e565b604051809103906000f08015801562000688573d6000803e3d6000fd5b506001600160a01b038082166000818152600260209081526040808320805473ffffffffffffffffffffffffffffffffffffffff199081168617909155600383528184208054968f169682168717905594835260049091529081902080549093169091179091555190915081907f30c05779f384e0ae9d43bbf7ec4417f28bdc53d02a35551b6eb270a9c4c71dca906200072e908a9084908b908b908b908b9062001144565b60405180910390a15050505050505050565b600054610100900460ff166200075d5760005460ff161562000761565b303b155b620007d55760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840162000136565b600054610100900460ff16158015620007f8576000805461ffff19166101011790555b620008038362000843565b6005805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03841617905580156200083e576000805461ff00191690555b505050565b600054610100900460ff16620008c25760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840162000136565b80600060026101000a8154816001600160a01b0302191690836001600160a01b03160217905550600060029054906101000a90046001600160a01b03166001600160a01b031663a1a227fa6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200093857600080fd5b505afa1580156200094d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000973919062001195565b6001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b039290921691909117905550565b6005546000546001600160a01b03918216916201000090910416331462000a335760405162461bcd60e51b815260206004820152603060248201527f436f6e74726163742063616c6c6572206973206e6f742074686520726567697360448201527f7465726564206d657373656e6765722100000000000000000000000000000000606482015260840162000136565b806001600160a01b031662000a4762000eaa565b6001600160a01b03161462000ac55760405162461bcd60e51b815260206004820152603160248201527f43726f737320636861696e206d65737361676520636f6d696e672066726f6d2060448201527f696e636f72726563742073656e64657221000000000000000000000000000000606482015260840162000136565b6001600160a01b0380851660009081526004602090815260408083205484168084526002909252909120549091168062000b685760405162461bcd60e51b815260206004820152602b60248201527f526563656976696e672061737365747320666f7220756e6b6e6f776e2077726160448201527f7070656420746f6b656e21000000000000000000000000000000000000000000606482015260840162000136565b6040517f979005ad0000000000000000000000000000000000000000000000000000000081526001600160a01b0385811660048301526024820187905282169063979005ad90604401600060405180830381600087803b15801562000bcc57600080fd5b505af115801562000be1573d6000803e3d6000fd5b50505050505050505050565b6001600160a01b038084166000908152600260205260409020541662000c565760405162461bcd60e51b815260206004820152601560248201527f4e6f206d617070696e6720666f7220746f6b656e2e0000000000000000000000604482015260640162000136565b6001600160a01b03838116600090815260026020526040908190205490517f1dd319cb000000000000000000000000000000000000000000000000000000008152336004820152602481018590529116908190631dd319cb90604401600060405180830381600087803b15801562000ccd57600080fd5b505af115801562000ce2573d6000803e3d6000fd5b505050506001600160a01b03848116600090815260036020908152604080832054815190851660248201526044810188905286851660648083019190915282518083039091018152608490910190915290810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166383bece4d60e01b179052600554909262000d7592911690839062000519565b5050505050565b60006040518060600160405280876001600160a01b031681526020018681526020018481525060405160200162000db4919062001205565b60408051808303601f19018152919052600180549192506001600160a01b0382169163b1454caa917401000000000000000000000000000000000000000090910463ffffffff1690601462000e09836200124c565b91906101000a81548163ffffffff021916908363ffffffff1602179055508684866040518563ffffffff1660e01b815260040162000e4b949392919062001298565b602060405180830381600087803b15801562000e6657600080fd5b505af115801562000e7b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000ea19190620012d7565b50505050505050565b60008060029054906101000a90046001600160a01b03166001600160a01b03166363012de56040518163ffffffff1660e01b815260040160206040518083038186803b15801562000efa57600080fd5b505afa15801562000f0f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000f35919062001195565b905090565b6119d7806200130483390190565b6001600160a01b038116811462000f5e57600080fd5b50565b60006020828403121562000f7457600080fd5b813562000f818162000f48565b9392505050565b60008083601f84011262000f9b57600080fd5b50813567ffffffffffffffff81111562000fb457600080fd5b60208301915083602082850101111562000fcd57600080fd5b9250929050565b60008060008060006060868803121562000fed57600080fd5b853562000ffa8162000f48565b9450602086013567ffffffffffffffff808211156200101857600080fd5b6200102689838a0162000f88565b909650945060408801359150808211156200104057600080fd5b506200104f8882890162000f88565b969995985093965092949392505050565b600080604083850312156200107457600080fd5b8235620010818162000f48565b91506020830135620010938162000f48565b809150509250929050565b600080600060608486031215620010b457600080fd5b8335620010c18162000f48565b9250602084013591506040840135620010da8162000f48565b809150509250925092565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60408152600062001124604083018688620010e5565b828103602084015262001139818587620010e5565b979650505050505050565b60006001600160a01b0380891683528088166020840152506080604083015262001173608083018688620010e5565b828103606084015262001188818587620010e5565b9998505050505050505050565b600060208284031215620011a857600080fd5b815162000f818162000f48565b6000815180845260005b81811015620011dd57602081850181015186830182015201620011bf565b81811115620011f0576000602083870101525b50601f01601f19169290920160200192915050565b602081526001600160a01b0382511660208201526000602083015160606040840152620012366080840182620011b5565b9050604084015160608401528091505092915050565b600063ffffffff808316818114156200128e577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6001019392505050565b600063ffffffff808716835280861660208401525060806040830152620012c36080830185620011b5565b905060ff8316606083015295945050505050565b600060208284031215620012ea57600080fd5b815167ffffffffffffffff8116811462000f8157600080fdfe6080604052600580546001600160a01b03191673deb34a740eca1ec42c8b8204cbec0ba34fdd27f31790553480156200003757600080fd5b50604051620019d7380380620019d78339810160408190526200005a91620002e3565b8181818181600390805190602001906200007692919062000170565b5080516200008c90600490602084019062000170565b5050505050620000c37fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177533620000cb60201b60201c565b50506200038a565b60008281526007602090815260408083206001600160a01b038516845290915290205460ff166200016c5760008281526007602090815260408083206001600160a01b03851684529091529020805460ff191660011790556200012b3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b8280546200017e906200034d565b90600052602060002090601f016020900481019282620001a25760008555620001ed565b82601f10620001bd57805160ff1916838001178555620001ed565b82800160010185558215620001ed579182015b82811115620001ed578251825591602001919060010190620001d0565b50620001fb929150620001ff565b5090565b5b80821115620001fb576000815560010162000200565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200023e57600080fd5b81516001600160401b03808211156200025b576200025b62000216565b604051601f8301601f19908116603f0116810190828211818310171562000286576200028662000216565b81604052838152602092508683858801011115620002a357600080fd5b600091505b83821015620002c75785820183015181830184015290820190620002a8565b83821115620002d95760008385830101525b9695505050505050565b60008060408385031215620002f757600080fd5b82516001600160401b03808211156200030f57600080fd5b6200031d868387016200022c565b935060208501519150808211156200033457600080fd5b5062000343858286016200022c565b9150509250929050565b600181811c908216806200036257607f821691505b602082108114156200038457634e487b7160e01b600052602260045260246000fd5b50919050565b61163d806200039a6000396000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806339509351116100d8578063979005ad1161008c578063a9059cbb11610066578063a9059cbb1461031a578063d547741f1461032d578063dd62ed3e1461034057600080fd5b8063979005ad146102ec578063a217fddf146102ff578063a457c2d71461030757600080fd5b806375b238fc116100bd57806375b238fc1461028457806391d14854146102ab57806395d89b41146102e457600080fd5b8063395093511461025e57806370a082311461027157600080fd5b806323b872dd1161012f5780632f2ff15d116101145780632f2ff15d14610229578063313ce5671461023c57806336568abe1461024b57600080fd5b806323b872dd146101f3578063248a9ca31461020657600080fd5b8063095ea7b311610160578063095ea7b3146101b957806318160ddd146101cc5780631dd319cb146101de57600080fd5b806301ffc9a71461017c57806306fdde03146101a4575b600080fd5b61018f61018a3660046112f7565b610353565b60405190151581526020015b60405180910390f35b6101ac6103ec565b60405161019b9190611365565b61018f6101c73660046113b4565b61047e565b6002545b60405190815260200161019b565b6101f16101ec3660046113b4565b610496565b005b61018f6102013660046113de565b61052d565b6101d061021436600461141a565b60009081526007602052604090206001015490565b6101f1610237366004611433565b610551565b6040516012815260200161019b565b6101f1610259366004611433565b610577565b61018f61026c3660046113b4565b610603565b6101d061027f36600461145f565b610642565b6101d07fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b61018f6102b9366004611433565b60009182526007602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6101ac6106ea565b6101f16102fa3660046113b4565b6106f9565b6101d0600081565b61018f6103153660046113b4565b61072e565b61018f6103283660046113b4565b6107d8565b6101f161033b366004611433565b6107e6565b6101d061034e36600461147a565b61080c565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806103e657507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b6060600380546103fb906114a4565b80601f0160208091040260200160405190810160405280929190818152602001828054610427906114a4565b80156104745780601f1061044957610100808354040283529160200191610474565b820191906000526020600020905b81548152906001019060200180831161045757829003601f168201915b5050505050905090565b60003361048c81858561091d565b5060019392505050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756104c18133610a75565b816104cb84610642565b101561051e5760405162461bcd60e51b815260206004820152601560248201527f496e73756666696369656e742062616c616e63652e000000000000000000000060448201526064015b60405180910390fd5b6105288383610af5565b505050565b60003361053b858285610c7a565b610546858585610cf4565b506001949350505050565b60008281526007602052604090206001015461056d8133610a75565b6105288383610f0b565b6001600160a01b03811633146105f55760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610515565b6105ff8282610fad565b5050565b3360008181526001602090815260408083206001600160a01b038716845290915281205490919061048c908290869061063d9087906114f5565b61091d565b6000326001600160a01b0383161415610673576001600160a01b0382166000908152602081905260409020546103e6565b336001600160a01b03831614156106a2576001600160a01b0382166000908152602081905260409020546103e6565b60405162461bcd60e51b815260206004820152601f60248201527f4e6f7420616c6c6f77656420746f2072656164207468652062616c616e6365006044820152606401610515565b6060600480546103fb906114a4565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756107248133610a75565b6105288383611030565b3360008181526001602090815260408083206001600160a01b0387168452909152812054909190838110156107cb5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610515565b610546828686840361091d565b60003361048c818585610cf4565b6000828152600760205260409020600101546108028133610a75565b6105288383610fad565b6000326001600160a01b038416148061082d5750326001600160a01b038316145b15610860576001600160a01b038084166000908152600160209081526040808320938616835292905220545b90506103e6565b336001600160a01b038416148061087f5750336001600160a01b038316145b156108af576001600160a01b03808416600090815260016020908152604080832093861683529290522054610859565b60405162461bcd60e51b815260206004820152602160248201527f4e6f7420616c6c6f77656420746f20726561642074686520616c6c6f77616e6360448201527f65000000000000000000000000000000000000000000000000000000000000006064820152608401610515565b6001600160a01b0383166109985760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610515565b6001600160a01b038216610a145760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610515565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60008281526007602090815260408083206001600160a01b038516845290915290205460ff166105ff57610ab3816001600160a01b0316601461110f565b610abe83602061110f565b604051602001610acf92919061150d565b60408051601f198184030181529082905262461bcd60e51b825261051591600401611365565b6001600160a01b038216610b715760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610515565b6001600160a01b03821660009081526020819052604090205481811015610c005760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152608401610515565b6001600160a01b0383166000908152602081905260408120838303905560028054849290610c2f90849061158e565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b6000610c86848461080c565b90506000198114610cee5781811015610ce15760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610515565b610cee848484840361091d565b50505050565b6001600160a01b038316610d705760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610515565b6001600160a01b038216610dec5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152608401610515565b6001600160a01b03831660009081526020819052604090205481811015610e7b5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610515565b6001600160a01b03808516600090815260208190526040808220858503905591851681529081208054849290610eb29084906114f5565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610efe91815260200190565b60405180910390a3610cee565b60008281526007602090815260408083206001600160a01b038516845290915290205460ff166105ff5760008281526007602090815260408083206001600160a01b03851684529091529020805460ff19166001179055610f693390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526007602090815260408083206001600160a01b038516845290915290205460ff16156105ff5760008281526007602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6001600160a01b0382166110865760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610515565b806002600082825461109891906114f5565b90915550506001600160a01b038216600090815260208190526040812080548392906110c59084906114f5565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b6060600061111e8360026115a5565b6111299060026114f5565b67ffffffffffffffff811115611141576111416115c4565b6040519080825280601f01601f19166020018201604052801561116b576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106111a2576111a26115da565b60200101906001600160f81b031916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106111ed576111ed6115da565b60200101906001600160f81b031916908160001a90535060006112118460026115a5565b61121c9060016114f5565b90505b60018111156112a1577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061125d5761125d6115da565b1a60f81b828281518110611273576112736115da565b60200101906001600160f81b031916908160001a90535060049490941c9361129a816115f0565b905061121f565b5083156112f05760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610515565b9392505050565b60006020828403121561130957600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146112f057600080fd5b60005b8381101561135457818101518382015260200161133c565b83811115610cee5750506000910152565b6020815260008251806020840152611384816040850160208701611339565b601f01601f19169190910160400192915050565b80356001600160a01b03811681146113af57600080fd5b919050565b600080604083850312156113c757600080fd5b6113d083611398565b946020939093013593505050565b6000806000606084860312156113f357600080fd5b6113fc84611398565b925061140a60208501611398565b9150604084013590509250925092565b60006020828403121561142c57600080fd5b5035919050565b6000806040838503121561144657600080fd5b8235915061145660208401611398565b90509250929050565b60006020828403121561147157600080fd5b6112f082611398565b6000806040838503121561148d57600080fd5b61149683611398565b915061145660208401611398565b600181811c908216806114b857607f821691505b602082108114156114d957634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b60008219821115611508576115086114df565b500190565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351611545816017850160208801611339565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351611582816028840160208801611339565b01602801949350505050565b6000828210156115a0576115a06114df565b500390565b60008160001904831182151516156115bf576115bf6114df565b500290565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6000816115ff576115ff6114df565b50600019019056fea26469706673582212201c0c3a851d2bc9f4f94393362a160e99651c656d627113abd657cce4d7d8770964736f6c63430008090033a26469706673582212209025675371a7cd9667ebd11bf443f5ad333fd6b958c0b2dd506b3cf13882f17164736f6c63430008090033", } // EthereumBridgeABI is the input ABI used to generate the binding from. @@ -44,7 +44,7 @@ var EthereumBridgeABI = EthereumBridgeMetaData.ABI var EthereumBridgeBin = EthereumBridgeMetaData.Bin // DeployEthereumBridge deploys a new Ethereum contract, binding an instance of EthereumBridge to it. -func DeployEthereumBridge(auth *bind.TransactOpts, backend bind.ContractBackend, messenger common.Address, remoteBridge common.Address) (common.Address, *types.Transaction, *EthereumBridge, error) { +func DeployEthereumBridge(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *EthereumBridge, error) { parsed, err := EthereumBridgeMetaData.GetAbi() if err != nil { return common.Address{}, nil, nil, err @@ -53,7 +53,7 @@ func DeployEthereumBridge(auth *bind.TransactOpts, backend bind.ContractBackend, return common.Address{}, nil, nil, errors.New("GetABI returned nil") } - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(EthereumBridgeBin), backend, messenger, remoteBridge) + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(EthereumBridgeBin), backend) if err != nil { return common.Address{}, nil, nil, err } @@ -326,6 +326,48 @@ func (_EthereumBridge *EthereumBridgeCallerSession) WrappedTokens(arg0 common.Ad return _EthereumBridge.Contract.WrappedTokens(&_EthereumBridge.CallOpts, arg0) } +// Configure is a paid mutator transaction binding the contract method 0x75cb2672. +// +// Solidity: function configure(address messengerAddress) returns() +func (_EthereumBridge *EthereumBridgeTransactor) Configure(opts *bind.TransactOpts, messengerAddress common.Address) (*types.Transaction, error) { + return _EthereumBridge.contract.Transact(opts, "configure", messengerAddress) +} + +// Configure is a paid mutator transaction binding the contract method 0x75cb2672. +// +// Solidity: function configure(address messengerAddress) returns() +func (_EthereumBridge *EthereumBridgeSession) Configure(messengerAddress common.Address) (*types.Transaction, error) { + return _EthereumBridge.Contract.Configure(&_EthereumBridge.TransactOpts, messengerAddress) +} + +// Configure is a paid mutator transaction binding the contract method 0x75cb2672. +// +// Solidity: function configure(address messengerAddress) returns() +func (_EthereumBridge *EthereumBridgeTransactorSession) Configure(messengerAddress common.Address) (*types.Transaction, error) { + return _EthereumBridge.Contract.Configure(&_EthereumBridge.TransactOpts, messengerAddress) +} + +// Initialize is a paid mutator transaction binding the contract method 0x485cc955. +// +// Solidity: function initialize(address messenger, address remoteBridge) returns() +func (_EthereumBridge *EthereumBridgeTransactor) Initialize(opts *bind.TransactOpts, messenger common.Address, remoteBridge common.Address) (*types.Transaction, error) { + return _EthereumBridge.contract.Transact(opts, "initialize", messenger, remoteBridge) +} + +// Initialize is a paid mutator transaction binding the contract method 0x485cc955. +// +// Solidity: function initialize(address messenger, address remoteBridge) returns() +func (_EthereumBridge *EthereumBridgeSession) Initialize(messenger common.Address, remoteBridge common.Address) (*types.Transaction, error) { + return _EthereumBridge.Contract.Initialize(&_EthereumBridge.TransactOpts, messenger, remoteBridge) +} + +// Initialize is a paid mutator transaction binding the contract method 0x485cc955. +// +// Solidity: function initialize(address messenger, address remoteBridge) returns() +func (_EthereumBridge *EthereumBridgeTransactorSession) Initialize(messenger common.Address, remoteBridge common.Address) (*types.Transaction, error) { + return _EthereumBridge.Contract.Initialize(&_EthereumBridge.TransactOpts, messenger, remoteBridge) +} + // OnCreateTokenCommand is a paid mutator transaction binding the contract method 0x458ffd63. // // Solidity: function onCreateTokenCommand(address crossChainAddress, string name, string symbol) returns() diff --git a/contracts/generated/ManagementContract/ManagementContract.go b/contracts/generated/ManagementContract/ManagementContract.go index ff0a490231..c74b748a1b 100644 --- a/contracts/generated/ManagementContract/ManagementContract.go +++ b/contracts/generated/ManagementContract/ManagementContract.go @@ -53,8 +53,8 @@ type StructsMetaRollup struct { // ManagementContractMetaData contains all meta data concerning the ManagementContract contract. var ManagementContractMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"key\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAddress\",\"type\":\"address\"}],\"name\":\"ImportantContractAddressUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"messageBusAddress\",\"type\":\"address\"}],\"name\":\"LogManagementContractCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"Hash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"AggregatorID\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"LastSequenceNumber\",\"type\":\"uint256\"}],\"internalType\":\"structStructs.MetaRollup\",\"name\":\"r\",\"type\":\"tuple\"},{\"internalType\":\"string\",\"name\":\"_rollupData\",\"type\":\"string\"},{\"components\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"sequence\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"nonce\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"topic\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"payload\",\"type\":\"bytes\"},{\"internalType\":\"uint8\",\"name\":\"consistencyLevel\",\"type\":\"uint8\"}],\"internalType\":\"structStructs.CrossChainMessage[]\",\"name\":\"messages\",\"type\":\"tuple[]\"}],\"internalType\":\"structStructs.HeaderCrossChainData\",\"name\":\"crossChainData\",\"type\":\"tuple\"}],\"name\":\"AddRollup\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"Attested\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GetHostAddresses\",\"outputs\":[{\"internalType\":\"string[]\",\"name\":\"\",\"type\":\"string[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GetImportantContractKeys\",\"outputs\":[{\"internalType\":\"string[]\",\"name\":\"\",\"type\":\"string[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"rollupHash\",\"type\":\"bytes32\"}],\"name\":\"GetRollupByHash\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"Hash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"AggregatorID\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"LastSequenceNumber\",\"type\":\"uint256\"}],\"internalType\":\"structStructs.MetaRollup\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_aggregatorID\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_initSecret\",\"type\":\"bytes\"},{\"internalType\":\"string\",\"name\":\"_hostAddress\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_genesisAttestation\",\"type\":\"string\"}],\"name\":\"InitializeNetworkSecret\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"IsWithdrawalAvailable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"requestReport\",\"type\":\"string\"}],\"name\":\"RequestNetworkSecret\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"attesterID\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"requesterID\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"attesterSig\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"responseSecret\",\"type\":\"bytes\"},{\"internalType\":\"string\",\"name\":\"hostAddress\",\"type\":\"string\"},{\"internalType\":\"bool\",\"name\":\"verifyAttester\",\"type\":\"bool\"}],\"name\":\"RespondNetworkSecret\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"RetrieveAllBridgeFunds\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"key\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"newAddress\",\"type\":\"address\"}],\"name\":\"SetImportantContractAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"name\":\"importantContractAddresses\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"importantContractKeys\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lastBatchSeqNo\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"messageBus\",\"outputs\":[{\"internalType\":\"contractIMessageBus\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x6080604052600060075534801561001557600080fd5b5061001f3361009f565b60405161002b906100ef565b604051809103906000f080158015610047573d6000803e3d6000fd5b50600980546001600160a01b0319166001600160a01b039290921691821790556040519081527fbd726cf82ac9c3260b1495107182e336e0654b25c10915648c0cc15b2bb72cbf9060200160405180910390a16100fd565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b61121d8062001d4583390190565b611c38806200010d6000396000f3fe608060405234801561001057600080fd5b50600436106101365760003560e01c80638236a7ba116100b2578063a1a227fa11610081578063bbd79e1511610066578063bbd79e151461033a578063e34fbfc81461034d578063f2fde38b1461036057600080fd5b8063a1a227fa14610317578063a52f433c1461032a57600080fd5b80638236a7ba146102385780638da5cb5b146102d35780638fa0d053146102e457806398077e86146102f757600080fd5b8063440c953b116101095780636a30d26c116100ee5780636a30d26c14610220578063715018a614610228578063728109961461023057600080fd5b8063440c953b146101f657806359a900711461020d57600080fd5b806303e72e481461013b578063324ff866146101505780633e60a22f1461016e57806343348b2f146101ba575b600080fd5b61014e6101493660046113fa565b610373565b005b6101586104da565b60405161016591906114a4565b60405180910390f35b6101a261017c366004611506565b80516020818301810180516005825292820191909301209152546001600160a01b031681565b6040516001600160a01b039091168152602001610165565b6101e66101c836600461153b565b6001600160a01b031660009081526002602052604090205460ff1690565b6040519015158152602001610165565b6101ff60075481565b604051908152602001610165565b61014e61021b3660046115a1565b6105b3565b61015861063d565b61014e61070d565b61014e610773565b6102a0610246366004611648565b6040805160608082018352600080835260208084018290529284018190528481526008835283902083519182018452805480835260018201546001600160a01b031693830193909352600201549281019290925290911491565b60408051921515835281516020808501919091528201516001600160a01b03168382015201516060820152608001610165565b6000546001600160a01b03166101a2565b61014e6102f2366004611661565b610845565b61030a610305366004611648565b6108d4565b60405161016591906116e8565b6009546101a2906001600160a01b031681565b600654610100900460ff166101e6565b61014e6103483660046116fb565b610980565b61014e61035b3660046117c1565b610ae5565b61014e61036e36600461153b565b610b04565b6000546001600160a01b031633146103d25760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b60006001600160a01b03166005836040516103ed9190611803565b908152604051908190036020019020546001600160a01b031614156104515760048054600181018255600091909152825161044f917f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b01906020850190611235565b505b806005836040516104629190611803565b90815260405190819003602001812080546001600160a01b039390931673ffffffffffffffffffffffffffffffffffffffff19909316929092179091557f17b2f9f5748931099ffee882b5b64f4a560b5c55da9b4f4e396dae3bb9f98cb5906104ce908490849061181f565b60405180910390a15050565b60606003805480602002602001604051908101604052809291908181526020016000905b828210156105aa57838290600052602060002001805461051d9061184a565b80601f01602080910402602001604051908101604052809291908181526020018280546105499061184a565b80156105965780601f1061056b57610100808354040283529160200191610596565b820191906000526020600020905b81548152906001019060200180831161057957829003601f168201915b5050505050815260200190600101906104fe565b50505050905090565b60065460ff16156105c357600080fd5b60068054600160ff1991821681179092556001600160a01b038816600090815260026020908152604082208054909316841790925560038054938401815590528451610634927fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0191860190611235565b50505050505050565b60606004805480602002602001604051908101604052809291908181526020016000905b828210156105aa5783829060005260206000200180546106809061184a565b80601f01602080910402602001604051908101604052809291908181526020018280546106ac9061184a565b80156106f95780601f106106ce576101008083540402835291602001916106f9565b820191906000526020600020905b8154815290600101906020018083116106dc57829003601f168201915b505050505081526020019060010190610661565b6000546001600160a01b031633146107675760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103c9565b6107716000610be6565b565b6000546001600160a01b031633146107cd5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103c9565b6009546040517f36d2da900000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03909116906336d2da9090602401600060405180830381600087803b15801561082b57600080fd5b505af115801561083f573d6000803e3d6000fd5b50505050565b60026000610859604087016020880161153b565b6001600160a01b0316815260208101919091526040016000205460ff166108c25760405162461bcd60e51b815260206004820152601760248201527f61676772656761746f72206e6f7420617474657374656400000000000000000060448201526064016103c9565b6108cb84610c43565b61083f81610c78565b600481815481106108e457600080fd5b9060005260206000200160009150905080546108ff9061184a565b80601f016020809104026020016040519081016040528092919081815260200182805461092b9061184a565b80156109785780601f1061094d57610100808354040283529160200191610978565b820191906000526020600020905b81548152906001019060200180831161095b57829003601f168201915b505050505081565b6001600160a01b03861660009081526002602052604090205460ff16806109a657600080fd5b8115610a765760006109dc888886886040516020016109c89493929190611885565b604051602081830303815290604052610d32565b905060006109ea8288610d6d565b9050886001600160a01b0316816001600160a01b031614610a735760405162461bcd60e51b815260206004820152602c60248201527f63616c63756c61746564206164647265737320616e642061747465737465724960448201527f4420646f6e74206d61746368000000000000000000000000000000000000000060648201526084016103c9565b50505b6001600160a01b03861660009081526002602090815260408220805460ff191660019081179091556003805491820181559092528451610adb927fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0191860190611235565b5050505050505050565b336000908152600160205260409020610aff9083836112b9565b505050565b6000546001600160a01b03163314610b5e5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103c9565b6001600160a01b038116610bda5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103c9565b610be381610be6565b50565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b803560009081526008602052604090208190610c5f82826118e1565b505060075460408201351115610be35760400135600755565b6000610c84828061192d565b9050905060005b81811015610aff576009546001600160a01b0316639730886d610cae858061192d565b84818110610cbe57610cbe611977565b9050602002810190610cd0919061198d565b60016040518363ffffffff1660e01b8152600401610cef929190611a3c565b600060405180830381600087803b158015610d0957600080fd5b505af1158015610d1d573d6000803e3d6000fd5b5050505080610d2b90611b09565b9050610c8b565b6000610d3e8251610d91565b82604051602001610d50929190611b24565b604051602081830303815290604052805190602001209050919050565b6000806000610d7c8585610ecb565b91509150610d8981610f3b565b509392505050565b606081610dd157505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115610dfb5780610de581611b09565b9150610df49050600a83611b95565b9150610dd5565b60008167ffffffffffffffff811115610e1657610e16611342565b6040519080825280601f01601f191660200182016040528015610e40576020820181803683370190505b5090505b8415610ec357610e55600183611ba9565b9150610e62600a86611bc0565b610e6d906030611bd4565b60f81b818381518110610e8257610e82611977565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350610ebc600a86611b95565b9450610e44565b949350505050565b600080825160411415610f025760208301516040840151606085015160001a610ef6878285856110f6565b94509450505050610f34565b825160401415610f2c5760208301516040840151610f218683836111e3565b935093505050610f34565b506000905060025b9250929050565b6000816004811115610f4f57610f4f611bec565b1415610f585750565b6001816004811115610f6c57610f6c611bec565b1415610fba5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016103c9565b6002816004811115610fce57610fce611bec565b141561101c5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016103c9565b600381600481111561103057611030611bec565b14156110895760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016103c9565b600481600481111561109d5761109d611bec565b1415610be35760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b60648201526084016103c9565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561112d57506000905060036111da565b8460ff16601b1415801561114557508460ff16601c14155b1561115657506000905060046111da565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156111aa573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166111d3576000600192509250506111da565b9150600090505b94509492505050565b6000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83168161121960ff86901c601b611bd4565b9050611227878288856110f6565b935093505050935093915050565b8280546112419061184a565b90600052602060002090601f01602090048101928261126357600085556112a9565b82601f1061127c57805160ff19168380011785556112a9565b828001600101855582156112a9579182015b828111156112a957825182559160200191906001019061128e565b506112b592915061132d565b5090565b8280546112c59061184a565b90600052602060002090601f0160209004810192826112e757600085556112a9565b82601f106113005782800160ff198235161785556112a9565b828001600101855582156112a9579182015b828111156112a9578235825591602001919060010190611312565b5b808211156112b5576000815560010161132e565b634e487b7160e01b600052604160045260246000fd5b600082601f83011261136957600080fd5b813567ffffffffffffffff8082111561138457611384611342565b604051601f8301601f19908116603f011681019082821181831017156113ac576113ac611342565b816040528381528660208588010111156113c557600080fd5b836020870160208301376000602085830101528094505050505092915050565b6001600160a01b0381168114610be357600080fd5b6000806040838503121561140d57600080fd5b823567ffffffffffffffff81111561142457600080fd5b61143085828601611358565b9250506020830135611441816113e5565b809150509250929050565b60005b8381101561146757818101518382015260200161144f565b8381111561083f5750506000910152565b6000815180845261149081602086016020860161144c565b601f01601f19169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b828110156114f957603f198886030184526114e7858351611478565b945092850192908501906001016114cb565b5092979650505050505050565b60006020828403121561151857600080fd5b813567ffffffffffffffff81111561152f57600080fd5b610ec384828501611358565b60006020828403121561154d57600080fd5b8135611558816113e5565b9392505050565b60008083601f84011261157157600080fd5b50813567ffffffffffffffff81111561158957600080fd5b602083019150836020828501011115610f3457600080fd5b600080600080600080608087890312156115ba57600080fd5b86356115c5816113e5565b9550602087013567ffffffffffffffff808211156115e257600080fd5b6115ee8a838b0161155f565b9097509550604089013591508082111561160757600080fd5b6116138a838b01611358565b9450606089013591508082111561162957600080fd5b5061163689828a0161155f565b979a9699509497509295939492505050565b60006020828403121561165a57600080fd5b5035919050565b60008060008084860360a081121561167857600080fd5b606081121561168657600080fd5b50849350606085013567ffffffffffffffff808211156116a557600080fd5b6116b18883890161155f565b909550935060808701359150808211156116ca57600080fd5b508501602081880312156116dd57600080fd5b939692955090935050565b6020815260006115586020830184611478565b60008060008060008060c0878903121561171457600080fd5b863561171f816113e5565b9550602087013561172f816113e5565b9450604087013567ffffffffffffffff8082111561174c57600080fd5b6117588a838b01611358565b9550606089013591508082111561176e57600080fd5b61177a8a838b01611358565b9450608089013591508082111561179057600080fd5b5061179d89828a01611358565b92505060a087013580151581146117b357600080fd5b809150509295509295509295565b600080602083850312156117d457600080fd5b823567ffffffffffffffff8111156117eb57600080fd5b6117f78582860161155f565b90969095509350505050565b6000825161181581846020870161144c565b9190910192915050565b6040815260006118326040830185611478565b90506001600160a01b03831660208301529392505050565b600181811c9082168061185e57607f821691505b6020821081141561187f57634e487b7160e01b600052602260045260246000fd5b50919050565b60006bffffffffffffffffffffffff19808760601b168352808660601b1660148401525083516118bc81602885016020880161144c565b8351908301906118d381602884016020880161144c565b016028019695505050505050565b813581556001810160208301356118f7816113e5565b6001600160a01b03811673ffffffffffffffffffffffffffffffffffffffff198354161782555050604082013560028201555050565b6000808335601e1984360301811261194457600080fd5b83018035915067ffffffffffffffff82111561195f57600080fd5b6020019150600581901b3603821315610f3457600080fd5b634e487b7160e01b600052603260045260246000fd5b6000823560be1983360301811261181557600080fd5b803563ffffffff811681146119b757600080fd5b919050565b6000808335601e198436030181126119d357600080fd5b830160208101925035905067ffffffffffffffff8111156119f357600080fd5b803603831315610f3457600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b803560ff811681146119b757600080fd5b6040815260008335611a4d816113e5565b6001600160a01b03166040830152602084013567ffffffffffffffff8116808214611a7757600080fd5b606084015250611a89604085016119a3565b63ffffffff166080830152611aa0606085016119a3565b63ffffffff1660a0830152611ab860808501856119bc565b60c080850152611acd61010085018284611a02565b915050611adc60a08601611a2b565b60ff1660e084015260209092019290925292915050565b634e487b7160e01b600052601160045260246000fd5b6000600019821415611b1d57611b1d611af3565b5060010190565b7f19457468657265756d205369676e6564204d6573736167653a0a000000000000815260008351611b5c81601a85016020880161144c565b835190830190611b7381601a84016020880161144c565b01601a01949350505050565b634e487b7160e01b600052601260045260246000fd5b600082611ba457611ba4611b7f565b500490565b600082821015611bbb57611bbb611af3565b500390565b600082611bcf57611bcf611b7f565b500690565b60008219821115611be757611be7611af3565b500190565b634e487b7160e01b600052602160045260246000fdfea2646970667358221220941db3413f38d3a6628646ec43968a2fe657e553082ef52e5e2986c8c7c4ce1c64736f6c63430008090033608060405234801561001057600080fd5b5061001a3361001f565b61006f565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b61119f8061007e6000396000f3fe6080604052600436106100b55760003560e01c80638da5cb5b1161006957806399a3ad211161004e57806399a3ad2114610270578063b1454caa14610290578063f2fde38b146102c95761012e565b80638da5cb5b146102285780639730886d146102505761012e565b8063346633fb1161009a578063346633fb146101de57806336d2da90146101f3578063715018a6146102135761012e565b80630fcfbd111461017b57806333a88c72146101ae5761012e565b3661012e576040517f346633fb0000000000000000000000000000000000000000000000000000000081523360048201523460248201819052309163346633fb91906044016000604051808303818588803b15801561011357600080fd5b505af1158015610127573d6000803e3d6000fd5b5050505050005b60405162461bcd60e51b815260206004820152600b60248201527f756e737570706f7274656400000000000000000000000000000000000000000060448201526064015b60405180910390fd5b34801561018757600080fd5b5061019b610196366004610ad9565b6102e9565b6040519081526020015b60405180910390f35b3480156101ba57600080fd5b506101ce6101c9366004610ad9565b61039f565b60405190151581526020016101a5565b6101f16101ec366004610b23565b6103f2565b005b3480156101ff57600080fd5b506101f161020e366004610b4f565b6104be565b34801561021f57600080fd5b506101f16105bf565b34801561023457600080fd5b506000546040516001600160a01b0390911681526020016101a5565b34801561025c57600080fd5b506101f161026b366004610b6c565b610625565b34801561027c57600080fd5b506101f161028b366004610b23565b6107c9565b34801561029c57600080fd5b506102b06102ab366004610be2565b6108cb565b60405167ffffffffffffffff90911681526020016101a5565b3480156102d557600080fd5b506101f16102e4366004610b4f565b610924565b600080826040516020016102fd9190610cce565b60408051601f19818403018152918152815160209283012060008181526001909352912054909150806103985760405162461bcd60e51b815260206004820152602160248201527f54686973206d65737361676520776173206e65766572207375626d697474656460448201527f2e000000000000000000000000000000000000000000000000000000000000006064820152608401610172565b9392505050565b600080826040516020016103b39190610cce565b60408051601f1981840301815291815281516020928301206000818152600190935291205490915080158015906103ea5750428111155b949350505050565b60003411801561040157508034145b6104735760405162461bcd60e51b815260206004820152603060248201527f417474656d7074696e6720746f2073656e642076616c756520776974686f757460448201527f2070726f766964696e67204574686572000000000000000000000000000000006064820152608401610172565b604080513381526001600160a01b0384166020820152348183015290517ff1365f826a788d6c1a955db0eed5ba8642674219c4771f8c65918617511a15609181900360600190a15050565b6000546001600160a01b031633146105185760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610172565b6000816001600160a01b03164760405160006040518083038185875af1925050503d8060008114610565576040519150601f19603f3d011682016040523d82523d6000602084013e61056a565b606091505b50509050806105bb5760405162461bcd60e51b815260206004820152601460248201527f6661696c65642073656e64696e672076616c75650000000000000000000000006044820152606401610172565b5050565b6000546001600160a01b031633146106195760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610172565b6106236000610a06565b565b6000546001600160a01b0316331461067f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610172565b600061068b8242610dce565b90506000836040516020016106a09190610cce565b60408051601f198184030181529181528151602092830120600081815260019093529120549091501561073b5760405162461bcd60e51b815260206004820152602160248201527f4d657373616765207375626d6974746564206d6f7265207468616e206f6e636560448201527f21000000000000000000000000000000000000000000000000000000000000006064820152608401610172565b600081815260016020908152604082208490556002919061075e90870187610b4f565b6001600160a01b03168152602081019190915260400160009081209061078a6080870160608801610de6565b63ffffffff168152602080820192909252604001600090812080546001810182559082529190208591600402016107c18282610fc3565b505050505050565b6000546001600160a01b031633146108235760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610172565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610870576040519150601f19603f3d011682016040523d82523d6000602084013e610875565b606091505b50509050806108c65760405162461bcd60e51b815260206004820152601460248201527f6661696c65642073656e64696e672076616c75650000000000000000000000006044820152606401610172565b505050565b60006108d633610a63565b90507fb93c37389233beb85a3a726c3f15c2d15533ee74cb602f20f490dfffef7759373382888888888860405161091397969594939291906110dd565b60405180910390a195945050505050565b6000546001600160a01b0316331461097e5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610172565b6001600160a01b0381166109fa5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610172565b610a0381610a06565b50565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b0381166000908152600360205260408120805467ffffffffffffffff169160019190610a96838561113d565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550919050565b600060c08284031215610ad357600080fd5b50919050565b600060208284031215610aeb57600080fd5b813567ffffffffffffffff811115610b0257600080fd5b6103ea84828501610ac1565b6001600160a01b0381168114610a0357600080fd5b60008060408385031215610b3657600080fd5b8235610b4181610b0e565b946020939093013593505050565b600060208284031215610b6157600080fd5b813561039881610b0e565b60008060408385031215610b7f57600080fd5b823567ffffffffffffffff811115610b9657600080fd5b610ba285828601610ac1565b95602094909401359450505050565b63ffffffff81168114610a0357600080fd5b60ff81168114610a0357600080fd5b8035610bdd81610bc3565b919050565b600080600080600060808688031215610bfa57600080fd5b8535610c0581610bb1565b94506020860135610c1581610bb1565b9350604086013567ffffffffffffffff80821115610c3257600080fd5b818801915088601f830112610c4657600080fd5b813581811115610c5557600080fd5b896020828501011115610c6757600080fd5b6020830195508094505050506060860135610c8181610bc3565b809150509295509295909350565b67ffffffffffffffff81168114610a0357600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6020815260008235610cdf81610b0e565b6001600160a01b0381166020840152506020830135610cfd81610c8f565b67ffffffffffffffff808216604085015260408501359150610d1e82610bb1565b63ffffffff808316606086015260608601359250610d3b83610bb1565b80831660808601525060808501359150601e19853603018212610d5d57600080fd5b90840190813581811115610d7057600080fd5b803603861315610d7f57600080fd5b60c060a0860152610d9760e086018260208601610ca5565b92505050610da760a08501610bd2565b60ff811660c0850152509392505050565b634e487b7160e01b600052601160045260246000fd5b60008219821115610de157610de1610db8565b500190565b600060208284031215610df857600080fd5b813561039881610bb1565b60008135610e1081610bb1565b92915050565b6000808335601e19843603018112610e2d57600080fd5b83018035915067ffffffffffffffff821115610e4857600080fd5b602001915036819003821315610e5d57600080fd5b9250929050565b634e487b7160e01b600052604160045260246000fd5b600181811c90821680610e8e57607f821691505b60208210811415610ad357634e487b7160e01b600052602260045260246000fd5b601f8211156108c657600081815260208120601f850160051c81016020861015610ed65750805b601f850160051c820191505b818110156107c157828155600101610ee2565b67ffffffffffffffff831115610f0d57610f0d610e64565b610f2183610f1b8354610e7a565b83610eaf565b6000601f841160018114610f555760008515610f3d5750838201355b600019600387901b1c1916600186901b178355610faf565b600083815260209020601f19861690835b82811015610f865786850135825560209485019460019092019101610f66565b5086821015610fa35760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b60008135610e1081610bc3565b8135610fce81610b0e565b6001600160a01b038116905081548173ffffffffffffffffffffffffffffffffffffffff198216178355602084013561100681610c8f565b7bffffffffffffffff00000000000000000000000000000000000000008160a01b1690507fffffffff000000000000000000000000000000000000000000000000000000008184828516171785556040860135925061106483610bb1565b921760e09190911b90911617815561109c61108160608401610e03565b6001830163ffffffff821663ffffffff198254161781555050565b6110a96080830183610e16565b6110b7818360028601610ef5565b50506105bb6110c860a08401610fb6565b6003830160ff821660ff198254161781555050565b6001600160a01b038816815267ffffffffffffffff87166020820152600063ffffffff808816604084015280871660608401525060c0608083015261112660c083018587610ca5565b905060ff831660a083015298975050505050505050565b600067ffffffffffffffff80831681851680830382111561116057611160610db8565b0194935050505056fea2646970667358221220a54aad59b2972196a793838aab3ac603764d8f10f53f8b069358ac232fba77fe64736f6c63430008090033", + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"string\",\"name\":\"key\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newAddress\",\"type\":\"address\"}],\"name\":\"ImportantContractAddressUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"messageBusAddress\",\"type\":\"address\"}],\"name\":\"LogManagementContractCreated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"Hash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"AggregatorID\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"LastSequenceNumber\",\"type\":\"uint256\"}],\"internalType\":\"structStructs.MetaRollup\",\"name\":\"r\",\"type\":\"tuple\"},{\"internalType\":\"string\",\"name\":\"_rollupData\",\"type\":\"string\"},{\"components\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"sequence\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"nonce\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"topic\",\"type\":\"uint32\"},{\"internalType\":\"bytes\",\"name\":\"payload\",\"type\":\"bytes\"},{\"internalType\":\"uint8\",\"name\":\"consistencyLevel\",\"type\":\"uint8\"}],\"internalType\":\"structStructs.CrossChainMessage[]\",\"name\":\"messages\",\"type\":\"tuple[]\"}],\"internalType\":\"structStructs.HeaderCrossChainData\",\"name\":\"crossChainData\",\"type\":\"tuple\"}],\"name\":\"AddRollup\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_addr\",\"type\":\"address\"}],\"name\":\"Attested\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GetHostAddresses\",\"outputs\":[{\"internalType\":\"string[]\",\"name\":\"\",\"type\":\"string[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"GetImportantContractKeys\",\"outputs\":[{\"internalType\":\"string[]\",\"name\":\"\",\"type\":\"string[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"rollupHash\",\"type\":\"bytes32\"}],\"name\":\"GetRollupByHash\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"Hash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"AggregatorID\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"LastSequenceNumber\",\"type\":\"uint256\"}],\"internalType\":\"structStructs.MetaRollup\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_aggregatorID\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_initSecret\",\"type\":\"bytes\"},{\"internalType\":\"string\",\"name\":\"_hostAddress\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_genesisAttestation\",\"type\":\"string\"}],\"name\":\"InitializeNetworkSecret\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"IsWithdrawalAvailable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"requestReport\",\"type\":\"string\"}],\"name\":\"RequestNetworkSecret\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"attesterID\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"requesterID\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"attesterSig\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"responseSecret\",\"type\":\"bytes\"},{\"internalType\":\"string\",\"name\":\"hostAddress\",\"type\":\"string\"},{\"internalType\":\"bool\",\"name\":\"verifyAttester\",\"type\":\"bool\"}],\"name\":\"RespondNetworkSecret\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"RetrieveAllBridgeFunds\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"key\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"newAddress\",\"type\":\"address\"}],\"name\":\"SetImportantContractAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"name\":\"importantContractAddresses\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"importantContractKeys\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"lastBatchSeqNo\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"messageBus\",\"outputs\":[{\"internalType\":\"contractIMessageBus\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x608060405234801561001057600080fd5b5061001a3361001f565b61006f565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b61303d8061007e6000396000f3fe608060405234801561001057600080fd5b50600436106101515760003560e01c80638129fc1c116100cd578063a1a227fa11610081578063bbd79e1511610066578063bbd79e151461035d578063e34fbfc814610370578063f2fde38b1461038357600080fd5b8063a1a227fa1461033a578063a52f433c1461034d57600080fd5b80638da5cb5b116100b25780638da5cb5b146102f65780638fa0d0531461030757806398077e861461031a57600080fd5b80638129fc1c146102535780638236a7ba1461025b57600080fd5b8063440c953b116101245780636a30d26c116101095780636a30d26c1461023b578063715018a614610243578063728109961461024b57600080fd5b8063440c953b1461021157806359a900711461022857600080fd5b806303e72e4814610156578063324ff8661461016b5780633e60a22f1461018957806343348b2f146101d5575b600080fd5b6101696101643660046115e2565b610396565b005b6101736104fd565b604051610180919061168c565b60405180910390f35b6101bd6101973660046116ee565b80516020818301810180516005825292820191909301209152546001600160a01b031681565b6040516001600160a01b039091168152602001610180565b6102016101e3366004611723565b6001600160a01b031660009081526002602052604090205460ff1690565b6040519015158152602001610180565b61021a60075481565b604051908152602001610180565b610169610236366004611789565b6105d6565b610173610660565b610169610730565b610169610796565b610169610868565b6102c3610269366004611830565b6040805160608082018352600080835260208084018290529284018190528481526008835283902083519182018452805480835260018201546001600160a01b031693830193909352600201549281019290925290911491565b60408051921515835281516020808501919091528201516001600160a01b03168382015201516060820152608001610180565b6000546001600160a01b03166101bd565b610169610315366004611849565b610a27565b61032d610328366004611830565b610ab6565b60405161018091906118d0565b6009546101bd906001600160a01b031681565b600654610100900460ff16610201565b61016961036b3660046118e3565b610b62565b61016961037e3660046119a9565b610cc7565b610169610391366004611723565b610ce6565b6000546001600160a01b031633146103f55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b60006001600160a01b031660058360405161041091906119eb565b908152604051908190036020019020546001600160a01b0316141561047457600480546001810182556000919091528251610472917f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b01906020850190611410565b505b8060058360405161048591906119eb565b90815260405190819003602001812080546001600160a01b039390931673ffffffffffffffffffffffffffffffffffffffff19909316929092179091557f17b2f9f5748931099ffee882b5b64f4a560b5c55da9b4f4e396dae3bb9f98cb5906104f19084908490611a07565b60405180910390a15050565b60606003805480602002602001604051908101604052809291908181526020016000905b828210156105cd57838290600052602060002001805461054090611a32565b80601f016020809104026020016040519081016040528092919081815260200182805461056c90611a32565b80156105b95780601f1061058e576101008083540402835291602001916105b9565b820191906000526020600020905b81548152906001019060200180831161059c57829003601f168201915b505050505081526020019060010190610521565b50505050905090565b60065460ff16156105e657600080fd5b60068054600160ff1991821681179092556001600160a01b038816600090815260026020908152604082208054909316841790925560038054938401815590528451610657927fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0191860190611410565b50505050505050565b60606004805480602002602001604051908101604052809291908181526020016000905b828210156105cd5783829060005260206000200180546106a390611a32565b80601f01602080910402602001604051908101604052809291908181526020018280546106cf90611a32565b801561071c5780601f106106f15761010080835404028352916020019161071c565b820191906000526020600020905b8154815290600101906020018083116106ff57829003601f168201915b505050505081526020019060010190610684565b6000546001600160a01b0316331461078a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103ec565b6107946000610dc1565b565b6000546001600160a01b031633146107f05760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103ec565b6009546040517f36d2da900000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03909116906336d2da9090602401600060405180830381600087803b15801561084e57600080fd5b505af1158015610862573d6000803e3d6000fd5b50505050565b600054600160a81b900460ff1661089d5760005474010000000000000000000000000000000000000000900460ff16156108a1565b303b155b6109135760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016103ec565b600054600160a81b900460ff1615801561096857600080547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff1675010100000000000000000000000000000000000000001790555b600060075560405161097990611494565b604051809103906000f080158015610995573d6000803e3d6000fd5b506009805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b039290921691821790556040519081527fbd726cf82ac9c3260b1495107182e336e0654b25c10915648c0cc15b2bb72cbf9060200160405180910390a18015610a2457600080547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff1690555b50565b60026000610a3b6040870160208801611723565b6001600160a01b0316815260208101919091526040016000205460ff16610aa45760405162461bcd60e51b815260206004820152601760248201527f61676772656761746f72206e6f7420617474657374656400000000000000000060448201526064016103ec565b610aad84610e1e565b61086281610e53565b60048181548110610ac657600080fd5b906000526020600020016000915090508054610ae190611a32565b80601f0160208091040260200160405190810160405280929190818152602001828054610b0d90611a32565b8015610b5a5780601f10610b2f57610100808354040283529160200191610b5a565b820191906000526020600020905b815481529060010190602001808311610b3d57829003601f168201915b505050505081565b6001600160a01b03861660009081526002602052604090205460ff1680610b8857600080fd5b8115610c58576000610bbe88888688604051602001610baa9493929190611a6d565b604051602081830303815290604052610f0d565b90506000610bcc8288610f48565b9050886001600160a01b0316816001600160a01b031614610c555760405162461bcd60e51b815260206004820152602c60248201527f63616c63756c61746564206164647265737320616e642061747465737465724960448201527f4420646f6e74206d61746368000000000000000000000000000000000000000060648201526084016103ec565b50505b6001600160a01b03861660009081526002602090815260408220805460ff191660019081179091556003805491820181559092528451610cbd927fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0191860190611410565b5050505050505050565b336000908152600160205260409020610ce19083836114a1565b505050565b6000546001600160a01b03163314610d405760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103ec565b6001600160a01b038116610dbc5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016103ec565b610a24815b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b803560009081526008602052604090208190610e3a8282611ac9565b505060075460408201351115610a245760400135600755565b6000610e5f8280611b15565b9050905060005b81811015610ce1576009546001600160a01b0316639730886d610e898580611b15565b84818110610e9957610e99611b5f565b9050602002810190610eab9190611b75565b60016040518363ffffffff1660e01b8152600401610eca929190611c24565b600060405180830381600087803b158015610ee457600080fd5b505af1158015610ef8573d6000803e3d6000fd5b5050505080610f0690611cf1565b9050610e66565b6000610f198251610f6c565b82604051602001610f2b929190611d0c565b604051602081830303815290604052805190602001209050919050565b6000806000610f5785856110a6565b91509150610f6481611116565b509392505050565b606081610fac57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115610fd65780610fc081611cf1565b9150610fcf9050600a83611d7d565b9150610fb0565b60008167ffffffffffffffff811115610ff157610ff161152a565b6040519080825280601f01601f19166020018201604052801561101b576020820181803683370190505b5090505b841561109e57611030600183611d91565b915061103d600a86611da8565b611048906030611dbc565b60f81b81838151811061105d5761105d611b5f565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350611097600a86611d7d565b945061101f565b949350505050565b6000808251604114156110dd5760208301516040840151606085015160001a6110d1878285856112d1565b9450945050505061110f565b82516040141561110757602083015160408401516110fc8683836113be565b93509350505061110f565b506000905060025b9250929050565b600081600481111561112a5761112a611dd4565b14156111335750565b600181600481111561114757611147611dd4565b14156111955760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016103ec565b60028160048111156111a9576111a9611dd4565b14156111f75760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016103ec565b600381600481111561120b5761120b611dd4565b14156112645760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016103ec565b600481600481111561127857611278611dd4565b1415610a245760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b60648201526084016103ec565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561130857506000905060036113b5565b8460ff16601b1415801561132057508460ff16601c14155b1561133157506000905060046113b5565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611385573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166113ae576000600192509250506113b5565b9150600090505b94509492505050565b6000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8316816113f460ff86901c601b611dbc565b9050611402878288856112d1565b935093505050935093915050565b82805461141c90611a32565b90600052602060002090601f01602090048101928261143e5760008555611484565b82601f1061145757805160ff1916838001178555611484565b82800160010185558215611484579182015b82811115611484578251825591602001919060010190611469565b50611490929150611515565b5090565b61121d80611deb83390190565b8280546114ad90611a32565b90600052602060002090601f0160209004810192826114cf5760008555611484565b82601f106114e85782800160ff19823516178555611484565b82800160010185558215611484579182015b828111156114845782358255916020019190600101906114fa565b5b808211156114905760008155600101611516565b634e487b7160e01b600052604160045260246000fd5b600082601f83011261155157600080fd5b813567ffffffffffffffff8082111561156c5761156c61152a565b604051601f8301601f19908116603f011681019082821181831017156115945761159461152a565b816040528381528660208588010111156115ad57600080fd5b836020870160208301376000602085830101528094505050505092915050565b6001600160a01b0381168114610a2457600080fd5b600080604083850312156115f557600080fd5b823567ffffffffffffffff81111561160c57600080fd5b61161885828601611540565b9250506020830135611629816115cd565b809150509250929050565b60005b8381101561164f578181015183820152602001611637565b838111156108625750506000910152565b60008151808452611678816020860160208601611634565b601f01601f19169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b828110156116e157603f198886030184526116cf858351611660565b945092850192908501906001016116b3565b5092979650505050505050565b60006020828403121561170057600080fd5b813567ffffffffffffffff81111561171757600080fd5b61109e84828501611540565b60006020828403121561173557600080fd5b8135611740816115cd565b9392505050565b60008083601f84011261175957600080fd5b50813567ffffffffffffffff81111561177157600080fd5b60208301915083602082850101111561110f57600080fd5b600080600080600080608087890312156117a257600080fd5b86356117ad816115cd565b9550602087013567ffffffffffffffff808211156117ca57600080fd5b6117d68a838b01611747565b909750955060408901359150808211156117ef57600080fd5b6117fb8a838b01611540565b9450606089013591508082111561181157600080fd5b5061181e89828a01611747565b979a9699509497509295939492505050565b60006020828403121561184257600080fd5b5035919050565b60008060008084860360a081121561186057600080fd5b606081121561186e57600080fd5b50849350606085013567ffffffffffffffff8082111561188d57600080fd5b61189988838901611747565b909550935060808701359150808211156118b257600080fd5b508501602081880312156118c557600080fd5b939692955090935050565b6020815260006117406020830184611660565b60008060008060008060c087890312156118fc57600080fd5b8635611907816115cd565b95506020870135611917816115cd565b9450604087013567ffffffffffffffff8082111561193457600080fd5b6119408a838b01611540565b9550606089013591508082111561195657600080fd5b6119628a838b01611540565b9450608089013591508082111561197857600080fd5b5061198589828a01611540565b92505060a0870135801515811461199b57600080fd5b809150509295509295509295565b600080602083850312156119bc57600080fd5b823567ffffffffffffffff8111156119d357600080fd5b6119df85828601611747565b90969095509350505050565b600082516119fd818460208701611634565b9190910192915050565b604081526000611a1a6040830185611660565b90506001600160a01b03831660208301529392505050565b600181811c90821680611a4657607f821691505b60208210811415611a6757634e487b7160e01b600052602260045260246000fd5b50919050565b60006bffffffffffffffffffffffff19808760601b168352808660601b166014840152508351611aa4816028850160208801611634565b835190830190611abb816028840160208801611634565b016028019695505050505050565b81358155600181016020830135611adf816115cd565b6001600160a01b03811673ffffffffffffffffffffffffffffffffffffffff198354161782555050604082013560028201555050565b6000808335601e19843603018112611b2c57600080fd5b83018035915067ffffffffffffffff821115611b4757600080fd5b6020019150600581901b360382131561110f57600080fd5b634e487b7160e01b600052603260045260246000fd5b6000823560be198336030181126119fd57600080fd5b803563ffffffff81168114611b9f57600080fd5b919050565b6000808335601e19843603018112611bbb57600080fd5b830160208101925035905067ffffffffffffffff811115611bdb57600080fd5b80360383131561110f57600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b803560ff81168114611b9f57600080fd5b6040815260008335611c35816115cd565b6001600160a01b03166040830152602084013567ffffffffffffffff8116808214611c5f57600080fd5b606084015250611c7160408501611b8b565b63ffffffff166080830152611c8860608501611b8b565b63ffffffff1660a0830152611ca06080850185611ba4565b60c080850152611cb561010085018284611bea565b915050611cc460a08601611c13565b60ff1660e084015260209092019290925292915050565b634e487b7160e01b600052601160045260246000fd5b6000600019821415611d0557611d05611cdb565b5060010190565b7f19457468657265756d205369676e6564204d6573736167653a0a000000000000815260008351611d4481601a850160208801611634565b835190830190611d5b81601a840160208801611634565b01601a01949350505050565b634e487b7160e01b600052601260045260246000fd5b600082611d8c57611d8c611d67565b500490565b600082821015611da357611da3611cdb565b500390565b600082611db757611db7611d67565b500690565b60008219821115611dcf57611dcf611cdb565b500190565b634e487b7160e01b600052602160045260246000fdfe608060405234801561001057600080fd5b5061001a3361001f565b61006f565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b61119f8061007e6000396000f3fe6080604052600436106100b55760003560e01c80638da5cb5b1161006957806399a3ad211161004e57806399a3ad2114610270578063b1454caa14610290578063f2fde38b146102c95761012e565b80638da5cb5b146102285780639730886d146102505761012e565b8063346633fb1161009a578063346633fb146101de57806336d2da90146101f3578063715018a6146102135761012e565b80630fcfbd111461017b57806333a88c72146101ae5761012e565b3661012e576040517f346633fb0000000000000000000000000000000000000000000000000000000081523360048201523460248201819052309163346633fb91906044016000604051808303818588803b15801561011357600080fd5b505af1158015610127573d6000803e3d6000fd5b5050505050005b60405162461bcd60e51b815260206004820152600b60248201527f756e737570706f7274656400000000000000000000000000000000000000000060448201526064015b60405180910390fd5b34801561018757600080fd5b5061019b610196366004610ad9565b6102e9565b6040519081526020015b60405180910390f35b3480156101ba57600080fd5b506101ce6101c9366004610ad9565b61039f565b60405190151581526020016101a5565b6101f16101ec366004610b23565b6103f2565b005b3480156101ff57600080fd5b506101f161020e366004610b4f565b6104be565b34801561021f57600080fd5b506101f16105bf565b34801561023457600080fd5b506000546040516001600160a01b0390911681526020016101a5565b34801561025c57600080fd5b506101f161026b366004610b6c565b610625565b34801561027c57600080fd5b506101f161028b366004610b23565b6107c9565b34801561029c57600080fd5b506102b06102ab366004610be2565b6108cb565b60405167ffffffffffffffff90911681526020016101a5565b3480156102d557600080fd5b506101f16102e4366004610b4f565b610924565b600080826040516020016102fd9190610cce565b60408051601f19818403018152918152815160209283012060008181526001909352912054909150806103985760405162461bcd60e51b815260206004820152602160248201527f54686973206d65737361676520776173206e65766572207375626d697474656460448201527f2e000000000000000000000000000000000000000000000000000000000000006064820152608401610172565b9392505050565b600080826040516020016103b39190610cce565b60408051601f1981840301815291815281516020928301206000818152600190935291205490915080158015906103ea5750428111155b949350505050565b60003411801561040157508034145b6104735760405162461bcd60e51b815260206004820152603060248201527f417474656d7074696e6720746f2073656e642076616c756520776974686f757460448201527f2070726f766964696e67204574686572000000000000000000000000000000006064820152608401610172565b604080513381526001600160a01b0384166020820152348183015290517ff1365f826a788d6c1a955db0eed5ba8642674219c4771f8c65918617511a15609181900360600190a15050565b6000546001600160a01b031633146105185760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610172565b6000816001600160a01b03164760405160006040518083038185875af1925050503d8060008114610565576040519150601f19603f3d011682016040523d82523d6000602084013e61056a565b606091505b50509050806105bb5760405162461bcd60e51b815260206004820152601460248201527f6661696c65642073656e64696e672076616c75650000000000000000000000006044820152606401610172565b5050565b6000546001600160a01b031633146106195760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610172565b6106236000610a06565b565b6000546001600160a01b0316331461067f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610172565b600061068b8242610dce565b90506000836040516020016106a09190610cce565b60408051601f198184030181529181528151602092830120600081815260019093529120549091501561073b5760405162461bcd60e51b815260206004820152602160248201527f4d657373616765207375626d6974746564206d6f7265207468616e206f6e636560448201527f21000000000000000000000000000000000000000000000000000000000000006064820152608401610172565b600081815260016020908152604082208490556002919061075e90870187610b4f565b6001600160a01b03168152602081019190915260400160009081209061078a6080870160608801610de6565b63ffffffff168152602080820192909252604001600090812080546001810182559082529190208591600402016107c18282610fc3565b505050505050565b6000546001600160a01b031633146108235760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610172565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610870576040519150601f19603f3d011682016040523d82523d6000602084013e610875565b606091505b50509050806108c65760405162461bcd60e51b815260206004820152601460248201527f6661696c65642073656e64696e672076616c75650000000000000000000000006044820152606401610172565b505050565b60006108d633610a63565b90507fb93c37389233beb85a3a726c3f15c2d15533ee74cb602f20f490dfffef7759373382888888888860405161091397969594939291906110dd565b60405180910390a195945050505050565b6000546001600160a01b0316331461097e5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610172565b6001600160a01b0381166109fa5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610172565b610a0381610a06565b50565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b0381166000908152600360205260408120805467ffffffffffffffff169160019190610a96838561113d565b92506101000a81548167ffffffffffffffff021916908367ffffffffffffffff160217905550919050565b600060c08284031215610ad357600080fd5b50919050565b600060208284031215610aeb57600080fd5b813567ffffffffffffffff811115610b0257600080fd5b6103ea84828501610ac1565b6001600160a01b0381168114610a0357600080fd5b60008060408385031215610b3657600080fd5b8235610b4181610b0e565b946020939093013593505050565b600060208284031215610b6157600080fd5b813561039881610b0e565b60008060408385031215610b7f57600080fd5b823567ffffffffffffffff811115610b9657600080fd5b610ba285828601610ac1565b95602094909401359450505050565b63ffffffff81168114610a0357600080fd5b60ff81168114610a0357600080fd5b8035610bdd81610bc3565b919050565b600080600080600060808688031215610bfa57600080fd5b8535610c0581610bb1565b94506020860135610c1581610bb1565b9350604086013567ffffffffffffffff80821115610c3257600080fd5b818801915088601f830112610c4657600080fd5b813581811115610c5557600080fd5b896020828501011115610c6757600080fd5b6020830195508094505050506060860135610c8181610bc3565b809150509295509295909350565b67ffffffffffffffff81168114610a0357600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6020815260008235610cdf81610b0e565b6001600160a01b0381166020840152506020830135610cfd81610c8f565b67ffffffffffffffff808216604085015260408501359150610d1e82610bb1565b63ffffffff808316606086015260608601359250610d3b83610bb1565b80831660808601525060808501359150601e19853603018212610d5d57600080fd5b90840190813581811115610d7057600080fd5b803603861315610d7f57600080fd5b60c060a0860152610d9760e086018260208601610ca5565b92505050610da760a08501610bd2565b60ff811660c0850152509392505050565b634e487b7160e01b600052601160045260246000fd5b60008219821115610de157610de1610db8565b500190565b600060208284031215610df857600080fd5b813561039881610bb1565b60008135610e1081610bb1565b92915050565b6000808335601e19843603018112610e2d57600080fd5b83018035915067ffffffffffffffff821115610e4857600080fd5b602001915036819003821315610e5d57600080fd5b9250929050565b634e487b7160e01b600052604160045260246000fd5b600181811c90821680610e8e57607f821691505b60208210811415610ad357634e487b7160e01b600052602260045260246000fd5b601f8211156108c657600081815260208120601f850160051c81016020861015610ed65750805b601f850160051c820191505b818110156107c157828155600101610ee2565b67ffffffffffffffff831115610f0d57610f0d610e64565b610f2183610f1b8354610e7a565b83610eaf565b6000601f841160018114610f555760008515610f3d5750838201355b600019600387901b1c1916600186901b178355610faf565b600083815260209020601f19861690835b82811015610f865786850135825560209485019460019092019101610f66565b5086821015610fa35760001960f88860031b161c19848701351681555b505060018560011b0183555b5050505050565b60008135610e1081610bc3565b8135610fce81610b0e565b6001600160a01b038116905081548173ffffffffffffffffffffffffffffffffffffffff198216178355602084013561100681610c8f565b7bffffffffffffffff00000000000000000000000000000000000000008160a01b1690507fffffffff000000000000000000000000000000000000000000000000000000008184828516171785556040860135925061106483610bb1565b921760e09190911b90911617815561109c61108160608401610e03565b6001830163ffffffff821663ffffffff198254161781555050565b6110a96080830183610e16565b6110b7818360028601610ef5565b50506105bb6110c860a08401610fb6565b6003830160ff821660ff198254161781555050565b6001600160a01b038816815267ffffffffffffffff87166020820152600063ffffffff808816604084015280871660608401525060c0608083015261112660c083018587610ca5565b905060ff831660a083015298975050505050505050565b600067ffffffffffffffff80831681851680830382111561116057611160610db8565b0194935050505056fea2646970667358221220a54aad59b2972196a793838aab3ac603764d8f10f53f8b069358ac232fba77fe64736f6c63430008090033a26469706673582212204f3aa48020ee7ed6375c2fef601af17d8aad13dee08c197cbddc2f4500931a8f64736f6c63430008090033", } // ManagementContractABI is the input ABI used to generate the binding from. @@ -661,6 +661,27 @@ func (_ManagementContract *ManagementContractTransactorSession) SetImportantCont return _ManagementContract.Contract.SetImportantContractAddress(&_ManagementContract.TransactOpts, key, newAddress) } +// Initialize is a paid mutator transaction binding the contract method 0x8129fc1c. +// +// Solidity: function initialize() returns() +func (_ManagementContract *ManagementContractTransactor) Initialize(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ManagementContract.contract.Transact(opts, "initialize") +} + +// Initialize is a paid mutator transaction binding the contract method 0x8129fc1c. +// +// Solidity: function initialize() returns() +func (_ManagementContract *ManagementContractSession) Initialize() (*types.Transaction, error) { + return _ManagementContract.Contract.Initialize(&_ManagementContract.TransactOpts) +} + +// Initialize is a paid mutator transaction binding the contract method 0x8129fc1c. +// +// Solidity: function initialize() returns() +func (_ManagementContract *ManagementContractTransactorSession) Initialize() (*types.Transaction, error) { + return _ManagementContract.Contract.Initialize(&_ManagementContract.TransactOpts) +} + // RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. // // Solidity: function renounceOwnership() returns() diff --git a/contracts/generated/ObscuroBridge/ObscuroBridge.go b/contracts/generated/ObscuroBridge/ObscuroBridge.go index 5ff4b0c468..24d5cf1172 100644 --- a/contracts/generated/ObscuroBridge/ObscuroBridge.go +++ b/contracts/generated/ObscuroBridge/ObscuroBridge.go @@ -31,8 +31,8 @@ var ( // ObscuroBridgeMetaData contains all meta data concerning the ObscuroBridge contract. var ObscuroBridgeMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"messenger\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ERC20_TOKEN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"NATIVE_TOKEN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"promoteToAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"receiveAssets\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"}],\"name\":\"removeToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"sendERC20\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"sendNative\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"bridge\",\"type\":\"address\"}],\"name\":\"setRemoteBridge\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"}],\"name\":\"whitelistToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x60806040526001805463ffffffff60a01b191690553480156200002157600080fd5b5060405162001c3838038062001c388339810160408190526200004491620001fc565b600080546001600160a01b0319166001600160a01b038316908117909155604080516350d113fd60e11b8152905183929163a1a227fa916004808301926020929190829003018186803b1580156200009b57600080fd5b505afa158015620000b0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000d69190620001fc565b600180546001600160a01b0319166001600160a01b039290921691909117905550620001237fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217753362000157565b620001507fd2fb17ceaa388942529b17e0006ffc4d559f040dd4f2157b8070f17ad2110578600062000157565b506200022e565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff16620001f85760008281526002602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620001b73390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b6000602082840312156200020f57600080fd5b81516001600160a01b03811681146200022757600080fd5b9392505050565b6119fa806200023e6000396000f3fe60806040526004361061010e5760003560e01c80635fa7b584116100a557806393b3744211610074578063a381c8e211610059578063a381c8e21461033e578063d547741f1461035e578063e4c3ebc71461037e57600080fd5b806393b3744214610309578063a217fddf1461032957600080fd5b80635fa7b5841461024f57806375b238fc1461026f57806383bece4d146102a357806391d14854146102c357600080fd5b80632f2ff15d116100e15780632f2ff15d146101bb57806336568abe146101db578063498d82ab146101fb5780635d8729701461021b57600080fd5b806301ffc9a71461011357806316ce8149146101485780631888d7121461016a578063248a9ca31461017d575b600080fd5b34801561011f57600080fd5b5061013361012e3660046114fc565b6103b2565b60405190151581526020015b60405180910390f35b34801561015457600080fd5b5061016861016336600461153e565b61041b565b005b61016861017836600461153e565b610481565b34801561018957600080fd5b506101ad61019836600461155b565b60009081526002602052604090206001015490565b60405190815260200161013f565b3480156101c757600080fd5b506101686101d6366004611574565b6105ba565b3480156101e757600080fd5b506101686101f6366004611574565b6105e5565b34801561020757600080fd5b506101686102163660046115ed565b610671565b34801561022757600080fd5b506101ad7f9f225881f6e7ac8a885b63aa2269cbce78dd6a669864ccd2cd2517a8e709d73a81565b34801561025b57600080fd5b5061016861026a36600461153e565b610736565b34801561027b57600080fd5b506101ad7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b3480156102af57600080fd5b506101686102be366004611670565b61078b565b3480156102cf57600080fd5b506101336102de366004611574565b60009182526002602090815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561031557600080fd5b5061016861032436600461153e565b6109ad565b34801561033557600080fd5b506101ad600081565b34801561034a57600080fd5b50610168610359366004611670565b610a02565b34801561036a57600080fd5b50610168610379366004611574565b610baf565b34801561038a57600080fd5b506101ad7fd2fb17ceaa388942529b17e0006ffc4d559f040dd4f2157b8070f17ad211057881565b60006001600160e01b031982167f7965db0b00000000000000000000000000000000000000000000000000000000148061041557507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316145b92915050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756104468133610bd5565b50600380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b600034116104d65760405162461bcd60e51b815260206004820152600f60248201527f456d707479207472616e736665722e000000000000000000000000000000000060448201526064015b60405180910390fd5b604080518082018252348082526001600160a01b03848116602093840190815284519384019290925290518116828401528251808303840181526060909201909252600354909161052e91168260025b600080610c55565b6001546001600160a01b03166040517f346633fb0000000000000000000000000000000000000000000000000000000081526001600160a01b038481166004830152346024830181905292169163346633fb916044016000604051808303818588803b15801561059d57600080fd5b505af11580156105b1573d6000803e3d6000fd5b50505050505050565b6000828152600260205260409020600101546105d68133610bd5565b6105e08383610d70565b505050565b6001600160a01b03811633146106635760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084016104cd565b61066d8282610e12565b5050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177561069c8133610bd5565b6106c67f9f225881f6e7ac8a885b63aa2269cbce78dd6a669864ccd2cd2517a8e709d73a87610d70565b600063458ffd6360e01b87878787876040516024016106e99594939291906116db565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526003549091506105b1906001600160a01b0316826001610526565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756107618133610bd5565b61066d7f9f225881f6e7ac8a885b63aa2269cbce78dd6a669864ccd2cd2517a8e709d73a83610e12565b6003546000546001600160a01b03918216911633146108125760405162461bcd60e51b815260206004820152603060248201527f436f6e74726163742063616c6c6572206973206e6f742074686520726567697360448201527f7465726564206d657373656e676572210000000000000000000000000000000060648201526084016104cd565b806001600160a01b0316610824610e95565b6001600160a01b0316146108a05760405162461bcd60e51b815260206004820152603160248201527f43726f737320636861696e206d65737361676520636f6d696e672066726f6d2060448201527f696e636f72726563742073656e6465722100000000000000000000000000000060648201526084016104cd565b6001600160a01b03841660009081527f32ef73018533fa188e9e42b313c0a4048c6052342b662fb7510c0d1abcea3413602052604090205460ff16156108f0576108eb848484610f21565b6109a7565b6001600160a01b03841660009081527f13ad2d85210d477fe1a6e25654c8250308cf29b050a4bf0b039d70467486712c602052604090205460ff1615610939576108eb82610f2c565b60405162461bcd60e51b815260206004820152602560248201527f417474656d7074696e6720746f20776974686472617720756e6b6e6f776e206160448201527f737365742e00000000000000000000000000000000000000000000000000000060648201526084016104cd565b50505050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756109d88133610bd5565b61066d7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177583610d70565b60008211610a525760405162461bcd60e51b815260206004820152601a60248201527f417474656d7074696e6720656d707479207472616e736665722e00000000000060448201526064016104cd565b6001600160a01b03831660009081527f32ef73018533fa188e9e42b313c0a4048c6052342b662fb7510c0d1abcea3413602052604090205460ff16610b255760405162461bcd60e51b815260206004820152604e60248201527f54686973206164647265737320686173206e6f74206265656e20676976656e2060448201527f61207479706520616e64206973207468757320636f6e73696465726564206e6f60648201527f742077686974656c69737465642e000000000000000000000000000000000000608482015260a4016104cd565b610b3183333085610fca565b604080516001600160a01b038581166024830152604482018590528381166064808401919091528351808403909101815260849092019092526020810180516001600160e01b03167f83bece4d0000000000000000000000000000000000000000000000000000000017905260035490916109a79116826000610526565b600082815260026020526040902060010154610bcb8133610bd5565b6105e08383610e12565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff1661066d57610c13816001600160a01b0316601461104e565b610c1e83602061104e565b604051602001610c2f929190611749565b60408051601f198184030181529082905262461bcd60e51b82526104cd916004016117f6565b60006040518060600160405280876001600160a01b0316815260200186815260200184815250604051602001610c8b9190611809565b60408051808303601f19018152919052600180549192506001600160a01b0382169163b1454caa917401000000000000000000000000000000000000000090910463ffffffff16906014610cde83611864565b91906101000a81548163ffffffff021916908363ffffffff1602179055508684866040518563ffffffff1660e01b8152600401610d1e9493929190611888565b602060405180830381600087803b158015610d3857600080fd5b505af1158015610d4c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105b191906118c5565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff1661066d5760008281526002602090815260408083206001600160a01b03851684529091529020805460ff19166001179055610dce3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff161561066d5760008281526002602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60008060009054906101000a90046001600160a01b03166001600160a01b03166363012de56040518163ffffffff1660e01b815260040160206040518083038186803b158015610ee457600080fd5b505afa158015610ef8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1c91906118ef565b905090565b6105e0838284611236565b6040516000906001600160a01b038316908281818181865af19150503d8060008114610f74576040519150601f19603f3d011682016040523d82523d6000602084013e610f79565b606091505b505090508061066d5760405162461bcd60e51b815260206004820152601460248201527f4661696c656420746f2073656e6420457468657200000000000000000000000060448201526064016104cd565b6040516001600160a01b03808516602483015283166044820152606481018290526109a79085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261127f565b6060600061105d83600261190c565b61106890600261192b565b67ffffffffffffffff81111561108057611080611943565b6040519080825280601f01601f1916602001820160405280156110aa576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106110e1576110e1611959565b60200101906001600160f81b031916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061112c5761112c611959565b60200101906001600160f81b031916908160001a905350600061115084600261190c565b61115b90600161192b565b90505b60018111156111e0577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061119c5761119c611959565b1a60f81b8282815181106111b2576111b2611959565b60200101906001600160f81b031916908160001a90535060049490941c936111d98161196f565b905061115e565b50831561122f5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016104cd565b9392505050565b6040516001600160a01b0383166024820152604481018290526105e09084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401611017565b60006112d4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166113649092919063ffffffff16565b8051909150156105e057808060200190518101906112f29190611986565b6105e05760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016104cd565b6060611373848460008561137b565b949350505050565b6060824710156113f35760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016104cd565b6001600160a01b0385163b61144a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016104cd565b600080866001600160a01b0316858760405161146691906119a8565b60006040518083038185875af1925050503d80600081146114a3576040519150601f19603f3d011682016040523d82523d6000602084013e6114a8565b606091505b50915091506114b88282866114c3565b979650505050505050565b606083156114d257508161122f565b8251156114e25782518084602001fd5b8160405162461bcd60e51b81526004016104cd91906117f6565b60006020828403121561150e57600080fd5b81356001600160e01b03198116811461122f57600080fd5b6001600160a01b038116811461153b57600080fd5b50565b60006020828403121561155057600080fd5b813561122f81611526565b60006020828403121561156d57600080fd5b5035919050565b6000806040838503121561158757600080fd5b82359150602083013561159981611526565b809150509250929050565b60008083601f8401126115b657600080fd5b50813567ffffffffffffffff8111156115ce57600080fd5b6020830191508360208285010111156115e657600080fd5b9250929050565b60008060008060006060868803121561160557600080fd5b853561161081611526565b9450602086013567ffffffffffffffff8082111561162d57600080fd5b61163989838a016115a4565b9096509450604088013591508082111561165257600080fd5b5061165f888289016115a4565b969995985093965092949392505050565b60008060006060848603121561168557600080fd5b833561169081611526565b92506020840135915060408401356116a781611526565b809150509250925092565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160a01b03861681526060602082015260006116fe6060830186886116b2565b82810360408401526117118185876116b2565b98975050505050505050565b60005b83811015611738578181015183820152602001611720565b838111156109a75750506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161178181601785016020880161171d565b7f206973206d697373696e6720726f6c652000000000000000000000000000000060179184019182015283516117be81602884016020880161171d565b01602801949350505050565b600081518084526117e281602086016020860161171d565b601f01601f19169290920160200192915050565b60208152600061122f60208301846117ca565b602081526001600160a01b038251166020820152600060208301516060604084015261183860808401826117ca565b9050604084015160608401528091505092915050565b634e487b7160e01b600052601160045260246000fd5b600063ffffffff8083168181141561187e5761187e61184e565b6001019392505050565b600063ffffffff8087168352808616602084015250608060408301526118b160808301856117ca565b905060ff8316606083015295945050505050565b6000602082840312156118d757600080fd5b815167ffffffffffffffff8116811461122f57600080fd5b60006020828403121561190157600080fd5b815161122f81611526565b60008160001904831182151516156119265761192661184e565b500290565b6000821982111561193e5761193e61184e565b500190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b60008161197e5761197e61184e565b506000190190565b60006020828403121561199857600080fd5b8151801515811461122f57600080fd5b600082516119ba81846020870161171d565b919091019291505056fea2646970667358221220894ec32d6644e213b6ae6c4bce90ec23ae4371dcc2b3b897983b8d8cc7f8a6db64736f6c63430008090033", + ABI: "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ERC20_TOKEN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"NATIVE_TOKEN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"messengerAddress\",\"type\":\"address\"}],\"name\":\"configure\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"messenger\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newAdmin\",\"type\":\"address\"}],\"name\":\"promoteToAdmin\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"receiveAssets\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"}],\"name\":\"removeToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"sendERC20\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"sendNative\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"bridge\",\"type\":\"address\"}],\"name\":\"setRemoteBridge\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"}],\"name\":\"whitelistToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", + Bin: "0x60806040526001805463ffffffff60a01b1916905534801561002057600080fd5b50611cec806100306000396000f3fe6080604052600436106101445760003560e01c806375b238fc116100c0578063a217fddf11610074578063c4d66de811610059578063c4d66de8146103b4578063d547741f146103d4578063e4c3ebc7146103f457600080fd5b8063a217fddf1461037f578063a381c8e21461039457600080fd5b806383bece4d116100a557806383bece4d146102f957806391d148541461031957806393b374421461035f57600080fd5b806375b238fc146102a557806375cb2672146102d957600080fd5b80632f2ff15d11610117578063498d82ab116100fc578063498d82ab146102315780635d872970146102515780635fa7b5841461028557600080fd5b80632f2ff15d146101f157806336568abe1461021157600080fd5b806301ffc9a71461014957806316ce81491461017e5780631888d712146101a0578063248a9ca3146101b3575b600080fd5b34801561015557600080fd5b506101696101643660046117ee565b610428565b60405190151581526020015b60405180910390f35b34801561018a57600080fd5b5061019e610199366004611830565b610491565b005b61019e6101ae366004611830565b6104ec565b3480156101bf57600080fd5b506101e36101ce36600461184d565b60009081526002602052604090206001015490565b604051908152602001610175565b3480156101fd57600080fd5b5061019e61020c366004611866565b610625565b34801561021d57600080fd5b5061019e61022c366004611866565b610650565b34801561023d57600080fd5b5061019e61024c3660046118df565b6106dc565b34801561025d57600080fd5b506101e37f9f225881f6e7ac8a885b63aa2269cbce78dd6a669864ccd2cd2517a8e709d73a81565b34801561029157600080fd5b5061019e6102a0366004611830565b6107a1565b3480156102b157600080fd5b506101e37fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b3480156102e557600080fd5b5061019e6102f4366004611830565b6107f6565b34801561030557600080fd5b5061019e610314366004611962565b610950565b34801561032557600080fd5b50610169610334366004611866565b60009182526002602090815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561036b57600080fd5b5061019e61037a366004611830565b610b79565b34801561038b57600080fd5b506101e3600081565b3480156103a057600080fd5b5061019e6103af366004611962565b610bce565b3480156103c057600080fd5b5061019e6103cf366004611830565b610d7b565b3480156103e057600080fd5b5061019e6103ef366004611866565b610ea1565b34801561040057600080fd5b506101e37fd2fb17ceaa388942529b17e0006ffc4d559f040dd4f2157b8070f17ad211057881565b60006001600160e01b031982167f7965db0b00000000000000000000000000000000000000000000000000000000148061048b57507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316145b92915050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756104bc8133610ec7565b506003805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b600034116105415760405162461bcd60e51b815260206004820152600f60248201527f456d707479207472616e736665722e000000000000000000000000000000000060448201526064015b60405180910390fd5b604080518082018252348082526001600160a01b03848116602093840190815284519384019290925290518116828401528251808303840181526060909201909252600354909161059991168260025b600080610f47565b6001546001600160a01b03166040517f346633fb0000000000000000000000000000000000000000000000000000000081526001600160a01b038481166004830152346024830181905292169163346633fb916044016000604051808303818588803b15801561060857600080fd5b505af115801561061c573d6000803e3d6000fd5b50505050505050565b6000828152600260205260409020600101546106418133610ec7565b61064b8383611062565b505050565b6001600160a01b03811633146106ce5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610538565b6106d88282611104565b5050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756107078133610ec7565b6107317f9f225881f6e7ac8a885b63aa2269cbce78dd6a669864ccd2cd2517a8e709d73a87611062565b600063458ffd6360e01b87878787876040516024016107549594939291906119cd565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915260035490915061061c906001600160a01b0316826001610591565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217756107cc8133610ec7565b6106d87f9f225881f6e7ac8a885b63aa2269cbce78dd6a669864ccd2cd2517a8e709d73a83611104565b600054610100900460ff166108735760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610538565b80600060026101000a8154816001600160a01b0302191690836001600160a01b03160217905550600060029054906101000a90046001600160a01b03166001600160a01b031663a1a227fa6040518163ffffffff1660e01b815260040160206040518083038186803b1580156108e857600080fd5b505afa1580156108fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109209190611a0f565b6001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b039290921691909117905550565b6003546000546001600160a01b0391821691620100009091041633146109de5760405162461bcd60e51b815260206004820152603060248201527f436f6e74726163742063616c6c6572206973206e6f742074686520726567697360448201527f7465726564206d657373656e67657221000000000000000000000000000000006064820152608401610538565b806001600160a01b03166109f0611187565b6001600160a01b031614610a6c5760405162461bcd60e51b815260206004820152603160248201527f43726f737320636861696e206d65737361676520636f6d696e672066726f6d2060448201527f696e636f72726563742073656e646572210000000000000000000000000000006064820152608401610538565b6001600160a01b03841660009081527f32ef73018533fa188e9e42b313c0a4048c6052342b662fb7510c0d1abcea3413602052604090205460ff1615610abc57610ab7848484611213565b610b73565b6001600160a01b03841660009081527f13ad2d85210d477fe1a6e25654c8250308cf29b050a4bf0b039d70467486712c602052604090205460ff1615610b0557610ab78261121e565b60405162461bcd60e51b815260206004820152602560248201527f417474656d7074696e6720746f20776974686472617720756e6b6e6f776e206160448201527f737365742e0000000000000000000000000000000000000000000000000000006064820152608401610538565b50505050565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775610ba48133610ec7565b6106d87fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177583611062565b60008211610c1e5760405162461bcd60e51b815260206004820152601a60248201527f417474656d7074696e6720656d707479207472616e736665722e0000000000006044820152606401610538565b6001600160a01b03831660009081527f32ef73018533fa188e9e42b313c0a4048c6052342b662fb7510c0d1abcea3413602052604090205460ff16610cf15760405162461bcd60e51b815260206004820152604e60248201527f54686973206164647265737320686173206e6f74206265656e20676976656e2060448201527f61207479706520616e64206973207468757320636f6e73696465726564206e6f60648201527f742077686974656c69737465642e000000000000000000000000000000000000608482015260a401610538565b610cfd833330856112bc565b604080516001600160a01b038581166024830152604482018590528381166064808401919091528351808403909101815260849092019092526020810180516001600160e01b03167f83bece4d000000000000000000000000000000000000000000000000000000001790526003549091610b739116826000610591565b600054610100900460ff16610d965760005460ff1615610d9a565b303b155b610e0c5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610538565b600054610100900460ff16158015610e2e576000805461ffff19166101011790555b610e37826107f6565b610e617fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177533611062565b610e8c7fd2fb17ceaa388942529b17e0006ffc4d559f040dd4f2157b8070f17ad21105786000611062565b80156106d8576000805461ff00191690555050565b600082815260026020526040902060010154610ebd8133610ec7565b61064b8383611104565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff166106d857610f05816001600160a01b03166014611340565b610f10836020611340565b604051602001610f21929190611a58565b60408051601f198184030181529082905262461bcd60e51b825261053891600401611b05565b60006040518060600160405280876001600160a01b0316815260200186815260200184815250604051602001610f7d9190611b18565b60408051808303601f19018152919052600180549192506001600160a01b0382169163b1454caa917401000000000000000000000000000000000000000090910463ffffffff16906014610fd083611b73565b91906101000a81548163ffffffff021916908363ffffffff1602179055508684866040518563ffffffff1660e01b81526004016110109493929190611b97565b602060405180830381600087803b15801561102a57600080fd5b505af115801561103e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061061c9190611bd4565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff166106d85760008281526002602090815260408083206001600160a01b03851684529091529020805460ff191660011790556110c03390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526002602090815260408083206001600160a01b038516845290915290205460ff16156106d85760008281526002602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60008060029054906101000a90046001600160a01b03166001600160a01b03166363012de56040518163ffffffff1660e01b815260040160206040518083038186803b1580156111d657600080fd5b505afa1580156111ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061120e9190611a0f565b905090565b61064b838284611528565b6040516000906001600160a01b038316908281818181865af19150503d8060008114611266576040519150601f19603f3d011682016040523d82523d6000602084013e61126b565b606091505b50509050806106d85760405162461bcd60e51b815260206004820152601460248201527f4661696c656420746f2073656e642045746865720000000000000000000000006044820152606401610538565b6040516001600160a01b0380851660248301528316604482015260648101829052610b739085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611571565b6060600061134f836002611bfe565b61135a906002611c1d565b67ffffffffffffffff81111561137257611372611c35565b6040519080825280601f01601f19166020018201604052801561139c576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106113d3576113d3611c4b565b60200101906001600160f81b031916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061141e5761141e611c4b565b60200101906001600160f81b031916908160001a9053506000611442846002611bfe565b61144d906001611c1d565b90505b60018111156114d2577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061148e5761148e611c4b565b1a60f81b8282815181106114a4576114a4611c4b565b60200101906001600160f81b031916908160001a90535060049490941c936114cb81611c61565b9050611450565b5083156115215760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610538565b9392505050565b6040516001600160a01b03831660248201526044810182905261064b9084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401611309565b60006115c6826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166116569092919063ffffffff16565b80519091501561064b57808060200190518101906115e49190611c78565b61064b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610538565b6060611665848460008561166d565b949350505050565b6060824710156116e55760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610538565b6001600160a01b0385163b61173c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610538565b600080866001600160a01b031685876040516117589190611c9a565b60006040518083038185875af1925050503d8060008114611795576040519150601f19603f3d011682016040523d82523d6000602084013e61179a565b606091505b50915091506117aa8282866117b5565b979650505050505050565b606083156117c4575081611521565b8251156117d45782518084602001fd5b8160405162461bcd60e51b81526004016105389190611b05565b60006020828403121561180057600080fd5b81356001600160e01b03198116811461152157600080fd5b6001600160a01b038116811461182d57600080fd5b50565b60006020828403121561184257600080fd5b813561152181611818565b60006020828403121561185f57600080fd5b5035919050565b6000806040838503121561187957600080fd5b82359150602083013561188b81611818565b809150509250929050565b60008083601f8401126118a857600080fd5b50813567ffffffffffffffff8111156118c057600080fd5b6020830191508360208285010111156118d857600080fd5b9250929050565b6000806000806000606086880312156118f757600080fd5b853561190281611818565b9450602086013567ffffffffffffffff8082111561191f57600080fd5b61192b89838a01611896565b9096509450604088013591508082111561194457600080fd5b5061195188828901611896565b969995985093965092949392505050565b60008060006060848603121561197757600080fd5b833561198281611818565b925060208401359150604084013561199981611818565b809150509250925092565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6001600160a01b03861681526060602082015260006119f06060830186886119a4565b8281036040840152611a038185876119a4565b98975050505050505050565b600060208284031215611a2157600080fd5b815161152181611818565b60005b83811015611a47578181015183820152602001611a2f565b83811115610b735750506000910152565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351611a90816017850160208801611a2c565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351611acd816028840160208801611a2c565b01602801949350505050565b60008151808452611af1816020860160208601611a2c565b601f01601f19169290920160200192915050565b6020815260006115216020830184611ad9565b602081526001600160a01b0382511660208201526000602083015160606040840152611b476080840182611ad9565b9050604084015160608401528091505092915050565b634e487b7160e01b600052601160045260246000fd5b600063ffffffff80831681811415611b8d57611b8d611b5d565b6001019392505050565b600063ffffffff808716835280861660208401525060806040830152611bc06080830185611ad9565b905060ff8316606083015295945050505050565b600060208284031215611be657600080fd5b815167ffffffffffffffff8116811461152157600080fd5b6000816000190483118215151615611c1857611c18611b5d565b500290565b60008219821115611c3057611c30611b5d565b500190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b600081611c7057611c70611b5d565b506000190190565b600060208284031215611c8a57600080fd5b8151801515811461152157600080fd5b60008251611cac818460208701611a2c565b919091019291505056fea2646970667358221220ff3d89bdd2a8c139f63057a849b2b635520784cd22e91cfd13360119ac56ca6e64736f6c63430008090033", } // ObscuroBridgeABI is the input ABI used to generate the binding from. @@ -44,7 +44,7 @@ var ObscuroBridgeABI = ObscuroBridgeMetaData.ABI var ObscuroBridgeBin = ObscuroBridgeMetaData.Bin // DeployObscuroBridge deploys a new Ethereum contract, binding an instance of ObscuroBridge to it. -func DeployObscuroBridge(auth *bind.TransactOpts, backend bind.ContractBackend, messenger common.Address) (common.Address, *types.Transaction, *ObscuroBridge, error) { +func DeployObscuroBridge(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *ObscuroBridge, error) { parsed, err := ObscuroBridgeMetaData.GetAbi() if err != nil { return common.Address{}, nil, nil, err @@ -53,7 +53,7 @@ func DeployObscuroBridge(auth *bind.TransactOpts, backend bind.ContractBackend, return common.Address{}, nil, nil, errors.New("GetABI returned nil") } - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(ObscuroBridgeBin), backend, messenger) + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(ObscuroBridgeBin), backend) if err != nil { return common.Address{}, nil, nil, err } @@ -419,6 +419,27 @@ func (_ObscuroBridge *ObscuroBridgeCallerSession) SupportsInterface(interfaceId return _ObscuroBridge.Contract.SupportsInterface(&_ObscuroBridge.CallOpts, interfaceId) } +// Configure is a paid mutator transaction binding the contract method 0x75cb2672. +// +// Solidity: function configure(address messengerAddress) returns() +func (_ObscuroBridge *ObscuroBridgeTransactor) Configure(opts *bind.TransactOpts, messengerAddress common.Address) (*types.Transaction, error) { + return _ObscuroBridge.contract.Transact(opts, "configure", messengerAddress) +} + +// Configure is a paid mutator transaction binding the contract method 0x75cb2672. +// +// Solidity: function configure(address messengerAddress) returns() +func (_ObscuroBridge *ObscuroBridgeSession) Configure(messengerAddress common.Address) (*types.Transaction, error) { + return _ObscuroBridge.Contract.Configure(&_ObscuroBridge.TransactOpts, messengerAddress) +} + +// Configure is a paid mutator transaction binding the contract method 0x75cb2672. +// +// Solidity: function configure(address messengerAddress) returns() +func (_ObscuroBridge *ObscuroBridgeTransactorSession) Configure(messengerAddress common.Address) (*types.Transaction, error) { + return _ObscuroBridge.Contract.Configure(&_ObscuroBridge.TransactOpts, messengerAddress) +} + // GrantRole is a paid mutator transaction binding the contract method 0x2f2ff15d. // // Solidity: function grantRole(bytes32 role, address account) returns() @@ -440,6 +461,27 @@ func (_ObscuroBridge *ObscuroBridgeTransactorSession) GrantRole(role [32]byte, a return _ObscuroBridge.Contract.GrantRole(&_ObscuroBridge.TransactOpts, role, account) } +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address messenger) returns() +func (_ObscuroBridge *ObscuroBridgeTransactor) Initialize(opts *bind.TransactOpts, messenger common.Address) (*types.Transaction, error) { + return _ObscuroBridge.contract.Transact(opts, "initialize", messenger) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address messenger) returns() +func (_ObscuroBridge *ObscuroBridgeSession) Initialize(messenger common.Address) (*types.Transaction, error) { + return _ObscuroBridge.Contract.Initialize(&_ObscuroBridge.TransactOpts, messenger) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address messenger) returns() +func (_ObscuroBridge *ObscuroBridgeTransactorSession) Initialize(messenger common.Address) (*types.Transaction, error) { + return _ObscuroBridge.Contract.Initialize(&_ObscuroBridge.TransactOpts, messenger) +} + // PromoteToAdmin is a paid mutator transaction binding the contract method 0x93b37442. // // Solidity: function promoteToAdmin(address newAdmin) returns() diff --git a/contracts/package.json b/contracts/package.json index 9d7b0f6751..a71aa4bf90 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -16,7 +16,7 @@ "@solidstate/hardhat-bytecode-exporter": "^1.1.1", "hardhat": "~2.12.4", "hardhat-abi-exporter": "^2.10.1", - "hardhat-deploy": "0.11.22", + "hardhat-deploy": "0.11.42", "node-docker-api": "^1.1.22", "ts-node": "~10.9.1", "typescript": "^4.9.4" diff --git a/contracts/src/bridge/L1/ObscuroBridge.sol b/contracts/src/bridge/L1/ObscuroBridge.sol index 49714d85d8..d89d1772b9 100644 --- a/contracts/src/bridge/L1/ObscuroBridge.sol +++ b/contracts/src/bridge/L1/ObscuroBridge.sol @@ -8,6 +8,8 @@ import "../ITokenFactory.sol"; import "../../messaging/messenger/CrossChainEnabledObscuro.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; +import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; + // This is the Ethereum side of the Obscuro Bridge. // End-users can interact with it to transfer ERC20 tokens and native eth to the Layer 2 Obscuro. @@ -30,7 +32,8 @@ contract ObscuroBridge is address remoteBridgeAddress; - constructor(address messenger) CrossChainEnabledObscuro(messenger) { + function initialize(address messenger) public initializer() { + CrossChainEnabledObscuro.configure(messenger); _grantRole(ADMIN_ROLE, msg.sender); _grantRole(NATIVE_TOKEN_ROLE, address(0x0)); } diff --git a/contracts/src/bridge/L2/EthereumBridge.sol b/contracts/src/bridge/L2/EthereumBridge.sol index d66aab8c54..7efce8b51e 100644 --- a/contracts/src/bridge/L2/EthereumBridge.sol +++ b/contracts/src/bridge/L2/EthereumBridge.sol @@ -4,6 +4,7 @@ pragma solidity >=0.7.0 <0.9.0; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; +import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; import "../IBridge.sol"; import "../ITokenFactory.sol"; @@ -28,10 +29,11 @@ contract EthereumBridge is address remoteBridgeAddress; - constructor( + function initialize( address messenger, address remoteBridge - ) CrossChainEnabledObscuro(messenger) { + ) public initializer { + CrossChainEnabledObscuro.configure(messenger); remoteBridgeAddress = remoteBridge; } diff --git a/contracts/src/management/ManagementContract.sol b/contracts/src/management/ManagementContract.sol index c8d5ebdc6b..f5b33bbcd6 100644 --- a/contracts/src/management/ManagementContract.sol +++ b/contracts/src/management/ManagementContract.sol @@ -3,11 +3,17 @@ pragma solidity >=0.7.0 <0.9.0; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; +import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; + import "./Structs.sol"; import * as MessageBus from "../messaging/MessageBus.sol"; -contract ManagementContract is Ownable { +contract ManagementContract is Ownable, Initializable { + + constructor() { + // _disableInitializers(); //todo @siliev - figure out why the solidity compiler cant find this. Perhaps OZ needs a version upgrade? + } event LogManagementContractCreated(address messageBusAddress); // Event to log changes to important contract addresses @@ -30,12 +36,13 @@ contract ManagementContract is Ownable { // isWithdrawalAvailable marks if the contract allows withdrawals or not bool private isWithdrawalAvailable; - uint256 public lastBatchSeqNo = 0; + uint256 public lastBatchSeqNo; Structs.RollupStorage private rollups; //The messageBus where messages can be sent to Obscuro MessageBus.IMessageBus public messageBus; - constructor() { + function initialize() public initializer { + lastBatchSeqNo = 0; messageBus = new MessageBus.MessageBus(); emit LogManagementContractCreated(address(messageBus)); } diff --git a/contracts/src/messaging/messenger/CrossChainEnabledObscuro.sol b/contracts/src/messaging/messenger/CrossChainEnabledObscuro.sol index 85f486d25a..d653c75808 100644 --- a/contracts/src/messaging/messenger/CrossChainEnabledObscuro.sol +++ b/contracts/src/messaging/messenger/CrossChainEnabledObscuro.sol @@ -3,16 +3,18 @@ pragma solidity >=0.7.0 <0.9.0; import "./ICrossChainMessenger.sol"; +import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; + // TODO: We need to upgrade the open zeppelin version to the 4.x that adds cross chain enabled -abstract contract CrossChainEnabledObscuro { +abstract contract CrossChainEnabledObscuro is Initializable { ICrossChainMessenger messenger; IMessageBus messageBus; uint32 nonce = 0; // The messenger contract passed will be the authority that we trust to tell us // who has sent the cross chain message and that the message is indeed cross chain. - constructor(address messengerAddress) { + function configure(address messengerAddress) public onlyInitializing { messenger = ICrossChainMessenger(messengerAddress); messageBus = IMessageBus(messenger.messageBus()); } diff --git a/contracts/src/messaging/messenger/CrossChainMessenger.sol b/contracts/src/messaging/messenger/CrossChainMessenger.sol index 51bb5b3e72..31a4d4d81d 100644 --- a/contracts/src/messaging/messenger/CrossChainMessenger.sol +++ b/contracts/src/messaging/messenger/CrossChainMessenger.sol @@ -3,6 +3,8 @@ pragma solidity >=0.7.0 <0.9.0; import "./ICrossChainMessenger.sol"; +import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; + // CrossChainMessenger is the contract that provides the context for contracts // that inherit CrossChainEnabledObscuro. It allows to deliver messages using relayMessage. @@ -14,15 +16,18 @@ import "./ICrossChainMessenger.sol"; // from whom the messages are coming from. // Notice that this Messenger has no restrictions on who can relay messages, nor does it have any understanding of fees. // You can opt in to deploy a customer messenger for your cross chain dApp with more specialized logic. -contract CrossChainMessenger is ICrossChainMessenger { +contract CrossChainMessenger is ICrossChainMessenger, Initializable { error CallFailed(bytes error); IMessageBus messageBusContract; - address public crossChainSender = address(0x0); + address public crossChainSender; mapping(bytes32 => bool) messageConsumed; - constructor(address messageBusAddr) { + + //todo - make only once + function initialize(address messageBusAddr) external initializer { messageBusContract = IMessageBus(messageBusAddr); + crossChainSender = address(0x0); } function messageBus() external view returns (address) { diff --git a/contracts/test/bridge-test.ts b/contracts/test/bridge-test.ts index f4ff550157..acb1ebb126 100644 --- a/contracts/test/bridge-test.ts +++ b/contracts/test/bridge-test.ts @@ -40,11 +40,15 @@ describe("Bridge", function () { busL1 = await MessageBus.deploy(); busL2 = await MessageBus.deploy(); - messengerL1 = await Messenger.deploy(busL1.address); - messengerL2 = await Messenger.deploy(busL2.address); - - bridgeL1 = await L1Bridge.deploy(messengerL1.address); - bridgeL2 = await L2Bridge.deploy(messengerL2.address, bridgeL1.address); + messengerL1 = await Messenger.deploy(); + await messengerL1.initialize(busL1.address); + messengerL2 = await Messenger.deploy(); + await messengerL2.initialize(busL2.address) + + bridgeL1 = await L1Bridge.deploy(); + bridgeL1.initialize(messengerL1.address); + bridgeL2 = await L2Bridge.deploy(); + bridgeL2.initialize(messengerL2.address, bridgeL1.address); const tx = await bridgeL1.setRemoteBridge(bridgeL2.address); await tx.wait(); diff --git a/integration/simulation/network/geth_utils.go b/integration/simulation/network/geth_utils.go index 4ab51389a7..42030e02f2 100644 --- a/integration/simulation/network/geth_utils.go +++ b/integration/simulation/network/geth_utils.go @@ -1,6 +1,7 @@ package network import ( + "context" "errors" "fmt" "math/big" @@ -14,6 +15,7 @@ import ( "github.com/ten-protocol/go-ten/go/ethadapter" "github.com/ten-protocol/go-ten/go/wallet" "github.com/ten-protocol/go-ten/integration" + integrationCommon "github.com/ten-protocol/go-ten/integration/common" "github.com/ten-protocol/go-ten/integration/common/testlog" "github.com/ten-protocol/go-ten/integration/erc20contract" "github.com/ten-protocol/go-ten/integration/eth2network" @@ -108,6 +110,21 @@ func DeployObscuroNetworkContracts(client ethadapter.EthClient, wallets *params. return nil, fmt.Errorf("failed to instantiate management contract. Cause: %w", err) } + opts, err := bind.NewKeyedTransactorWithChainID(wallets.MCOwnerWallet.PrivateKey(), wallets.MCOwnerWallet.ChainID()) + if err != nil { + return nil, fmt.Errorf("unable to create a keyed transactor for initializing the management contract. Cause: %w", err) + } + + tx, err := managementContract.Initialize(opts) + if err != nil { + return nil, fmt.Errorf("unable to initialize management contract. Cause: %w", err) + } + + _, err = integrationCommon.AwaitReceiptEth(context.Background(), client.EthClient(), tx.Hash(), 25*time.Second) + if err != nil { + return nil, fmt.Errorf("no receipt for management contract initialization") + } + l1BusAddress, err := managementContract.MessageBus(&bind.CallOpts{}) if err != nil { return nil, fmt.Errorf("failed to fetch MessageBus address. Cause: %w", err) diff --git a/testnet/launcher/docker.go b/testnet/launcher/docker.go index 3b282a6fe6..ce936a0542 100644 --- a/testnet/launcher/docker.go +++ b/testnet/launcher/docker.go @@ -124,8 +124,8 @@ func (t *Testnet) Start() error { l2cd.WithL2Host("sequencer-host"), l2cd.WithL2WSPort(81), l2cd.WithL1PrivateKey("f52e5418e349dccdda29b6ac8b0abe6576bb7713886aa85abea6181ba731f9bb"), - l2cd.WithManagementContractAddress("0xeDa66Cc53bd2f26896f6Ba6b736B1Ca325DE04eF"), - l2cd.WithMessageBusContractAddress("0xFD03804faCA2538F4633B3EBdfEfc38adafa259B"), + l2cd.WithMessageBusContractAddress("0xDaBD89EEA0f08B602Ec509c3C608Cb8ED095249C"), + l2cd.WithManagementContractAddress("0x51D43a3Ca257584E770B6188232b199E76B022A2"), l2cd.WithL2PrivateKey("8dfb8083da6275ae3e4f41e3e8a8c19d028d32c9247e24530933782f2a05035b"), l2cd.WithHocPKString("6e384a07a01263518a09a5424c7b6bbfc3604ba7d93f47e3a455cbdd7f9f0682"), l2cd.WithPocPKString("4bfe14725e685901c062ccd4e220c61cf9c189897b6c78bd18d7f51291b2b8f8"), diff --git a/testnet/launcher/l1contractdeployer/docker.go b/testnet/launcher/l1contractdeployer/docker.go index 2530342015..5ffedda3a1 100644 --- a/testnet/launcher/l1contractdeployer/docker.go +++ b/testnet/launcher/l1contractdeployer/docker.go @@ -95,6 +95,8 @@ func (n *ContractDeployer) RetrieveL1ContractAddresses() (*node.NetworkConfig, e // Get the last three lines output := buf.String() + fmt.Printf("L2 Deployer output %s\n", output) + lines := strings.Split(output, "\n") managementAddr, err := findAddress(lines[0])