Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev: update by coderabbit #73

Merged
merged 16 commits into from
Nov 29, 2024
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
110 changes: 102 additions & 8 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ <h2>Table of Contents</h2>
<a href="#api.v1.GetAccountResponse"><span class="badge">M</span>GetAccountResponse</a>
</li>

<li>
<a href="#api.v1.GetNonceRequest"><span class="badge">M</span>GetNonceRequest</a>
</li>

<li>
<a href="#api.v1.GetNonceResponse"><span class="badge">M</span>GetNonceResponse</a>
</li>

<li>
<a href="#api.v1.IsAccountLockedRequest"><span class="badge">M</span>IsAccountLockedRequest</a>
</li>
Expand Down Expand Up @@ -322,7 +330,7 @@ <h2>Table of Contents</h2>


<li>
<a href="#api.v1.Curve"><span class="badge">E</span>Curve</a>
<a href="#api.v1.SignatureAlgorithm"><span class="badge">E</span>SignatureAlgorithm</a>
</li>


Expand Down Expand Up @@ -606,8 +614,8 @@ <h3 id="api.v1.Account">Account</h3>
</tr>

<tr>
<td>curve</td>
<td><a href="#api.v1.Curve">Curve</a></td>
<td>signature_algorithm</td>
<td><a href="#api.v1.SignatureAlgorithm">SignatureAlgorithm</a></td>
<td></td>
<td><p> </p></td>
</tr>
Expand Down Expand Up @@ -760,6 +768,13 @@ <h3 id="api.v1.CreateAccountResponse">CreateAccountResponse</h3>
<td><p> </p></td>
</tr>

<tr>
<td>ethereum_address</td>
<td><a href="#string">string</a></td>
<td></td>
<td><p> </p></td>
</tr>

</tbody>
</table>

Expand Down Expand Up @@ -863,6 +878,54 @@ <h3 id="api.v1.GetAccountResponse">GetAccountResponse</h3>



<h3 id="api.v1.GetNonceRequest">GetNonceRequest</h3>
<p></p>


<table class="field-table">
<thead>
<tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
</thead>
<tbody>

<tr>
<td>address</td>
<td><a href="#string">string</a></td>
<td></td>
<td><p> </p></td>
</tr>

</tbody>
</table>





<h3 id="api.v1.GetNonceResponse">GetNonceResponse</h3>
<p></p>


<table class="field-table">
<thead>
<tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
</thead>
<tbody>

<tr>
<td>nonce</td>
<td><a href="#uint64">uint64</a></td>
<td></td>
<td><p> </p></td>
</tr>

</tbody>
</table>





<h3 id="api.v1.IsAccountLockedRequest">IsAccountLockedRequest</h3>
<p></p>

Expand Down Expand Up @@ -1200,6 +1263,20 @@ <h3 id="api.v1.TimedSignature">TimedSignature</h3>
<td><p>address </p></td>
</tr>

<tr>
<td>nonce</td>
<td><a href="#uint64">uint64</a></td>
<td></td>
<td><p> </p></td>
</tr>

<tr>
<td>target_function_hash</td>
<td><a href="#string">string</a></td>
<td></td>
<td><p>hex encoded </p></td>
</tr>

</tbody>
</table>

Expand All @@ -1225,7 +1302,7 @@ <h3 id="api.v1.TransferAccountRequest">TransferAccountRequest</h3>
</tr>

<tr>
<td>to</td>
<td>address</td>
<td><a href="#string">string</a></td>
<td></td>
<td><p> </p></td>
Expand Down Expand Up @@ -1312,7 +1389,7 @@ <h3 id="api.v1.UnlockAccountResponse">UnlockAccountResponse</h3>



<h3 id="api.v1.Curve">Curve</h3>
<h3 id="api.v1.SignatureAlgorithm">SignatureAlgorithm</h3>
<p></p>
<table class="enum-table">
<thead>
Expand All @@ -1321,19 +1398,19 @@ <h3 id="api.v1.Curve">Curve</h3>
<tbody>

<tr>
<td>CURVE_UNSPECIFIED</td>
<td>SignatureAlgorithm_UNSPECIFIED</td>
<td>0</td>
<td><p></p></td>
</tr>

<tr>
<td>CURVE_ECDSA</td>
<td>SignatureAlgorithm_ECDSA</td>
<td>1</td>
<td><p></p></td>
</tr>

