-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0824b39
commit 5dca9be
Showing
16 changed files
with
829 additions
and
88 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
syntax = "proto3"; | ||
package rarimo.rarimocore.rarimocore; | ||
|
||
import "rarimocore/params.proto"; | ||
|
||
option go_package = "github.com/rarimo/rarimo-core/x/rarimocore/types"; | ||
|
||
message Arbitrary { | ||
// Hex encoded data to be signed. AWARE do not make collisions with existing operations. | ||
string data = 1; | ||
} | ||
|
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,24 @@ | ||
package operation | ||
|
||
import ( | ||
"bytes" | ||
|
||
eth "github.com/ethereum/go-ethereum/crypto" | ||
merkle "github.com/rarimo/go-merkle" | ||
) | ||
|
||
// ArbitraryContent implements the Content interface provided by go-merkle and represents the content stored in the tree. | ||
type ArbitraryContent struct { | ||
Data []byte | ||
} | ||
|
||
var _ merkle.Content = ArbitraryContent{} | ||
|
||
func (c ArbitraryContent) CalculateHash() []byte { | ||
return eth.Keccak256(c.Data) | ||
} | ||
|
||
// Equals tests for equality of two Contents | ||
func (c ArbitraryContent) Equals(other merkle.Content) bool { | ||
return bytes.Equal(other.CalculateHash(), c.CalculateHash()) | ||
} |
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,24 @@ | ||
package pkg | ||
|
||
import ( | ||
"cosmossdk.io/errors" | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
"github.com/ethereum/go-ethereum/common/hexutil" | ||
"github.com/gogo/protobuf/proto" | ||
"github.com/rarimo/rarimo-core/x/rarimocore/crypto/operation" | ||
"github.com/rarimo/rarimo-core/x/rarimocore/types" | ||
) | ||
|
||
func GetArbitrary(operation types.Operation) (*types.Arbitrary, error) { | ||
if operation.OperationType == types.OpType_ARBITRARY { | ||
op := new(types.Arbitrary) | ||
return op, proto.Unmarshal(operation.Details.Value, op) | ||
} | ||
return nil, errors.Wrap(sdkerrors.ErrInvalidType, "invalid operation type") | ||
} | ||
|
||
func GetArbitraryContent(op *types.Arbitrary) (*operation.ArbitraryContent, error) { | ||
return &operation.ArbitraryContent{ | ||
Data: hexutil.MustDecode(op.Data), | ||
}, nil | ||
} |
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
Oops, something went wrong.