-
Notifications
You must be signed in to change notification settings - Fork 3
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
1d778a0
commit 0d414bd
Showing
5 changed files
with
94 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package contract_api | ||
|
||
import ( | ||
"github.com/hyperledger/fabric-chaincode-go/pkg/cid" | ||
"github.com/hyperledger/fabric-chaincode-go/shim" | ||
"github.com/hyperledger/fabric-contract-api-go/contractapi" | ||
"github.com/hyperledger/fabric-contract-api-go/metadata" | ||
) | ||
|
||
type ExtendedContract contractapi.Contract | ||
|
||
func (c *ExtendedContract) GetIgnoredFunctions() []string { | ||
return []string{ | ||
"GetClientIdentity", "GetStub", | ||
} | ||
} | ||
func (c *ExtendedContract) GetStub() shim.ChaincodeStubInterface { | ||
var context = c.TransactionContextHandler.(*contractapi.TransactionContext) | ||
return context.GetStub() | ||
} | ||
func (c *ExtendedContract) GetClientIdentity() cid.ClientIdentity { | ||
var context = c.TransactionContextHandler.(*contractapi.TransactionContext) | ||
return context.GetClientIdentity() | ||
} | ||
|
||
func (c *ExtendedContract) GetInfo() metadata.InfoMetadata { | ||
return c.Info | ||
} | ||
|
||
func (c *ExtendedContract) GetUnknownTransaction() interface{} { | ||
return c.UnknownTransaction | ||
} | ||
|
||
func (c *ExtendedContract) GetBeforeTransaction() interface{} { | ||
return c.BeforeTransaction | ||
} | ||
|
||
func (c *ExtendedContract) GetAfterTransaction() interface{} { | ||
return c.AfterTransaction | ||
} | ||
|
||
// GetName returns the name of the contract | ||
func (c *ExtendedContract) GetName() string { | ||
return c.Name | ||
} | ||
|
||
// GetTransactionContextHandler returns the current transaction context set for | ||
// the contract. If none has been set then TransactionContext will be returned | ||
func (c *ExtendedContract) GetTransactionContextHandler() contractapi.SettableTransactionContextInterface { | ||
if c.TransactionContextHandler == nil { | ||
return new(contractapi.TransactionContext) | ||
} | ||
|
||
return c.TransactionContextHandler | ||
} |
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,18 @@ | ||
package contract_api | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
type StupidContract struct { | ||
ExtendedContract | ||
} | ||
|
||
func (c *StupidContract) Ping() { | ||
|
||
} | ||
func TestBuild(t *testing.T) { | ||
|
||
Start(NewChaincode(&StupidContract{})) | ||
|
||
} |
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