diff --git a/doc-site/docs/tutorials/custom_contracts/cardano.md b/doc-site/docs/tutorials/custom_contracts/cardano.md index 22f4d8a8cc..8d8301facc 100644 --- a/doc-site/docs/tutorials/custom_contracts/cardano.md +++ b/doc-site/docs/tutorials/custom_contracts/cardano.md @@ -101,6 +101,7 @@ First, decide on the contract which your dApp will satisfy. FireFly uses [FireFl This is describing a contract with a single method, named `send_ada`. This method takes three parameters: a `fromAddress`, a `toAddress`, and an `amount`. It also emits three events: + - `TransactionAccepted(string)` is emitted when the transaction is included in a block. - `TransactionRolledBack(string)` is emitted if the transaction was included in a block, and that block got rolled back. This happens maybe once or twice a day on the Cardano network, which is more likely than some other chains, so your code must be able to gracefully handle rollbacks. - `TransactionFinalized(string)` is emitted when the transaction has been on the chain for "long enough" that it is effectively immutable. It is up to your tolerance risk. @@ -121,7 +122,7 @@ edition = "2021" [dependencies] # The version of firefly-balius should match the version of firefly-cardano which you are using. -firefly-balius = { git = "https://github.com/hyperledger/firefly-cardano", rev = "0.4.2" } +firefly-balius = { git = "https://github.com/hyperledger/firefly-cardano", rev = "" } pallas-addresses = "0.32" serde = { version = "1", features = ["derive"] } @@ -236,6 +237,7 @@ fn main() -> Worker { You can use the `firefly-cardano-deploy` tool to deploy this dApp to your running FireFly instance. This tool will + - Compile your dApp to WebAssembly - Deploy that WebAssembly to a running FireFly node - Deploy your interface to that FireFly node @@ -243,7 +245,7 @@ This tool will ```sh # The version here should match the version of firefly-cardano which you are using. -cargo install --git https://github.com/hyperledger/firefly-cardano --version 0.3.1 firefly-cardano-deploy +cargo install --git https://github.com/hyperledger/firefly-cardano --version firefly-cardano-deploy CONTRACT_PATH="/path/to/your/dapp" FIREFLY_URL="http://localhost:5000" @@ -272,7 +274,8 @@ Now that we've set everything up, let's prove it works by sending 1 ADA back to "fromAddress": "", "toAddress": "addr_test1vqeux7xwusdju9dvsj8h7mca9aup2k439kfmwy773xxc2hcu7zy99", "amount": 1000000 - } + }, + "key": "" } ``` diff --git a/internal/blockchain/cardano/cardano.go b/internal/blockchain/cardano/cardano.go index 14d8e46d21..5b7be00480 100644 --- a/internal/blockchain/cardano/cardano.go +++ b/internal/blockchain/cardano/cardano.go @@ -111,7 +111,7 @@ func (c *Cardano) Init(ctx context.Context, cancelCtx context.CancelFunc, conf c } if c.wsConfig.WSKeyPath == "" { - c.wsConfig.WSKeyPath = "/ws" + c.wsConfig.WSKeyPath = "/api/v1/ws" } c.streamIDs = make(map[string]string) @@ -243,7 +243,7 @@ func (c *Cardano) DeployContract(ctx context.Context, nsOpID, signingKey string, SetContext(ctx). SetBody(body). SetError(&resErr). - Post("/contracts/deploy") + Post("/api/v1/contracts/deploy") if err != nil || !res.IsSuccess() { return resErr.SubmissionRejected, common.WrapRESTError(ctx, &resErr, res, err, coremsgs.MsgCardanoconnectRESTErr) } @@ -287,7 +287,7 @@ func (c *Cardano) InvokeContract(ctx context.Context, nsOpID string, signingKey SetContext(ctx). SetBody(body). SetError(&resErr). - Post("/contracts/invoke") + Post("/api/v1/contracts/invoke") if err != nil || !res.IsSuccess() { return resErr.SubmissionRejected, common.WrapRESTError(ctx, &resErr, res, err, coremsgs.MsgCardanoconnectRESTErr) } @@ -324,7 +324,7 @@ func (c *Cardano) QueryContract(ctx context.Context, signingKey string, location SetContext(ctx). SetBody(body). SetError(&resErr). - Post("/contracts/query") + Post("/api/v1/contracts/query") if err != nil || !res.IsSuccess() { return nil, common.WrapRESTError(ctx, &resErr, res, err, coremsgs.MsgCardanoconnectRESTErr) } @@ -488,7 +488,7 @@ func (c *Cardano) GetAndConvertDeprecatedContractConfig(ctx context.Context) (lo func (c *Cardano) GetTransactionStatus(ctx context.Context, operation *core.Operation) (interface{}, error) { txnID := (&core.PreparedOperation{ID: operation.ID, Namespace: operation.Namespace}).NamespacedIDString() - transactionRequestPath := fmt.Sprintf("/transactions/%s", txnID) + transactionRequestPath := fmt.Sprintf("/api/v1/transactions/%s", txnID) client := c.client var resErr common.BlockchainRESTError var statusResponse fftypes.JSONObject diff --git a/internal/blockchain/cardano/cardano_test.go b/internal/blockchain/cardano/cardano_test.go index 4ca5fc0cf1..b6375903cd 100644 --- a/internal/blockchain/cardano/cardano_test.go +++ b/internal/blockchain/cardano/cardano_test.go @@ -142,9 +142,9 @@ func TestInitAndStartWithCardanoConnect(t *testing.T) { u.Scheme = "http" httpURL := u.String() - httpmock.RegisterResponder("GET", fmt.Sprintf("%s/eventstreams", httpURL), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/api/v1/eventstreams", httpURL), httpmock.NewJsonResponderOrPanic(200, []eventStream{})) - httpmock.RegisterResponder("POST", fmt.Sprintf("%s/eventstreams", httpURL), + httpmock.RegisterResponder("POST", fmt.Sprintf("%s/api/v1/eventstreams", httpURL), httpmock.NewJsonResponderOrPanic(200, eventStream{ID: "es12345"})) resetConf(c) @@ -209,7 +209,7 @@ func TestStartNamespaceStreamQueryError(t *testing.T) { httpmock.ActivateNonDefault(mockedClient) defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder("GET", "http://localhost:12345/eventstreams", + httpmock.RegisterResponder("GET", "http://localhost:12345/api/v1/eventstreams", httpmock.NewStringResponder(500, `pop`)) resetConf(c) @@ -233,9 +233,9 @@ func TestStartNamespaceStreamCreateError(t *testing.T) { httpmock.ActivateNonDefault(mockedClient) defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder("GET", "http://localhost:12345/eventstreams", + httpmock.RegisterResponder("GET", "http://localhost:12345/api/v1/eventstreams", httpmock.NewJsonResponderOrPanic(200, []eventStream{})) - httpmock.RegisterResponder("POST", "http://localhost:12345/eventstreams", + httpmock.RegisterResponder("POST", "http://localhost:12345/api/v1/eventstreams", httpmock.NewStringResponder(500, "pop")) resetConf(c) @@ -259,9 +259,9 @@ func TestStartNamespaceStreamUpdateError(t *testing.T) { httpmock.ActivateNonDefault(mockedClient) defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder("GET", "http://localhost:12345/eventstreams", + httpmock.RegisterResponder("GET", "http://localhost:12345/api/v1/eventstreams", httpmock.NewJsonResponderOrPanic(200, []eventStream{{ID: "es12345", Name: "topic1/ns1"}})) - httpmock.RegisterResponder("PATCH", "http://localhost:12345/eventstreams/es12345", + httpmock.RegisterResponder("PATCH", "http://localhost:12345/api/v1/eventstreams/es12345", httpmock.NewStringResponder(500, "pop")) resetConf(c) @@ -287,11 +287,11 @@ func TestStartNamespaceWSConnectFail(t *testing.T) { httpURL := "http://localhost:12345" - httpmock.RegisterResponder("GET", fmt.Sprintf("%s/eventstreams", httpURL), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/api/v1/eventstreams", httpURL), httpmock.NewJsonResponderOrPanic(200, []eventStream{})) - httpmock.RegisterResponder("POST", fmt.Sprintf("%s/eventstreams", httpURL), + httpmock.RegisterResponder("POST", fmt.Sprintf("%s/api/v1/eventstreams", httpURL), httpmock.NewJsonResponderOrPanic(200, eventStream{ID: "es12345"})) - httpmock.RegisterResponder("GET", fmt.Sprintf("%s/ws", httpURL), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/api/v1/ws", httpURL), httpmock.NewJsonResponderOrPanic(500, "{}")) resetConf(c) @@ -322,9 +322,9 @@ func TestStartStopNamespace(t *testing.T) { u.Scheme = "http" httpURL := u.String() - httpmock.RegisterResponder("GET", fmt.Sprintf("%s/eventstreams", httpURL), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/api/v1/eventstreams", httpURL), httpmock.NewJsonResponderOrPanic(200, []eventStream{})) - httpmock.RegisterResponder("POST", fmt.Sprintf("%s/eventstreams", httpURL), + httpmock.RegisterResponder("POST", fmt.Sprintf("%s/api/v1/eventstreams", httpURL), httpmock.NewJsonResponderOrPanic(200, eventStream{ID: "es12345"})) resetConf(c) @@ -439,7 +439,7 @@ func TestEventLoopReceiveBatch(t *testing.T) { httpmock.ActivateNonDefault(mockedClient) defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder("GET", "http://localhost:12345/eventstreams/es12345/listeners/lst12345", + httpmock.RegisterResponder("GET", "http://localhost:12345/api/v1/eventstreams/es12345/listeners/lst12345", httpmock.NewJsonResponderOrPanic(200, listener{ID: "lst12345", Name: "ff-sub-default-12345"})) r := make(chan []byte) @@ -511,7 +511,7 @@ func TestEventLoopReceiveBadBatch(t *testing.T) { httpmock.ActivateNonDefault(mockedClient) defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder("GET", "http://localhost:12345/eventstreams/es12345/listeners/lst12345", + httpmock.RegisterResponder("GET", "http://localhost:12345/api/v1/eventstreams/es12345/listeners/lst12345", httpmock.NewJsonResponderOrPanic(200, listener{ID: "lst12345", Name: "ff-sub-default-12345"})) client := resty.NewWithClient(mockedClient) client.SetBaseURL("http://localhost:12345") @@ -771,7 +771,7 @@ func TestAddContractListener(t *testing.T) { }, } - httpmock.RegisterResponder("POST", "http://localhost:12345/eventstreams/es-1/listeners", + httpmock.RegisterResponder("POST", "http://localhost:12345/api/v1/eventstreams/es-1/listeners", httpmock.NewJsonResponderOrPanic(200, &listener{ID: "new-id"})) err := c.AddContractListener(context.Background(), sub, "") @@ -824,7 +824,7 @@ func TestAddContractListenerBadLocation(t *testing.T) { }, } - httpmock.RegisterResponder("POST", "http://localhost:12345/eventstreams/es-1/listeners", + httpmock.RegisterResponder("POST", "http://localhost:12345/api/v1/eventstreams/es-1/listeners", httpmock.NewJsonResponderOrPanic(200, &listener{ID: "new-id"})) err := c.AddContractListener(context.Background(), sub, "") @@ -844,7 +844,7 @@ func TestDeleteContractListener(t *testing.T) { BackendID: "sb-1", } - httpmock.RegisterResponder("DELETE", `http://localhost:12345/eventstreams/es-1/listeners/sb-1`, + httpmock.RegisterResponder("DELETE", `http://localhost:12345/api/v1/eventstreams/es-1/listeners/sb-1`, httpmock.NewStringResponder(204, "")) err := c.DeleteContractListener(context.Background(), sub, true) @@ -864,7 +864,7 @@ func TestDeleteContractListenerFail(t *testing.T) { BackendID: "sb-1", } - httpmock.RegisterResponder("DELETE", `http://localhost:12345/eventstreams/es-1/listeners/sb-1`, + httpmock.RegisterResponder("DELETE", `http://localhost:12345/api/v1/eventstreams/es-1/listeners/sb-1`, httpmock.NewStringResponder(500, "oops")) err := c.DeleteContractListener(context.Background(), sub, true) @@ -879,7 +879,7 @@ func TestGetContractListenerStatus(t *testing.T) { c.streamIDs["ns1"] = "es-1" - httpmock.RegisterResponder("GET", `http://localhost:12345/eventstreams/es-1/listeners/sb-1`, + httpmock.RegisterResponder("GET", `http://localhost:12345/api/v1/eventstreams/es-1/listeners/sb-1`, httpmock.NewJsonResponderOrPanic(200, &listener{ID: "sb-1", Name: "something"})) found, _, status, err := c.GetContractListenerStatus(context.Background(), "ns1", "sb-1", true) @@ -896,7 +896,7 @@ func TestGetContractListenerStatusNotFound(t *testing.T) { c.streamIDs["ns1"] = "es-1" - httpmock.RegisterResponder("GET", `http://localhost:12345/eventstreams/es-1/listeners/sb-1`, + httpmock.RegisterResponder("GET", `http://localhost:12345/api/v1/eventstreams/es-1/listeners/sb-1`, httpmock.NewStringResponder(404, "no")) found, _, status, err := c.GetContractListenerStatus(context.Background(), "ns1", "sb-1", true) @@ -913,7 +913,7 @@ func TestGetContractListenerErrorNotFound(t *testing.T) { c.streamIDs["ns1"] = "es-1" - httpmock.RegisterResponder("GET", `http://localhost:12345/eventstreams/es-1/listeners/sb-1`, + httpmock.RegisterResponder("GET", `http://localhost:12345/api/v1/eventstreams/es-1/listeners/sb-1`, httpmock.NewStringResponder(404, "no")) _, _, _, err := c.GetContractListenerStatus(context.Background(), "ns1", "sb-1", false) @@ -933,7 +933,7 @@ func TestGetTransactionStatusSuccess(t *testing.T) { Status: "Pending", } - httpmock.RegisterResponder("GET", "http://localhost:12345/transactions/ns1:9ffc50ff-6bfe-4502-adc7-93aea54cc059", + httpmock.RegisterResponder("GET", "http://localhost:12345/api/v1/transactions/ns1:9ffc50ff-6bfe-4502-adc7-93aea54cc059", func(req *http.Request) (*http.Response, error) { transactionStatus := make(map[string]interface{}) transactionStatus["id"] = "ns1:9ffc50ff-6bfe-4502-adc7-93aea54cc059" @@ -960,7 +960,7 @@ func TestGetTransactionStatusFailure(t *testing.T) { Status: "Pending", } - httpmock.RegisterResponder("GET", "http://localhost:12345/transactions/ns1:9ffc50ff-6bfe-4502-adc7-93aea54cc059", + httpmock.RegisterResponder("GET", "http://localhost:12345/api/v1/transactions/ns1:9ffc50ff-6bfe-4502-adc7-93aea54cc059", func(req *http.Request) (*http.Response, error) { transactionStatus := make(map[string]interface{}) transactionStatus["id"] = "ns1:9ffc50ff-6bfe-4502-adc7-93aea54cc059" @@ -987,7 +987,7 @@ func TestGetTransactionStatusEmptyObject(t *testing.T) { Status: "Pending", } - httpmock.RegisterResponder("GET", "http://localhost:12345/transactions/ns1:9ffc50ff-6bfe-4502-adc7-93aea54cc059", + httpmock.RegisterResponder("GET", "http://localhost:12345/api/v1/transactions/ns1:9ffc50ff-6bfe-4502-adc7-93aea54cc059", func(req *http.Request) (*http.Response, error) { transactionStatus := make(map[string]interface{}) return httpmock.NewJsonResponderOrPanic(200, transactionStatus)(req) @@ -1011,7 +1011,7 @@ func TestGetTransactionStatusInvalidTx(t *testing.T) { Status: "Pending", } - httpmock.RegisterResponder("GET", "http://localhost:12345/transactions/:9ffc50ff-6bfe-4502-adc7-93aea54cc059", + httpmock.RegisterResponder("GET", "http://localhost:12345/api/v1/transactions/:9ffc50ff-6bfe-4502-adc7-93aea54cc059", func(req *http.Request) (*http.Response, error) { transactionStatus := make(map[string]interface{}) transactionStatus["status"] = "Failed" @@ -1037,7 +1037,7 @@ func TestGetTransactionStatusNotFound(t *testing.T) { Status: "Pending", } - httpmock.RegisterResponder("GET", "http://localhost:12345/transactions/ns1:9ffc50ff-6bfe-4502-adc7-93aea54cc059", + httpmock.RegisterResponder("GET", "http://localhost:12345/api/v1/transactions/ns1:9ffc50ff-6bfe-4502-adc7-93aea54cc059", httpmock.NewStringResponder(404, "nah")) status, err := c.GetTransactionStatus(context.Background(), op) @@ -1058,7 +1058,7 @@ func TestGetTransactionStatusError(t *testing.T) { Status: "Pending", } - httpmock.RegisterResponder("GET", "http://localhost:12345/transactions/ns1:9ffc50ff-6bfe-4502-adc7-93aea54cc059", + httpmock.RegisterResponder("GET", "http://localhost:12345/api/v1/transactions/ns1:9ffc50ff-6bfe-4502-adc7-93aea54cc059", httpmock.NewStringResponder(500, "uh oh")) _, err := c.GetTransactionStatus(context.Background(), op) @@ -1078,7 +1078,7 @@ func TestGetTransactionStatusHandleReceipt(t *testing.T) { Status: "Pending", } - httpmock.RegisterResponder("GET", "http://localhost:12345/transactions/ns1:9ffc50ff-6bfe-4502-adc7-93aea54cc059", + httpmock.RegisterResponder("GET", "http://localhost:12345/api/v1/transactions/ns1:9ffc50ff-6bfe-4502-adc7-93aea54cc059", func(req *http.Request) (*http.Response, error) { transactionStatus := make(map[string]interface{}) transactionStatus["status"] = "Succeeded" @@ -1106,7 +1106,7 @@ func TestAddFireflySubscriptionBadLocation(t *testing.T) { httpmock.ActivateNonDefault(mockedClient) defer httpmock.DeactivateAndReset() - httpmock.RegisterResponder("GET", "http://localhost:12345/eventstreams/es12345/listeners", + httpmock.RegisterResponder("GET", "http://localhost:12345/api/v1/eventstreams/es12345/listeners", httpmock.NewJsonResponderOrPanic(200, &[]listener{})) client := resty.NewWithClient(mockedClient) client.SetBaseURL("http://localhost:12345") @@ -1140,13 +1140,13 @@ func TestAddAndRemoveFireflySubscription(t *testing.T) { u.Scheme = "http" httpURL := u.String() - httpmock.RegisterResponder("GET", fmt.Sprintf("%s/eventstreams", httpURL), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/api/v1/eventstreams", httpURL), httpmock.NewJsonResponderOrPanic(200, []eventStream{{ID: "es12345", Name: "topic1/ns1"}})) - httpmock.RegisterResponder("PATCH", fmt.Sprintf("%s/eventstreams/es12345", httpURL), + httpmock.RegisterResponder("PATCH", fmt.Sprintf("%s/api/v1/eventstreams/es12345", httpURL), httpmock.NewJsonResponderOrPanic(200, eventStream{ID: "es12345", Name: "topic1/ns1"})) - httpmock.RegisterResponder("GET", fmt.Sprintf("%s/eventstreams/es12345/listeners", httpURL), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/api/v1/eventstreams/es12345/listeners", httpURL), httpmock.NewJsonResponderOrPanic(200, []listener{})) - httpmock.RegisterResponder("POST", fmt.Sprintf("%s/eventstreams/es12345/listeners", httpURL), + httpmock.RegisterResponder("POST", fmt.Sprintf("%s/api/v1/eventstreams/es12345/listeners", httpURL), httpmock.NewJsonResponderOrPanic(200, listener{ID: "lst12345", Name: "ns1_2_BatchPin"})) resetConf(c) @@ -1195,11 +1195,11 @@ func TestAddFireflySubscriptionListError(t *testing.T) { u.Scheme = "http" httpURL := u.String() - httpmock.RegisterResponder("GET", fmt.Sprintf("%s/eventstreams", httpURL), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/api/v1/eventstreams", httpURL), httpmock.NewJsonResponderOrPanic(200, []eventStream{{ID: "es12345", Name: "topic1/ns1"}})) - httpmock.RegisterResponder("PATCH", fmt.Sprintf("%s/eventstreams/es12345", httpURL), + httpmock.RegisterResponder("PATCH", fmt.Sprintf("%s/api/v1/eventstreams/es12345", httpURL), httpmock.NewJsonResponderOrPanic(200, eventStream{ID: "es12345", Name: "topic1/ns1"})) - httpmock.RegisterResponder("GET", fmt.Sprintf("%s/eventstreams/es12345/listeners", httpURL), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/api/v1/eventstreams/es12345/listeners", httpURL), httpmock.NewStringResponder(500, "whoopsies")) resetConf(c) @@ -1244,11 +1244,11 @@ func TestAddFireflySubscriptionAlreadyExists(t *testing.T) { u.Scheme = "http" httpURL := u.String() - httpmock.RegisterResponder("GET", fmt.Sprintf("%s/eventstreams", httpURL), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/api/v1/eventstreams", httpURL), httpmock.NewJsonResponderOrPanic(200, []eventStream{{ID: "es12345", Name: "topic1/ns1"}})) - httpmock.RegisterResponder("PATCH", fmt.Sprintf("%s/eventstreams/es12345", httpURL), + httpmock.RegisterResponder("PATCH", fmt.Sprintf("%s/api/v1/eventstreams/es12345", httpURL), httpmock.NewJsonResponderOrPanic(200, eventStream{ID: "es12345", Name: "topic1/ns1"})) - httpmock.RegisterResponder("GET", fmt.Sprintf("%s/eventstreams/es12345/listeners", httpURL), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/api/v1/eventstreams/es12345/listeners", httpURL), httpmock.NewJsonResponderOrPanic(200, []listener{{ID: "lst12345", Name: "ns1_2_BatchPin"}})) resetConf(c) @@ -1293,13 +1293,13 @@ func TestAddFireflySubscriptionCreateError(t *testing.T) { u.Scheme = "http" httpURL := u.String() - httpmock.RegisterResponder("GET", fmt.Sprintf("%s/eventstreams", httpURL), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/api/v1/eventstreams", httpURL), httpmock.NewJsonResponderOrPanic(200, []eventStream{{ID: "es12345", Name: "topic1/ns1"}})) - httpmock.RegisterResponder("PATCH", fmt.Sprintf("%s/eventstreams/es12345", httpURL), + httpmock.RegisterResponder("PATCH", fmt.Sprintf("%s/api/v1/eventstreams/es12345", httpURL), httpmock.NewJsonResponderOrPanic(200, eventStream{ID: "es12345", Name: "topic1/ns1"})) - httpmock.RegisterResponder("GET", fmt.Sprintf("%s/eventstreams/es12345/listeners", httpURL), + httpmock.RegisterResponder("GET", fmt.Sprintf("%s/api/v1/eventstreams/es12345/listeners", httpURL), httpmock.NewJsonResponderOrPanic(200, []listener{})) - httpmock.RegisterResponder("POST", fmt.Sprintf("%s/eventstreams/es12345/listeners", httpURL), + httpmock.RegisterResponder("POST", fmt.Sprintf("%s/api/v1/eventstreams/es12345/listeners", httpURL), httpmock.NewStringResponder(500, "whoopsies")) resetConf(c) @@ -1348,7 +1348,7 @@ func TestInvokeContractOK(t *testing.T) { locationBytes, err := json.Marshal(location) assert.NoError(t, err) - httpmock.RegisterResponder("POST", "http://localhost:12345/contracts/invoke", func(req *http.Request) (*http.Response, error) { + httpmock.RegisterResponder("POST", "http://localhost:12345/api/v1/contracts/invoke", func(req *http.Request) (*http.Response, error) { var body map[string]interface{} json.NewDecoder(req.Body).Decode(&body) params := body["params"].([]interface{}) @@ -1436,7 +1436,7 @@ func TestInvokeContractConnectorError(t *testing.T) { locationBytes, err := json.Marshal(location) assert.NoError(t, err) - httpmock.RegisterResponder("POST", "http://localhost:12345/contracts/invoke", func(req *http.Request) (*http.Response, error) { + httpmock.RegisterResponder("POST", "http://localhost:12345/api/v1/contracts/invoke", func(req *http.Request) (*http.Response, error) { var body map[string]interface{} json.NewDecoder(req.Body).Decode(&body) params := body["params"].([]interface{}) @@ -1478,7 +1478,7 @@ func TestQueryContractOK(t *testing.T) { locationBytes, err := json.Marshal(location) assert.NoError(t, err) - httpmock.RegisterResponder("POST", "http://localhost:12345/contracts/query", func(req *http.Request) (*http.Response, error) { + httpmock.RegisterResponder("POST", "http://localhost:12345/api/v1/contracts/query", func(req *http.Request) (*http.Response, error) { var body map[string]interface{} json.NewDecoder(req.Body).Decode(&body) params := body["params"].([]interface{}) @@ -1569,7 +1569,7 @@ func TestQueryContractConnectorError(t *testing.T) { locationBytes, err := json.Marshal(location) assert.NoError(t, err) - httpmock.RegisterResponder("POST", "http://localhost:12345/contracts/invoke", func(req *http.Request) (*http.Response, error) { + httpmock.RegisterResponder("POST", "http://localhost:12345/api/v1/contracts/invoke", func(req *http.Request) (*http.Response, error) { var body map[string]interface{} json.NewDecoder(req.Body).Decode(&body) params := body["params"].([]interface{}) @@ -1609,7 +1609,7 @@ func TestQueryContractInvalidJson(t *testing.T) { locationBytes, err := json.Marshal(location) assert.NoError(t, err) - httpmock.RegisterResponder("POST", "http://localhost:12345/contracts/query", httpmock.NewStringResponder(200, "\"whoops forgot a quote")) + httpmock.RegisterResponder("POST", "http://localhost:12345/api/v1/contracts/query", httpmock.NewStringResponder(200, "\"whoops forgot a quote")) parsedMethod, err := c.ParseInterface(context.Background(), method, nil) assert.NoError(t, err) @@ -1628,7 +1628,7 @@ func TestDeployContractOK(t *testing.T) { definition := fftypes.JSONAnyPtr("{}") contract := fftypes.JSONAnyPtr("\"cafed00d\"") - httpmock.RegisterResponder("POST", "http://localhost:12345/contracts/deploy", + httpmock.RegisterResponder("POST", "http://localhost:12345/api/v1/contracts/deploy", httpmock.NewStringResponder(202, "")) _, err := c.DeployContract(context.Background(), nsOpId, signingKey, definition, contract, nil, nil) @@ -1645,7 +1645,7 @@ func TestDeployContractConnectorError(t *testing.T) { definition := fftypes.JSONAnyPtr("{}") contract := fftypes.JSONAnyPtr("\"cafed00d\"") - httpmock.RegisterResponder("POST", "http://localhost:12345/contracts/deploy", + httpmock.RegisterResponder("POST", "http://localhost:12345/api/v1/contracts/deploy", httpmock.NewJsonResponderOrPanic(500, &common.BlockchainRESTError{ Error: "oh no", SubmissionRejected: true, diff --git a/internal/blockchain/cardano/eventstream.go b/internal/blockchain/cardano/eventstream.go index 5a27011eb0..aaa122e8a4 100644 --- a/internal/blockchain/cardano/eventstream.go +++ b/internal/blockchain/cardano/eventstream.go @@ -68,7 +68,7 @@ func (s *streamManager) getEventStreams(ctx context.Context) (streams []*eventSt res, err := s.client.R(). SetContext(ctx). SetResult(&streams). - Get("/eventstreams") + Get("/api/v1/eventstreams") if err != nil || !res.IsSuccess() { return nil, ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgCardanoconnectRESTErr) } @@ -92,7 +92,7 @@ func (s *streamManager) createEventStream(ctx context.Context, topic string) (*e SetContext(ctx). SetBody(stream). SetResult(stream). - Post("/eventstreams") + Post("/api/v1/eventstreams") if err != nil || !res.IsSuccess() { return nil, ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgCardanoconnectRESTErr) } @@ -105,7 +105,7 @@ func (s *streamManager) updateEventStream(ctx context.Context, topic string, bat SetContext(ctx). SetBody(stream). SetResult(stream). - Patch("/eventstreams/" + eventStreamID) + Patch("/api/v1/eventstreams/" + eventStreamID) if err != nil || !res.IsSuccess() { return nil, ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgCardanoconnectRESTErr) } @@ -133,7 +133,7 @@ func (s *streamManager) getListener(ctx context.Context, streamID string, listen res, err := s.client.R(). SetContext(ctx). SetResult(&listener). - Get(fmt.Sprintf("/eventstreams/%s/listeners/%s", streamID, listenerID)) + Get(fmt.Sprintf("/api/v1/eventstreams/%s/listeners/%s", streamID, listenerID)) if err != nil || !res.IsSuccess() { if okNotFound && res.StatusCode() == 404 { return nil, nil @@ -147,7 +147,7 @@ func (s *streamManager) getListeners(ctx context.Context, streamID string) (list res, err := s.client.R(). SetContext(ctx). SetResult(&listeners). - Get(fmt.Sprintf("/eventstreams/%s/listeners", streamID)) + Get(fmt.Sprintf("/api/v1/eventstreams/%s/listeners", streamID)) if err != nil || !res.IsSuccess() { return nil, ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgCardanoconnectRESTErr) } @@ -166,7 +166,7 @@ func (s *streamManager) createListener(ctx context.Context, streamID, name, last SetContext(ctx). SetBody(body). SetResult(&listener). - Post(fmt.Sprintf("/eventstreams/%s/listeners", streamID)) + Post(fmt.Sprintf("/api/v1/eventstreams/%s/listeners", streamID)) if err != nil || !res.IsSuccess() { return nil, ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgCardanoconnectRESTErr) @@ -178,7 +178,7 @@ func (s *streamManager) createListener(ctx context.Context, streamID, name, last func (s *streamManager) deleteListener(ctx context.Context, streamID, listenerID string) error { res, err := s.client.R(). SetContext(ctx). - Delete(fmt.Sprintf("/eventstreams/%s/listeners/%s", streamID, listenerID)) + Delete(fmt.Sprintf("/api/v1/eventstreams/%s/listeners/%s", streamID, listenerID)) if err != nil || !res.IsSuccess() { return ffresty.WrapRestErr(ctx, res, err, coremsgs.MsgCardanoconnectRESTErr) diff --git a/manifest.json b/manifest.json index e3f5b1af25..27820517bd 100644 --- a/manifest.json +++ b/manifest.json @@ -1,13 +1,13 @@ { "cardanoconnect": { "image": "ghcr.io/hyperledger/firefly-cardanoconnect", - "tag": "0.5.0", - "sha": "f80b3a43960fc9d7a6f7c9af42bf2390fb6d5751fbcc49f43197e8d4d2f2a601" + "tag": "v0.6.1", + "sha": "6a7c0534cf08b1afcce56a8234f1da3ef08594b3cbf27d4a9ee84bf4ecd096dd" }, "cardanosigner": { "image": "ghcr.io/hyperledger/firefly-cardanosigner", - "tag": "0.5.0", - "sha": "5af17007c13cb5325f0ae5295ff37d29f7fcd811b3d12d15d5e67cfae0d9a336" + "tag": "v0.6.1", + "sha": "b950c1d902d58f132f69f5b10aeb1623732de8db4d223534797be87766f123e9" }, "ethconnect": { "image": "ghcr.io/hyperledger/firefly-ethconnect", diff --git a/manifestgen.sh b/manifestgen.sh index 319efed5fa..5a60d5c96c 100755 --- a/manifestgen.sh +++ b/manifestgen.sh @@ -91,7 +91,7 @@ do # If the tag / build number wasn't set in the label, use whatever docker tag we fetched # This is done for backwards compatability, because not all images have labels yet - if [ -z "$TAG_LABEL" ]; then + if [ -z "$TAG_LABEL" ] || [ "$TAG_LABEL" == "null" ]; then TAG_LABEL=$TAG fi