Skip to content

Commit

Permalink
add account_offers
Browse files Browse the repository at this point in the history
  • Loading branch information
pdp2121 committed Jan 21, 2025
1 parent bc3b725 commit a28143b
Show file tree
Hide file tree
Showing 8 changed files with 285 additions and 3 deletions.
75 changes: 75 additions & 0 deletions async_api/requests/account_offers_async_api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
components:
schemas:
AccountOffersRequest:
type: object
allOf:
- $ref: ../../shared/requests/account_offers.yaml#/components/schemas/AccountOffersRequest
properties:
command:
type: string
enum:
- account_offers
id:
description: A unique identifier for the request.
required:
- command
- id
example:
id: 9
command: account_offers
account: rpP2JgiMyTF5jR5hLG3xHCPi1knBb1v9cM
AccountOffersResponse:
type: object
properties:
result:
type: object
discriminator:
propertyName: status
mapping:
success: ../../shared/requests/account_offers.yaml#/components/schemas/AccountOffersSuccessResponse
error: '#/components/schemas/AccountOffersErrorResponse'
oneOf:
- $ref: ../../shared/requests/account_offers.yaml#/components/schemas/AccountOffersSuccessResponse
- $ref: '#/components/schemas/AccountOffersErrorResponse'
id:
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: 9
status: success
type: response
result:
account: rpP2JgiMyTF5jR5hLG3xHCPi1knBb1v9cM
ledger_current_index: 18539550
offers:
- flags: 0
quality: '0.00000000574666765650638'
seq: 6577664
taker_gets: '33687728098'
taker_pays:
currency: EUR
issuer: rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq
value: '193.5921774819578'
- flags: 0
quality: '7989247009094510e-27'
seq: 6572128
taker_gets: '2361918758'
taker_pays:
currency: XAU
issuer: rrh7rf1gV2pXAoqA8oYbpHd8TKv5ZQeo67
value: '0.01886995237307572'
validated: false
AccountOffersErrorResponse:
oneOf:
- $ref: ../../shared/base.yaml#/components/schemas/WebsocketErrorFields
- $ref: ../../shared/requests/account_offers.yaml#/components/schemas/AccountOffersErrorResponse
20 changes: 19 additions & 1 deletion async_api/websocket_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ channels:
- $ref: '#/components/messages/LedgerEntryRequest'
- $ref: '#/components/messages/AccountCurrenciesRequest'
- $ref: '#/components/messages/AccountNftsRequest'
- $ref: '#/components/messages/AccountOffersRequest'
# ... (Add references for additional requests)
publish:
operationId: publishToRoot
Expand All @@ -68,6 +69,7 @@ channels:
- $ref: '#/components/messages/LedgerEntryResponse'
- $ref: '#/components/messages/AccountCurrenciesResponse'

Check failure on line 70 in async_api/websocket_api.yaml

View workflow job for this annotation

GitHub Actions / validate-asyncapi

asyncapi-document-resolved Property "payload" is not expected to be here

Check failure on line 70 in async_api/websocket_api.yaml

View workflow job for this annotation

GitHub Actions / validate-asyncapi

asyncapi-document-resolved "discriminator" property type must be string

Check failure on line 70 in async_api/websocket_api.yaml

View workflow job for this annotation

GitHub Actions / validate-asyncapi

asyncapi2-schemas must be string
- $ref: '#/components/messages/AccountNftsResponse'

Check failure on line 71 in async_api/websocket_api.yaml

View workflow job for this annotation

GitHub Actions / validate-asyncapi

asyncapi-document-resolved Property "payload" is not expected to be here

Check failure on line 71 in async_api/websocket_api.yaml

View workflow job for this annotation

GitHub Actions / validate-asyncapi

asyncapi-document-resolved "discriminator" property type must be string

Check failure on line 71 in async_api/websocket_api.yaml

View workflow job for this annotation

GitHub Actions / validate-asyncapi

asyncapi2-schemas must be string
- $ref: '#/components/messages/AccountOffersResponse'

Check failure on line 72 in async_api/websocket_api.yaml

View workflow job for this annotation

GitHub Actions / validate-asyncapi

asyncapi-document-resolved Property "payload" is not expected to be here

Check failure on line 72 in async_api/websocket_api.yaml

View workflow job for this annotation

GitHub Actions / validate-asyncapi

asyncapi-document-resolved "discriminator" property type must be string

