Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/apiserver/route_get_contract_api_by_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
"github.com/hyperledger/firefly/pkg/core"
)

Expand All @@ -37,6 +38,9 @@ var getContractAPIByName = &ffapi.Route{
JSONOutputValue: func() interface{} { return &core.ContractAPI{} },
JSONOutputCodes: []int{http.StatusOK},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Contracts() != nil
},
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
return cr.or.Contracts().GetContractAPI(cr.ctx, cr.apiBaseURL, r.PP["apiName"])
},
Expand Down
4 changes: 4 additions & 0 deletions internal/apiserver/route_get_contract_api_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly-common/pkg/fftypes"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
)

var getContractAPIInterface = &ffapi.Route{
Expand All @@ -37,6 +38,9 @@ var getContractAPIInterface = &ffapi.Route{
JSONOutputValue: func() interface{} { return &fftypes.FFI{} },
JSONOutputCodes: []int{http.StatusOK},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Contracts() != nil
},
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
return cr.or.Contracts().GetContractAPIInterface(cr.ctx, r.PP["apiName"])
},
Expand Down
4 changes: 4 additions & 0 deletions internal/apiserver/route_get_contract_api_listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
"github.com/hyperledger/firefly/pkg/core"
"github.com/hyperledger/firefly/pkg/database"
)
Expand All @@ -39,6 +40,9 @@ var getContractAPIListeners = &ffapi.Route{
JSONOutputValue: func() interface{} { return []*core.ContractListener{} },
JSONOutputCodes: []int{http.StatusOK},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Contracts() != nil
},
FilterFactory: database.ContractListenerQueryFactory,
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
return filterResult(cr.or.Contracts().GetContractAPIListeners(cr.ctx, r.PP["apiName"], r.PP["eventPath"], cr.filter))
Expand Down
4 changes: 4 additions & 0 deletions internal/apiserver/route_get_contract_apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
"github.com/hyperledger/firefly/pkg/core"
"github.com/hyperledger/firefly/pkg/database"
)
Expand All @@ -36,6 +37,9 @@ var getContractAPIs = &ffapi.Route{
JSONOutputValue: func() interface{} { return []*core.ContractAPI{} },
JSONOutputCodes: []int{http.StatusOK},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Contracts() != nil
},
FilterFactory: database.ContractAPIQueryFactory,
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
return filterResult(cr.or.Contracts().GetContractAPIs(cr.ctx, cr.apiBaseURL, cr.filter))
Expand Down
4 changes: 4 additions & 0 deletions internal/apiserver/route_get_contract_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly-common/pkg/fftypes"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
)

var getContractInterface = &ffapi.Route{
Expand All @@ -40,6 +41,9 @@ var getContractInterface = &ffapi.Route{
JSONOutputValue: func() interface{} { return &fftypes.FFI{} },
JSONOutputCodes: []int{http.StatusOK},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Contracts() != nil
},
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
interfaceID, err := fftypes.ParseUUID(cr.ctx, r.PP["interfaceId"])
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly-common/pkg/fftypes"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
)

var getContractInterfaceNameVersion = &ffapi.Route{
Expand All @@ -41,6 +42,9 @@ var getContractInterfaceNameVersion = &ffapi.Route{
JSONOutputValue: func() interface{} { return &fftypes.FFI{} },
JSONOutputCodes: []int{http.StatusOK},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Contracts() != nil
},
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
if strings.EqualFold(r.QP["fetchchildren"], "true") {
return cr.or.Contracts().GetFFIWithChildren(cr.ctx, r.PP["name"], r.PP["version"])
Expand Down
1 change: 1 addition & 0 deletions internal/apiserver/route_get_contract_interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
func TestGetContractInterfaceBadID(t *testing.T) {
o, r := newTestAPIServer()
o.On("Authorize", mock.Anything, mock.Anything).Return(nil)
o.On("Contracts").Return(&contractmocks.Manager{})
input := core.Datatype{}
var buf bytes.Buffer
json.NewEncoder(&buf).Encode(&input)
Expand Down
4 changes: 4 additions & 0 deletions internal/apiserver/route_get_contract_interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly-common/pkg/fftypes"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
"github.com/hyperledger/firefly/pkg/database"
)

Expand All @@ -36,6 +37,9 @@ var getContractInterfaces = &ffapi.Route{
JSONOutputValue: func() interface{} { return []*fftypes.FFI{} },
JSONOutputCodes: []int{http.StatusOK},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Contracts() != nil
},
FilterFactory: database.FFIQueryFactory,
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
return filterResult(cr.or.Contracts().GetFFIs(cr.ctx, cr.filter))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
"github.com/hyperledger/firefly/pkg/core"
)

Expand All @@ -37,6 +38,9 @@ var getContractListenerByNameOrID = &ffapi.Route{
JSONOutputValue: func() interface{} { return &core.ContractListener{} },
JSONOutputCodes: []int{http.StatusOK},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Contracts() != nil
},
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
return cr.or.Contracts().GetContractListenerByNameOrID(cr.ctx, r.PP["nameOrId"])
},
Expand Down
4 changes: 4 additions & 0 deletions internal/apiserver/route_get_contract_listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
"github.com/hyperledger/firefly/pkg/core"
"github.com/hyperledger/firefly/pkg/database"
)
Expand All @@ -36,6 +37,9 @@ var getContractListeners = &ffapi.Route{
JSONOutputValue: func() interface{} { return []*core.ContractListener{} },
JSONOutputCodes: []int{http.StatusOK},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Contracts() != nil
},
FilterFactory: database.ContractListenerQueryFactory,
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
return filterResult(cr.or.Contracts().GetContractListeners(cr.ctx, cr.filter))
Expand Down
4 changes: 4 additions & 0 deletions internal/apiserver/route_post_contract_api_invoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
"github.com/hyperledger/firefly/pkg/core"
)

