difftreelog
Merge branch 'develop' into feature/polkadot-js-7
in: master
6 files changed
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -162,9 +162,12 @@
type EvmBackwardsAddressMapping: up_evm_mapping::EvmBackwardsAddressMapping<Self::AccountId>;
type Currency: Currency<Self::AccountId>;
+
+ #[pallet::constant]
type CollectionCreationPrice: Get<
<<Self as Config>::Currency as Currency<Self::AccountId>>::Balance,
>;
+
type TreasuryAccountId: Get<Self::AccountId>;
}
primitives/data-structs/src/lib.rsdiffbeforeafterboth--- a/primitives/data-structs/src/lib.rs
+++ b/primitives/data-structs/src/lib.rs
@@ -64,7 +64,7 @@
// Schema limits
pub const OFFCHAIN_SCHEMA_LIMIT: u32 = 8192;
pub const VARIABLE_ON_CHAIN_SCHEMA_LIMIT: u32 = 8192;
-pub const CONST_ON_CHAIN_SCHEMA_LIMIT: u32 = 1048576;
+pub const CONST_ON_CHAIN_SCHEMA_LIMIT: u32 = 32768;
pub const MAX_COLLECTION_NAME_LENGTH: u32 = 64;
pub const MAX_COLLECTION_DESCRIPTION_LENGTH: u32 = 256;
runtime/src/lib.rsdiffbeforeafterboth--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -250,8 +250,13 @@
pub const SS58Prefix: u8 = 42;
}
+/*
+8880 - Unique
+8881 - Quartz
+8882 - Opal
+*/
parameter_types! {
- pub const ChainId: u64 = 8888;
+ pub const ChainId: u64 = 8882;
}
pub struct FixedFee;
@@ -874,7 +879,7 @@
parameter_types! {
pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();
- pub const CollectionCreationPrice: Balance = 100 * UNIQUE;
+ pub const CollectionCreationPrice: Balance = 2 * UNIQUE;
}
impl pallet_common::Config for Runtime {
tests/src/confirmSponsorship.test.tsdiffbeforeafterboth--- a/tests/src/confirmSponsorship.test.ts
+++ b/tests/src/confirmSponsorship.test.ts
@@ -373,4 +373,31 @@
await destroyCollectionExpectSuccess(collectionId);
await confirmSponsorshipExpectFailure(collectionId, '//Bob');
});
+
+ it('(!negative test!) Transfer fees are not paid by the sponsor if the transfer failed', async () => {
+ const collectionId = await createCollectionExpectSuccess();
+ await setCollectionSponsorExpectSuccess(collectionId, bob.address);
+ await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
+
+ await usingApi(async (api) => {
+ // Find unused address
+ const ownerZeroBalance = await findUnusedAddress(api);
+
+ // Find another unused address
+ const senderZeroBalance = await findUnusedAddress(api);
+
+ // Mint token for an unused address
+ const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', ownerZeroBalance.address);
+
+ const sponsorBalanceBeforeTx = (await api.query.system.account(bob.address)).data.free.toBigInt();
+
+ // Try to transfer this token from an unsponsored unused adress to Alice
+ const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(alice.address), collectionId, itemId, 0);
+ await expect(submitTransactionExpectFailAsync(senderZeroBalance, zeroToAlice)).to.be.rejected;
+
+ const sponsorBalanceAfterTx = (await api.query.system.account(bob.address)).data.free.toBigInt();
+
+ expect(sponsorBalanceAfterTx).to.equal(sponsorBalanceBeforeTx);
+ });
+ });
});
tests/src/eth/allowlist.test.tsdiffbeforeafterboth--- a/tests/src/eth/allowlist.test.ts
+++ b/tests/src/eth/allowlist.test.ts
@@ -1,27 +1,23 @@
import {expect} from 'chai';
-import {contractHelpers, createEthAccount, createEthAccountWithBalance, deployFlipper, itWeb3} from './util/helpers';
+import {contractHelpers, createEthAccountWithBalance, deployFlipper, itWeb3} from './util/helpers';
describe('EVM allowlist', () => {
itWeb3('Contract allowlist can be toggled', async ({api, web3}) => {
const owner = await createEthAccountWithBalance(api, web3);
const flipper = await deployFlipper(web3, owner);
- const randomUser = createEthAccount(web3);
const helpers = contractHelpers(web3, owner);
// Any user is allowed by default
expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.false;
- expect(await helpers.methods.allowed(flipper.options.address, randomUser).call()).to.be.true;
// Enable
await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});
expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.true;
- expect(await helpers.methods.allowed(flipper.options.address, randomUser).call()).to.be.false;
// Disable
await helpers.methods.toggleAllowlist(flipper.options.address, false).send({from: owner});
expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.false;
- expect(await helpers.methods.allowed(flipper.options.address, randomUser).call()).to.be.true;
});
itWeb3('Non-allowlisted user can\'t call contract with allowlist enabled', async ({api, web3}) => {
tests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import privateKey from '../substrate/privateKey';7import {expect} from 'chai';8import {9 contractHelpers,10 createEthAccountWithBalance,11 transferBalanceToEth,12 deployFlipper,13 itWeb3,14 SponsoringMode,15 createEthAccount,16} from './util/helpers';1718describe('Sponsoring EVM contracts', () => {19 itWeb3('Sponsoring can be set by the address that has deployed the contract', async ({api, web3}) => {20 const owner = await createEthAccountWithBalance(api, web3);21 const flipper = await deployFlipper(web3, owner);22 const helpers = contractHelpers(web3, owner);23 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;24 await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});25 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;26 });2728 itWeb3('Sponsoring cannot be set by the address that did not deployed the contract', async ({api, web3}) => {29 const owner = await createEthAccountWithBalance(api, web3);30 const notOwner = await createEthAccountWithBalance(api, web3);31 const flipper = await deployFlipper(web3, owner);32 const helpers = contractHelpers(web3, owner);33 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;34 await expect(helpers.methods.setSponsoringMode(notOwner, SponsoringMode.Allowlisted).send({from: notOwner})).to.rejected;35 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;36 });3738 itWeb3('In generous mode, non-allowlisted user transaction will be sponsored', async ({api, web3}) => {39 const alice = privateKey('//Alice');4041 const owner = await createEthAccountWithBalance(api, web3);42 const caller = await createEthAccountWithBalance(api, web3);4344 const flipper = await deployFlipper(web3, owner);4546 const helpers = contractHelpers(web3, owner);4748 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;49 await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Generous).send({from: owner});50 await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});51 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;5253 await transferBalanceToEth(api, alice, flipper.options.address);5455 const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);56 expect(originalFlipperBalance).to.be.not.equal('0');5758 await flipper.methods.flip().send({from: caller});59 expect(await flipper.methods.getValue().call()).to.be.true;6061 // Balance should be taken from flipper instead of caller62 const balanceAfter = await web3.eth.getBalance(flipper.options.address);63 expect(+balanceAfter).to.be.lessThan(+originalFlipperBalance);64 });6566 itWeb3('Sponsoring is set, an address that has no UNQ can send a transaction and it works. Sponsor balance should decrease (allowlisted)', async ({api, web3}) => {67 const alice = privateKey('//Alice');6869 const owner = await createEthAccountWithBalance(api, web3);70 const caller = createEthAccount(web3);7172 const flipper = await deployFlipper(web3, owner);7374 const helpers = contractHelpers(web3, owner);75 await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});76 await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});7778 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;79 await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});80 await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});81 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;8283 await transferBalanceToEth(api, alice, flipper.options.address);8485 const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);86 expect(originalFlipperBalance).to.be.not.equal('0');8788 await flipper.methods.flip().send({from: caller});89 expect(await flipper.methods.getValue().call()).to.be.true;9091 // Balance should be taken from flipper instead of caller92 const balanceAfter = await web3.eth.getBalance(flipper.options.address);93 expect(+balanceAfter).to.be.lessThan(+originalFlipperBalance);94 });9596 itWeb3('Sponsoring is set, an address that has no UNQ can send a transaction and it works. Sponsor balance should not decrease (non-allowlisted)', async ({api, web3}) => {97 const alice = privateKey('//Alice');9899 const owner = await createEthAccountWithBalance(api, web3);100 const caller = createEthAccount(web3);101102 const flipper = await deployFlipper(web3, owner);103104 const helpers = contractHelpers(web3, owner);105106 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;107 await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});108 await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});109 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;110111 await transferBalanceToEth(api, alice, flipper.options.address);112113 const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);114 expect(originalFlipperBalance).to.be.not.equal('0');115116 await flipper.methods.flip().send({from: caller});117 expect(await flipper.methods.getValue().call()).to.be.true;118119 // Balance should be taken from flipper instead of caller120 const balanceAfter = await web3.eth.getBalance(flipper.options.address);121 expect(+balanceAfter).to.be.equals(+originalFlipperBalance);122 });123124 itWeb3('Sponsoring is set, an address that has UNQ can send a transaction and it works. User balance should not change', async ({api, web3}) => {125 const alice = privateKey('//Alice');126127 const owner = await createEthAccountWithBalance(api, web3);128 const caller = await createEthAccountWithBalance(api, web3);129 const originalCallerBalance = await web3.eth.getBalance(caller);130131 const flipper = await deployFlipper(web3, owner);132133 const helpers = contractHelpers(web3, owner);134 await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});135 await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});136137 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;138 await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});139 await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});140 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;141142 await transferBalanceToEth(api, alice, flipper.options.address);143144 const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);145 expect(originalFlipperBalance).to.be.not.equal('0');146147 await flipper.methods.flip().send({from: caller});148 expect(await flipper.methods.getValue().call()).to.be.true;149150 expect(await web3.eth.getBalance(caller)).to.be.equals(originalCallerBalance);151 });152153 itWeb3('Sponsoring is limited, with setContractRateLimit. The limitation is working if transactions are sent more often, the sender pays the commission.', async ({api, web3}) => {154 const alice = privateKey('//Alice');155156 const owner = await createEthAccountWithBalance(api, web3);157 const caller = await createEthAccountWithBalance(api, web3);158 const originalCallerBalance = await web3.eth.getBalance(caller);159160 const flipper = await deployFlipper(web3, owner);161162 const helpers = contractHelpers(web3, owner);163 await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});164 await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});165166 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;167 await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});168 await helpers.methods.setSponsoringRateLimit(flipper.options.address, 10).send({from: owner});169 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;170171 await transferBalanceToEth(api, alice, flipper.options.address);172173 const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);174 expect(originalFlipperBalance).to.be.not.equal('0');175176 await flipper.methods.flip().send({from: caller});177 expect(await flipper.methods.getValue().call()).to.be.true;178 expect(await web3.eth.getBalance(caller)).to.be.equals(originalCallerBalance);179180 await flipper.methods.flip().send({from: caller});181 expect(await web3.eth.getBalance(caller)).to.be.not.equals(originalCallerBalance);182 });183184 // TODO: Find a way to calculate default rate limit185 itWeb3('Default rate limit equals 7200', async ({api, web3}) => {186 const owner = await createEthAccountWithBalance(api, web3);187 const flipper = await deployFlipper(web3, owner);188 const helpers = contractHelpers(web3, owner);189 expect(await helpers.methods.getSponsoringRateLimit(flipper.options.address).call()).to.be.equals('7200');190 });191});1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import privateKey from '../substrate/privateKey';7import {expect} from 'chai';8import {9 contractHelpers,10 createEthAccountWithBalance,11 transferBalanceToEth,12 deployFlipper,13 itWeb3,14 SponsoringMode,15 createEthAccount,16} from './util/helpers';1718describe('Sponsoring EVM contracts', () => {19 itWeb3('Sponsoring can be set by the address that has deployed the contract', async ({api, web3}) => {20 const owner = await createEthAccountWithBalance(api, web3);21 const flipper = await deployFlipper(web3, owner);22 const helpers = contractHelpers(web3, owner);23 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;24 await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});25 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;26 });2728 itWeb3('Sponsoring cannot be set by the address that did not deployed the contract', async ({api, web3}) => {29 const owner = await createEthAccountWithBalance(api, web3);30 const notOwner = await createEthAccountWithBalance(api, web3);31 const flipper = await deployFlipper(web3, owner);32 const helpers = contractHelpers(web3, owner);33 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;34 await expect(helpers.methods.setSponsoringMode(notOwner, SponsoringMode.Allowlisted).send({from: notOwner})).to.rejected;35 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;36 });3738 itWeb3('In generous mode, non-allowlisted user transaction will be sponsored', async ({api, web3}) => {39 const alice = privateKey('//Alice');4041 const owner = await createEthAccountWithBalance(api, web3);42 const caller = await createEthAccountWithBalance(api, web3);4344 const flipper = await deployFlipper(web3, owner);4546 const helpers = contractHelpers(web3, owner);4748 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;49 await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Generous).send({from: owner});50 await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});51 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;5253 await transferBalanceToEth(api, alice, flipper.options.address);5455 const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);56 expect(originalFlipperBalance).to.be.not.equal('0');5758 await flipper.methods.flip().send({from: caller});59 expect(await flipper.methods.getValue().call()).to.be.true;6061 // Balance should be taken from flipper instead of caller62 const balanceAfter = await web3.eth.getBalance(flipper.options.address);63 expect(+balanceAfter).to.be.lessThan(+originalFlipperBalance);64 });6566 itWeb3('Sponsoring is set, an address that has no UNQ can send a transaction and it works. Sponsor balance should decrease (allowlisted)', async ({api, web3}) => {67 const alice = privateKey('//Alice');6869 const owner = await createEthAccountWithBalance(api, web3);70 const caller = createEthAccount(web3);7172 const flipper = await deployFlipper(web3, owner);7374 const helpers = contractHelpers(web3, owner);75 await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});76 await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});7778 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;79 await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});80 await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});81 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;8283 await transferBalanceToEth(api, alice, flipper.options.address);8485 const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);86 expect(originalFlipperBalance).to.be.not.equal('0');8788 await flipper.methods.flip().send({from: caller});89 expect(await flipper.methods.getValue().call()).to.be.true;9091 // Balance should be taken from flipper instead of caller92 const balanceAfter = await web3.eth.getBalance(flipper.options.address);93 expect(+balanceAfter).to.be.lessThan(+originalFlipperBalance);94 });9596 itWeb3('Sponsoring is set, an address that has no UNQ can send a transaction and it works. Sponsor balance should not decrease (non-allowlisted)', async ({api, web3}) => {97 const alice = privateKey('//Alice');9899 const owner = await createEthAccountWithBalance(api, web3);100 const caller = createEthAccount(web3);101102 const flipper = await deployFlipper(web3, owner);103104 const helpers = contractHelpers(web3, owner);105106 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;107 await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});108 await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});109 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;110111 await transferBalanceToEth(api, alice, flipper.options.address);112113 const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);114 expect(originalFlipperBalance).to.be.not.equal('0');115116 await expect(flipper.methods.flip().send({from: caller})).to.be.rejectedWith(/InvalidTransaction::Payment/);117 expect(await flipper.methods.getValue().call()).to.be.false;118119 // Balance should be taken from flipper instead of caller120 const balanceAfter = await web3.eth.getBalance(flipper.options.address);121 expect(+balanceAfter).to.be.equals(+originalFlipperBalance);122 });123124 itWeb3('Sponsoring is set, an address that has UNQ can send a transaction and it works. User balance should not change', async ({api, web3}) => {125 const alice = privateKey('//Alice');126127 const owner = await createEthAccountWithBalance(api, web3);128 const caller = await createEthAccountWithBalance(api, web3);129 const originalCallerBalance = await web3.eth.getBalance(caller);130131 const flipper = await deployFlipper(web3, owner);132133 const helpers = contractHelpers(web3, owner);134 await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});135 await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});136137 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;138 await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});139 await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});140 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;141142 await transferBalanceToEth(api, alice, flipper.options.address);143144 const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);145 expect(originalFlipperBalance).to.be.not.equal('0');146147 await flipper.methods.flip().send({from: caller});148 expect(await flipper.methods.getValue().call()).to.be.true;149150 expect(await web3.eth.getBalance(caller)).to.be.equals(originalCallerBalance);151 });152153 itWeb3('Sponsoring is limited, with setContractRateLimit. The limitation is working if transactions are sent more often, the sender pays the commission.', async ({api, web3}) => {154 const alice = privateKey('//Alice');155156 const owner = await createEthAccountWithBalance(api, web3);157 const caller = await createEthAccountWithBalance(api, web3);158 const originalCallerBalance = await web3.eth.getBalance(caller);159160 const flipper = await deployFlipper(web3, owner);161162 const helpers = contractHelpers(web3, owner);163 await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});164 await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});165166 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;167 await helpers.methods.setSponsoringMode(flipper.options.address, SponsoringMode.Allowlisted).send({from: owner});168 await helpers.methods.setSponsoringRateLimit(flipper.options.address, 10).send({from: owner});169 expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;170171 await transferBalanceToEth(api, alice, flipper.options.address);172173 const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);174 expect(originalFlipperBalance).to.be.not.equal('0');175176 await flipper.methods.flip().send({from: caller});177 expect(await flipper.methods.getValue().call()).to.be.true;178 expect(await web3.eth.getBalance(caller)).to.be.equals(originalCallerBalance);179180 await flipper.methods.flip().send({from: caller});181 expect(await web3.eth.getBalance(caller)).to.be.not.equals(originalCallerBalance);182 });183184 // TODO: Find a way to calculate default rate limit185 itWeb3('Default rate limit equals 7200', async ({api, web3}) => {186 const owner = await createEthAccountWithBalance(api, web3);187 const flipper = await deployFlipper(web3, owner);188 const helpers = contractHelpers(web3, owner);189 expect(await helpers.methods.getSponsoringRateLimit(flipper.options.address).call()).to.be.equals('7200');190 });191});