git.delta.rocks / unique-network / refs/commits / 79a270aa7ee9

difftreelog

fix serde rpc Fixed method signature `total_pieces`. Before that the number of pieces greater than 2^53 -1 caused an error when calling this method.

PraetorP2022-08-12parent: #e4268af.patch.diff
in: master

7 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -12379,7 +12379,7 @@
 
 [[package]]
 name = "uc-rpc"
-version = "0.1.1"
+version = "0.1.2"
 dependencies = [
  "anyhow",
  "jsonrpsee",
modifiedclient/rpc/CHANGELOG.mddiffbeforeafterboth
22
3All notable changes to this project will be documented in this file.3All notable changes to this project will be documented in this file.
44
5## [0.1.2] - 2022-08-12
6
7### Fixed
8
9- Method signature `total_pieces`. Before that the number of pieces greater than 2^53 -1 caused an error when calling this method.
10
5## [0.1.1] - 2022-07-1411## [0.1.1] - 2022-07-14
612
7### Added13### Added
814
9 - Implementation of RPC method `token_owners` returning 10 owners in no particular order.15- Implementation of RPC method `token_owners` returning 10 owners in no particular order.
10 This was an internal request to improve the web interface and support fractionalization event. 16 This was an internal request to improve the web interface and support fractionalization event.
11 17
modifiedclient/rpc/Cargo.tomldiffbeforeafterboth
--- a/client/rpc/Cargo.toml
+++ b/client/rpc/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "uc-rpc"
-version = "0.1.1"
+version = "0.1.2"
 license = "GPLv3"
 edition = "2021"
 
modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -242,7 +242,7 @@
 		collection_id: CollectionId,
 		token_id: TokenId,
 		at: Option<BlockHash>,
-	) -> Result<Option<u128>>;
+	) -> Result<Option<String>>;
 }
 
 mod rmrk_unique_rpc {
@@ -518,7 +518,7 @@
 	pass_method!(collection_stats() -> CollectionStats, unique_api);
 	pass_method!(next_sponsored(collection: CollectionId, account: CrossAccountId, token: TokenId) -> Option<u64>, unique_api);
 	pass_method!(effective_collection_limits(collection_id: CollectionId) -> Option<CollectionLimits>, unique_api);
-	pass_method!(total_pieces(collection_id: CollectionId, token_id: TokenId) -> Option<u128>, unique_api);
+	pass_method!(total_pieces(collection_id: CollectionId, token_id: TokenId) -> Option<String> => |o| o.map(|number| number.to_string()) , unique_api);
 	pass_method!(token_owners(collection: CollectionId, token: TokenId) -> Vec<CrossAccountId>, unique_api);
 }
 
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -536,7 +536,7 @@
 		/// Can't transfer tokens to ethereum zero address
 		AddressIsZero,
 
-		/// The oprtation is not supported
+		/// The operation is not supported
 		UnsupportedOperation,
 
 		/// Insufficient funds to perform an action
modifiedtests/CHANGELOG.mddiffbeforeafterboth
--- a/tests/CHANGELOG.md
+++ b/tests/CHANGELOG.md
@@ -2,10 +2,15 @@
 
 All notable changes to this project will be documented in this file.
 
+## 2022-08-12
+
+### Added
+
+-   In integration tests for `RFT` added check of work with the maximum allowable number of pieces (MAX_REFUNGIBLE_PIECES).
+
 ## 2022-07-14
 
 ### Added
- - Integrintegration tests of RPC method `token_owners`.
- - Integrintegration tests of Fungible Pallet.
-  
- 
\ No newline at end of file
+
+-   Integrintegration tests of RPC method `token_owners`.
+-   Integrintegration tests of Fungible Pallet.
modifiedtests/src/refungible.test.tsdiffbeforeafterboth
--- a/tests/src/refungible.test.ts
+++ b/tests/src/refungible.test.ts
@@ -16,7 +16,7 @@
 
 import {IKeyringPair} from '@polkadot/types/types';
 
-import { usingPlaygrounds } from './util/playgrounds';
+import {usingPlaygrounds} from './util/playgrounds';
 import {
   getModuleNames,
   Pallets,
@@ -30,6 +30,7 @@
 
 let alice: IKeyringPair;
 let bob: IKeyringPair;
+const MAX_REFUNGIBLE_PIECES = 1_000_000_000_000_000_000_000n;
 
 describe('integration test: Refungible functionality:', async () => {
   before(async function() {
@@ -58,6 +59,22 @@
     });
   });
   
+  it('Checking RPC methods when interacting with maximum allowed values (MAX_REFUNGIBLE_PIECES)', async () => {
+    await usingPlaygrounds(async helper => {
+      const collection = await helper.rft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'});
+      
+      const token = await collection.mintToken(alice, {Substrate: alice.address}, MAX_REFUNGIBLE_PIECES);
+      
+      expect(await collection.getTokenBalance(token.tokenId, {Substrate: alice.address})).to.be.equal(MAX_REFUNGIBLE_PIECES);
+      
+      await collection.transferToken(alice, token.tokenId, {Substrate: bob.address}, MAX_REFUNGIBLE_PIECES);
+      expect(await collection.getTokenBalance(token.tokenId, {Substrate: bob.address})).to.be.equal(MAX_REFUNGIBLE_PIECES);
+      expect(await token.getTotalPieces()).to.be.equal(MAX_REFUNGIBLE_PIECES);
+      
+      await expect(collection.mintToken(alice, {Substrate: alice.address}, MAX_REFUNGIBLE_PIECES + 1n)).to.eventually.be.rejected;
+    });
+  });
+  
   it('RPC method tokenOnewrs for refungible collection and token', async () => {
     await usingPlaygrounds(async (helper, privateKey) => {
       const ethAcc = {Ethereum: '0x67fb3503a61b284dc83fa96dceec4192db47dc7c'};