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
package mapping_test | |
import ( | |
"testing" | |
"github.com/hyperledger/fabric/protos/peer" | |
"github.com/golang/protobuf/ptypes" | |
"github.com/golang/protobuf/proto" |
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
package cpaper | |
import ( | |
"fmt" | |
"github.com/pkg/errors" | |
"github.com/s7techlab/cckit/examples/cpaper/schema" | |
"github.com/s7techlab/cckit/extensions/debug" | |
"github.com/s7techlab/cckit/extensions/encryption" | |
"github.com/s7techlab/cckit/extensions/owner" |
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
var ( | |
// State mappings | |
StateMappings = m.StateMappings{}. | |
//key namespace will be <`CommercialPaper`, Issuer, PaperNumber> | |
Add(&schema.CommercialPaper{}, m.PKeySchema(&schema.CommercialPaperId{})) | |
// EventMappings | |
EventMappings = m.EventMappings{}. | |
// event name will be `IssueCommercialPaper`, payload - same as issue payload | |
Add(&schema.IssueCommercialPaper{}). |
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
syntax = "proto3"; | |
package schema; | |
import "google/protobuf/timestamp.proto"; | |
message CommercialPaper { | |
enum State { | |
ISSUED = 0; | |
TRADING = 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
type ( | |
// Key type | |
Key []string | |
// Keyer interface for entity containing logic of its key creation | |
Keyer interface { | |
Key() (Key, error) | |
} | |
) |
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
interface ChaincodeStubInterface { | |
// The function creates a key by combining the attributes into a single string. | |
// The arguments must be valid utf8 strings and must not contain U+0000 (nil byte) and U+10FFFF charactres. | |
func CreateCompositeKey(objectType string, attributes []string) (string, error) | |
// The function splits the compositeKey into attributes from which the key was formed. | |
// This function is useful for extracting attributes from keys returned by range queries. | |
func SplitCompositeKey(compositeKey string) (string, []string, error) | |
} |
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
type ( | |
// FromByter interface supports FromBytes func for converting from slice of bytes to target type | |
FromByter interface { | |
FromBytes([]byte) (interface{}, error) | |
} | |
// ToByter interface supports ToBytes func for converting to slice of bytes from source type | |
ToByter interface { | |
ToBytes() ([]byte, error) | |
} |
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
type State interface { | |
// Get returns value from state, converted to target type | |
// entry can be Key (string or []string) or type implementing Keyer interface | |
Get(entry interface{}, target ...interface{}) (result interface{}, err error) | |
// Get returns value from state, converted to int | |
// entry can be Key (string or []string) or type implementing Keyer interface | |
GetInt(entry interface{}, defaultValue int) (result int, err error) | |
// GetHistory returns slice of history records for entry, with values converted to target type |
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
ct := ContractType{} | |
err := json.Unmarshal([]byte(args[0]), &req) | |
if err != nil { | |
return shim.Error(err.Error()) | |
} | |
key, err := stub.CreateCompositeKey(prefixContractType, []string{req.UUID}) | |
if err != nil { | |
return shim.Error(err.Error()) |
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
Describe("ERC-20 transfer", func() { | |
It("Disallow to transfer token to same account", func() { | |
expectcc.ResponseError( | |
erc20fs.From(actors[`token_owner`]).Invoke( | |
`transfer`, actors[`token_owner`].GetMSPID(), actors[`token_owner`].GetID(), 100), | |
ErrForbiddenToTransferToSameAccount) | |
}) | |
It("Disallow token holder with zero balance to transfer tokens", func() { | |
expectcc.ResponseError( |
NewerOlder