git.delta.rocks / unique-network / refs/commits / 54811ce8b19d

difftreelog

Contract sponsoring

str-mv2021-08-29parent: #70da175.patch.diff
in: master

4 files changed

addedtests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth

no changes

addedtests/src/eth/util/ERC721.soldiffbeforeafterboth

no changes

modifiedtests/src/eth/util/helpers.tsdiffbeforeafterboth
17import config from '../../config';17import config from '../../config';
18import privateKey from '../../substrate/privateKey';18import privateKey from '../../substrate/privateKey';
19import contractHelpersAbi from './contractHelpersAbi.json';19import contractHelpersAbi from './contractHelpersAbi.json';
20import fs from 'fs';
2021
21export const GAS_ARGS = { gas: 0x1000000, gasPrice: '0x01' };22export const GAS_ARGS = { gas: 0x1000000, gasPrice: '0x01' };
2223
175 };176 };
176}177}
178
179export async function deployFungibleContract(web3: Web3 & Web3HttpMarker, deployer: string) {
180
181 const sol = fs.readFileSync(__dirname + '/ERC721.sol').toString();
182
183 const compiled = compileContract('ERC721', sol);
184 const ERC721 = new web3.eth.Contract(compiled.abi, undefined, {
185 data: compiled.object,
186 from: deployer,
187 ...GAS_ARGS,
188 });
189 const fungible = await ERC721.deploy({ data: compiled.object }).send({from: deployer});
190
191 return fungible;
192}
177193
178export async function deployFlipper(web3: Web3 & Web3HttpMarker, deployer: string) {194export async function deployFlipper(web3: Web3 & Web3HttpMarker, deployer: string) {
179 const compiled = compileContract('Flipper', `195 const compiled = compileContract('Flipper', `
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
95 checkMsgSysMethod: string;95 checkMsgSysMethod: string;
96}96}
97
98export interface IFungibleTokenDataType {
99 Value: number;
100}
101
102export interface IChainLimits {
103 CollectionNumbersLimit: number;
104 AccountTokenOwnershipLimit: number;
105 CollectionsAdminsLimit: number;
106 CustomDataLimit: number;
107 NftSponsorTransferTimeout: number;
108 FungibleSponsorTransferTimeout: number;
109 RefungibleSponsorTransferTimeout: number;
110 OffchainSchemaLimit: number;
111 VariableOnChainSchemaLimit: number;
112 ConstOnChainSchemaLimit: number;
113}
11497
115export interface IReFungibleTokenDataType {98export interface IReFungibleTokenDataType {
116 Owner: IReFungibleOwner[];99 Owner: IReFungibleOwner[];
469 });452 });
470}453}
471454
472export async function removeCollectionSponsorExpectFailure(collectionId: number, senderSeed = '//Alice') {455export async function removeCollectionSponsorExpectFailure(collectionId: number) {
473 await usingApi(async (api) => {456 await usingApi(async (api) => {
474457
475 // Run the transaction458 // Run the transaction
476 const alicePrivateKey = privateKey(senderSeed);459 const alicePrivateKey = privateKey('//Alice');
477 const tx = api.tx.nft.removeCollectionSponsor(collectionId);460 const tx = api.tx.nft.removeCollectionSponsor(collectionId);
478 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;461 await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;
479 });462 });
782 });765 });
783}766}
784
785export async function addCollectionAdminExpectSuccess(sender: IKeyringPair, collectionId: number, address: IKeyringPair) {
786 await usingApi(async (api) => {
787 const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(address.address));
788 const events = await submitTransactionAsync(sender, changeAdminTx);
789 const result = getCreateCollectionResult(events);
790 expect(result.success).to.be.true;
791 });
792}
793767
794export async function768export async function
795scheduleTransferExpectSuccess(769scheduleTransferExpectSuccess(
1047 });1021 });
1048}1022}
1049
1050export async function setChainLimitsExpectFailure(sender: IKeyringPair, limits: IChainLimits) {
1051 await usingApi(async (api) => {
1052 // Run the transaction
1053 const tx = api.tx.nft.setChainLimits(limits);
1054 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
1055 const result = getCreateCollectionResult(events);
1056 // tslint:disable-next-line:no-unused-expression
1057 expect(result.success).to.be.false;
1058 });
1059}
10601023
1061export async function isWhitelisted(collectionId: number, address: string) {1024export async function isWhitelisted(collectionId: number, address: string) {
1062 let whitelisted = false;1025 let whitelisted = false;