Skip to content

feat: use json rpc apis for IOTA-Names reads #6617

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

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 23 additions & 2 deletions crates/iota-indexer/src/apis/indexer_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use iota_json_rpc_types::{
IotaTransactionBlockResponseQuery, ObjectsPage, Page, TransactionBlocksPage, TransactionFilter,
};
use iota_names::{
IotaNamesNft, IotaNamesRegistration, config::IotaNamesConfig, domain::Domain,
error::IotaNamesError, registry::NameRecord,
IotaNamesNft, IotaNamesRegistration, SubdomainRegistration, config::IotaNamesConfig,
domain::Domain, error::IotaNamesError, registry::NameRecord,
};
use iota_open_rpc::Module;
use iota_types::{
Expand Down Expand Up @@ -463,6 +463,27 @@ impl IndexerApiServer for IndexerApi {

Ok(owned_objects)
}

async fn iota_names_find_all_subdomain_nfts(
&self,
address: IotaAddress,
cursor: Option<ObjectID>,
limit: Option<usize>,
options: Option<IotaObjectDataOptions>,
) -> RpcResult<ObjectsPage> {
let query = IotaObjectResponseQuery {
filter: Some(IotaObjectDataFilter::StructType(
SubdomainRegistration::type_(self.iota_names_config.package_address.into()),
)),
options,
};

let owned_objects = self
.get_owned_objects(address, Some(query), cursor, limit)
.await?;

Ok(owned_objects)
}
}

impl IotaRpcModule for IndexerApi {
Expand Down
10 changes: 10 additions & 0 deletions crates/iota-json-rpc-api/src/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,14 @@ pub trait IndexerApi {
limit: Option<usize>,
options: Option<IotaObjectDataOptions>,
) -> RpcResult<ObjectsPage>;

/// Find all subdomain NFTs for the given address.
#[method(name = "iotaNamesFindAllSubdomainNFTs")]
async fn iota_names_find_all_subdomain_nfts(
&self,
address: IotaAddress,
cursor: Option<ObjectID>,
limit: Option<usize>,
options: Option<IotaObjectDataOptions>,
) -> RpcResult<ObjectsPage>;
}
26 changes: 24 additions & 2 deletions crates/iota-json-rpc/src/indexer_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use iota_json_rpc_types::{
};
use iota_metrics::spawn_monitored_task;
use iota_names::{
IotaNamesNft, IotaNamesRegistration, config::IotaNamesConfig, domain::Domain,
error::IotaNamesError, registry::NameRecord,
IotaNamesNft, IotaNamesRegistration, SubdomainRegistration, config::IotaNamesConfig,
domain::Domain, error::IotaNamesError, registry::NameRecord,
};
use iota_open_rpc::Module;
use iota_storage::key_value_store::TransactionKeyValueStore;
Expand Down Expand Up @@ -582,6 +582,28 @@ impl<R: ReadApiServer> IndexerApiServer for IndexerApi<R> {

Ok(owned_objects)
}

#[instrument(skip(self))]
async fn iota_names_find_all_subdomain_nfts(
&self,
address: IotaAddress,
cursor: Option<ObjectID>,
limit: Option<usize>,
options: Option<IotaObjectDataOptions>,
) -> RpcResult<ObjectsPage> {
let query = IotaObjectResponseQuery {
filter: Some(IotaObjectDataFilter::StructType(
SubdomainRegistration::type_(self.iota_names_config.package_address.into()),
)),
options,
};

let owned_objects = self
.get_owned_objects(address, Some(query), cursor, limit)
.await?;

Ok(owned_objects)
}
}

impl<R: ReadApiServer> IotaRpcModule for IndexerApi<R> {
Expand Down
45 changes: 45 additions & 0 deletions crates/iota-open-rpc/spec/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4636,6 +4636,51 @@
}
}
},
{
"name": "iotax_iotaNamesFindAllSubdomainNFTs",
"tags": [
{
"name": "Extended API"
}
],
"description": "Find all subdomain NFTs for the given address.",
"params": [
{
"name": "address",
"required": true,
"schema": {
"$ref": "#/components/schemas/IotaAddress"
}
},
{
"name": "cursor",
"schema": {
"$ref": "#/components/schemas/ObjectID"
}
},
{
"name": "limit",
"schema": {
"type": "integer",
"format": "uint",
"minimum": 0.0
}
},
{
"name": "options",
"schema": {
"$ref": "#/components/schemas/ObjectDataOptions"
}
}
],
"result": {
"name": "ObjectsPage",
"required": true,
"schema": {
"$ref": "#/components/schemas/Page_for_IotaObjectResponse_and_ObjectID"
}
}
},
{
"name": "iotax_iotaNamesLookup",
"tags": [
Expand Down
1 change: 1 addition & 0 deletions crates/iota/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ iota-graphql-rpc = { workspace = true, optional = true }
iota-graphql-rpc-client = { workspace = true, optional = true }
iota-indexer = { workspace = true, optional = true }
iota-json.workspace = true
iota-json-rpc-api.workspace = true
iota-json-rpc-types.workspace = true
iota-keys.workspace = true
iota-move.workspace = true
Expand Down
Loading
Loading