Skip to content

Commit

Permalink
[API] Add Poem as an alternative backend (aptos-labs#1906)
Browse files Browse the repository at this point in the history
* [API] Add crate to help types self-describe for the OpenAPI spec generator

* [API] Add boilerplate for using Poem as an alternative backend

* [API] Add support for index with Poem backend

* [API] Add TLS support to Poem backend

* [API] Add CORS for Poem API backend

* [API] Add support for logging middleware to the Poem backend

* [API] Add response status tracking to Poem backend

* [API] Break APIs up in Poem backend

* [API] Make a BCS payload type

* [API] Make all API types self-describe for generating an OpenAPI spec

* [API] Fix up Rosetta following adding IdentifierWrapper

* [API] Add request and response types for the JSON / BCS enum

* [API] Add headers to response in Poem backend

* [API] Add endpoint for get_account for Poem backend

* [API] Add /accounts/{address}/resources endpoint

* [API] Add /accounts/{address}/modules endpoint

* [API] Add /events/{event_key} endpoint

* [API] Add /accounts/{address}/events/{event_handle_struct}/{field_name} endpoint

* [API] Run both APIs alongside each other

* [API] Add GET /transactions

* fixup: Remove use_poem_backend_flag

* Add comments explaining what the aptos-openapi macros do
  • Loading branch information
banool authored Jul 22, 2022
1 parent c57de10 commit c6e13a7
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/models/write_set_changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
// SPDX-License-Identifier: Apache-2.0

use crate::{models::transactions::Transaction, schema::write_set_changes};
use aptos_rest_client::aptos_api_types::WriteSetChange as APIWriteSetChange;
use aptos_rest_client::aptos_api_types::{
DeleteModule, DeleteResource, DeleteTableItem, WriteModule, WriteResource,
WriteSetChange as APIWriteSetChange, WriteTableItem,
};
use serde::Serialize;
use serde_json::json;

Expand Down Expand Up @@ -30,11 +33,11 @@ impl WriteSetChange {
write_set_change: &APIWriteSetChange,
) -> Self {
match write_set_change {
APIWriteSetChange::DeleteModule {
APIWriteSetChange::DeleteModule(DeleteModule {
address,
state_key_hash,
module,
} => WriteSetChange {
}) => WriteSetChange {
transaction_hash,
hash: state_key_hash.clone(),
type_: write_set_change.type_str().to_string(),
Expand All @@ -44,11 +47,11 @@ impl WriteSetChange {
data: Default::default(),
inserted_at: chrono::Utc::now().naive_utc(),
},
APIWriteSetChange::DeleteResource {
APIWriteSetChange::DeleteResource(DeleteResource {
address,
state_key_hash,
resource,
} => WriteSetChange {
}) => WriteSetChange {
transaction_hash,
hash: state_key_hash.clone(),
type_: write_set_change.type_str().to_string(),
Expand All @@ -58,11 +61,11 @@ impl WriteSetChange {
data: Default::default(),
inserted_at: chrono::Utc::now().naive_utc(),
},
APIWriteSetChange::DeleteTableItem {
APIWriteSetChange::DeleteTableItem(DeleteTableItem {
state_key_hash,
handle,
key,
} => WriteSetChange {
}) => WriteSetChange {
transaction_hash,
hash: state_key_hash.clone(),
type_: write_set_change.type_str().to_string(),
Expand All @@ -75,11 +78,11 @@ impl WriteSetChange {
}),
inserted_at: chrono::Utc::now().naive_utc(),
},
APIWriteSetChange::WriteModule {
APIWriteSetChange::WriteModule(WriteModule {
address,
state_key_hash,
data,
} => WriteSetChange {
}) => WriteSetChange {
transaction_hash,
hash: state_key_hash.clone(),
type_: write_set_change.type_str().to_string(),
Expand All @@ -89,11 +92,11 @@ impl WriteSetChange {
data: serde_json::to_value(data).unwrap(),
inserted_at: chrono::Utc::now().naive_utc(),
},
APIWriteSetChange::WriteResource {
APIWriteSetChange::WriteResource(WriteResource {
address,
state_key_hash,
data,
} => WriteSetChange {
}) => WriteSetChange {
transaction_hash,
hash: state_key_hash.clone(),
type_: write_set_change.type_str().to_string(),
Expand All @@ -103,12 +106,12 @@ impl WriteSetChange {
data: serde_json::to_value(data).unwrap(),
inserted_at: chrono::Utc::now().naive_utc(),
},
APIWriteSetChange::WriteTableItem {
APIWriteSetChange::WriteTableItem(WriteTableItem {
state_key_hash,
handle,
key,
value,
} => WriteSetChange {
}) => WriteSetChange {
transaction_hash,
hash: state_key_hash.clone(),
type_: write_set_change.type_str().to_string(),
Expand Down

0 comments on commit c6e13a7

Please sign in to comment.