Check failure on line 72 in async_api/websocket_api.yaml

View workflow job for this annotation

GitHub Actions / validate-asyncapi

asyncapi2-schemas must be string
# ... (Add references for additional responses)

# Moved message definitions to a separate components section
Expand Down Expand Up @@ -121,6 +123,14 @@ components:
payload:
$ref: './requests/account_nfts_async_api.yaml#/components/schemas/AccountNftsRequest'

# Account offers request message
AccountOffersRequest:
name: AccountOffersRequest
messageId: AccountOffersRequest
contentType: application/json
payload:
$ref: './requests/account_offers_async_api.yaml#/components/schemas/AccountOffersRequest'

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

# Account channels response message
Expand Down Expand Up @@ -169,6 +179,14 @@ components:
messageId: AccountNftsResponse
contentType: application/json
payload:
$ref: './requests/account_nfts_async_api.yaml#/components/schemas/AccountNftsResponse'
$ref: './requests/account_offers_async_api.yaml#/components/schemas/AccountOffersResponse'

# Account offers response message
AccountOffersResponse:
name: AccountOffersResponse
messageId: AccountOffersResponse
contentType: application/json
payload:
$ref: './requests/account_offers_async_api.yaml#/components/schemas/AccountOffersResponse'

# ... (Add definitions for additional response types)
18 changes: 18 additions & 0 deletions async_api/websocket_api_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ channels:
- $ref: '#/components/messages/LedgerEntryRequest'
- $ref: '#/components/messages/AccountCurrenciesRequest'
- $ref: '#/components/messages/AccountNftsRequest'
- $ref: '#/components/messages/AccountOffersRequest'
# ... (Add references for additional requests)
publish:
operationId: publishToRoot
Expand All @@ -67,6 +68,7 @@ channels:
- $ref: '#/components/messages/LedgerEntryResponse'
- $ref: '#/components/messages/AccountCurrenciesResponse'
- $ref: '#/components/messages/AccountNftsResponse'
- $ref: '#/components/messages/AccountOffersResponse'
# ... (Add references for additional responses)

# Moved message definitions to a separate components section
Expand Down Expand Up @@ -120,6 +122,14 @@ components:
payload:
$ref: './requests/account_nfts_async_api.yaml#/components/schemas/AccountNftsRequest'

# Account offers request message
AccountOffersRequest:
name: AccountOffersRequest
messageId: AccountOffersRequest
contentType: application/json
payload:
$ref: './requests/account_offers_async_api.yaml#/components/schemas/AccountOffersRequest'

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

# Account channels response message
Expand Down Expand Up @@ -170,4 +180,12 @@ components:
payload:
$ref: './requests/account_nfts_async_api.yaml#/components/schemas/AccountNftsResponse'

# Account offers response message
AccountOffersResponse:
name: AccountOffersResponse
messageId: AccountOffersResponse
contentType: application/json
payload:
$ref: './requests/account_offers_async_api.yaml#/components/schemas/AccountOffersResponse'

