Skip to content

Commit

Permalink
Merge pull request #16 from mysteriumnetwork/experiment/generation-cl…
Browse files Browse the repository at this point in the history
…eanup

Experiment/generation cleanup
  • Loading branch information
tadovas authored Dec 19, 2018
2 parents bc96e8b + c374fb3 commit 011ce6e
Show file tree
Hide file tree
Showing 8 changed files with 1,253 additions and 4,271 deletions.
2 changes: 1 addition & 1 deletion balances/balances.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/mysteriumnetwork/payments/identity"
)

//go:generate abigen --sol ../contracts/IdentityBalances.sol --pkg balances --out abigen_balances.go
//go:generate abigen --sol ../contracts/IdentityBalances.sol --exc contracts/deps/OpenZeppelin/contracts/token/ERC20/ERC20.sol:ERC20 --pkg balances --out abigen_balances.go

type IdentityBalance struct {
Address common.Address
Expand Down
4 changes: 2 additions & 2 deletions cli/minter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ func mintToken() (err error) {
}
fmt.Println("Your balance is:", balance.String(), "wei")

erc20token, err := mysttoken.NewMystTokenTransactor(common.HexToAddress(*erc20contract), client)
mystToken, err := mysttoken.NewMystTokenTransactor(common.HexToAddress(*erc20contract), client)
if err != nil {
return
}
tx, err := erc20token.Mint(transactor, common.HexToAddress(*whom), big.NewInt(*amount))
tx, err := mystToken.Mint(transactor, common.HexToAddress(*whom), big.NewInt(*amount))
fmt.Println("Tx id:", tx.Hash())
return err
}
10 changes: 5 additions & 5 deletions cli/payments/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/mysteriumnetwork/payments/cli/helpers"
"github.com/mysteriumnetwork/payments/promises"
"github.com/mysteriumnetwork/payments/contracts/abigen"
)

var paymentsContract = flag.String("payments.contract", "", "Address of payments contract")
Expand All @@ -22,15 +22,15 @@ func main() {
checkError(err)
<-syncCompleted

contract, err := promises.NewIdentityRegistryCaller(common.HexToAddress(*paymentsContract), client)
contractCaller, err := abigen.NewIdentityPromisesCaller(common.HexToAddress(*paymentsContract), client)
checkError(err)

paymentsSession := promises.IdentityRegistryCallerSession{
Contract: contract,
paymentsContract := abigen.IdentityPromisesCallerSession{
Contract: contractCaller,
CallOpts: bind.CallOpts{},
}

registered, err := paymentsSession.IsRegistered(common.HexToAddress(*identity))
registered, err := paymentsContract.IsRegistered(common.HexToAddress(*identity))
checkError(err)
fmt.Println("Identity: ", *identity, "registration status: ", registered)
}
Expand Down
3 changes: 3 additions & 0 deletions contracts/abigen/gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package abigen

//go:generate abigen --sol ../IdentityPromises.sol --pkg abigen --out payments.go -exc ../Utils.sol:Utils,../deps/OpenZeppelin/contracts/ownership/Ownable.sol:Ownable,../deps/OpenZeppelin/contracts/math/Math.sol:Math,../deps/OpenZeppelin/contracts/token/ERC20/ERC20Basic.sol:ERC20Basic,../ERC20Aware.sol:ERC20Aware,../deps/OpenZeppelin/contracts/token/ERC20/ERC20.sol:ERC20,../IdentityRegistry.sol:IdentityRegistry,../IdentityBalances.sol:IdentityBalances
1,232 changes: 1,232 additions & 0 deletions contracts/abigen/payments.go

Large diffs are not rendered by default.

4,253 changes: 0 additions & 4,253 deletions promises/abigen_promises.go

This file was deleted.

13 changes: 6 additions & 7 deletions promises/clearing.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,29 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/event"
"github.com/mysteriumnetwork/payments/contracts/abigen"
"github.com/mysteriumnetwork/payments/identity"
"github.com/mysteriumnetwork/payments/registry"
)

//go:generate abigen --sol ../contracts/IdentityPromises.sol --exc contract/registry.sol:IdentityRegistry --pkg promises --out abigen_promises.go

type PromiseClearing struct {
Address common.Address
IdentityPromisesSession
abigen.IdentityPromisesSession
}

func DeployPromiseClearer(owner *bind.TransactOpts, erc20Token common.Address, fee int64, backend bind.ContractBackend) (*PromiseClearing, error) {
address, _, clearingContract, err := DeployIdentityPromises(owner, backend, erc20Token, big.NewInt(fee))
address, _, clearingContract, err := abigen.DeployIdentityPromises(owner, backend, erc20Token, big.NewInt(fee))
if err != nil {
return nil, err
}

return NewPromiseClearer(owner, clearingContract, address), nil
}

func NewPromiseClearer(transactOpts *bind.TransactOpts, contract *IdentityPromises, address common.Address) *PromiseClearing {
func NewPromiseClearer(transactOpts *bind.TransactOpts, contract *abigen.IdentityPromises, address common.Address) *PromiseClearing {
return &PromiseClearing{
address,
IdentityPromisesSession{
abigen.IdentityPromisesSession{
Contract: contract,
CallOpts: bind.CallOpts{},
TransactOpts: *transactOpts,
Expand Down Expand Up @@ -85,7 +84,7 @@ func (pc *PromiseClearing) ClearReceivedPromise(promise *ReceivedPromise) error
return err
}

func (pc *PromiseClearing) BindForEvents(eventChan chan<- *IdentityPromisesPromiseCleared) (event.Subscription, error) {
func (pc *PromiseClearing) BindForEvents(eventChan chan<- *abigen.IdentityPromisesPromiseCleared) (event.Subscription, error) {
start := uint64(0)
return pc.Contract.WatchPromiseCleared(&bind.WatchOpts{Start: &start}, eventChan, []common.Address{}, []common.Address{})
}
Expand Down
7 changes: 4 additions & 3 deletions promises/clearing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"
"time"

"github.com/mysteriumnetwork/payments/contracts/abigen"
"github.com/mysteriumnetwork/payments/mysttoken"
"github.com/mysteriumnetwork/payments/test_utils"
"github.com/stretchr/testify/assert"
Expand All @@ -16,8 +17,8 @@ var abiList, _ = test_utils.ParseAbis(test_utils.AbiMap{
mysttoken.MystTokenBin,
},
"IdentityPromises": {
IdentityPromisesABI,
IdentityPromisesBin,
abigen.IdentityPromisesABI,
abigen.IdentityPromisesBin,
},
})

Expand All @@ -35,7 +36,7 @@ func TestPromiseClearingEmitsClearedEvent(t *testing.T) {
assert.NoError(t, err)
backend.Commit()

events := make(chan *IdentityPromisesPromiseCleared, 1)
events := make(chan *abigen.IdentityPromisesPromiseCleared, 1)
sub, err := clearing.BindForEvents(events)
assert.NoError(t, err)

Expand Down

0 comments on commit 011ce6e

Please sign in to comment.