Expand All @@ -41,6 +42,9 @@ var postContractAPIInvoke = &ffapi.Route{
JSONOutputValue: func() interface{} { return &core.Operation{} },
JSONOutputCodes: []int{http.StatusOK, http.StatusAccepted},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Contracts() != nil
},
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
waitConfirm := strings.EqualFold(r.QP["confirm"], "true")
r.SuccessStatus = syncRetcode(waitConfirm)
Expand Down
4 changes: 4 additions & 0 deletions internal/apiserver/route_post_contract_api_listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
"github.com/hyperledger/firefly/pkg/core"
)

Expand All @@ -38,6 +39,9 @@ var postContractAPIListeners = &ffapi.Route{
JSONOutputValue: func() interface{} { return &core.ContractListener{} },
JSONOutputCodes: []int{http.StatusOK},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Contracts() != nil
},
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
return cr.or.Contracts().AddContractAPIListener(cr.ctx, r.PP["apiName"], r.PP["eventPath"], r.Input.(*core.ContractListener))
},
Expand Down
4 changes: 4 additions & 0 deletions internal/apiserver/route_post_contract_api_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
"github.com/hyperledger/firefly/pkg/core"
)

Expand All @@ -38,6 +39,9 @@ var postContractAPIQuery = &ffapi.Route{
JSONOutputValue: func() interface{} { return make(map[string]interface{}) },
JSONOutputCodes: []int{http.StatusOK},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Contracts() != nil
},
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
req := r.Input.(*core.ContractCallRequest)
req.Type = core.CallTypeQuery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly-common/pkg/fftypes"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
)

var postContractInterfaceGenerate = &ffapi.Route{
Expand All @@ -35,6 +36,9 @@ var postContractInterfaceGenerate = &ffapi.Route{
JSONOutputValue: func() interface{} { return &fftypes.FFI{} },
JSONOutputCodes: []int{http.StatusOK},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Contracts() != nil
},
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
generationRequest := r.Input.(*fftypes.FFIGenerationRequest)
return cr.or.Contracts().GenerateFFI(cr.ctx, generationRequest)
Expand Down
4 changes: 4 additions & 0 deletions internal/apiserver/route_post_contract_invoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
"github.com/hyperledger/firefly/pkg/core"
)

Expand All @@ -38,6 +39,9 @@ var postContractInvoke = &ffapi.Route{
JSONOutputValue: func() interface{} { return &core.Operation{} },
JSONOutputCodes: []int{http.StatusOK, http.StatusAccepted},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Contracts() != nil
},
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
waitConfirm := strings.EqualFold(r.QP["confirm"], "true")
r.SuccessStatus = syncRetcode(waitConfirm)
Expand Down
4 changes: 4 additions & 0 deletions internal/apiserver/route_post_contract_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
"github.com/hyperledger/firefly/pkg/core"
)

Expand All @@ -35,6 +36,9 @@ var postContractQuery = &ffapi.Route{
JSONOutputValue: func() interface{} { return make(map[string]interface{}) },
JSONOutputCodes: []int{http.StatusOK},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Contracts() != nil
},
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
req := r.Input.(*core.ContractCallRequest)
req.Type = core.CallTypeQuery
Expand Down
4 changes: 4 additions & 0 deletions internal/apiserver/route_post_new_contract_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
"github.com/hyperledger/firefly/pkg/core"
)

