Skip to content

Commit

Permalink
Add /starname/query/resourceAccounts endpoint to swagger for reverse …
Browse files Browse the repository at this point in the history
…look-ups (#365)

* Add reverse look-up test

* Add resourceAccounts endpoint to swagger

* Bump version

Co-authored-by: Dave Puchyr <[email protected]>
  • Loading branch information
davepuchyr and Dave Puchyr authored Oct 13, 2020
1 parent 1cb4e44 commit a110277
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## HEAD

## v0.9.5

- REST: Add /starname/query/resourceAccounts endpoint to swagger for reverse look-ups

## v0.9.4

- CLI: Fix output on verify
Expand Down
15 changes: 15 additions & 0 deletions scripts/integration/test/CLI.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,4 +432,19 @@ describe( "Tests the CLI.", () => {
expect( e.message.indexOf( "ERROR: invalid signature from address found at index 0" ) ).toEqual( 0 );
}
} );


it( `Should do a reverse look-up.`, async () => {
const uri = "asset:eth";
const resource = "0x6DF432079347050e0D8dA43C21fa6fe54697AfA7"; // 01node*iov
const result = iovnscli( [ "query", "starname", "resolve-resource", "--uri", uri, "--resource", resource ] );

expect( result.accounts.length ).toEqual( 1 );

const account0 = result.accounts[0];

expect( account0.name ).toEqual( "01node" );
expect( account0.domain ).toEqual( "iov" );
expect( account0.resources.find( r => r.uri == uri && r.resource == resource ) ).toBeDefined();
} );
} );
2 changes: 1 addition & 1 deletion swagger-ui/statik/statik.go

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions swagger-ui/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2152,6 +2152,36 @@ paths:
description: Account not found
"500":
description: Internal Server Error
"/starname/query/resourceAccounts":
post:
summary: Resolves account(s) associated with the given uri and resource
requestBody:
content:
application/json:
schema:
$ref: "#/components/requestBodies/ResourceAccountsQueryBody"
description: Resolves starname(s) associated with the given uri and resource
tags:
- Starname
responses:
"200":
description: Resource resolved successfully to one or more accounts
content:
application/json:
schema:
properties:
height:
type: number
example: 368
result:
type: object
properties:
account:
$ref: "#/components/schemas/Account"
"400":
description: Account not found
"500":
description: Internal Server Error
components:
requestBodies:
WithdrawRequestBody:
Expand Down Expand Up @@ -2218,6 +2248,28 @@ components:
type: string
example: "*iov"
description: Starname of the form "*domain" or "account*domain"
ResourceAccountsQueryBody:
type: object
properties:
resource:
type: object
properties:
uri:
type: string
example: asset:iov
description: Uniform resource identifier (URI) for the resource
resource:
type: string
example: star1478t4fltj689nqu83vsmhz27quk7uggjwe96yk
description: Resource associated with the URI
results_per_page:
type: number
example: 5
description: Results per page
offset:
type: number
example: 1
description: Page number
securitySchemes:
kms:
type: http
Expand Down

0 comments on commit a110277

Please sign in to comment.