-
Notifications
You must be signed in to change notification settings - Fork 23
/
deployers.go
32 lines (27 loc) · 1.3 KB
/
deployers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package testutil
import (
"context"
"github.com/synapsecns/sanguine/ethergo/contracts"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/synapsecns/sanguine/ethergo/backends"
"github.com/synapsecns/sanguine/ethergo/deployer"
"github.com/synapsecns/sanguine/services/scribe/testutil/testcontract"
)
// TestContractDeployer deploys a test contract.
type TestContractDeployer struct {
*deployer.BaseDeployer
}
// NewTestContractDeployer creates a new test contract deployer.
func NewTestContractDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer {
return TestContractDeployer{deployer.NewSimpleDeployer(registry, backend, TestContractType)}
}
// Deploy deploys the test contract.
func (t TestContractDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error) {
return t.DeploySimpleContract(ctx, func(transactOps *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error) {
return testcontract.DeployTestContract(transactOps, backend)
}, func(address common.Address, backend bind.ContractBackend) (interface{}, error) {
return testcontract.NewTestContractRef(address, backend)
})
}