Expand All @@ -38,6 +39,9 @@ var postNewContractAPI = &ffapi.Route{
JSONOutputValue: func() interface{} { return &core.ContractAPI{} },
JSONOutputCodes: []int{http.StatusOK, http.StatusAccepted},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Contracts() != nil
},
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
waitConfirm := strings.EqualFold(r.QP["confirm"], "true")
r.SuccessStatus = syncRetcode(waitConfirm)
Expand Down
3 changes: 3 additions & 0 deletions internal/apiserver/route_post_new_contract_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"net/http/httptest"
"testing"

"github.com/hyperledger/firefly/mocks/contractmocks"
"github.com/hyperledger/firefly/mocks/definitionsmocks"
"github.com/hyperledger/firefly/pkg/core"
"github.com/stretchr/testify/assert"
Expand All @@ -32,6 +33,7 @@ func TestPostNewContractAPI(t *testing.T) {
o, r := newTestAPIServer()
o.On("Authorize", mock.Anything, mock.Anything).Return(nil)
mds := &definitionsmocks.Sender{}
o.On("Contracts").Return(&contractmocks.Manager{})
o.On("DefinitionSender").Return(mds)
input := core.Datatype{}
var buf bytes.Buffer
Expand All @@ -50,6 +52,7 @@ func TestPostNewContractAPISync(t *testing.T) {
o, r := newTestAPIServer()
o.On("Authorize", mock.Anything, mock.Anything).Return(nil)
mds := &definitionsmocks.Sender{}
o.On("Contracts").Return(&contractmocks.Manager{})
o.On("DefinitionSender").Return(mds)
input := core.Datatype{}
var buf bytes.Buffer
Expand Down
4 changes: 4 additions & 0 deletions internal/apiserver/route_post_new_contract_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly-common/pkg/fftypes"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
)

var postNewContractInterface = &ffapi.Route{
Expand All @@ -38,6 +39,9 @@ var postNewContractInterface = &ffapi.Route{
JSONOutputValue: func() interface{} { return &fftypes.FFI{} },
JSONOutputCodes: []int{http.StatusOK},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Contracts() != nil
},
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
waitConfirm := strings.EqualFold(r.QP["confirm"], "true")
r.SuccessStatus = syncRetcode(waitConfirm)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"net/http/httptest"
"testing"

"github.com/hyperledger/firefly/mocks/contractmocks"
"github.com/hyperledger/firefly/mocks/definitionsmocks"
"github.com/hyperledger/firefly/pkg/core"
"github.com/stretchr/testify/assert"
Expand All @@ -32,6 +33,7 @@ func TestPostNewContractInterface(t *testing.T) {
o, r := newTestAPIServer()
o.On("Authorize", mock.Anything, mock.Anything).Return(nil)
mds := &definitionsmocks.Sender{}
o.On("Contracts").Return(&contractmocks.Manager{})
o.On("DefinitionSender").Return(mds)
input := core.Datatype{}
var buf bytes.Buffer
Expand All @@ -50,6 +52,7 @@ func TestPostNewContractInterfaceSync(t *testing.T) {
o, r := newTestAPIServer()
o.On("Authorize", mock.Anything, mock.Anything).Return(nil)
mds := &definitionsmocks.Sender{}
o.On("Contracts").Return(&contractmocks.Manager{})
o.On("DefinitionSender").Return(mds)
input := core.Datatype{}
var buf bytes.Buffer
Expand Down
4 changes: 4 additions & 0 deletions internal/apiserver/route_post_new_contract_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
"github.com/hyperledger/firefly/pkg/core"
)

Expand All @@ -35,6 +36,9 @@ var postNewContractListener = &ffapi.Route{
JSONOutputValue: func() interface{} { return &core.ContractListener{} },
JSONOutputCodes: []int{http.StatusOK},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Contracts() != nil
},
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
return cr.or.Contracts().AddContractListener(cr.ctx, r.Input.(*core.ContractListenerInput))
},
Expand Down
4 changes: 4 additions & 0 deletions internal/apiserver/route_put_contract_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/hyperledger/firefly-common/pkg/ffapi"
"github.com/hyperledger/firefly-common/pkg/fftypes"
"github.com/hyperledger/firefly/internal/coremsgs"
"github.com/hyperledger/firefly/internal/orchestrator"
"github.com/hyperledger/firefly/pkg/core"
)

Expand All @@ -41,6 +42,9 @@ var putContractAPI = &ffapi.Route{
JSONOutputValue: func() interface{} { return &core.ContractAPI{} },
JSONOutputCodes: []int{http.StatusOK, http.StatusAccepted},
Extensions: &coreExtensions{
EnabledIf: func(or orchestrator.Orchestrator) bool {
return or.Contracts() != nil
},
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
waitConfirm := strings.EqualFold(r.QP["confirm"], "true")
r.SuccessStatus = syncRetcode(waitConfirm)
Expand Down
Loading