diff --git a/cmd/sendTxs.go b/cmd/sendTxs.go
index 3f6b522..c180e41 100644
--- a/cmd/sendTxs.go
+++ b/cmd/sendTxs.go
@@ -23,7 +23,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
- "github.com/vulcanize/tx_spammer/pkg"
+ "github.com/vulcanize/tx_spammer/pkg/manual"
)
// sendTxsCmd represents the sendTxs command
@@ -41,11 +41,11 @@ Support standard, optimism L2, optimism L1 to L2, and EIP1559 transactions`,
}
func sendTxs() {
- params, err := tx_spammer.NewTxParams()
+ params, err := manual.NewTxParams()
if err != nil {
logWithCommand.Fatal(err)
}
- txSpammer := tx_spammer.NewTxSpammer(params)
+ txSpammer := manual.NewTxSpammer(params)
wg := new(sync.WaitGroup)
quitChan := make(chan bool)
txSpammer.Loop(wg, quitChan)
diff --git a/pkg/config.go b/pkg/manual/config.go
similarity index 98%
rename from pkg/config.go
rename to pkg/manual/config.go
index 51e16f7..bbc7747 100644
--- a/pkg/config.go
+++ b/pkg/manual/config.go
@@ -14,11 +14,12 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-package tx_spammer
+package manual
import (
"crypto/ecdsa"
"fmt"
+ "github.com/vulcanize/tx_spammer/pkg/shared"
"math/big"
"os"
"strings"
@@ -32,6 +33,36 @@ import (
"github.com/spf13/viper"
)
+const (
+ ETH_TX_LIST = "ETH_TX_LIST"
+ ETH_ADDR_LOG = "ETH_ADDR_LOG"
+
+ defaultGenKeyWritePathPrefix = "./accounts/keys/"
+ defaultAddrLogPath = "./accounts/addresses/accounts"
+
+ typeSuffix = ".type"
+ httpPathSuffix = ".http"
+ toSuffix = ".to"
+ amountSuffix = ".amount"
+ gasLimitSuffix = ".gasLimit"
+ gasPriceSuffix = ".gasPrice"
+ gasPremiumSuffix = ".gasPremium"
+ feeCapSuffix = ".feeCap"
+ dataSuffix = ".data"
+ senderKeyPathSuffix = ".senderKeyPath"
+ writeSenderPathSuffix = ".writeSenderPath"
+ l1SenderSuffix = ".l1Sender"
+ l1RollupTxIdSuffix = ".l1RollupTxId"
+ sigHashTypeSuffix = ".sigHashType"
+ frequencySuffix = ".frequency"
+ totalNumberSuffix = ".totalNumber"
+ delaySuffix = ".delay"
+ startingNonceSuffix = ".startingNonce"
+ queueOriginSuffix = ".queueOrigin"
+ chainIDSuffix = ".chainID"
+ contractWriteSuffix = ".writeDeploymentAddrPath"
+)
+
// TxParams holds the parameters for a given transaction
type TxParams struct {
// Name of this tx in the .toml file
@@ -41,7 +72,7 @@ type TxParams struct {
Client *rpc.Client
// Type of the tx
- Type TxType
+ Type shared.TxType
// Chain ID
ChainID uint64
@@ -78,36 +109,6 @@ type TxParams struct {
Delay time.Duration
}
-const (
- ETH_TX_LIST = "ETH_TX_LIST"
- ETH_ADDR_LOG = "ETH_ADDR_LOG"
-
- defaultGenKeyWritePathPrefix = "./accounts/keys/"
- defaultAddrLogPath = "./accounts/addresses/accounts"
-
- typeSuffix = ".type"
- httpPathSuffix = ".http"
- toSuffix = ".to"
- amountSuffix = ".amount"
- gasLimitSuffix = ".gasLimit"
- gasPriceSuffix = ".gasPrice"
- gasPremiumSuffix = ".gasPremium"
- feeCapSuffix = ".feeCap"
- dataSuffix = ".data"
- senderKeyPathSuffix = ".senderKeyPath"
- writeSenderPathSuffix = ".writeSenderPath"
- l1SenderSuffix = ".l1Sender"
- l1RollupTxIdSuffix = ".l1RollupTxId"
- sigHashTypeSuffix = ".sigHashType"
- frequencySuffix = ".frequency"
- totalNumberSuffix = ".totalNumber"
- delaySuffix = ".delay"
- startingNonceSuffix = ".startingNonce"
- queueOriginSuffix = ".queueOrigin"
- chainIDSuffix = ".chainID"
- contractWriteSuffix = ".writeDeploymentAddrPath"
-)
-
// NewConfig returns a new tx spammer config
func NewTxParams() ([]TxParams, error) {
viper.BindEnv("eth.txs", ETH_TX_LIST)
@@ -135,7 +136,7 @@ func NewTxParams() ([]TxParams, error) {
if txTypeStr == "" {
return nil, fmt.Errorf("need tx type for tx %s", txName)
}
- txType, err := TxTypeFromString(txTypeStr)
+ txType, err := shared.TxTypeFromString(txTypeStr)
if err != nil {
return nil, err
}
diff --git a/pkg/sender.go b/pkg/manual/sender.go
similarity index 99%
rename from pkg/sender.go
rename to pkg/manual/sender.go
index 577da66..c420709 100644
--- a/pkg/sender.go
+++ b/pkg/manual/sender.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-package tx_spammer
+package manual
import (
"context"
diff --git a/pkg/service.go b/pkg/manual/service.go
similarity index 98%
rename from pkg/service.go
rename to pkg/manual/service.go
index 5e9728e..6e01d9c 100644
--- a/pkg/service.go
+++ b/pkg/manual/service.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-package tx_spammer
+package manual
import (
"sync"
diff --git a/pkg/tx_generator.go b/pkg/manual/tx_generator.go
similarity index 94%
rename from pkg/tx_generator.go
rename to pkg/manual/tx_generator.go
index 2fc6949..cdd7a20 100644
--- a/pkg/tx_generator.go
+++ b/pkg/manual/tx_generator.go
@@ -14,10 +14,11 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-package tx_spammer
+package manual
import (
"fmt"
+ "github.com/vulcanize/tx_spammer/pkg/shared"
"os"
"sync/atomic"
@@ -53,9 +54,9 @@ func NewTxGenerator(params []TxParams) *TxGenerator {
func (tg TxGenerator) GenerateTx(params TxParams) ([]byte, error) {
tx := make([]byte, 0)
switch params.Type {
- case Standard, OptimismL1ToL2, OptimismL2:
+ case shared.Standard, shared.OptimismL1ToL2, shared.OptimismL2:
return tg.gen(params)
- case EIP1559:
+ case shared.EIP1559:
return tg.gen1559(params)
default:
return nil, fmt.Errorf("unsupported tx type: %s", params.Type.String())
@@ -75,7 +76,7 @@ func (gen TxGenerator) gen(params TxParams) ([]byte, error) {
} else {
tx = types.NewTransaction(nonce, *params.To, params.Amount, params.GasLimit, params.GasPrice, params.Data, params.L1SenderAddr, params.L1RollupTxId, params.QueueOrigin, params.SigHashType)
}
- signer, err := TxSigner(params.Type, params.ChainID)
+ signer, err := shared.TxSigner(params.Type, params.ChainID)
if err != nil {
return nil, err
}
diff --git a/pkg/tx_type.go b/pkg/shared/tx_type.go
similarity index 98%
rename from pkg/tx_type.go
rename to pkg/shared/tx_type.go
index 0cabf0c..dd6b0cd 100644
--- a/pkg/tx_type.go
+++ b/pkg/shared/tx_type.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-package tx_spammer
+package shared
import (
"fmt"
diff --git a/pkg/util.go b/pkg/shared/util.go
similarity index 98%
rename from pkg/util.go
rename to pkg/shared/util.go
index a074399..788caab 100644
--- a/pkg/util.go
+++ b/pkg/shared/util.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-package tx_spammer
+package shared
import (
"fmt"