utils.go 883 Bytes
Newer Older
1 2 3 4 5 6
package setuputils

import (
	"crypto/ecdsa"
	"time"

7 8
	"github.com/ethereum-optimism/optimism/op-service/crypto"

9 10 11 12 13 14 15
	"github.com/ethereum/go-ethereum/common/hexutil"

	"github.com/ethereum-optimism/optimism/op-service/endpoint"
	"github.com/ethereum-optimism/optimism/op-service/txmgr"
)

func hexPriv(in *ecdsa.PrivateKey) string {
16
	b := crypto.EncodePrivKey(in)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
	return hexutil.Encode(b)
}

func NewTxMgrConfig(l1Addr endpoint.RPC, privKey *ecdsa.PrivateKey) txmgr.CLIConfig {
	return txmgr.CLIConfig{
		L1RPCURL:                  l1Addr.RPC(),
		PrivateKey:                hexPriv(privKey),
		NumConfirmations:          1,
		SafeAbortNonceTooLowCount: 3,
		FeeLimitMultiplier:        5,
		ResubmissionTimeout:       3 * time.Second,
		ReceiptQueryInterval:      50 * time.Millisecond,
		NetworkTimeout:            2 * time.Second,
		TxNotInMempoolTimeout:     2 * time.Minute,
	}
}