-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* config refactors * fix tests * lint * lint
- Loading branch information
1 parent
0c0a8d6
commit 6073ce7
Showing
12 changed files
with
245 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package config | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/ethereum-optimism/supersim/hdaccount" | ||
|
||
"github.com/ethereum/go-ethereum" | ||
"github.com/ethereum/go-ethereum/accounts" | ||
"github.com/ethereum/go-ethereum/core/types" | ||
) | ||
|
||
var ( | ||
DefaultSecretsConfig = SecretsConfig{ | ||
Accounts: 10, | ||
Mnemonic: "test test test test test test test test test test test junk", | ||
DerivationPath: accounts.DefaultRootDerivationPath, | ||
} | ||
|
||
DefaultChainConfigs = []ChainConfig{ | ||
{ | ||
Name: "SourceChain", | ||
ChainID: 1, | ||
SecretsConfig: DefaultSecretsConfig, | ||
}, | ||
{ | ||
Name: "OPChainA", | ||
ChainID: 10, | ||
SourceChainID: 1, | ||
SecretsConfig: DefaultSecretsConfig, | ||
}, | ||
{ | ||
Name: "OPChainB", | ||
ChainID: 30, | ||
SourceChainID: 1, | ||
SecretsConfig: DefaultSecretsConfig, | ||
}, | ||
} | ||
) | ||
|
||
type ForkConfig struct { | ||
RPCUrl string | ||
BlockNumber uint64 | ||
} | ||
|
||
type SecretsConfig struct { | ||
Accounts uint64 | ||
Mnemonic string | ||
DerivationPath accounts.DerivationPath | ||
} | ||
|
||
type ChainConfig struct { | ||
Name string | ||
Port uint64 | ||
|
||
ChainID uint64 | ||
SourceChainID uint64 // "L1" | ||
|
||
SecretsConfig SecretsConfig | ||
|
||
// Optional Config | ||
ForkConfig *ForkConfig | ||
} | ||
|
||
type Chain interface { | ||
Name() string | ||
Endpoint() string | ||
ChainID() uint64 | ||
LogPath() string | ||
|
||
// API methods | ||
EthSendTransaction(ctx context.Context, tx *types.Transaction) error | ||
EthGetLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error) | ||
SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) | ||
} | ||
|
||
// Note: The default secrets config is used everywhere | ||
func DefaultSecretsConfigAsString() string { | ||
hdAccountStore, err := hdaccount.NewHdAccountStore(DefaultSecretsConfig.Mnemonic, DefaultSecretsConfig.DerivationPath) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
var b strings.Builder | ||
|
||
fmt.Fprintf(&b, "\nAvailable Accounts\n") | ||
fmt.Fprintf(&b, "-----------------------\n") | ||
|
||
for i := range DefaultSecretsConfig.Accounts { | ||
addressHex, _ := hdAccountStore.AddressHexAt(uint32(i)) | ||
fmt.Fprintf(&b, "(%d): %s\n", i, addressHex) | ||
} | ||
|
||
fmt.Fprintf(&b, "\nPrivate Keys\n") | ||
fmt.Fprintf(&b, "-----------------------\n") | ||
|
||
for i := range DefaultSecretsConfig.Accounts { | ||
privateKeyHex, _ := hdAccountStore.PrivateKeyHexAt(uint32(i)) | ||
fmt.Fprintf(&b, "(%d): %s\n", i, privateKeyHex) | ||
} | ||
|
||
return b.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.