-
Notifications
You must be signed in to change notification settings - Fork 105
[OpenAPI Codegen] Update scaffolding models from rippled-api-spec v0.1.0-b1 #832
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
base: main
Are you sure you want to change the base?
Changes from all commits
208a632
ea2b8a6
44c1c3c
3b696d0
6e39d92
b4dc28d
9f3bfdb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[mypy] | ||
exclude = dist | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't exclude the folder, if there's something wrong with the typing then the codegen probably needs to be fixed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I will fix the CI/CD pipeline on the codegen end to fix linting issues before publishing the code |
||
exclude = ^(dist|xrpl/openapi-codegen) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,7 @@ build-backend = "poetry.core.masonry.api" | |
[tool.coverage.run] | ||
branch = true | ||
source = ["xrpl"] | ||
omit = ["xrpl/openapi-codegen/*"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't be needed if the |
||
|
||
[tool.coverage.report] | ||
show_missing = true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"""Model for AuthAccount.""" | ||
|
||
from dataclasses import dataclass | ||
from xrpl.models.base_model import BaseModel | ||
from xrpl.models.utils import REQUIRED | ||
from xrpl.models.utils import require_kwargs_on_init | ||
|
||
|
||
@require_kwargs_on_init | ||
@dataclass(frozen=True) | ||
class AuthAccount(BaseModel): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree. Will fix in the next version |
||
account: str = REQUIRED | ||
""" | ||
(Required) The address of the account to authorize. | ||
""" | ||
|
||
def _get_errors(self: AuthAccount) -> Dict[str, str]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great catch, I think this is a spec error specific to this object (probably we added a validation rule with incorrect name for this object |
||
errors = super._get_errors() | ||
return errors |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""Model for AuthorizeCredentials.""" | ||
|
||
from dataclasses import dataclass | ||
from xrpl.models.base_model import BaseModel | ||
from xrpl.models.utils import REQUIRED | ||
from xrpl.models.utils import require_kwargs_on_init | ||
|
||
|
||
@require_kwargs_on_init | ||
@dataclass(frozen=True) | ||
class AuthorizeCredentials(BaseModel): | ||
""" | ||
Represents a credential used for preauthorization. | ||
""" | ||
|
||
issuer: str = REQUIRED | ||
""" | ||
(Required) The issuer of the credential. | ||
""" | ||
|
||
credential_type: str = REQUIRED | ||
""" | ||
(Required) The credential type of the credential. | ||
""" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
""" | ||
The XRP Ledger has two kinds of money: XRP, and issued currencies. Both types have high | ||
precision, although their formats are different. | ||
""" | ||
|
||
from typing import Union | ||
from xrpl.models.issued_currency import IssuedCurrency | ||
from xrpl.models.xrp import XRP | ||
|
||
Currency = Union[IssuedCurrency, XRP] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"""Model for IssuedCurrency.""" | ||
|
||
from dataclasses import dataclass | ||
from typing import Optional | ||
from xrpl.models.base_model import BaseModel | ||
from xrpl.models.utils import require_kwargs_on_init | ||
|
||
|
||
@require_kwargs_on_init | ||
@dataclass(frozen=True) | ||
class IssuedCurrency(BaseModel): | ||
currency: Optional[str] = None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't all types have a description? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we will fix after revising the spec |
||
""" | ||
Arbitrary currency code for the token. | ||
""" | ||
|
||
issuer: Optional[str] = None | ||
""" | ||
Generally, the account that issues this token. In special cases, this can refer to the | ||
account that holds the token instead (for example, in a Clawback transaction). | ||
""" | ||
|
||
def _get_errors(self: IssuedCurrency) -> Dict[str, str]: | ||
errors = super._get_errors() | ||
return errors |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""Model for Memo.""" | ||
|
||
from dataclasses import dataclass | ||
from typing import Optional | ||
from xrpl.models.base_model import BaseModel | ||
from xrpl.models.utils import require_kwargs_on_init | ||
|
||
|
||
@require_kwargs_on_init | ||
@dataclass(frozen=True) | ||
class Memo(BaseModel): | ||
memo_data: Optional[str] = None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: if a type doesn't have a description, can there be a newline between the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree. But all of them should have a description imo so probably will need to add to the spec |
||
""" | ||
Arbitrary hex value, conventionally containing the content of the memo. | ||
""" | ||
|
||
memo_format: Optional[str] = None | ||
""" | ||
Hex value representing characters allowed in URLs. Conventionally containing information | ||
on how the memo is encoded, for example as a [MIME | ||
type](https://www.iana.org/assignments/media-types/media-types.xhtml). | ||
""" | ||
|
||
memo_type: Optional[str] = None | ||
""" | ||
Hex value representing characters allowed in URLs. Conventionally, a unique relation | ||
(according to [RFC 5988](https://datatracker.ietf.org/doc/html/rfc5988#section-4)) that | ||
defines the format of this memo. | ||
""" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
"""Model for PathStep.""" | ||
|
||
from dataclasses import dataclass | ||
from typing import Optional | ||
from xrpl.models.base_model import BaseModel | ||
from xrpl.models.utils import require_kwargs_on_init | ||
|
||
|
||
@require_kwargs_on_init | ||
@dataclass(frozen=True) | ||
class PathStep(BaseModel): | ||
""" | ||
A PathStep represents an individual step along a Path. | ||
""" | ||
|
||
account: Optional[str] = None | ||
""" | ||
(Optional) If present, this path step represents rippling through the specified address. | ||
MUST NOT be provided if this step specifies the currency or issuer fields. | ||
""" | ||
|
||
currency: Optional[str] = None | ||
""" | ||
(Optional) If present, this path step represents changing currencies through an order | ||
book. The currency specified indicates the new currency. MUST NOT be provided if this | ||
step specifies the account field. | ||
""" | ||
|
||
issuer: Optional[str] = None | ||
""" | ||
(Optional) If present, this path step represents changing currencies and this address | ||
defines the issuer of the new currency. If omitted in a step with a non-XRP currency, a | ||
previous step of the path defines the issuer. If present when currency is omitted, | ||
indicates a path step that uses an order book between same-named currencies with | ||
different issuers. MUST be omitted if the currency is XRP. MUST NOT be provided if this | ||
step specifies the account field. | ||
""" | ||
|
||
type: Optional[int] = None | ||
""" | ||
DEPRECATED (Optional) An indicator of which other fields are present. | ||
""" | ||
|
||
type_hex: Optional[str] = None | ||
""" | ||
DEPRECATED: (Optional) A hexadecimal representation of the type field. | ||
""" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"""Model for PriceData.""" | ||
|
||
from dataclasses import dataclass | ||
from typing import Optional | ||
from xrpl.models.base_model import BaseModel | ||
from xrpl.models.utils import REQUIRED | ||
from xrpl.models.utils import require_kwargs_on_init | ||
|
||
|
||
@require_kwargs_on_init | ||
@dataclass(frozen=True) | ||
class PriceData(BaseModel): | ||
base_asset: str = REQUIRED | ||
""" | ||
The primary asset in a trading pair (e.g., BTC in BTC/USD). Any valid identifier, such | ||
as a stock symbol, bond CUSIP, or currency code, is allowed. | ||
""" | ||
|
||
quote_asset: str = REQUIRED | ||
""" | ||
The quote asset in a trading pair, denoting the price of one unit of the base asset | ||
(e.g., USD in BTC/USD). | ||
""" | ||
|
||
asset_price: Optional[str] = None | ||
""" | ||
The asset price after applying the Scale precision level. Recommended to be provided as | ||
a hexadecimal, but decimal numbers are accepted. Not included if the last update | ||
transaction didn't include the BaseAsset/QuoteAsset pair. | ||
""" | ||
|
||
scale: Optional[int] = None | ||
""" | ||
The scaling factor to apply to an asset price. If Scale is 6 and the original price is | ||
0.155, then the scaled price is 155000. Valid scale ranges are 0-10. Not included if | ||
the last update transaction didn't include the BaseAsset/QuoteAsset pair. | ||
""" | ||
|
||
def _get_errors(self: PriceData) -> Dict[str, str]: | ||
errors = super._get_errors() | ||
if (self.asset_price is not None) != (self.scale is not None): | ||
errors["PriceData"] = ( | ||
"Both `asset_price` and `scale` are required if any is presented." | ||
) | ||
if ( | ||
self.asset_price is not None | ||
and self.asset_price != REQUIRED | ||
and not self.asset_price.isnumeric() | ||
): | ||
errors["PriceData"] = "`asset_price` must be numeric." | ||
if self.scale is not None and self.scale < 0: | ||
errors["PriceData"] = ( | ||
"Field `scale` must have a value greater than or equal to 0" | ||
) | ||
if self.scale is not None and self.scale > 10: | ||
errors["PriceData"] = ( | ||
"Field `scale` must have a value less than or equal to 10" | ||
) | ||
return errors |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""Request models.""" | ||
|
||
from xrpl.models.requests.account_channels import AccountChannels | ||
from xrpl.models.requests.account_info import AccountInfo | ||
from xrpl.models.requests.account_lines import AccountLines | ||
from xrpl.models.requests.lookup_by_ledger_request import LookupByLedgerRequest | ||
from xrpl.models.requests.lookup_by_ledger_request import ( | ||
LookupByLedgerRequestLedgerIndex, | ||
) | ||
from xrpl.models.requests.request import Request | ||
from xrpl.models.requests.server_info import ServerInfo | ||
|
||
__all__ = [ | ||
AccountChannels, | ||
AccountInfo, | ||
AccountLines, | ||
LookupByLedgerRequest, | ||
LookupByLedgerRequestLedgerIndex, | ||
Request, | ||
ServerInfo, | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
"""Model for AccountChannels request type.""" | ||
|
||
from dataclasses import dataclass, field | ||
from typing import Any, Optional, Union | ||
from xrpl.models.requests.request import RequestMethod | ||
from xrpl.models.utils import REQUIRED | ||
from xrpl.models.requests.base_request import BaseRequest | ||
from xrpl.models.requests.lookup_by_ledger import LookupByLedgerRequest | ||
from xrpl.models.utils import require_kwargs_on_init | ||
|
||
|
||
@require_kwargs_on_init | ||
@dataclass(frozen=True) | ||
class AccountChannels(BaseRequest, LookupByLedgerRequest): | ||
""" | ||
The account_channels method returns information about an account's Payment Channels. | ||
This includes only channels where the specified account is the channel's source, not the | ||
destination. (A channel's source and owner are the same.) All information retrieved is | ||
relative to a particular version of the ledger. Returns an AccountChannelsResponse. | ||
""" | ||
|
||
method: RequestMethod = field(default=RequestMethod.ACCOUNT_CHANNELS, init=False) | ||
|
||
account: str = REQUIRED | ||
""" | ||
The unique identifier of an account, typically the account's address. | ||
""" | ||
|
||
destination_account: Optional[str] = None | ||
""" | ||
The unique identifier of an account, typically the account's address. If provided, | ||
filter results to payment channels whose destination is this account. | ||
""" | ||
|
||
limit: Optional[Union[float, int]] = None | ||
""" | ||
Limit the number of transactions to retrieve. Cannot be less than 10 or more than 400. | ||
The default is 200. | ||
""" | ||
|
||
marker: Optional[Any] = None | ||
""" | ||
Value from a previous paginated response. Resume retrieving data where that response | ||
left off. | ||
""" | ||
|
||
def _get_errors(self: AccountChannels) -> Dict[str, str]: | ||
errors = super._get_errors() | ||
if self.limit is not None and self.limit < 10: | ||
errors["AccountChannels"] = ( | ||
"Field `limit` must have a value greater than or equal to 10" | ||
) | ||
if self.limit is not None and self.limit > 400: | ||
errors["AccountChannels"] = ( | ||
"Field `limit` must have a value less than or equal to 400" | ||
) | ||
return errors |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""Model for AccountInfo request type.""" | ||
|
||
from dataclasses import dataclass, field | ||
from typing import Optional | ||
from xrpl.models.requests.request import RequestMethod | ||
from xrpl.models.utils import REQUIRED | ||
from xrpl.models.requests.base_request import BaseRequest | ||
from xrpl.models.requests.lookup_by_ledger import LookupByLedgerRequest | ||
from xrpl.models.utils import require_kwargs_on_init | ||
|
||
|
||
@require_kwargs_on_init | ||
@dataclass(frozen=True) | ||
class AccountInfo(BaseRequest, LookupByLedgerRequest): | ||
""" | ||
The account_info command retrieves information about an account, its activity, and its | ||
XRP balance. All information retrieved is relative to a particular version of the | ||
ledger. Returns an AccountInfoResponse | ||
""" | ||
|
||
method: RequestMethod = field(default=RequestMethod.ACCOUNT_INFO, init=False) | ||
|
||
account: str = REQUIRED | ||
""" | ||
The account to look up. | ||
""" | ||
|
||
queue: Optional[bool] = None | ||
""" | ||
If true, return stats about queued transactions sent by this account. Can only be used | ||
when querying for the data from the current open ledger. Not available from servers in | ||
Reporting Mode. | ||
""" | ||
|
||
signer_lists: Optional[bool] = None | ||
""" | ||
API v1: If true, return any SignerList objects associated with this account. API v2: | ||
Identical to v1, but also returns an invalidParams error if you provide a non-boolean | ||
value. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't exclude the folder, if there's something wrong with the typing then the codegen probably needs to be fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, will fix the pipeline