<tr>
<td>CURVE_EDDSA</td>
<td>SignatureAlgorithm_EDDSA</td>
<td>2</td>
<td><p></p></td>
</tr>
Expand Down Expand Up @@ -1409,6 +1486,13 @@ <h3 id="api.v1.AccountService">AccountService</h3>
<td><p></p></td>
</tr>

<tr>
<td>GetNonce</td>
<td><a href="#api.v1.GetNonceRequest">GetNonceRequest</a></td>
<td><a href="#api.v1.GetNonceResponse">GetNonceResponse</a></td>
<td><p></p></td>
</tr>

<tr>
<td>IsApproved</td>
<td><a href="#api.v1.IsApprovedRequest">IsApprovedRequest</a></td>
Expand Down Expand Up @@ -1530,6 +1614,16 @@ <h4>Methods with HTTP bindings</h4>



<tr>
<td>GetNonce</td>
<td>GET</td>
<td>/v1/nonce/{address}</td>
<td></td>
</tr>




<tr>
<td>IsApproved</td>
<td>GET</td>
Expand Down
39 changes: 37 additions & 2 deletions docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,30 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Status'
/v1/nonce/{address}:
get:
tags:
- AccountService
operationId: AccountService_GetNonce
parameters:
- name: address
in: path
required: true
schema:
type: string
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/GetNonceResponse'
default:
description: Default error response
content:
application/json:
schema:
$ref: '#/components/schemas/Status'
components:
schemas:
Account:
Expand All @@ -330,7 +354,7 @@ components:
type: string
publicKeyY:
type: string
curve:
signatureAlgorithm:
type: integer
format: enum
isLocked:
Expand Down Expand Up @@ -367,6 +391,8 @@ components:
type: string
accountId:
type: string
ethereumAddress:
type: string
description: Responses
DeleteAccountRequest:
type: object
Expand All @@ -383,6 +409,11 @@ components:
properties:
account:
$ref: '#/components/schemas/Account'
GetNonceResponse:
type: object
properties:
nonce:
type: string
GoogleProtobufAny:
type: object
properties:
Expand Down Expand Up @@ -459,13 +490,17 @@ components:
type: string
signer:
type: string
nonce:
type: string
targetFunctionHash:
type: string
description: Requests
TransferAccountRequest:
type: object
properties:
base:
$ref: '#/components/schemas/AccountOperationRequest'
to:
address:
type: string
TransferAccountResponse:
type: object
Expand Down
7 changes: 6 additions & 1 deletion scripts/utils/generate_function_hash/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ import (

func main() {
if len(os.Args) < 2 {
fmt.Println("Usage: go run main.go <argument>")
fmt.Fprintln(os.Stderr, "Usage: go run main.go <function_signature>")
fmt.Fprintln(os.Stderr, "Example: go run main.go \"transfer(address,uint256)\"")
os.Exit(1)
}

argument := os.Args[1]
if len(argument) == 0 {
fmt.Fprintln(os.Stderr, "Error: Empty input string")
os.Exit(1)
}

hash := keccak256(argument)
fmt.Printf("0x%s\n", hash)
Expand Down
8 changes: 4 additions & 4 deletions scripts/utils/generate_timed_signature/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
func main() {
err := godotenv.Load()
if err != nil {
log.Fatalf("Error loading .env file")
log.Fatalf("Error loading .env file: %v", err)
}

if len(os.Args) != 3 {
Expand Down Expand Up @@ -68,16 +68,16 @@ func main() {
log.Fatalf("Failed to bind to existing contract: %v", err)
}

valdFor := uint64(time.Now().Unix() + 86400)
validFor := uint64(time.Now().Unix() + 86400)

timedSignature, err := testutil.NewPbTimedSignature(taStoreContract, privKey, valdFor, targetFunctionHash)
timedSignature, err := testutil.NewPbTimedSignature(taStoreContract, privKey, validFor, targetFunctionHash)

if err != nil {
log.Fatalf("Failed to generate timed signature: %v", err)
}

fmt.Printf("\"proof\": {\n")
fmt.Printf(" \"validFor\": %d,\n", valdFor)
fmt.Printf(" \"validFor\": %d,\n", validFor)
fmt.Printf(" \"messageHash\": \"%s\",\n", timedSignature.MessageHash)
fmt.Printf(" \"signature\": \"%s\",\n", timedSignature.Signature)
fmt.Printf(" \"signer\": \"%s\",\n", timedSignature.Signer)
Expand Down
Loading
Loading