-
Notifications
You must be signed in to change notification settings - Fork 3
refactor(amplifier-api): introduce codegen for open-api #43
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?
Conversation
| # properties: | ||
| # type: | ||
| # $ref: '#/components/schemas/EventType' | ||
| # required: | ||
| # - type |
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.
This is commented out to get the generated code like this:
pub enum Event {
GasCreditEvent(GasCreditEvent),
GasRefundedEvent(GasRefundedEvent),
CallEvent(CallEvent),
MessageApprovedEvent(MessageApprovedEvent),
MessageExecutedEvent(MessageExecutedEvent),
MessageExecutedEventV2(MessageExecutedEventV2),
CannotExecuteMessageEvent(CannotExecuteMessageEvent),
CannotExecuteMessageEventV2(CannotExecuteMessageEventV2),
CannotRouteMessageEvent(CannotRouteMessageEvent),
CannotExecuteTaskEvent(CannotExecuteTaskEvent),
SignersRotatedEvent(SignersRotatedEvent),
ItsLinkTokenStartedEvent(ItsLinkTokenStartedEvent),
ItsTokenMetadataRegisteredEvent(ItsTokenMetadataRegisteredEvent),
ItsInterchainTokenDeploymentStartedEvent(
ItsInterchainTokenDeploymentStartedEvent,
),
ItsInterchainTransferEvent(ItsInterchainTransferEvent),
AppInterchainTransferSentEvent(AppInterchainTransferSentEvent),
AppInterchainTransferReceivedEvent(AppInterchainTransferReceivedEvent),
}If have those lines enabled the generated code looks like this:
pub enum Event {
Variant0 {
#[serde(rename = "eventID")]
event_id: EventVariant0EventId,
#[serde(rename = "messageID")]
message_id: EventVariant0MessageId,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
meta: ::std::option::Option<EventMetadata>,
payment: UnsignedToken,
#[serde(rename = "refundAddress")]
refund_address: Address,
#[serde(rename = "type")]
type_: EventType,
},
Variant1 {
cost: Cost,
#[serde(rename = "eventID")]
event_id: EventVariant1EventId,
#[serde(rename = "messageID")]
message_id: EventVariant1MessageId,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
meta: ::std::option::Option<EventMetadata>,
#[serde(rename = "recipientAddress")]
recipient_address: Address,
#[serde(rename = "refundedAmount")]
refunded_amount: UnsignedToken,
#[serde(rename = "type")]
type_: EventType,
},| @@ -0,0 +1,138 @@ | |||
| //! Helpers for creating an authenticated `reqwest::Client` for amplifier-api. | |||
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.
This code is moved from the previous implementation. It was at crates/amplifier-api/src/client.rs.
| // while returning the result of `internal`. | ||
| cx.waker().wake_by_ref(); | ||
| return Poll::Ready(Some(Ok(res))); | ||
| return Poll::Ready(Some(Ok(Ok(())))); |
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’d prefer not to edit this file much, so I added Ok(Ok(())) here. Later, in the JoinSet, a future returning eyre::Result<()> will be added.
|
|
||
| cx.waker().wake_by_ref(); | ||
| return Poll::Ready(Some(Ok(res))); | ||
| return Poll::Ready(Some(Ok(Ok(())))); |
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’d prefer not to edit this file much, so I added Ok(Ok(())) here. Later, in the JoinSet, a future returning eyre::Result<()> will be added.
|
If you have any good suggestion, I prefer to drop the changes of crate |
|
I have convert it back to Draft because the |
refactor(amplifier-api): migrate to codegen OpenAPI client, remove hand-written types/client
The schema is coming from here:
schema/schema.yaml