# ... (Add definitions for additional response types)
4 changes: 4 additions & 0 deletions open_api/json_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ paths:
ledger_entry: 'requests/ledger_entry_open_api.yaml#/components/schemas/LedgerEntryRequest'
account_currencies: 'requests/account_currencies_open_api.yaml#/components/schemas/AccountCurrenciesRequest'
account_nfts: 'requests/account_nfts_open_api.yaml#/components/schemas/AccountNftsRequest'
account_offers: 'requests/account_offers_open_api.yaml#/components/schemas/AccountOffersRequest'
# TODO: Add the rest of the JSON RPC requests here
oneOf:
- $ref: 'requests/account_channels_open_api.yaml#/components/schemas/AccountChannelsRequest'
Expand All @@ -47,6 +48,7 @@ paths:
- $ref: 'requests/ledger_entry_open_api.yaml#/components/schemas/LedgerEntryRequest'
- $ref: 'requests/account_currencies_open_api.yaml#/components/schemas/AccountCurrenciesRequest'
- $ref: 'requests/account_nfts_open_api.yaml#/components/schemas/AccountNftsRequest'
- $ref: 'requests/account_offers_open_api.yaml#/components/schemas/AccountOffersRequest'
# TODO: Add the rest of the JSON RPC requests here
required: true
operationId: 'POST'
Expand All @@ -69,6 +71,8 @@ paths:
- $ref: 'requests/account_lines_open_api.yaml#/components/schemas/AccountLinesResponse'
- $ref: 'requests/ledger_entry_open_api.yaml#/components/schemas/LedgerEntryResponse'
- $ref: 'requests/account_currencies_open_api.yaml#/components/schemas/AccountCurrenciesResponse'
- $ref: 'requests/account_nfts_open_api.yaml#/components/schemas/AccountNftsResponse'
- $ref: 'requests/account_offers_open_api.yaml#/components/schemas/AccountOffersResponse'
# 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
4 changes: 4 additions & 0 deletions open_api/json_api_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ paths:
ledger_entry: 'requests/ledger_entry_open_api.yaml#/components/schemas/LedgerEntryRequest'
account_currencies: 'requests/account_currencies_open_api.yaml#/components/schemas/AccountCurrenciesRequest'
account_nfts: 'requests/account_nfts_open_api.yaml#/components/schemas/AccountNftsRequest'
account_offers: 'requests/account_offers_open_api.yaml#/components/schemas/AccountOffersRequest'
# TODO: Add the rest of the JSON RPC requests here
oneOf:
- $ref: 'requests/account_channels_open_api.yaml#/components/schemas/AccountChannelsRequest'
Expand All @@ -45,6 +46,7 @@ paths:
- $ref: 'requests/ledger_entry_open_api.yaml#/components/schemas/LedgerEntryRequest'
- $ref: 'requests/account_currencies_open_api.yaml#/components/schemas/AccountCurrenciesRequest'
- $ref: 'requests/account_nfts_open_api.yaml#/components/schemas/AccountNftsRequest'
- $ref: 'requests/account_offers_open_api.yaml#/components/schemas/AccountOffersRequest'
# TODO: Add the rest of the JSON RPC requests here
required: true
operationId: 'POST'
Expand All @@ -61,6 +63,8 @@ paths:
- $ref: 'requests/account_lines_open_api.yaml#/components/schemas/AccountLinesResponse'
- $ref: 'requests/ledger_entry_open_api.yaml#/components/schemas/LedgerEntryResponse'
- $ref: 'requests/account_currencies_open_api.yaml#/components/schemas/AccountCurrenciesResponse'
- $ref: 'requests/account_nfts_open_api.yaml#/components/schemas/AccountNftsResponse'
- $ref: 'requests/account_offers_open_api.yaml#/components/schemas/AccountOffersResponse'
# 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
70 changes: 70 additions & 0 deletions open_api/requests/account_offers_open_api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
components:
schemas:
AccountOffersRequest:
type: object
properties:
method:
type: string
enum:
- account_offers
params:
type: array
items:
$ref: ../../shared/requests/account_offers.yaml#/components/schemas/AccountOffersRequest
required:
- method
example:
method: account_offers
params:
- account: rpP2JgiMyTF5jR5hLG3xHCPi1knBb1v9cM
AccountOffersResponse:
type: object
properties:
result:
type: object
discriminator:
propertyName: status
mapping:
success: ../../shared/requests/account_offers.yaml#/components/schemas/AccountOffersSuccessResponse
error: ../../shared/requests/account_offers.yaml#/components/schemas/AccountOffersErrorResponse
oneOf:
- $ref: ../../shared/requests/account_offers.yaml#/components/schemas/AccountOffersSuccessResponse
- $ref: ../../shared/requests/account_offers.yaml#/components/schemas/AccountOffersErrorResponse
required:
- result
example:
result:
account: rpP2JgiMyTF5jR5hLG3xHCPi1knBb1v9cM
ledger_current_index: 18539596
offers:
- flags: 0
quality: '0.000000007599140009999998'
seq: 6578020
taker_gets: '29740867287'
taker_pays:
currency: USD
issuer: rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q
value: '226.0050145327418'
- flags: 0
quality: '7989247009094510e-27'
seq: 6572128
taker_gets: '2361918758'
taker_pays:
currency: XAU
issuer: rrh7rf1gV2pXAoqA8oYbpHd8TKv5ZQeo67
value: '0.01886995237307572'
- flags: 0
quality: '0.00000004059594001318974'
seq: 6576905
taker_gets: '3892952574'
taker_pays:
currency: CNY
issuer: rKiCet8SdvWxPXnAgYarFUXMh1zCPz432Y
value: '158.0380691682966'
status: success
validated: false
AccountOffersSuccessResponse:
type: object
allOf:
- $ref: ../../shared/base.yaml#/components/schemas/BaseSuccessResponse
- $ref: ../../shared/requests/account_offers.yaml#/components/schemas/AccountOffersSuccessResponse
3 changes: 1 addition & 2 deletions shared/requests/account_nfts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ components:
description: The token sequence number of this NFToken, which is unique for its issuer.

