git.delta.rocks / unique-network / refs/commits / f462fd90fa85

difftreelog

Tests: code-style fixes

Andrey2022-10-06parent: #21df7e4.patch.diff
in: master

14 files changed

modifiedtests/src/addCollectionAdmin.test.tsdiffbeforeafterboth
110 const [alice, ...accounts] = await helper.arrange.createAccounts([10n, 0n, 0n, 0n, 0n, 0n, 0n, 0n], donor);110 const [alice, ...accounts] = await helper.arrange.createAccounts([10n, 0n, 0n, 0n, 0n, 0n, 0n, 0n], donor);
111 const collection = await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});111 const collection = await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});
112112
113 const chainAdminLimit = (helper.api!.consts.common.collectionAdminsLimit as any).toNumber();113 const chainAdminLimit = (helper.getApi().consts.common.collectionAdminsLimit as any).toNumber();
114 expect(chainAdminLimit).to.be.equal(5);114 expect(chainAdminLimit).to.be.equal(5);
115115
116 for (let i = 0; i < chainAdminLimit; i++) {116 for (let i = 0; i < chainAdminLimit; i++) {
modifiedtests/src/approve.test.tsdiffbeforeafterboth
60 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});60 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
61 await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});61 await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});
62 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;62 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;
63 await helper.signTransaction(alice, helper.api?.tx.unique.approve({Substrate: bob.address}, collectionId, tokenId, 0));63 await helper.signTransaction(alice, helper.constructApiCall('api.tx.unique.approve', [{Substrate: bob.address}, collectionId, tokenId, 0]));
64 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;64 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;
65 });65 });
6666
275 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});275 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
276 await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});276 await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});
277 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;277 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;
278 await helper.signTransaction(alice, helper.api?.tx.unique.approve({Substrate: bob.address}, collectionId, tokenId, 0));278 await helper.signTransaction(alice, helper.constructApiCall('api.tx.unique.approve', [{Substrate: bob.address}, collectionId, tokenId, 0]));
279 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;279 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;
280 const transferTokenFromTx = async () => helper.nft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: bob.address});280 const transferTokenFromTx = async () => helper.nft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: bob.address});
281 await expect(transferTokenFromTx()).to.be.rejected;281 await expect(transferTokenFromTx()).to.be.rejected;
328 itSub('1 for NFT', async ({helper}) => {328 itSub('1 for NFT', async ({helper}) => {
329 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});329 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
330 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});330 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
331 const approveTx = async () => helper.signTransaction(bob, helper.api?.tx.unique.approve({Substrate: charlie.address}, collectionId, tokenId, 2));331 const approveTx = async () => helper.signTransaction(bob, helper.constructApiCall('api.tx.unique.approve', [{Substrate: charlie.address}, collectionId, tokenId, 2]));
332 await expect(approveTx()).to.be.rejected;332 await expect(approveTx()).to.be.rejected;
333 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: charlie.address})).to.be.false;333 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: charlie.address})).to.be.false;
334 });334 });
modifiedtests/src/block-production.test.tsdiffbeforeafterboth
3737
38describe('Block Production smoke test', () => {38describe('Block Production smoke test', () => {
39 itSub('Node produces new blocks', async ({helper}) => {39 itSub('Node produces new blocks', async ({helper}) => {
40 const blocks: number[] | undefined = await getBlocks(helper.api!);40 const blocks: number[] | undefined = await getBlocks(helper.getApi());
41 expect(blocks[0]).to.be.lessThan(blocks[1]);41 expect(blocks[0]).to.be.lessThan(blocks[1]);
42 });42 });
43});43});
modifiedtests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth
178 tokenPrefix: 'COL',178 tokenPrefix: 'COL',
179 }, 0);179 }, 0);
180180
181 const api = helper.api;
182 await helper.signTransaction(alice, api?.tx.unique.createMultipleItemsEx(collection.collectionId, {181 await helper.executeExtrinsic(alice, 'api.tx.unique.createMultipleItemsEx',[collection.collectionId, {
183 Fungible: new Map([182 Fungible: new Map([
184 [JSON.stringify({Substrate: alice.address}), 50],183 [JSON.stringify({Substrate: alice.address}), 50],
185 [JSON.stringify({Substrate: bob.address}), 100],184 [JSON.stringify({Substrate: bob.address}), 100],
186 ]),185 ]),
187 }));186 }], true);
188187
189 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(50n);188 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(50n);
190 expect(await collection.getBalance({Substrate: bob.address})).to.be.equal(100n);189 expect(await collection.getBalance({Substrate: bob.address})).to.be.equal(100n);
200 ],199 ],
201 });200 });
202201
203 const api = helper.api;
204 await helper.signTransaction(alice, api?.tx.unique.createMultipleItemsEx(collection.collectionId, {202 await helper.executeExtrinsic(alice, 'api.tx.unique.createMultipleItemsEx', [collection.collectionId, {
205 RefungibleMultipleOwners: {203 RefungibleMultipleOwners: {
206 users: new Map([204 users: new Map([
207 [JSON.stringify({Substrate: alice.address}), 1],205 [JSON.stringify({Substrate: alice.address}), 1],
211 {key: 'k', value: 'v'},209 {key: 'k', value: 'v'},
212 ],210 ],
213 },211 },
214 }));212 }], true);
215 const tokenId = await collection.getLastTokenId();213 const tokenId = await collection.getLastTokenId();
216 expect(tokenId).to.be.equal(1);214 expect(tokenId).to.be.equal(1);
217 expect(await collection.getTokenBalance(1, {Substrate: alice.address})).to.be.equal(1n);215 expect(await collection.getTokenBalance(1, {Substrate: alice.address})).to.be.equal(1n);
228 ],226 ],
229 });227 });
230
231 const api = helper.api;
232228
233 await helper.signTransaction(alice, api?.tx.unique.createMultipleItemsEx(collection.collectionId, {229 await helper.executeExtrinsic(alice, 'api.tx.unique.createMultipleItemsEx', [collection.collectionId, {
234 RefungibleMultipleItems: [230 RefungibleMultipleItems: [
235 {231 {
236 user: {Substrate: alice.address}, pieces: 1,232 user: {Substrate: alice.address}, pieces: 1,
245 ],241 ],
246 },242 },
247 ],243 ],
248 }));244 }], true);
249245
250 expect(await collection.getLastTokenId()).to.be.equal(2);246 expect(await collection.getLastTokenId()).to.be.equal(2);
251 expect(await collection.getTokenBalance(1, {Substrate: alice.address})).to.be.equal(1n);247 expect(await collection.getTokenBalance(1, {Substrate: alice.address})).to.be.equal(1n);
modifiedtests/src/creditFeesToTreasury.test.tsdiffbeforeafterboth
70 });70 });
7171
72 itSub('Sender balance decreased by fee+sent amount, Treasury balance increased by fee', async ({helper}) => {72 itSub('Sender balance decreased by fee+sent amount, Treasury balance increased by fee', async ({helper}) => {
73 await skipInflationBlock(helper.api!);73 await skipInflationBlock(helper.getApi());
74 await helper.wait.newBlocks(1);74 await helper.wait.newBlocks(1);
7575
76 const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);76 const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);
89 });89 });
9090
91 itSub('Treasury balance increased by failed tx fee', async ({helper}) => {91 itSub('Treasury balance increased by failed tx fee', async ({helper}) => {
92 const api = helper.api!;92 const api = helper.getApi();
93 await helper.wait.newBlocks(1);93 await helper.wait.newBlocks(1);
9494
95 const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);95 const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);
107 });107 });
108108
109 itSub('NFT Transactions also send fees to Treasury', async ({helper}) => {109 itSub('NFT Transactions also send fees to Treasury', async ({helper}) => {
110 await skipInflationBlock(helper.api!);110 await skipInflationBlock(helper.getApi());
111 await helper.wait.newBlocks(1);111 await helper.wait.newBlocks(1);
112112
113 const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);113 const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);
125125
126 itSub('Fees are sane', async ({helper}) => {126 itSub('Fees are sane', async ({helper}) => {
127 const unique = helper.balance.getOneTokenNominal();127 const unique = helper.balance.getOneTokenNominal();
128 await skipInflationBlock(helper.api!);128 await skipInflationBlock(helper.getApi());
129 await helper.wait.newBlocks(1);129 await helper.wait.newBlocks(1);
130130
131 const aliceBalanceBefore = await helper.balance.getSubstrate(alice.address);131 const aliceBalanceBefore = await helper.balance.getSubstrate(alice.address);
140 });140 });
141141
142 itSub('NFT Transfer fee is close to 0.1 Unique', async ({helper}) => {142 itSub('NFT Transfer fee is close to 0.1 Unique', async ({helper}) => {
143 await skipInflationBlock(helper.api!);143 await skipInflationBlock(helper.getApi());
144 await helper.wait.newBlocks(1);144 await helper.wait.newBlocks(1);
145145
146 const collection = await helper.nft.mintCollection(alice, {146 const collection = await helper.nft.mintCollection(alice, {
modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
152 before(async function() {152 before(async function() {
153 await usingEthPlaygrounds(async (helper, privateKey) => {153 await usingEthPlaygrounds(async (helper, privateKey) => {
154 donor = privateKey('//Alice');154 donor = privateKey('//Alice');
155 nominal = helper.balance.getOneTokenNominal()155 nominal = helper.balance.getOneTokenNominal();
156 });156 });
157 });157 });
158158
modifiedtests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth
138 });138 });
139139
140 //TODO: CORE-302 add eth methods140 //TODO: CORE-302 add eth methods
141 itEth.skip('Can perform mintBulk()', async ({helper, privateKey}) => {141 itEth.skip('Can perform mintBulk()', async ({helper}) => {
142 const collection = await helper.nft.mintCollection(donor, {name: 'New', description: 'New collection', tokenPrefix: 'NEW'});
143
144 const caller = await helper.eth.createAccountWithBalance(donor, 30n);
142 const api = helper.getApi();145 const receiver = helper.eth.createAccount();
146
143 const web3 = helper.getWeb3();147 const address = helper.ethAddress.fromCollectionId(collection.collectionId);
144 const privateKeyWrapper = privateKey;148 const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);
145 /*149 const contract = await proxyWrap(helper, evmCollection, donor);
146 const collection = await createCollectionExpectSuccess({150 await collection.addAdmin(donor, {Ethereum: contract.options.address});
147 mode: {type: 'NFT'},151
148 });152 {
149 const alice = privateKeyWrapper('//Alice');153 const nextTokenId = await contract.methods.nextTokenId().call();
150154 expect(nextTokenId).to.be.equal('1');
151 const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);155 const result = await contract.methods.mintBulkWithTokenURI(
152 const receiver = createEthAccount(web3);156 receiver,
153157 [
154 const address = collectionIdToAddress(collection);158 [nextTokenId, 'Test URI 0'],
155 const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}), privateKeyWrapper);159 [+nextTokenId + 1, 'Test URI 1'],
156 const changeAdminTx = api.tx.unique.addCollectionAdmin(collection, {Ethereum: contract.options.address});160 [+nextTokenId + 2, 'Test URI 2'],
157 await submitTransactionAsync(alice, changeAdminTx);161 ],
158162 ).send({from: caller});
159 {163 const events = helper.eth.normalizeEvents(result.events);
160 const nextTokenId = await contract.methods.nextTokenId().call();164
161 expect(nextTokenId).to.be.equal('1');165 expect(events).to.be.deep.equal([
162 const result = await contract.methods.mintBulkWithTokenURI(166 {
163 receiver,167 address,
164 [168 event: 'Transfer',
165 [nextTokenId, 'Test URI 0'],169 args: {
166 [+nextTokenId + 1, 'Test URI 1'],170 from: '0x0000000000000000000000000000000000000000',
167 [+nextTokenId + 2, 'Test URI 2'],171 to: receiver,
168 ],172 tokenId: nextTokenId,
169 ).send({from: caller});173 },
170 const events = normalizeEvents(result.events);174 },
171175 {
172 expect(events).to.be.deep.equal([176 address,
173 {177 event: 'Transfer',
174 address,178 args: {
175 event: 'Transfer',179 from: '0x0000000000000000000000000000000000000000',
176 args: {180 to: receiver,
177 from: '0x0000000000000000000000000000000000000000',181 tokenId: String(+nextTokenId + 1),
178 to: receiver,182 },
179 tokenId: nextTokenId,183 },
180 },184 {
181 },185 address,
182 {186 event: 'Transfer',
183 address,187 args: {
184 event: 'Transfer',188 from: '0x0000000000000000000000000000000000000000',
185 args: {189 to: receiver,
186 from: '0x0000000000000000000000000000000000000000',190 tokenId: String(+nextTokenId + 2),
187 to: receiver,191 },
188 tokenId: String(+nextTokenId + 1),192 },
189 },193 ]);
190 },194
191 {195 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI 0');
192 address,196 expect(await contract.methods.tokenURI(+nextTokenId + 1).call()).to.be.equal('Test URI 1');
193 event: 'Transfer',197 expect(await contract.methods.tokenURI(+nextTokenId + 2).call()).to.be.equal('Test URI 2');
194 args: {198 }
195 from: '0x0000000000000000000000000000000000000000',
196 to: receiver,
197 tokenId: String(+nextTokenId + 2),
198 },
199 },
200 ]);
201
202 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI 0');
203 expect(await contract.methods.tokenURI(+nextTokenId + 1).call()).to.be.equal('Test URI 1');
204 expect(await contract.methods.tokenURI(+nextTokenId + 2).call()).to.be.equal('Test URI 2');
205 }
206 */
207 });199 });
208200
209 itEth('Can perform burn()', async ({helper}) => {201 itEth('Can perform burn()', async ({helper}) => {
modifiedtests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth
285 await code();285 await code();
286 // In dev mode, the transaction might not finish processing in time286 // In dev mode, the transaction might not finish processing in time
287 await this.helper.wait.newBlocks(1);287 await this.helper.wait.newBlocks(1);
288 }288 };
289 return await this.helper.arrange.calculcateFee(address, code);289 return await this.helper.arrange.calculcateFee(address, wrappedCode);
290 }290 }
291} 291}
292292
modifiedtests/src/inflation.test.tsdiffbeforeafterboth
40 const tx = helper.constructApiCall('api.tx.inflation.startInflation', [1]);40 const tx = helper.constructApiCall('api.tx.inflation.startInflation', [1]);
41 await expect(helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [tx])).to.not.be.rejected;41 await expect(helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [tx])).to.not.be.rejected;
4242
43 const blockInterval = (helper.api!.consts.inflation.inflationBlockInterval as any).toBigInt();43 const blockInterval = (helper.getApi().consts.inflation.inflationBlockInterval as any).toBigInt();
44 const totalIssuanceStart = ((await helper.api!.query.inflation.startingYearTotalIssuance()) as any).toBigInt();44 const totalIssuanceStart = ((await helper.callRpc('api.query.inflation.startingYearTotalIssuance', [])) as any).toBigInt();
45 const blockInflation = (await helper.api!.query.inflation.blockInflation() as any).toBigInt();45 const blockInflation = (await helper.callRpc('api.query.inflation.blockInflation', []) as any).toBigInt();
4646
47 const YEAR = 5259600n; // 6-second block. Blocks in one year47 const YEAR = 5259600n; // 6-second block. Blocks in one year
48 // const YEAR = 2629800n; // 12-second block. Blocks in one year48 // const YEAR = 2629800n; // 12-second block. Blocks in one year
modifiedtests/src/nesting/properties.test.tsdiffbeforeafterboth
276 276
277 itSub('Reads access rights to properties of a collection', async ({helper}) => {277 itSub('Reads access rights to properties of a collection', async ({helper}) => {
278 const collection = await helper.nft.mintCollection(alice);278 const collection = await helper.nft.mintCollection(alice);
279 const propertyRights = (await helper.api!.query.common.collectionPropertyPermissions(collection.collectionId)).toJSON();279 const propertyRights = (await helper.callRpc('api.query.common.collectionPropertyPermissions', [collection.collectionId])).toJSON();
280 expect(propertyRights).to.be.empty;280 expect(propertyRights).to.be.empty;
281 });281 });
282 282
817 ).to.be.fulfilled;817 ).to.be.fulfilled;
818 }818 }
819819
820 const originalSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 820 const originalSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT');
821 return originalSpace;821 return originalSpace;
822 }822 }
823823
840 ).to.be.rejectedWith(/common\.NoPermission/);840 ).to.be.rejectedWith(/common\.NoPermission/);
841 }841 }
842842
843 const consumedSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 843 const consumedSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT');
844 expect(consumedSpace).to.be.equal(originalSpace);844 expect(consumedSpace).to.be.equal(originalSpace);
845 }845 }
846846
875 ).to.be.rejectedWith(/common\.NoPermission/);875 ).to.be.rejectedWith(/common\.NoPermission/);
876 }876 }
877 877
878 const consumedSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 878 const consumedSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT');
879 expect(consumedSpace).to.be.equal(originalSpace);879 expect(consumedSpace).to.be.equal(originalSpace);
880 }880 }
881881
911911
912 expect(await token.getProperties(['non-existent', 'now-existent'])).to.be.empty;912 expect(await token.getProperties(['non-existent', 'now-existent'])).to.be.empty;
913 913
914 const consumedSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 914 const consumedSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT');
915 expect(consumedSpace).to.be.equal(originalSpace);915 expect(consumedSpace).to.be.equal(originalSpace);
916 }916 }
917917
951 ])).to.be.rejectedWith(/common\.NoSpaceForProperty/);951 ])).to.be.rejectedWith(/common\.NoSpaceForProperty/);
952 952
953 expect(await token.getProperties(['a_holy_book', 'young_years'])).to.be.empty;953 expect(await token.getProperties(['a_holy_book', 'young_years'])).to.be.empty;
954 const consumedSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT'); 954 const consumedSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT');
955 expect(consumedSpace).to.be.equal(originalSpace);955 expect(consumedSpace).to.be.equal(originalSpace);
956 }956 }
957957
modifiedtests/src/pallet-presence.test.tsdiffbeforeafterboth
59describe('Pallet presence', () => {59describe('Pallet presence', () => {
60 before(async () => {60 before(async () => {
61 await usingPlaygrounds(async helper => {61 await usingPlaygrounds(async helper => {
62 const chain = await helper.api!.rpc.system.chain();62 const chain = await helper.callRpc('api.rpc.system.chain', []);
6363
64 const refungible = 'refungible';64 const refungible = 'refungible';
65 const scheduler = 'scheduler';65 const scheduler = 'scheduler';
modifiedtests/src/tx-version-presence.test.tsdiffbeforeafterboth
22describe('TxVersion is present', () => {22describe('TxVersion is present', () => {
23 before(async () => {23 before(async () => {
24 await usingPlaygrounds(async helper => {24 await usingPlaygrounds(async helper => {
25 metadata = await helper.api!.rpc.state.getMetadata();25 metadata = await helper.callRpc('api.rpc.state.getMetadata', []);
26 });26 });
27 });27 });
2828
modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
215 };215 };
216216
217 isDevNode = async () => {217 isDevNode = async () => {
218 const block1 = await this.helper.api?.rpc.chain.getBlock(await this.helper.api?.rpc.chain.getBlockHash(1));218 const block1 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [1])]);
219 const block2 = await this.helper.api?.rpc.chain.getBlock(await this.helper.api?.rpc.chain.getBlockHash(2));219 const block2 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [2])]);
220 const findCreationDate = async (block: any) => {220 const findCreationDate = async (block: any) => {
221 const humanBlock = block.toHuman();221 const humanBlock = block.toHuman();
222 let date;222 let date;
259 async newBlocks(blocksCount = 1): Promise<void> {259 async newBlocks(blocksCount = 1): Promise<void> {
260 // eslint-disable-next-line no-async-promise-executor260 // eslint-disable-next-line no-async-promise-executor
261 const promise = new Promise<void>(async (resolve) => {261 const promise = new Promise<void>(async (resolve) => {
262 const unsubscribe = await this.helper.api!.rpc.chain.subscribeNewHeads(() => {262 const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(() => {
263 if (blocksCount > 0) {263 if (blocksCount > 0) {
264 blocksCount--;264 blocksCount--;
265 } else {265 } else {
274 async forParachainBlockNumber(blockNumber: bigint) {274 async forParachainBlockNumber(blockNumber: bigint) {
275 // eslint-disable-next-line no-async-promise-executor275 // eslint-disable-next-line no-async-promise-executor
276 return new Promise<void>(async (resolve) => {276 return new Promise<void>(async (resolve) => {
277 const unsubscribe = await this.helper.api!.rpc.chain.subscribeNewHeads(async (data: any) => {277 const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(async (data: any) => {
278 if (data.number.toNumber() >= blockNumber) {278 if (data.number.toNumber() >= blockNumber) {
279 unsubscribe();279 unsubscribe();
280 resolve();280 resolve();
286 async forRelayBlockNumber(blockNumber: bigint) {286 async forRelayBlockNumber(blockNumber: bigint) {
287 // eslint-disable-next-line no-async-promise-executor287 // eslint-disable-next-line no-async-promise-executor
288 return new Promise<void>(async (resolve) => {288 return new Promise<void>(async (resolve) => {
289 const unsubscribe = await this.helper.api!.query.parachainSystem.validationData(async (data: any) => {289 const unsubscribe = await this.helper.getApi().query.parachainSystem.validationData(async (data: any) => {
290 if (data.value.relayParentNumber.toNumber() >= blockNumber) {290 if (data.value.relayParentNumber.toNumber() >= blockNumber) {
291 // @ts-ignore291 // @ts-ignore
292 unsubscribe();292 unsubscribe();
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
1991 * @returns ss58Format, token decimals, and token symbol1991 * @returns ss58Format, token decimals, and token symbol
1992 */1992 */
1993 getChainProperties(): IChainProperties {1993 getChainProperties(): IChainProperties {
1994 const properties = (this.helper.api as any).registry.getChainProperties().toJSON();1994 const properties = (this.helper.getApi() as any).registry.getChainProperties().toJSON();
1995 return {1995 return {
1996 ss58Format: properties.ss58Format.toJSON(),1996 ss58Format: properties.ss58Format.toJSON(),
1997 tokenDecimals: properties.tokenDecimals.toJSON(),1997 tokenDecimals: properties.tokenDecimals.toJSON(),
2034 * @returns number, account's nonce2034 * @returns number, account's nonce
2035 */2035 */
2036 async getNonce(address: TSubstrateAccount): Promise<number> {2036 async getNonce(address: TSubstrateAccount): Promise<number> {
2037 return (await (this.helper.api as any).query.system.account(address)).nonce.toNumber();2037 return (await this.helper.callRpc('api.query.system.account', [address])).nonce.toNumber();
2038 }2038 }
2039}2039}
20402040