git.delta.rocks / unique-network / refs/commits / 81e4f2e24fd5

difftreelog

fix change sponsor to OptioCrossAddress

Trubnikov Sergey2022-12-22parent: #6bfcb42.patch.diff
in: master

9 files changed

modifiedcrates/evm-coder/src/abi/impls.rsdiffbeforeafterboth
181 }181 }
182}182}
183
184macro_rules! count {
185 () => (0usize);
186 ( $x:tt $($xs:tt)* ) => (1usize + count!($($xs)*));
187}
188183
189macro_rules! impl_tuples {184macro_rules! impl_tuples {
190 ($($ident:ident)+) => {185 ($($ident:ident)+) => {
modifiedpallets/common/src/eth.rsdiffbeforeafterboth
122 }122 }
123}123}
124
125/// Ethereum representation of Optional value with CrossAddress.
126#[derive(Debug, Default, AbiCoder)]
127pub struct OptionCrossAddress {
128 pub status: bool,
129 pub value: CrossAddress,
130}
124131
125/// Cross account struct132/// Cross account struct
126#[derive(Debug, Default, AbiCoder)]133#[derive(Debug, Default, AbiCoder)]
modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
25 types::*,25 types::*,
26 ToLog,26 ToLog,
27};27};
28use pallet_common::eth;
28use pallet_evm::{29use pallet_evm::{
29 ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure, PrecompileHandle,30 ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure, PrecompileHandle,
30 account::CrossAccountId,31 account::CrossAccountId,
174 ///175 ///
175 /// @param contractAddress The contract for which a sponsor is requested.176 /// @param contractAddress The contract for which a sponsor is requested.
176 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.177 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
177 fn sponsor(&self, contract_address: address) -> Result<pallet_common::eth::CrossAddress> {178 fn sponsor(&self, contract_address: address) -> Result<eth::OptionCrossAddress> {
178 Ok(179 Ok(match Pallet::<T>::get_sponsor(contract_address) {
179 pallet_common::eth::CrossAddress::from_sub_cross_account::<T>(180 Some(ref value) => eth::OptionCrossAddress {
181 status: true,
180 &Pallet::<T>::get_sponsor(contract_address).ok_or("Contract has no sponsor")?,182 value: eth::CrossAddress::from_sub_cross_account::<T>(value),
181 ),183 },
184 None => eth::OptionCrossAddress {
185 status: false,
186 value: Default::default(),
187 },
182 )188 })
183 }189 }
184190
185 /// Check tat contract has confirmed sponsor.191 /// Check tat contract has confirmed sponsor.
modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.soldiffbeforeafterboth
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: 0x766c4f37,97 /// @dev EVM selector for this function is: 0x766c4f37,
98 /// or in textual repr: sponsor(address)98 /// or in textual repr: sponsor(address)
99 function sponsor(address contractAddress) public view returns (CrossAddress memory) {99 function sponsor(address contractAddress) public view returns (OptionCrossAddress memory) {
100 require(false, stub_error);100 require(false, stub_error);
101 contractAddress;101 contractAddress;
102 dummy;102 dummy;
103 return CrossAddress(0x0000000000000000000000000000000000000000, 0);103 return OptionCrossAddress(false, CrossAddress(0x0000000000000000000000000000000000000000, 0));
104 }104 }
105105
106 /// Check tat contract has confirmed sponsor.106 /// Check tat contract has confirmed sponsor.
271 uint256 sub;271 uint256 sub;
272}272}
273
274/// @dev Ethereum representation of Optional value with CrossAddress.
275struct OptionCrossAddress {
276 bool status;
277 CrossAddress value;
278}
273279
modifiedpallets/unique/src/lib.rsdiffbeforeafterboth
74extern crate alloc;74extern crate alloc;
7575
76use frame_support::{76use frame_support::{
77 decl_module, decl_storage, decl_error, decl_event,77 decl_module, decl_storage, decl_error,
78 dispatch::DispatchResult,78 dispatch::DispatchResult,
79 ensure, fail,79 ensure, fail,
80 weights::{Weight},80 weights::{Weight},
modifiedtests/src/eth/abi/contractHelpers.jsondiffbeforeafterboth
222 "name": "sponsor",222 "name": "sponsor",
223 "outputs": [223 "outputs": [
224 {224 {
225 "components": [
226 { "internalType": "bool", "name": "status", "type": "bool" },
227 {
225 "components": [228 "components": [
226 { "internalType": "address", "name": "eth", "type": "address" },229 { "internalType": "address", "name": "eth", "type": "address" },
227 { "internalType": "uint256", "name": "sub", "type": "uint256" }230 { "internalType": "uint256", "name": "sub", "type": "uint256" }
228 ],231 ],
229 "internalType": "struct CrossAddress",232 "internalType": "struct CrossAddress",
233 "name": "value",
234 "type": "tuple"
235 }
236 ],
237 "internalType": "struct OptionCrossAddress",
230 "name": "",238 "name": "",
231 "type": "tuple"239 "type": "tuple"
232 }240 }
modifiedtests/src/eth/api/ContractHelpers.soldiffbeforeafterboth
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: 0x766c4f37,70 /// @dev EVM selector for this function is: 0x766c4f37,
71 /// or in textual repr: sponsor(address)71 /// or in textual repr: sponsor(address)
72 function sponsor(address contractAddress) external view returns (CrossAddress memory);72 function sponsor(address contractAddress) external view returns (OptionCrossAddress memory);
7373
74 /// Check tat contract has confirmed sponsor.74 /// Check tat contract has confirmed sponsor.
75 ///75 ///
171 function toggleAllowlist(address contractAddress, bool enabled) external;171 function toggleAllowlist(address contractAddress, bool enabled) external;
172}172}
173
174/// @dev Ethereum representation of Optional value with CrossAddress.
175struct OptionCrossAddress {
176 bool status;
177 CrossAddress value;
178}
173179
174/// @dev Cross account struct180/// @dev Cross account struct
175struct CrossAddress {181struct CrossAddress {
modifiedtests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth
42 expect(await helpers.methods.hasSponsor(flipper.options.address).call()).to.be.true;42 expect(await helpers.methods.hasSponsor(flipper.options.address).call()).to.be.true;
4343
44 // 1.1 Can get sponsor using methods.sponsor:44 // 1.1 Can get sponsor using methods.sponsor:
45 const actualSponsor = await helpers.methods.sponsor(flipper.options.address).call();45 const actualSponsorOpt = await helpers.methods.sponsor(flipper.options.address).call();
46 expect(actualSponsorOpt.status).to.be.true;
47 const actualSponsor = actualSponsorOpt.value;
46 expect(actualSponsor.eth).to.eq(flipper.options.address);48 expect(actualSponsor.eth).to.eq(flipper.options.address);
47 expect(actualSponsor.sub).to.eq('0');49 expect(actualSponsor.sub).to.eq('0');
4850
151 expect(await helpers.methods.hasSponsor(flipper.options.address).call()).to.be.true;153 expect(await helpers.methods.hasSponsor(flipper.options.address).call()).to.be.true;
152154
153 // 1.1 Can get sponsor using methods.sponsor:155 // 1.1 Can get sponsor using methods.sponsor:
154 const actualSponsor = await helpers.methods.sponsor(flipper.options.address).call();156 const actualSponsorOpt = await helpers.methods.sponsor(flipper.options.address).call();
157 expect(actualSponsorOpt.status).to.be.true;
158 const actualSponsor = actualSponsorOpt.value;
155 expect(actualSponsor.eth).to.eq(sponsor);159 expect(actualSponsor.eth).to.eq(sponsor);
156 expect(actualSponsor.sub).to.eq('0');160 expect(actualSponsor.sub).to.eq('0');
157161