difftreelog
fix(rpc) wrong return type for collectionTokens call
in: master
7 files changed
client/rpc/src/lib.rsdiffbeforeafterboth--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -33,6 +33,12 @@
account: CrossAccountId,
at: Option<BlockHash>,
) -> Result<Vec<TokenId>>;
+ #[rpc(name = "unique_collectionTokens")]
+ fn collection_tokens(
+ &self,
+ collection: CollectionId,
+ at: Option<BlockHash>,
+ ) -> Result<Vec<TokenId>>;
#[rpc(name = "unique_tokenExists")]
fn token_exists(
&self,
@@ -70,8 +76,6 @@
at: Option<BlockHash>,
) -> Result<Vec<u8>>;
- #[rpc(name = "unique_collectionTokens")]
- fn collection_tokens(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<u32>;
#[rpc(name = "unique_accountBalance")]
fn account_balance(
&self,
@@ -226,6 +230,7 @@
CrossAccountId: pallet_evm::account::CrossAccountId<AccountId>,
{
pass_method!(account_tokens(collection: CollectionId, account: CrossAccountId) -> Vec<TokenId>);
+ pass_method!(collection_tokens(collection: CollectionId) -> Vec<TokenId>);
pass_method!(token_exists(collection: CollectionId, token: TokenId) -> bool);
pass_method!(
token_owner(collection: CollectionId, token: TokenId) -> Option<CrossAccountId>;
@@ -234,7 +239,6 @@
pass_method!(topmost_token_owner(collection: CollectionId, token: TokenId) -> Option<CrossAccountId>);
pass_method!(const_metadata(collection: CollectionId, token: TokenId) -> Vec<u8>);
pass_method!(variable_metadata(collection: CollectionId, token: TokenId) -> Vec<u8>);
- pass_method!(collection_tokens(collection: CollectionId) -> u32);
pass_method!(account_balance(collection: CollectionId, account: CrossAccountId) -> u32);
pass_method!(balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> String => |v| v.to_string());
pass_method!(allowance(collection: CollectionId, sender: CrossAccountId, spender: CrossAccountId, token: TokenId) -> String => |v| v.to_string());
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -924,6 +924,7 @@
) -> DispatchResult;
fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId>;
+ fn collection_tokens(&self) -> Vec<TokenId>;
fn token_exists(&self, token: TokenId) -> bool;
fn last_token_id(&self) -> TokenId;
@@ -931,8 +932,6 @@
fn const_metadata(&self, token: TokenId) -> Vec<u8>;
fn variable_metadata(&self, token: TokenId) -> Vec<u8>;
- /// How many tokens collection contains (Applicable to nonfungible/refungible)
- fn collection_tokens(&self) -> u32;
/// Amount of different tokens account has (Applicable to nonfungible/refungible)
fn account_balance(&self, account: T::CrossAccountId) -> u32;
/// Amount of specific token account have (Applicable to fungible/refungible)
pallets/fungible/src/common.rsdiffbeforeafterboth--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -270,8 +270,8 @@
Vec::new()
}
- fn collection_tokens(&self) -> u32 {
- 1
+ fn collection_tokens(&self) -> Vec<TokenId> {
+ vec![TokenId::default()]
}
fn account_balance(&self, account: T::CrossAccountId) -> u32 {
pallets/nonfungible/src/common.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -264,6 +264,12 @@
.collect()
}
+ fn collection_tokens(&self) -> Vec<TokenId> {
+ <TokenData<T>>::iter_prefix((self.id,))
+ .map(|(id, _)| id)
+ .collect()
+ }
+
fn token_exists(&self, token: TokenId) -> bool {
<Pallet<T>>::token_exists(self, token)
}
@@ -286,10 +292,6 @@
.map(|t| t.variable_data)
.unwrap_or_default()
.into_inner()
- }
-
- fn collection_tokens(&self) -> u32 {
- <Pallet<T>>::total_supply(self)
}
fn account_balance(&self, account: T::CrossAccountId) -> u32 {
pallets/refungible/src/common.rsdiffbeforeafterboth--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -273,6 +273,12 @@
.collect()
}
+ fn collection_tokens(&self) -> Vec<TokenId> {
+ <TokenData<T>>::iter_prefix((self.id,))
+ .map(|(id, _)| id)
+ .collect()
+ }
+
fn token_exists(&self, token: TokenId) -> bool {
<Pallet<T>>::token_exists(self, token)
}
@@ -293,10 +299,6 @@
<TokenData<T>>::get((self.id, token))
.variable_data
.into_inner()
- }
-
- fn collection_tokens(&self) -> u32 {
- <Pallet<T>>::total_supply(self)
}
fn account_balance(&self, account: T::CrossAccountId) -> u32 {
primitives/rpc/src/lib.rsdiffbeforeafterboth--- a/primitives/rpc/src/lib.rs
+++ b/primitives/rpc/src/lib.rs
@@ -33,6 +33,7 @@
fn token_owner(collection: CollectionId, token: TokenId) -> Result<CrossAccountId>;
fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>>;
+ fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>>;
fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool>;
fn token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>>;
@@ -40,7 +41,6 @@
fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>>;
fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>>;
- fn collection_tokens(collection: CollectionId) -> Result<u32>;
fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32>;
fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128>;
fn allowance(
runtime/common/src/runtime_apis.rsdiffbeforeafterboth33 dispatch_unique_runtime!(collection.variable_metadata(token))33 dispatch_unique_runtime!(collection.variable_metadata(token))34 }34 }353536 fn collection_tokens(collection: CollectionId) -> Result<u32, DispatchError> {36 fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>, DispatchError> {37 dispatch_unique_runtime!(collection.collection_tokens())37 dispatch_unique_runtime!(collection.collection_tokens())38 }38 }39 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {39 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {