git.delta.rocks / unique-network / refs/commits / 231992803ffe

difftreelog

fix rename some methods

Trubnikov Sergey2022-09-19parent: #b85120e.patch.diff
in: master

6 files changed

modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
169 ///169 ///
170 /// @param contractAddress The contract for which a sponsor is requested.170 /// @param contractAddress The contract for which a sponsor is requested.
171 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.171 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
172 fn get_sponsor(&self, contract_address: address) -> Result<(address, uint256)> {172 fn sponsor(&self, contract_address: address) -> Result<(address, uint256)> {
173 let sponsor =173 let sponsor =
174 Pallet::<T>::get_sponsor(contract_address).ok_or("Contract has no sponsor")?;174 Pallet::<T>::get_sponsor(contract_address).ok_or("Contract has no sponsor")?;
175 Ok(pallet_common::eth::convert_cross_account_to_tuple::<T>(175 Ok(pallet_common::eth::convert_cross_account_to_tuple::<T>(
220 /// Get current contract sponsoring rate limit220 /// Get current contract sponsoring rate limit
221 /// @param contractAddress Contract to get sponsoring rate limit of221 /// @param contractAddress Contract to get sponsoring rate limit of
222 /// @return uint32 Amount of blocks between two sponsored transactions222 /// @return uint32 Amount of blocks between two sponsored transactions
223 fn get_sponsoring_rate_limit(&self, contract_address: address) -> Result<uint32> {223 fn sponsoring_rate_limit(&self, contract_address: address) -> Result<uint32> {
224 self.recorder().consume_sload()?;224 self.recorder().consume_sload()?;
225225
226 Ok(<SponsoringRateLimit<T>>::get(contract_address)226 Ok(<SponsoringRateLimit<T>>::get(contract_address)
273 /// @param contractAddress Contract to get sponsoring fee limit of273 /// @param contractAddress Contract to get sponsoring fee limit of
274 /// @return uint256 Maximum amount of fee that could be spent by single274 /// @return uint256 Maximum amount of fee that could be spent by single
275 /// transaction275 /// transaction
276 fn get_sponsoring_fee_limit(&self, contract_address: address) -> Result<uint256> {276 fn sponsoring_fee_limit(&self, contract_address: address) -> Result<uint256> {
277 self.recorder().consume_sload()?;277 self.recorder().consume_sload()?;
278278
279 Ok(get_sponsoring_fee_limit::<T>(contract_address))279 Ok(get_sponsoring_fee_limit::<T>(contract_address))
modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.soldiffbeforeafterboth
25}25}
2626
27/// @title Magic contract, which allows users to reconfigure other contracts27/// @title Magic contract, which allows users to reconfigure other contracts
28/// @dev the ERC-165 identifier for this interface is 0x172cb4fb28/// @dev the ERC-165 identifier for this interface is 0x30afad04
29contract ContractHelpers is Dummy, ERC165, ContractHelpersEvents {29contract ContractHelpers is Dummy, ERC165, ContractHelpersEvents {
30 /// Get user, which deployed specified contract30 /// Get user, which deployed specified contract
31 /// @dev May return zero address in case if contract is deployed31 /// @dev May return zero address in case if contract is deployed
94 ///94 ///
95 /// @param contractAddress The contract for which a sponsor is requested.95 /// @param contractAddress The contract for which a sponsor is requested.
96 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.96 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
97 /// @dev EVM selector for this function is: 0x743fc745,97 /// @dev EVM selector for this function is: 0x766c4f37,
98 /// or in textual repr: getSponsor(address)98 /// or in textual repr: sponsor(address)
99 function getSponsor(address contractAddress) public view returns (Tuple0 memory) {99 function sponsor(address contractAddress) public view returns (Tuple0 memory) {
100 require(false, stub_error);100 require(false, stub_error);
101 contractAddress;101 contractAddress;
102 dummy;102 dummy;
150 /// Get current contract sponsoring rate limit150 /// Get current contract sponsoring rate limit
151 /// @param contractAddress Contract to get sponsoring rate limit of151 /// @param contractAddress Contract to get sponsoring rate limit of
152 /// @return uint32 Amount of blocks between two sponsored transactions152 /// @return uint32 Amount of blocks between two sponsored transactions
153 /// @dev EVM selector for this function is: 0x610cfabd,153 /// @dev EVM selector for this function is: 0xf29694d8,
154 /// or in textual repr: getSponsoringRateLimit(address)154 /// or in textual repr: sponsoringRateLimit(address)
155 function getSponsoringRateLimit(address contractAddress) public view returns (uint32) {155 function sponsoringRateLimit(address contractAddress) public view returns (uint32) {
156 require(false, stub_error);156 require(false, stub_error);
157 contractAddress;157 contractAddress;
158 dummy;158 dummy;
193 /// @param contractAddress Contract to get sponsoring fee limit of193 /// @param contractAddress Contract to get sponsoring fee limit of
194 /// @return uint256 Maximum amount of fee that could be spent by single194 /// @return uint256 Maximum amount of fee that could be spent by single
195 /// transaction195 /// transaction
196 /// @dev EVM selector for this function is: 0xc3fdc9ee,196 /// @dev EVM selector for this function is: 0x75b73606,
197 /// or in textual repr: getSponsoringFeeLimit(address)197 /// or in textual repr: sponsoringFeeLimit(address)
198 function getSponsoringFeeLimit(address contractAddress) public view returns (uint256) {198 function sponsoringFeeLimit(address contractAddress) public view returns (uint256) {
199 require(false, stub_error);199 require(false, stub_error);
200 contractAddress;200 contractAddress;
201 dummy;201 dummy;
modifiedtests/src/eth/api/ContractHelpers.soldiffbeforeafterboth
20}20}
2121
22/// @title Magic contract, which allows users to reconfigure other contracts22/// @title Magic contract, which allows users to reconfigure other contracts
23/// @dev the ERC-165 identifier for this interface is 0x172cb4fb23/// @dev the ERC-165 identifier for this interface is 0x30afad04
24interface ContractHelpers is Dummy, ERC165, ContractHelpersEvents {24interface ContractHelpers is Dummy, ERC165, ContractHelpersEvents {
25 /// Get user, which deployed specified contract25 /// Get user, which deployed specified contract
26 /// @dev May return zero address in case if contract is deployed26 /// @dev May return zero address in case if contract is deployed
67 ///67 ///
68 /// @param contractAddress The contract for which a sponsor is requested.68 /// @param contractAddress The contract for which a sponsor is requested.
69 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.69 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
70 /// @dev EVM selector for this function is: 0x743fc745,70 /// @dev EVM selector for this function is: 0x766c4f37,
71 /// or in textual repr: getSponsor(address)71 /// or in textual repr: sponsor(address)
72 function getSponsor(address contractAddress) external view returns (Tuple0 memory);72 function sponsor(address contractAddress) external view returns (Tuple0 memory);
7373
74 /// Check tat contract has confirmed sponsor.74 /// Check tat contract has confirmed sponsor.
75 ///75 ///
98 /// Get current contract sponsoring rate limit98 /// Get current contract sponsoring rate limit
99 /// @param contractAddress Contract to get sponsoring rate limit of99 /// @param contractAddress Contract to get sponsoring rate limit of
100 /// @return uint32 Amount of blocks between two sponsored transactions100 /// @return uint32 Amount of blocks between two sponsored transactions
101 /// @dev EVM selector for this function is: 0x610cfabd,101 /// @dev EVM selector for this function is: 0xf29694d8,
102 /// or in textual repr: getSponsoringRateLimit(address)102 /// or in textual repr: sponsoringRateLimit(address)
103 function getSponsoringRateLimit(address contractAddress) external view returns (uint32);103 function sponsoringRateLimit(address contractAddress) external view returns (uint32);
104104
105 /// Set contract sponsoring rate limit105 /// Set contract sponsoring rate limit
106 /// @dev Sponsoring rate limit - is a minimum amount of blocks that should106 /// @dev Sponsoring rate limit - is a minimum amount of blocks that should
126 /// @param contractAddress Contract to get sponsoring fee limit of126 /// @param contractAddress Contract to get sponsoring fee limit of
127 /// @return uint256 Maximum amount of fee that could be spent by single127 /// @return uint256 Maximum amount of fee that could be spent by single
128 /// transaction128 /// transaction
129 /// @dev EVM selector for this function is: 0xc3fdc9ee,129 /// @dev EVM selector for this function is: 0x75b73606,
130 /// or in textual repr: getSponsoringFeeLimit(address)130 /// or in textual repr: sponsoringFeeLimit(address)
131 function getSponsoringFeeLimit(address contractAddress) external view returns (uint256);131 function sponsoringFeeLimit(address contractAddress) external view returns (uint256);
132132
133 /// Is specified user present in contract allow list133 /// Is specified user present in contract allow list
134 /// @dev Contract owner always implicitly included134 /// @dev Contract owner always implicitly included
modifiedtests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth
223 const helpers = contractHelpers(web3, owner);223 const helpers = contractHelpers(web3, owner);
224 await helpers.methods.selfSponsoredEnable(flipper.options.address).send();224 await helpers.methods.selfSponsoredEnable(flipper.options.address).send();
225 225
226 const result = await helpers.methods.getSponsor(flipper.options.address).call();226 const result = await helpers.methods.sponsor(flipper.options.address).call();
227227
228 expect(result[0]).to.be.eq(flipper.options.address);228 expect(result[0]).to.be.eq(flipper.options.address);
229 expect(result[1]).to.be.eq('0');229 expect(result[1]).to.be.eq('0');
237 await helpers.methods.setSponsor(flipper.options.address, sponsor).send();237 await helpers.methods.setSponsor(flipper.options.address, sponsor).send();
238 await helpers.methods.confirmSponsorship(flipper.options.address).send({from: sponsor});238 await helpers.methods.confirmSponsorship(flipper.options.address).send({from: sponsor});
239 239
240 const result = await helpers.methods.getSponsor(flipper.options.address).call();240 const result = await helpers.methods.sponsor(flipper.options.address).call();
241241
242 expect(result[0]).to.be.eq(sponsor);242 expect(result[0]).to.be.eq(sponsor);
243 expect(result[1]).to.be.eq('0');243 expect(result[1]).to.be.eq('0');
482 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);482 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
483 const flipper = await deployFlipper(web3, owner);483 const flipper = await deployFlipper(web3, owner);
484 const helpers = contractHelpers(web3, owner);484 const helpers = contractHelpers(web3, owner);
485 expect(await helpers.methods.getSponsoringRateLimit(flipper.options.address).call()).to.be.equals('7200');485 expect(await helpers.methods.sponsoringRateLimit(flipper.options.address).call()).to.be.equals('7200');
486 });486 });
487});487});
488488
551 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);551 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
552 const flipper = await deployFlipper(web3, owner);552 const flipper = await deployFlipper(web3, owner);
553 const helpers = contractHelpers(web3, owner);553 const helpers = contractHelpers(web3, owner);
554 expect(await helpers.methods.getSponsoringFeeLimit(flipper.options.address).call()).to.be.equals('115792089237316195423570985008687907853269984665640564039457584007913129639935');554 expect(await helpers.methods.sponsoringFeeLimit(flipper.options.address).call()).to.be.equals('115792089237316195423570985008687907853269984665640564039457584007913129639935');
555 });555 });
556556
557 itWeb3('Set fee limit', async ({api, web3, privateKeyWrapper}) => {557 itWeb3('Set fee limit', async ({api, web3, privateKeyWrapper}) => {
558 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);558 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
559 const flipper = await deployFlipper(web3, owner);559 const flipper = await deployFlipper(web3, owner);
560 const helpers = contractHelpers(web3, owner);560 const helpers = contractHelpers(web3, owner);
561 await helpers.methods.setSponsoringFeeLimit(flipper.options.address, 100).send();561 await helpers.methods.setSponsoringFeeLimit(flipper.options.address, 100).send();
562 expect(await helpers.methods.getSponsoringFeeLimit(flipper.options.address).call()).to.be.equals('100');562 expect(await helpers.methods.sponsoringFeeLimit(flipper.options.address).call()).to.be.equals('100');
563 });563 });
564564
565 itWeb3('Negative test - set fee limit by non-owner', async ({api, web3, privateKeyWrapper}) => {565 itWeb3('Negative test - set fee limit by non-owner', async ({api, web3, privateKeyWrapper}) => {
modifiedtests/src/eth/util/contractHelpersAbi.jsondiffbeforeafterboth
103 "stateMutability": "view",103 "stateMutability": "view",
104 "type": "function"104 "type": "function"
105 },105 },
106 {
107 "inputs": [
108 {
109 "internalType": "address",
110 "name": "contractAddress",
111 "type": "address"
112 }
113 ],
114 "name": "getSponsor",
115 "outputs": [
116 {
117 "components": [
118 { "internalType": "address", "name": "field_0", "type": "address" },
119 { "internalType": "uint256", "name": "field_1", "type": "uint256" }
120 ],
121 "internalType": "struct Tuple0",
122 "name": "",
123 "type": "tuple"
124 }
125 ],
126 "stateMutability": "view",
127 "type": "function"
128 },
129 {
130 "inputs": [
131 {
132 "internalType": "address",
133 "name": "contractAddress",
134 "type": "address"
135 }
136 ],
137 "name": "getSponsoringFeeLimit",
138 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
139 "stateMutability": "view",
140 "type": "function"
141 },
142 {
143 "inputs": [
144 {
145 "internalType": "address",
146 "name": "contractAddress",
147 "type": "address"
148 }
149 ],
150 "name": "getSponsoringRateLimit",
151 "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }],
152 "stateMutability": "view",
153 "type": "function"
154 },
155 {106 {
156 "inputs": [107 "inputs": [
157 {108 {
260 "stateMutability": "nonpayable",211 "stateMutability": "nonpayable",
261 "type": "function"212 "type": "function"
262 },213 },
214 {
215 "inputs": [
216 {
217 "internalType": "address",
218 "name": "contractAddress",
219 "type": "address"
220 }
221 ],
222 "name": "sponsor",
223 "outputs": [
224 {
225 "components": [
226 { "internalType": "address", "name": "field_0", "type": "address" },
227 { "internalType": "uint256", "name": "field_1", "type": "uint256" }
228 ],
229 "internalType": "struct Tuple0",
230 "name": "",
231 "type": "tuple"
232 }
233 ],
234 "stateMutability": "view",
235 "type": "function"
236 },
263 {237 {
264 "inputs": [238 "inputs": [
265 {239 {
273 "stateMutability": "view",247 "stateMutability": "view",
274 "type": "function"248 "type": "function"
275 },249 },
250 {
251 "inputs": [
252 {
253 "internalType": "address",
254 "name": "contractAddress",
255 "type": "address"
256 }
257 ],
258 "name": "sponsoringFeeLimit",
259 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
260 "stateMutability": "view",
261 "type": "function"
262 },
263 {
264 "inputs": [
265 {
266 "internalType": "address",
267 "name": "contractAddress",
268 "type": "address"
269 }
270 ],
271 "name": "sponsoringRateLimit",
272 "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }],
273 "stateMutability": "view",
274 "type": "function"
275 },
276 {276 {
277 "inputs": [277 "inputs": [
278 { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }278 { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }