Skip to content

Commit

Permalink
retrieve token balances
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo committed Nov 18, 2024
1 parent a28545d commit 78a341d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/torii/grpc/proto/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ message Token {
string metadata = 6;
}

message Balance {
message TokenBalance {
string balance = 1;
string account_address = 2;
string contract_address = 3;
Expand Down
16 changes: 16 additions & 0 deletions crates/torii/grpc/proto/world.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ service World {

// Retrieve tokens
rpc RetrieveTokens (RetrieveTokensRequest) returns (RetrieveTokensResponse);

// Retrieve token balances
rpc RetrieveTokenBalances (RetrieveTokenBalancesRequest) returns (RetrieveTokenBalancesResponse);
}

// A request to retrieve tokens
Expand All @@ -58,6 +61,19 @@ message RetrieveTokensResponse {
repeated types.Token tokens = 1;
}

// A request to retrieve token balances
message RetrieveTokenBalancesRequest {
// The account addresses to retrieve balances for
repeated bytes account_addresses = 1;
// The list of token contract addresses to retrieve balances for
repeated bytes contract_addresses = 2;
}

// A response containing token balances
message RetrieveTokenBalancesResponse {
repeated types.TokenBalance balances = 1;
}

// A request to subscribe to indexer updates.
message SubscribeIndexerRequest {
bytes contract_address = 1;
Expand Down
8 changes: 8 additions & 0 deletions crates/torii/grpc/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,14 @@ impl DojoWorld {
Ok(RetrieveTokensResponse { tokens })
}

async fn retrieve_balances(
&self,
account_address: Vec<Felt>,
contract_addresses: Vec<Felt>,
) -> Result<RetrieveBalancesResponse, Status> {

}

async fn subscribe_indexer(
&self,
contract_address: Felt,
Expand Down

0 comments on commit 78a341d

Please sign in to comment.