difftreelog
feat(rpc) totalSupply
in: master
8 files changed
client/rpc/src/lib.rsdiffbeforeafterboth76 at: Option<BlockHash>,76 at: Option<BlockHash>,77 ) -> Result<Vec<u8>>;77 ) -> Result<Vec<u8>>;787879 #[rpc(name = "unique_totalSupply")]80 fn total_supply(81 &self,82 collection: CollectionId,83 at: Option<BlockHash>,84 ) -> Result<u32>;79 #[rpc(name = "unique_accountBalance")]85 #[rpc(name = "unique_accountBalance")]80 fn account_balance(86 fn account_balance(81 &self,87 &self,240 pass_method!(const_metadata(collection: CollectionId, token: TokenId) -> Vec<u8>);246 pass_method!(const_metadata(collection: CollectionId, token: TokenId) -> Vec<u8>);241 pass_method!(variable_metadata(collection: CollectionId, token: TokenId) -> Vec<u8>);247 pass_method!(variable_metadata(collection: CollectionId, token: TokenId) -> Vec<u8>);248249 pass_method!(total_supply(collection: CollectionId) -> u32);242 pass_method!(account_balance(collection: CollectionId, account: CrossAccountId) -> u32);250 pass_method!(account_balance(collection: CollectionId, account: CrossAccountId) -> u32);243 pass_method!(balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> String => |v| v.to_string());251 pass_method!(balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> String => |v| v.to_string());244 pass_method!(allowance(collection: CollectionId, sender: CrossAccountId, spender: CrossAccountId, token: TokenId) -> String => |v| v.to_string());252 pass_method!(allowance(collection: CollectionId, sender: CrossAccountId, spender: CrossAccountId, token: TokenId) -> String => |v| v.to_string());pallets/common/src/lib.rsdiffbeforeafterboth932 fn const_metadata(&self, token: TokenId) -> Vec<u8>;932 fn const_metadata(&self, token: TokenId) -> Vec<u8>;933 fn variable_metadata(&self, token: TokenId) -> Vec<u8>;933 fn variable_metadata(&self, token: TokenId) -> Vec<u8>;934934935 /// Amount of unique collection tokens936 fn total_supply(&self) -> u32;935 /// Amount of different tokens account has (Applicable to nonfungible/refungible)937 /// Amount of different tokens account has (Applicable to nonfungible/refungible)936 fn account_balance(&self, account: T::CrossAccountId) -> u32;938 fn account_balance(&self, account: T::CrossAccountId) -> u32;937 /// Amount of specific token account have (Applicable to fungible/refungible)939 /// Amount of specific token account have (Applicable to fungible/refungible)pallets/fungible/src/common.rsdiffbeforeafterboth244 fail!(<Error<T>>::FungibleDisallowsNesting)244 fail!(<Error<T>>::FungibleDisallowsNesting)245 }245 }246247 fn collection_tokens(&self) -> Vec<TokenId> {248 vec![TokenId::default()]249 }246250247 fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {251 fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {248 if <Balance<T>>::get((self.id, account)) != 0 {252 if <Balance<T>>::get((self.id, account)) != 0 {270 Vec::new()274 Vec::new()271 }275 }272276273 fn collection_tokens(&self) -> Vec<TokenId> {277 fn total_supply(&self) -> u32 {274 vec![TokenId::default()]278 1275 }279 }276280277 fn account_balance(&self, account: T::CrossAccountId) -> u32 {281 fn account_balance(&self, account: T::CrossAccountId) -> u32 {pallets/nonfungible/src/common.rsdiffbeforeafterboth294 .into_inner()294 .into_inner()295 }295 }296297 fn total_supply(&self) -> u32 {298 <Pallet<T>>::total_supply(self)299 }296300297 fn account_balance(&self, account: T::CrossAccountId) -> u32 {301 fn account_balance(&self, account: T::CrossAccountId) -> u32 {298 <AccountBalance<T>>::get((self.id, account))302 <AccountBalance<T>>::get((self.id, account))pallets/refungible/src/common.rsdiffbeforeafterboth301 .into_inner()301 .into_inner()302 }302 }303304 fn total_supply(&self) -> u32 {305 <Pallet<T>>::total_supply(self)306 }303307304 fn account_balance(&self, account: T::CrossAccountId) -> u32 {308 fn account_balance(&self, account: T::CrossAccountId) -> u32 {305 <AccountBalance<T>>::get((self.id, account))309 <AccountBalance<T>>::get((self.id, account))primitives/rpc/src/lib.rsdiffbeforeafterboth41 fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>>;41 fn const_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>>;42 fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>>;42 fn variable_metadata(collection: CollectionId, token: TokenId) -> Result<Vec<u8>>;434344 fn total_supply(collection: CollectionId) -> Result<u32>;44 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32>;45 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32>;45 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128>;46 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Result<u128>;46 fn allowance(47 fn allowance(runtime/common/src/runtime_apis.rsdiffbeforeafterboth14 fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {14 fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Result<Vec<TokenId>, DispatchError> {15 dispatch_unique_runtime!(collection.account_tokens(account))15 dispatch_unique_runtime!(collection.account_tokens(account))16 }16 }17 fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>, DispatchError> {18 dispatch_unique_runtime!(collection.collection_tokens())19 }17 fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {20 fn token_exists(collection: CollectionId, token: TokenId) -> Result<bool, DispatchError> {18 dispatch_unique_runtime!(collection.token_exists(token))21 dispatch_unique_runtime!(collection.token_exists(token))19 }22 }33 dispatch_unique_runtime!(collection.variable_metadata(token))36 dispatch_unique_runtime!(collection.variable_metadata(token))34 }37 }353836 fn collection_tokens(collection: CollectionId) -> Result<Vec<TokenId>, DispatchError> {39 fn total_supply(collection: CollectionId) -> Result<u32, DispatchError> {37 dispatch_unique_runtime!(collection.collection_tokens())40 dispatch_unique_runtime!(collection.total_supply())38 }41 }39 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {42 fn account_balance(collection: CollectionId, account: CrossAccountId) -> Result<u32, DispatchError> {40 dispatch_unique_runtime!(collection.account_balance(account))43 dispatch_unique_runtime!(collection.account_balance(account))tests/src/interfaces/unique/definitions.tsdiffbeforeafterboth45 collectionTokens: fun('Get tokens contained in collection', [collectionParam], 'Vec<u32>'),45 collectionTokens: fun('Get tokens contained in collection', [collectionParam], 'Vec<u32>'),464647 lastTokenId: fun('Get last token id', [collectionParam], 'u32'),47 lastTokenId: fun('Get last token id', [collectionParam], 'u32'),48 totalSupply: fun('Get amount of unique collection tokens', [collectionParam], 'u32'),48 accountBalance: fun('Get amount of different user tokens', [collectionParam, crossAccountParam()], 'u32'),49 accountBalance: fun('Get amount of different user tokens', [collectionParam, crossAccountParam()], 'u32'),49 balance: fun('Get amount of specific account token', [collectionParam, crossAccountParam(), tokenParam], 'u128'),50 balance: fun('Get amount of specific account token', [collectionParam, crossAccountParam(), tokenParam], 'u128'),50 allowance: fun('Get allowed amount', [collectionParam, crossAccountParam('sender'), crossAccountParam('spender'), tokenParam], 'u128'),51 allowance: fun('Get allowed amount', [collectionParam, crossAccountParam('sender'), crossAccountParam('spender'), tokenParam], 'u128'),