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

difftreelog

refac: rename substrate methods to cross

Trubnikov Sergey2022-09-28parent: #01b189e.patch.diff
in: master

16 files changed

modifiedpallets/common/src/erc.rsdiffbeforeafterboth
656656
657 /// Get collection owner.657 /// Get collection owner.
658 ///658 ///
659 /// @return Tuple with sponsor address and his substrate mirror.659 /// @return Tuble with sponsor address and his substrate mirror.
660 /// If address is canonical then substrate mirror is zero and vice versa.660 /// If address is canonical then substrate mirror is zero and vice versa.
661 fn collection_owner(&self) -> Result<(address, uint256)> {661 fn collection_owner(&self) -> Result<(address, uint256)> {
662 Ok(convert_cross_account_to_tuple::<T>(662 Ok(convert_cross_account_to_tuple::<T>(
modifiedpallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth
385385
386 /// Get collection owner.386 /// Get collection owner.
387 ///387 ///
388 /// @return Tuple with sponsor address and his substrate mirror.388 /// @return Tuble with sponsor address and his substrate mirror.
389 /// If address is canonical then substrate mirror is zero and vice versa.389 /// If address is canonical then substrate mirror is zero and vice versa.
390 /// @dev EVM selector for this function is: 0xdf727d3b,390 /// @dev EVM selector for this function is: 0xdf727d3b,
391 /// or in textual repr: collectionOwner()391 /// or in textual repr: collectionOwner()
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
471471
472 /// Get collection owner.472 /// Get collection owner.
473 ///473 ///
474 /// @return Tuple with sponsor address and his substrate mirror.474 /// @return Tuble with sponsor address and his substrate mirror.
475 /// If address is canonical then substrate mirror is zero and vice versa.475 /// If address is canonical then substrate mirror is zero and vice versa.
476 /// @dev EVM selector for this function is: 0xdf727d3b,476 /// @dev EVM selector for this function is: 0xdf727d3b,
477 /// or in textual repr: collectionOwner()477 /// or in textual repr: collectionOwner()
modifiedpallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth
471471
472 /// Get collection owner.472 /// Get collection owner.
473 ///473 ///
474 /// @return Tuple with sponsor address and his substrate mirror.474 /// @return Tuble with sponsor address and his substrate mirror.
475 /// If address is canonical then substrate mirror is zero and vice versa.475 /// If address is canonical then substrate mirror is zero and vice versa.
476 /// @dev EVM selector for this function is: 0xdf727d3b,476 /// @dev EVM selector for this function is: 0xdf727d3b,
477 /// or in textual repr: collectionOwner()477 /// or in textual repr: collectionOwner()
modifiedtests/src/eth/allowlist.test.tsdiffbeforeafterboth
89 expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.false;89 expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.false;
90 });90 });
9191
92 //itEth('Collection allowlist can be added and removed by [cross] address', async ({helper}) => {92 itEth('Collection allowlist can be added and removed by [cross] address', async ({helper}) => {
93 // const owner = await helper.eth.createAccountWithBalance(donor);93 const owner = await helper.eth.createAccountWithBalance(donor);
94 // const user = donor;94 const user = donor;
95 // 95
96 // const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');96 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
97 // const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);97 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
98 // const userCross = helper.ethCrossAccount.fromKeyringPair(user);98 const userCross = helper.ethCrossAccount.fromKeyringPair(user);
99 // 99
100 // expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;100 expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;
101 // await collectionEvm.methods.addToCollectionAllowListCross(userCross).send({from: owner});101 await collectionEvm.methods.addToCollectionAllowListCross(userCross).send({from: owner});
102 // expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.true;102 expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.true;
103 // 103
104 // await collectionEvm.methods.removeFromCollectionAllowListCross(userCross).send({from: owner});104 await collectionEvm.methods.removeFromCollectionAllowListCross(userCross).send({from: owner});
105 // expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;105 expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;
106 //});106 });
107107
108 itEth('Collection allowlist can not be add and remove [eth] address by not owner', async ({helper}) => {108 itEth('Collection allowlist can not be add and remove [eth] address by not owner', async ({helper}) => {
109 const owner = await helper.eth.createAccountWithBalance(donor);109 const owner = await helper.eth.createAccountWithBalance(donor);
122 expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.true;122 expect(await collectionEvm.methods.allowed(user).call({from: owner})).to.be.true;
123 });123 });
124124
125 //itEth('Collection allowlist can not be add and remove [cross] address by not owner', async ({helper}) => {125 itEth('Collection allowlist can not be add and remove [cross] address by not owner', async ({helper}) => {
126 // const owner = await helper.eth.createAccountWithBalance(donor);126 const owner = await helper.eth.createAccountWithBalance(donor);
127 // const notOwner = await helper.eth.createAccountWithBalance(donor);127 const notOwner = await helper.eth.createAccountWithBalance(donor);
128 // const user = donor;128 const user = donor;
129 // 129
130 // const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');130 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
131 // const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);131 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
132 // 132
133 // expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;133 expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;
134 // const userCross = helper.ethCrossAccount.fromKeyringPair(user);134 const userCross = helper.ethCrossAccount.fromKeyringPair(user);
135 // await expect(collectionEvm.methods.addToCollectionAllowListCross(userCross).call({from: notOwner})).to.be.rejectedWith('NoPermission');135 await expect(collectionEvm.methods.addToCollectionAllowListCross(userCross).call({from: notOwner})).to.be.rejectedWith('NoPermission');
136 // expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;136 expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.false;
137 // await collectionEvm.methods.addToCollectionAllowListCross(userCross).send({from: owner});137 await collectionEvm.methods.addToCollectionAllowListCross(userCross).send({from: owner});
138 // 138
139 // expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.true;139 expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.true;
140 // await expect(collectionEvm.methods.removeFromCollectionAllowListCross(userCross).call({from: notOwner})).to.be.rejectedWith('NoPermission');140 await expect(collectionEvm.methods.removeFromCollectionAllowListCross(userCross).call({from: notOwner})).to.be.rejectedWith('NoPermission');
141 // expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.true;141 expect(await helper.collection.allowed(collectionId, {Substrate: user.address})).to.be.true;
142 //});142 });
143});143});
144144
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
249249
250 /// Get collection owner.250 /// Get collection owner.
251 ///251 ///
252 /// @return Tuple with sponsor address and his substrate mirror.252 /// @return Tuble with sponsor address and his substrate mirror.
253 /// If address is canonical then substrate mirror is zero and vice versa.253 /// If address is canonical then substrate mirror is zero and vice versa.
254 /// @dev EVM selector for this function is: 0xdf727d3b,254 /// @dev EVM selector for this function is: 0xdf727d3b,
255 /// or in textual repr: collectionOwner()255 /// or in textual repr: collectionOwner()
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
306306
307 /// Get collection owner.307 /// Get collection owner.
308 ///308 ///
309 /// @return Tuple with sponsor address and his substrate mirror.309 /// @return Tuble with sponsor address and his substrate mirror.
310 /// If address is canonical then substrate mirror is zero and vice versa.310 /// If address is canonical then substrate mirror is zero and vice versa.
311 /// @dev EVM selector for this function is: 0xdf727d3b,311 /// @dev EVM selector for this function is: 0xdf727d3b,
312 /// or in textual repr: collectionOwner()312 /// or in textual repr: collectionOwner()
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
306306
307 /// Get collection owner.307 /// Get collection owner.
308 ///308 ///
309 /// @return Tuple with sponsor address and his substrate mirror.309 /// @return Tuble with sponsor address and his substrate mirror.
310 /// If address is canonical then substrate mirror is zero and vice versa.310 /// If address is canonical then substrate mirror is zero and vice versa.
311 /// @dev EVM selector for this function is: 0xdf727d3b,311 /// @dev EVM selector for this function is: 0xdf727d3b,
312 /// or in textual repr: collectionOwner()312 /// or in textual repr: collectionOwner()
modifiedtests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth
53 itEth('Add cross account admin by owner', async ({helper, privateKey}) => {53 itEth('Add cross account admin by owner', async ({helper, privateKey}) => {
54 const owner = await helper.eth.createAccountWithBalance(donor);54 const owner = await helper.eth.createAccountWithBalance(donor);
55 55
56 const {collectionAddress, collectionId} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');56 const {collectionAddress, collectionId} = await helper.eth.createNonfungibleCollection(owner, 'A', 'B', 'C');
57 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);57 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
58 58
59 const newAdmin = await privateKey('//Bob');59 const newAdmin = privateKey('//Bob');
60 const newAdminCross = helper.ethCrossAccount.fromKeyringPair(newAdmin);60 const newAdminCross = helper.ethCrossAccount.fromKeyringPair(newAdmin);
61 await collectionEvm.methods.addCollectionAdminCross(newAdminCross).send();61 await collectionEvm.methods.addCollectionAdminCross(newAdminCross).send();
6262
modifiedtests/src/eth/fungible.test.tsdiffbeforeafterboth
149 });149 });
150150
151 itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {151 itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {
152 const alice = await privateKey('//Alice');152 const alice = privateKey('//Alice');
153 const sender = await helper.eth.createAccountWithBalance(alice, 100n);153 const sender = await helper.eth.createAccountWithBalance(alice, 100n);
154154
155 const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);155 const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);
261 });261 });
262262
263 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {263 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {
264 const alice = await privateKey('//Alice');264 const alice = privateKey('//Alice');
265 const sender = await helper.eth.createAccountWithBalance(alice, 100n);265 const sender = await helper.eth.createAccountWithBalance(alice, 100n);
266266
267 const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);267 const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);
455 });455 });
456456
457 itEth('Events emitted for transferFromCross()', async ({helper, privateKey}) => {457 itEth('Events emitted for transferFromCross()', async ({helper, privateKey}) => {
458 const alice = await privateKey('//Alice');458 const alice = privateKey('//Alice');
459 const sender = await helper.eth.createAccountWithBalance(alice, 100n);459 const sender = await helper.eth.createAccountWithBalance(alice, 100n);
460460
461 const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);461 const collection = await helper.ft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'}, 0);
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
247 });247 });
248248
249 itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {249 itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {
250 const alice = await privateKey('//Alice');250 const alice = privateKey('//Alice');
251 const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});251 const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
252252
253 const owner = await privateKey('//Bob');253 const owner = privateKey('//Bob');
254 const spender = await helper.eth.createAccountWithBalance(alice, 100n);254 const spender = await helper.eth.createAccountWithBalance(alice, 100n);
255255
256 const token = await collection.mintToken(alice, {Substrate: owner.address});256 const token = await collection.mintToken(alice, {Substrate: owner.address});
277 });277 });
278278
279 itEth('Can perform approveCross()', async ({helper, privateKey}) => {279 itEth('Can perform approveCross()', async ({helper, privateKey}) => {
280 const alice = await privateKey('//Alice');280 const alice = privateKey('//Alice');
281 const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});281 const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
282282
283 const owner = await helper.eth.createAccountWithBalance(alice, 100n);283 const owner = await helper.eth.createAccountWithBalance(alice, 100n);
284 const receiver = await privateKey('//Charlie');284 const receiver = privateKey('//Charlie');
285285
286 const token = await collection.mintToken(alice, {Ethereum: owner});286 const token = await collection.mintToken(alice, {Ethereum: owner});
287287
410 });410 });
411411
412 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {412 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {
413 const alice = await privateKey('//Alice');413 const alice = privateKey('//Alice');
414 const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});414 const collection = await helper.nft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
415415
416 const owner = await privateKey('//Bob');416 const owner = privateKey('//Bob');
417 const spender = await helper.eth.createAccountWithBalance(alice, 100n);417 const spender = await helper.eth.createAccountWithBalance(alice, 100n);
418 const receiver = await privateKey('//Charlie');418 const receiver = privateKey('//Charlie');
419419
420 const token = await collection.mintToken(alice, {Substrate: owner.address});420 const token = await collection.mintToken(alice, {Substrate: owner.address});
421421
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
228 });228 });
229229
230 itEth('Can perform burnFrom()', async ({helper, privateKey}) => {230 itEth('Can perform burnFrom()', async ({helper, privateKey}) => {
231 const alice = await privateKey('//Alice');231 const alice = privateKey('//Alice');
232 const collection = await helper.rft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});232 const collection = await helper.rft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
233233
234 const owner = await helper.eth.createAccountWithBalance(alice, 100n);234 const owner = await helper.eth.createAccountWithBalance(alice, 100n);
262 });262 });
263263
264 itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {264 itEth('Can perform burnFromCross()', async ({helper, privateKey}) => {
265 const alice = await privateKey('//Alice');265 const alice = privateKey('//Alice');
266 const collection = await helper.rft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});266 const collection = await helper.rft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
267267
268 const owner = await privateKey('//Bob');268 const owner = privateKey('//Bob');
269 const spender = await helper.eth.createAccountWithBalance(alice, 100n);269 const spender = await helper.eth.createAccountWithBalance(alice, 100n);
270270
271 const token = await collection.mintToken(alice, 100n, {Substrate: owner.address});271 const token = await collection.mintToken(alice, 100n, {Substrate: owner.address});
295 });295 });
296296
297 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {297 itEth('Can perform transferFromCross()', async ({helper, privateKey}) => {
298 const alice = await privateKey('//Alice');298 const alice = privateKey('//Alice');
299 const collection = await helper.rft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});299 const collection = await helper.rft.mintCollection(alice, {name: 'A', description: 'B', tokenPrefix: 'C'});
300300
301 const owner = await privateKey('//Bob');301 const owner = privateKey('//Bob');
302 const spender = await helper.eth.createAccountWithBalance(alice, 100n);302 const spender = await helper.eth.createAccountWithBalance(alice, 100n);
303 const receiver = await privateKey('//Charlie');303 const receiver = privateKey('//Charlie');
304304
305 const token = await collection.mintToken(alice, 100n, {Substrate: owner.address});305 const token = await collection.mintToken(alice, 100n, {Substrate: owner.address});
306306
modifiedtests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth
361}361}
362export type EthUniqueHelperConstructor = new (...args: any[]) => EthUniqueHelper;362export type EthUniqueHelperConstructor = new (...args: any[]) => EthUniqueHelper;
363
364export class EthCrossAccountGroup extends EthGroupBase {
365 fromAddress(address: TEthereumAccount): TEthCrossAccount {
366 return {
367 0: address,
368 1: '0',
369 field_0: address,
370 field_1: '0',
371 };
372 }
373
374 fromKeyringPair(keyring: IKeyringPair): TEthCrossAccount {
375 return {
376 0: '0x0000000000000000000000000000000000000000',
377 1: keyring.addressRaw,
378 field_0: '0x0000000000000000000000000000000000000000',
379 field_1: keyring.addressRaw,
380 };
381 }
382}
383
384export class EthCrossAccountGroup extends EthGroupBase {
385 fromAddress(address: TEthereumAccount): TEthCrossAccount {
386 return {
387 0: address,
388 1: '0',
389 field_0: address,
390 field_1: '0',
391 };
392 }
393
394 fromKeyringPair(keyring: IKeyringPair): TEthCrossAccount {
395 return {
396 0: '0x0000000000000000000000000000000000000000',
397 1: keyring.addressRaw,
398 field_0: '0x0000000000000000000000000000000000000000',
399 field_1: keyring.addressRaw,
400 };
401 }
402}
363403
364export class EthCrossAccountGroup extends EthGroupBase {404export class EthCrossAccountGroup extends EthGroupBase {
365 fromAddress(address: TEthereumAccount): TEthCrossAccount {405 fromAddress(address: TEthereumAccount): TEthCrossAccount {