Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add chain id in API body
Browse files Browse the repository at this point in the history
Thykof committed Dec 18, 2023
1 parent ec65869 commit d81aa50
Showing 4 changed files with 37 additions and 6 deletions.
17 changes: 17 additions & 0 deletions api/server/models/sign_request.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions api/server/restapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions api/walletApi-V0.yml
Original file line number Diff line number Diff line change
@@ -555,6 +555,7 @@ definitions:
type: object
required:
- operation
- chainId
properties:
description:
type: string
@@ -569,6 +570,9 @@ definitions:
type: boolean
correlationId:
$ref: "#/definitions/CorrelationId"
chainId:
type: integer
description: The chain id of the network to which the operation will be sent.

SignMessageRequest:
type: object
8 changes: 4 additions & 4 deletions internal/handler/wallet/sign_test.go
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ func Test_walletSign_Handle(t *testing.T) {
api, prompterApp, _, resChan, err := MockAPI()
assert.NoError(t, err)

transactionData := fmt.Sprintf(`{"operation":"%s"}`, callSCString)
transactionData := fmt.Sprintf(`{"chainId": 1, "operation":"%s"}`, callSCString)
nickname := "walletToDelete"
password := "zePassword"
createAccount(password, nickname, t, prompterApp)
@@ -151,7 +151,7 @@ func Test_walletSign_Handle(t *testing.T) {
})

t.Run("sign transaction batch", func(t *testing.T) {
transactionDataBatch := fmt.Sprintf(`{"operation":"%s","batch":true}`, callSCString)
transactionDataBatch := fmt.Sprintf(`{"chainId": 1, "operation":"%s","batch":true}`, callSCString)
testResult := make(chan walletapp.EventData)

// Send password to prompter app and wait for result
@@ -174,14 +174,14 @@ func Test_walletSign_Handle(t *testing.T) {

correlationId := base64.StdEncoding.EncodeToString(body.CorrelationID)

transactionDataBatch = fmt.Sprintf(`{"operation":"%s","correlationId":"%s"}`, callSCString, correlationId)
transactionDataBatch = fmt.Sprintf(`{"chainId": 1, "operation":"%s","correlationId":"%s"}`, callSCString, correlationId)
// Send new transaction without password prompt
resp = signTransaction(t, api, nickname, transactionDataBatch)
verifyStatusCode(t, resp, http.StatusOK)

// Send new transaction with incorrect correlation id
correlationId = base64.StdEncoding.EncodeToString([]byte("wrong correlation id"))
transactionDataBatch = fmt.Sprintf(`{"operation":"%s","correlationId":"%s"}`, callSCString, correlationId)
transactionDataBatch = fmt.Sprintf(`{"chainId": 1, "operation":"%s","correlationId":"%s"}`, callSCString, correlationId)
resp = signTransaction(t, api, nickname, transactionDataBatch)
var bodyError operations.SignInternalServerError
err = json.Unmarshal(resp.Body.Bytes(), &bodyError)

0 comments on commit d81aa50

Please sign in to comment.