This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP Improve scenario package * Create orderopts package. Update scenario and ordervalidator to use it * Fix remaining ordervalidator tests * Update most orderwatcher tests * Support setting taker state and enable remaining orderwatcher tests * Fix remaining tests (only MultiAsset disabled) * Uncomment test that depends on on-chain state for a StaticCall order * Fix browser integration test * Remove unneeded ethClient parameter in a few places * Move sleep statement in order_watcher_test.go * Address Alex Towle's feedback * Remove old comment
- Loading branch information
Showing
10 changed files
with
645 additions
and
707 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
package orderopts | ||
|
||
import ( | ||
"math/big" | ||
|
||
"github.com/0xProject/0x-mesh/zeroex" | ||
"github.com/ethereum/go-ethereum/common" | ||
) | ||
|
||
type Config struct { | ||
Order *zeroex.Order | ||
SetupMakerState bool | ||
SetupTakerAddress common.Address | ||
} | ||
|
||
type Option func(order *Config) error | ||
|
||
// Apply applies the given options to the config, returning the first error | ||
// encountered (if any). | ||
func (cfg *Config) Apply(opts ...Option) error { | ||
for _, opt := range opts { | ||
if opt == nil { | ||
continue | ||
} | ||
if err := opt(cfg); err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func MakerAddress(address common.Address) Option { | ||
return func(cfg *Config) error { | ||
cfg.Order.MakerAddress = address | ||
return nil | ||
} | ||
} | ||
|
||
func MakerAssetData(assetData []byte) Option { | ||
return func(cfg *Config) error { | ||
cfg.Order.MakerAssetData = assetData | ||
return nil | ||
} | ||
} | ||
|
||
func MakerAssetAmount(amount *big.Int) Option { | ||
return func(cfg *Config) error { | ||
cfg.Order.MakerAssetAmount = amount | ||
return nil | ||
} | ||
} | ||
|
||
func TakerAssetData(assetData []byte) Option { | ||
return func(cfg *Config) error { | ||
cfg.Order.TakerAssetData = assetData | ||
return nil | ||
} | ||
} | ||
|
||
func TakerAssetAmount(amount *big.Int) Option { | ||
return func(cfg *Config) error { | ||
cfg.Order.TakerAssetAmount = amount | ||
return nil | ||
} | ||
} | ||
|
||
func ExpirationTimeSeconds(expirationTimeSeconds *big.Int) Option { | ||
return func(cfg *Config) error { | ||
cfg.Order.ExpirationTimeSeconds = expirationTimeSeconds | ||
return nil | ||
} | ||
} | ||
|
||
func MakerFeeAssetData(assetData []byte) Option { | ||
return func(cfg *Config) error { | ||
cfg.Order.MakerFeeAssetData = assetData | ||
return nil | ||
} | ||
} | ||
|
||
func MakerFee(amount *big.Int) Option { | ||
return func(cfg *Config) error { | ||
cfg.Order.MakerFee = amount | ||
return nil | ||
} | ||
} | ||
|
||
func SenderAddress(address common.Address) Option { | ||
return func(cfg *Config) error { | ||
cfg.Order.SenderAddress = address | ||
return nil | ||
} | ||
} | ||
|
||
func FeeRecipientAddress(address common.Address) Option { | ||
return func(cfg *Config) error { | ||
cfg.Order.FeeRecipientAddress = address | ||
return nil | ||
} | ||
} | ||
|
||
func SetupMakerState(b bool) Option { | ||
return func(cfg *Config) error { | ||
cfg.SetupMakerState = b | ||
return nil | ||
} | ||
} | ||
|
||
func SetupTakerAddress(takerAddress common.Address) Option { | ||
return func(cfg *Config) error { | ||
cfg.SetupTakerAddress = takerAddress | ||
return nil | ||
} | ||
} |
Oops, something went wrong.