-
Notifications
You must be signed in to change notification settings - Fork 109
Swap Bounced Cheque Verification Process #2134
base: master
Are you sure you want to change the base?
Changes from 12 commits
5dd7877
0e36987
c57f5cb
c0ee1e9
df12915
a5e942e
7ae1bd2
2e05270
1ab8756
4716f90
a8a06ff
bbdde40
bde1927
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ import ( | |
| "github.com/ethereum/go-ethereum/accounts/abi/bind" | ||
| "github.com/ethereum/go-ethereum/common" | ||
| "github.com/ethereum/go-ethereum/core/types" | ||
| contract "github.com/ethersphere/go-sw3/contracts-v0-2-0/erc20simpleswap" | ||
| contract "github.com/ethersphere/go-sw3/contracts-v0-2-3/erc20simpleswap" | ||
| "github.com/ethersphere/swarm/swap/chain" | ||
| "github.com/ethersphere/swarm/swap/int256" | ||
| ) | ||
|
|
@@ -53,6 +53,8 @@ type Contract interface { | |
| Issuer(opts *bind.CallOpts) (common.Address, error) | ||
| // PaidOut returns the total paid out amount for the given address | ||
| PaidOut(opts *bind.CallOpts, addr common.Address) (*big.Int, error) | ||
| // Bounced returns if there has been a bounced cheque from the chequebook | ||
| Bounced(opts *bind.CallOpts) (bool, error) | ||
| } | ||
|
|
||
| // CashChequeResult summarizes the result of a CashCheque or CashChequeBeneficiary call | ||
|
|
@@ -91,6 +93,12 @@ func InstanceAt(address common.Address, backend chain.Backend) (Contract, error) | |
| return c, err | ||
| } | ||
|
|
||
| // Bounced obtains if a cheque has been bounced previously of a contract at a specific address. | ||
| // Once it's bounced, it will not change it's state again, unless re deployed. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you fixed the one that was correct, it should read:
|
||
| func (s simpleContract) Bounced(opts *bind.CallOpts) (bool, error) { | ||
| return s.instance.Bounced(opts) | ||
| } | ||
|
|
||
| // Withdraw withdraws amount from the chequebook and blocks until the transaction is mined | ||
| func (s simpleContract) Withdraw(auth *bind.TransactOpts, amount *big.Int) (*types.Receipt, error) { | ||
| tx, err := s.instance.Withdraw(auth, amount) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -463,6 +463,14 @@ func (s *Swap) processAndVerifyCheque(cheque *Cheque, p *Peer) (*int256.Uint256, | |
| return nil, err | ||
| } | ||
|
|
||
| bounced, err := p.getBouncedCheque() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the |
||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| if bounced { | ||
| return nil, ErrBouncedCheque | ||
| } | ||
|
|
||
| lastCheque := p.getLastReceivedCheque() | ||
|
|
||
| // TODO: there should probably be a lock here? | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.