Skip to content

Commit

Permalink
fix: add signmessage to grpc-gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
ZigBalthazar committed Jul 5, 2024
1 parent dbfbac7 commit 3cf30ce
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 2 deletions.
3 changes: 1 addition & 2 deletions util/crypto/crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ func TestSignMessageWithPrivateKey(t *testing.T) {
prvStr := "SECRET1PDRWTLP5PX0FAHDX39GXZJP7FKZFALML0D5U9TT9KVQHDUC99CMGQQJVK67"
invalidPrvStr := "INVSECRET1PDRWTLP5PX0FAHDX39GXZJP7FKZFALML0D5U9TT9KVQHDUC99CMGQQJVK67"
sigStr := "923d67a8624cbb7972b29328e15ec76cc846076ccf00a9e94d991c677846f334ae4ba4551396fbcd6d1cab7593baf3b7"

sig, err := SignMessageWithPrivateKey(prvStr, msg)
assert.Nil(t, err)
assert.Equal(t, sig, sigStr)


sig, err = SignMessageWithPrivateKey(invalidPrvStr, msg)
assert.NotNil(t, err)
Expand Down
3 changes: 3 additions & 0 deletions www/grpc/buf/grpc-gateway.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,6 @@ http:

- selector: pactus.Wallet.GetTotalBalance
get: "/pactus/wallet/get_total_balance"

- selector: pactus.Wallet.SignMessage
get: "/pactus/wallet/sign_message"
87 changes: 87 additions & 0 deletions www/grpc/gen/go/wallet.pb.gw.go

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

53 changes: 53 additions & 0 deletions www/grpc/swagger-ui/pactus.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,59 @@
]
}
},
"/pactus/wallet/sign_message": {
"get": {
"summary": "SignMessage signs an arbitrary message.",
"operationId": "Wallet_SignMessage",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/pactusSignMessageResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "walletName",
"description": "The name of the wallet.",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "password",
"description": "The password for unlocking the wallet for signing.",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "address",
"description": "The account address associated with the private key.",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "message",
"description": "The arbitrary message to be signed.",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
"Wallet"
]
}
},
"/pactus/wallet/sign_raw_transaction": {
"get": {
"summary": "SignRawTransaction signs a raw transaction for a specified wallet.",
Expand Down

0 comments on commit 3cf30ce

Please sign in to comment.