-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ERC 1155 tokens bridge integration (#1332)
* Generate ERC1155 bindings * Initialize contracts * Deposit ERC1155 tokens * Withdraw ERC1155 tokens * ERC1155 E2E test * Rename withdraw result * Provide corret child predicate address to the root predicate * Pass E2E test * Refactor commands and E2E test a bit * Simplifications * Simplify ERC 20 bridge commands * Address comment * Comment * Move disabled root predicate dummy address to a const * Update SC spec * Fix ERC-1155 bridge e2e test * Regenerate SC without logs
- Loading branch information
1 parent
8165cd8
commit b2b7c15
Showing
22 changed files
with
1,406 additions
and
206 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 was deleted.
Oops, something went wrong.
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,78 @@ | ||
package common | ||
|
||
import ( | ||
"errors" | ||
) | ||
|
||
type TokenType int | ||
|
||
const ( | ||
ERC20 TokenType = iota | ||
ERC721 | ||
ERC1155 | ||
) | ||
|
||
const ( | ||
SenderKeyFlag = "sender-key" | ||
ReceiversFlag = "receivers" | ||
AmountsFlag = "amounts" | ||
TokenIDsFlag = "token-ids" | ||
|
||
RootTokenFlag = "root-token" | ||
RootPredicateFlag = "root-predicate" | ||
ChildPredicateFlag = "child-predicate" | ||
ChildTokenFlag = "child-token" | ||
JSONRPCFlag = "json-rpc" | ||
) | ||
|
||
var ( | ||
errInconsistentAmounts = errors.New("receivers and amounts must be equal length") | ||
errInconsistentTokenIds = errors.New("receivers and token ids must be equal length") | ||
) | ||
|
||
type BridgeParams struct { | ||
SenderKey string | ||
Receivers []string | ||
TokenAddr string | ||
PredicateAddr string | ||
JSONRPCAddr string | ||
} | ||
|
||
type ERC20BridgeParams struct { | ||
*BridgeParams | ||
Amounts []string | ||
} | ||
|
||
func NewERC20BridgeParams() *ERC20BridgeParams { | ||
return &ERC20BridgeParams{BridgeParams: &BridgeParams{}} | ||
} | ||
|
||
func (bp *ERC20BridgeParams) Validate() error { | ||
if len(bp.Receivers) != len(bp.Amounts) { | ||
return errInconsistentAmounts | ||
} | ||
|
||
return nil | ||
} | ||
|
||
type ERC1155BridgeParams struct { | ||
*BridgeParams | ||
Amounts []string | ||
TokenIDs []string | ||
} | ||
|
||
func NewERC1155BridgeParams() *ERC1155BridgeParams { | ||
return &ERC1155BridgeParams{BridgeParams: &BridgeParams{}} | ||
} | ||
|
||
func (bp *ERC1155BridgeParams) Validate() error { | ||
if len(bp.Receivers) != len(bp.Amounts) { | ||
return errInconsistentAmounts | ||
} | ||
|
||
if len(bp.Receivers) != len(bp.TokenIDs) { | ||
return errInconsistentTokenIds | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.