Skip to content

Commit

Permalink
account_lines request schema (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
ckeshava authored Sep 4, 2024
1 parent 8bc5f3d commit 39d8277
Show file tree
Hide file tree
Showing 8 changed files with 310 additions and 1 deletion.
105 changes: 105 additions & 0 deletions async_api/requests/account_lines_async_api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
components:
schemas:
AccountLinesRequest:
$id: AccountLinesRequest
type: object
description: >
The account_lines command retrieves information about an account's trust lines, including balances in all non-XRP currencies and assets.
All information retrieved is relative to a particular version of the ledger.
allOf:
- $ref: '../../shared/requests/account_lines.yaml#/components/schemas/AccountLinesRequest'
- type: object
properties:
command:
$ref: '../../shared/base.yaml#/components/schemas/CommandTypes'
id:
# Not specifying a type is how we express "any" value is acceptable
description: 'A unique identifier for the request.'
required:
- command
- id
example:
id: 2
command: account_lines
account: rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn
ledger_index: validated

AccountLinesResponse:
$id: AccountLinesResponse
type: object
oneOf:
- $ref: '#/components/schemas/AccountLinesSuccessResponse'
- $ref: '#/components/schemas/AccountLinesErrorResponse'
properties:
id:
# Not specifying a type is how we express "any" value is acceptable
description: 'A unique identifier for the request.'
type:
type: string
description: The value response indicates a direct response to an API request. Asynchronous notifications use a different value such as `ledgerClosed` or `transaction`.
enum:
- response
required:
- id
- type
example:
id: 2
type: response
result:
account: rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn
ledger_hash: 16566FE44F0222B4373BBA5CD8B62AA0200D1D42031A946D15F96DE5479A1564
ledger_index: 90395101
validated: true
limit: 200
lines:
- account: rJF9txJpy3RG7XkXsiL72us5X5txbQDFgA
balance: '0'
currency: VGB
limit: '0'
limit_peer: '100000000'
quality_in: 0
quality_out: 0
no_ripple: false
no_ripple_peer: true
- account: rJXhkzNcijhgwkPHUT966Mhr22b4CwPkjS
balance: '0'
currency: USD
limit: '0'
limit_peer: '14.0301'
quality_in: 0
quality_out: 0
no_ripple: false
no_ripple_peer: true
status: success
type: response
warnings:
- id: 2001
message:
This is a clio server. clio only serves validated data. If you want to
talk to rippled, include 'ledger_index':'current' in your request

AccountLinesSuccessResponse:
$id: AccountLinesSuccessResponse
allOf:
- $ref: '../../shared/requests/account_lines.yaml#/components/schemas/AccountLinesSuccessResponse'
- type: object
properties:
status:
type: string
enum:
- success
required:
- status

AccountLinesErrorResponse:
$id: AccountLinesErrorResponse
allOf:
- $ref: '../../shared/requests/account_lines.yaml#/components/schemas/AccountLinesErrorResponse'
- type: object
properties:
status:
type: string
enum:
- error
required:
- status
19 changes: 18 additions & 1 deletion async_api/websocket_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ channels:
# Reusable message references
- $ref: '#/components/messages/AccountChannelsRequest'
- $ref: '#/components/messages/AccountInfoRequest'
- $ref: '#/components/messages/AccountLinesRequest'
# ... (Add references for additional requests)
publish:
operationId: publishToRoot
message:
oneOf:
- $ref: '#/components/messages/AccountChannelsResponse'
- $ref: '#/components/messages/AccountInfoResponseV1'
- $ref: '#/components/messages/AccountLinesResponse'
# ... (Add references for additional responses)

# Moved message definitions to a separate components section
Expand All @@ -81,6 +83,14 @@ components:
payload:
$ref: './requests/account_info_async_api.yaml#/components/schemas/AccountInfoRequest'

# Account lines request message
AccountLinesRequest:
name: AccountLinesRequest
messageId: AccountLinesRequest
contentType: application/json
payload:
$ref: './requests/account_lines_async_api.yaml#/components/schemas/AccountLinesRequest'

# ... (Add definitions for additional message types)

# Account channels response message
Expand All @@ -94,9 +104,16 @@ components:
# Account info response message (version 1)
AccountInfoResponseV1:
name: AccountInfoResponse
messageId: AccountInfoResponseV1 # Consider using a version suffix
messageId: AccountInfoResponseV1 # Consider using a version suffix
contentType: application/json
payload:
$ref: './requests/account_info_async_api.yaml#/components/schemas/AccountInfoResponseV1'

# Account lines response message
AccountLinesResponse:
name: AccountLinesResponse
messageId: AccountLinesResponse
contentType: application/json
payload:
$ref: './requests/account_lines_async_api.yaml#/components/schemas/AccountLinesResponse'
# ... (Add definitions for additional response types)
10 changes: 10 additions & 0 deletions async_api/websocket_api_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ channels:
contentType: application/json
payload:
$ref: './requests/account_info_async_api.yaml#/components/schemas/AccountInfoRequest'
- name: AccountLinesRequest
messageId: AccountLinesRequest
contentType: application/json
payload:
$ref: './requests/account_lines_async_api.yaml#/components/schemas/AccountLinesRequest'
# TODO: Add additional request types for individual requests here
publish:
operationId: publishToRoot
Expand All @@ -73,4 +78,9 @@ channels:
contentType: application/json
payload:
$ref: './requests/account_info_async_api.yaml#/components/schemas/AccountInfoResponseV2'
- name: AccountLinesResponse
messageId: AccountLinesResponse
contentType: application/json
payload:
$ref: './requests/account_lines_async_api.yaml#/components/schemas/AccountLinesResponse'
# TODO: Add additional response types for individual requests here
3 changes: 3 additions & 0 deletions open_api/json_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ paths:
mapping:
account_channels: 'requests/account_channels_open_api.yaml#/components/schemas/AccountChannelsRequest' # TODO: Verify this is the correct syntax
account_info: 'requests/account_info_open_api.yaml#/components/schemas/AccountInfoRequest'
account_lines: 'requests/account_lines_open_api.yaml#/components/schemas/AccountLinesRequest'
submit: 'requests/submit_open_api.yaml#/components/schemas/SubmitRequestV1'
# TODO: Add the rest of the JSON RPC requests here
oneOf:
- $ref: 'requests/account_channels_open_api.yaml#/components/schemas/AccountChannelsRequest'
- $ref: 'requests/account_info_open_api.yaml#/components/schemas/AccountInfoRequest'
- $ref: 'requests/account_lines_open_api.yaml#/components/schemas/AccountLinesRequest'
- $ref: 'requests/submit_open_api.yaml#/components/schemas/SubmitRequestV1'
# TODO: Add the rest of the JSON RPC requests here
required: true
Expand All @@ -58,6 +60,7 @@ paths:
- $ref: 'requests/account_channels_open_api.yaml#/components/schemas/AccountChannelsResponse'
- $ref: 'requests/account_info_open_api.yaml#/components/schemas/AccountInfoResponseV1'
- $ref: 'requests/submit_open_api.yaml#/components/schemas/SubmitResponseV1'
- $ref: 'requests/account_lines_open_api.yaml#/components/schemas/AccountLinesResponse'
# TODO: Add the rest of the JSON RPC responses here

# TODO: We want to be much more explicit with http error codes for a full implementation of this spec.
Expand Down
3 changes: 3 additions & 0 deletions open_api/json_api_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ paths:
account_channels: 'requests/account_channels_open_api.yaml#/components/schemas/AccountChannelsRequest' # TODO: Verify this is the correct syntax
account_info: 'requests/account_info_open_api.yaml#/components/schemas/AccountInfoRequest'
submit: 'requests/submit_open_api.yaml#/components/schemas/SubmitRequestV2'
account_lines: 'requests/account_lines_open_api.yaml#/components/schemas/AccountLinesRequest'
# TODO: Add the rest of the JSON RPC requests here
oneOf:
- $ref: 'requests/account_channels_open_api.yaml#/components/schemas/AccountChannelsRequest'
- $ref: 'requests/account_info_open_api.yaml#/components/schemas/AccountInfoRequest'
- $ref: 'requests/submit_open_api.yaml#/components/schemas/SubmitRequestV2'
- $ref: 'requests/account_lines_open_api.yaml#/components/schemas/AccountLinesRequest'
# TODO: Add the rest of the JSON RPC requests here
required: true
operationId: 'POST'
Expand All @@ -50,6 +52,7 @@ paths:
- $ref: 'requests/account_channels_open_api.yaml#/components/schemas/AccountChannelsResponse'
- $ref: 'requests/account_info_open_api.yaml#/components/schemas/AccountInfoResponseV2'
- $ref: 'requests/submit_open_api.yaml#/components/schemas/SubmitResponseV2'
- $ref: 'requests/account_lines_open_api.yaml#/components/schemas/AccountLinesResponse'
# TODO: Add the rest of the JSON RPC responses here

# TODO: We want to be much more explicit with http error codes for a full implementation of this spec.
Expand Down
56 changes: 56 additions & 0 deletions open_api/requests/account_lines_open_api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
components:
schemas:
AccountLinesRequest:
type: object
description: >
The account_lines command retrieves information about an account's trust lines, including balances in all non-XRP currencies and assets.
All information retrieved is relative to a particular version of the ledger.
Returns an AccountLinesResponse
properties:
method:
type: string
enum:
- account_lines
params:
type: array
items:
$ref: '../../shared/requests/account_lines.yaml#/components/schemas/AccountLinesRequest'
required:
- method
example:
method: 'account_lines'
params:
- account: 'rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn'
ledger_index: 'current'
peer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'
limit: 200

AccountLinesResponse:
type: object
properties:
result:
type: object
discriminator:
propertyName: status
mapping:
success: '../../shared/requests/account_lines.yaml#/components/schemas/AccountLinesSuccessResponse'
error: '../../shared/requests/account_lines.yaml#/components/schemas/AccountLinesErrorResponse'
oneOf:
- $ref: '../../shared/requests/account_lines.yaml#/components/schemas/AccountLinesSuccessResponse'
- $ref: '../../shared/requests/account_lines.yaml#/components/schemas/AccountLinesErrorResponse'
required:
- result
example:
result:
account: 'rG1QQv2nh2gr7RCZ1P8YYcBUKCCN633jCn'
lines:
- account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'
balance: '0'
currency: 'USD'
limit: '1000000000'
limit_peer: '0'
quality_in: 0
quality_out: 0
ledger_current_index: 14380380
validated: false
status: 'success'
1 change: 1 addition & 0 deletions shared/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ components:
- account_channels
- account_info
- submit
- account_lines

ResponseWarning:
$id: ResponseWarning
Expand Down
Loading

0 comments on commit 39d8277

Please sign in to comment.