AccountNftsErrorResponse:
description: ''
type: object
properties:
error:
Expand All @@ -89,7 +88,7 @@ components:
enum:
- error
request:
$ref: '#/components/schemas/AccountCurrenciesRequest'
$ref: '#/components/schemas/AccountNftsRequest'
required:
- status
- error
Expand Down
94 changes: 94 additions & 0 deletions shared/requests/account_offers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
components:
schemas:
AccountOffersRequest:
description: >
The account_offers method retrieves a list of offers made by a given account that are outstanding as of a particular ledger version.
type: object
allOf:
- $ref: '../base.yaml#/components/schemas/BaseRequest'
- $ref: '../base.yaml#/components/schemas/LookupByLedgerRequest'
properties:
account:
type: string
description: The unique identifier of an account, typically the account's Address. The request returns a list of NFTs owned by this account.
limit:
type: integer
description: (Optional) Limit the number of token pages to retrieve. Each page can contain up to 32 NFTs. The limit value cannot be lower than 20 or more than 400. Positive values outside this range are replaced with the closest valid option. The default is 100.
marker:
type: string
description: (Optional) Value from a previous paginated response. Resume retrieving data where that response left off.
required:
- account
AccountOffersSuccessResponse:
type: object
properties:
account:
type: string
description: Unique Address identifying the account that made the offers.
offers:
type: array
items:
$ref: '#/components/schemas/Offer'
description: Array of objects, where each object represents an offer made by this account that is outstanding as of the requested ledger version. If the number of offers is large, only returns up to limit at a time.
ledger_current_index:
type: integer
description: (Omitted if ledger_hash or ledger_index provided) The ledger index of the current in-progress ledger version, which was used when retrieving this data.
ledger_index:
type: integer
description: (Omitted if ledger_current_index provided instead) The ledger index of the ledger version that was used when retrieving this data, as requested.
ledger_hash:
type: string
description: (May be omitted) The identifying hash of the ledger version that was used when retrieving this data.
marker:
type: string
description: (May be omitted) Server-defined value indicating the response is paginated. Pass this to the next call to resume where this call left off. Omitted when there are no pages of information after this one.
Offer:
type: object
properties:
flags:
type: integer
description: Options set for this offer entry as bit-flags.
seq:
type: integer
description: Sequence number of the transaction that created this entry. (Transaction sequence numbers are relative to accounts.)
taker_gets:
$ref: '../base.yaml#/components/schemas/CurrencyAmount'
description: The amount the account accepting the offer receives, as a String representing an amount in XRP, or a currency specification object.
taker_pays:
$ref: '../base.yaml#/components/schemas/CurrencyAmount'
description: The amount the account accepting the offer provides, as a String representing an amount in XRP, or a currency specification object.
quality:
type: string
description: The exchange rate of the offer, as the ratio of the original taker_pays divided by the original taker_gets. When executing offers, the offer with the most favorable (lowest) quality is consumed first; offers with the same quality are executed from oldest to newest.
expiration:
type: integer
description: (May be omitted) A time after which this offer is considered unfunded, as the number of seconds since the Ripple Epoch.

AccountOffersErrorResponse:
description: ''
type: object
properties:
error:
type: string
oneOf:
- $ref: '../base.yaml#/components/schemas/UniversalErrorResponseCodes'
- enum:
- invalidParams
- actNotFound
- lgrNotFound
- actMalformed
description: >
* `invalidParams` - One or more fields are specified incorrectly, or one or more required fields are missing.
* `actNotFound` - The address specified in the `account` field of the request does not correspond to an account in the ledger.
* `lgrNotFound` - The ledger specified by the `ledger_hash` or `ledger_index` does not exist, or it does exist but the server does not have it.
* `actMalformed` - The marker field provided is incorrect.
status:
type: string
enum:
- error
request:
$ref: '#/components/schemas/AccountOffersRequest'
required:
- status
- error
- request

0 comments on commit a28143b

Please sign in to comment.