difftreelog
Contract sponsoring
in: master
4 files changed
tests/src/eth/contractSponsoring.test.tsdiffbeforeafterbothno changes
tests/src/eth/util/ERC721.soldiffbeforeafterbothno changes
tests/src/eth/util/helpers.tsdiffbeforeafterboth17import 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';202121export const GAS_ARGS = { gas: 0x1000000, gasPrice: '0x01' };22export const GAS_ARGS = { gas: 0x1000000, gasPrice: '0x01' };2223175 };176 };176}177}178179export async function deployFungibleContract(web3: Web3 & Web3HttpMarker, deployer: string) {180181 const sol = fs.readFileSync(__dirname + '/ERC721.sol').toString();182183 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});190191 return fungible;192}177193178export 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', `tests/src/util/helpers.tsdiffbeforeafterboth95 checkMsgSysMethod: string;95 checkMsgSysMethod: string;96}96}9798export interface IFungibleTokenDataType {99 Value: number;100}101102export 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}11497115export interface IReFungibleTokenDataType {98export interface IReFungibleTokenDataType {116 Owner: IReFungibleOwner[];99 Owner: IReFungibleOwner[];469 });452 });470}453}471454472export async function removeCollectionSponsorExpectFailure(collectionId: number, senderSeed = '//Alice') {455export async function removeCollectionSponsorExpectFailure(collectionId: number) {473 await usingApi(async (api) => {456 await usingApi(async (api) => {474457475 // Run the transaction458 // Run the transaction476 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}784785export 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}793767794export async function768export async function795scheduleTransferExpectSuccess(769scheduleTransferExpectSuccess(1047 });1021 });1048}1022}10491050export async function setChainLimitsExpectFailure(sender: IKeyringPair, limits: IChainLimits) {1051 await usingApi(async (api) => {1052 // Run the transaction1053 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-expression1057 expect(result.success).to.be.false;1058 });1059}106010231061export async function isWhitelisted(collectionId: number, address: string) {1024export async function isWhitelisted(collectionId: number, address: string) {1062 let whitelisted = false;1025 let whitelisted = false;