git.delta.rocks / unique-network / refs/commits / 361b516d69f6

difftreelog

feat dispatch call to Native fingible

Trubnikov Sergey2023-04-24parent: #dfdf994.patch.diff
in: master

6 files changed

modifiedpallets/common/src/dispatch.rsdiffbeforeafterboth
94 /// * `handle` - Collection handle.94 /// * `handle` - Collection handle.
95 fn dispatch(handle: CollectionHandle<T>) -> Self;95 fn dispatch(handle: CollectionHandle<T>) -> Self;
96
97 /// Get the collection handle for the corresponding implementation.
98 fn into_inner(self) -> CollectionHandle<T>;
9996
100 /// Get the implementation of [`CommonCollectionOperations`].97 /// Get the implementation of [`CommonCollectionOperations`].
101 fn as_dyn(&self) -> &dyn CommonCollectionOperations<T>;98 fn as_dyn(&self) -> &dyn CommonCollectionOperations<T>;
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
125impl<T: Config> CollectionHandle<T> {125impl<T: Config> CollectionHandle<T> {
126 /// Same as [CollectionHandle::new] but with an explicit gas limit.126 /// Same as [CollectionHandle::new] but with an explicit gas limit.
127 pub fn new_with_gas_limit(id: CollectionId, gas_limit: u64) -> Option<Self> {127 pub fn new_with_gas_limit(id: CollectionId, gas_limit: u64) -> Option<Self> {
128 <CollectionById<T>>::get(id).map(|collection| Self {128 Self::new_with_recorder(id, SubstrateRecorder::new(gas_limit))
129 id,
130 collection,
131 recorder: SubstrateRecorder::new(gas_limit),
132 })
133 }129 }
134130
135 /// Same as [CollectionHandle::new] but with an existed [`SubstrateRecorder`].131 /// Same as [CollectionHandle::new] but with an existed [`SubstrateRecorder`].
modifiedruntime/common/dispatch.rsdiffbeforeafterboth
118 }118 }
119 }119 }
120
121 fn into_inner(self) -> CollectionHandle<T> {
122 match self {
123 Self::Fungible(f) => f.into_inner(),
124 Self::Nonfungible(f) => f.into_inner(),
125 Self::Refungible(f) => f.into_inner(),
126 Self::NativeFungible(f) => f.into_inner(),
127 }
128 }
129120
130 fn as_dyn(&self) -> &dyn CommonCollectionOperations<T> {121 fn as_dyn(&self) -> &dyn CommonCollectionOperations<T> {
131 match self {122 match self {
189 Self::Fungible(h) => h.call(handle),180 Self::Fungible(h) => h.call(handle),
190 Self::Nonfungible(h) => h.call(handle),181 Self::Nonfungible(h) => h.call(handle),
191 Self::Refungible(h) => h.call(handle),182 Self::Refungible(h) => h.call(handle),
192 Self::NativeFungible(f) => todo!(),183 Self::NativeFungible(h) => h.call(handle),
193 }184 }
194 } else if let Some((collection_id, token_id)) =185 } else if let Some((collection_id, token_id)) =
195 <T as pallet_common::Config>::EvmTokenAddressMapping::address_to_token(186 <T as pallet_common::Config>::EvmTokenAddressMapping::address_to_token(
modifiedtests/src/eth/fungible.test.tsdiffbeforeafterboth
33 'substrate' as const,33 'substrate' as const,
34 'ethereum' as const,34 'ethereum' as const,
35 ].map(testCase => {35 ].map(testCase => {
36 itEth(`Can perform mintCross() for ${testCase} address`, async ({helper}) => {36 itEth.only(`Can perform mintCross() for ${testCase} address`, async ({helper}) => {
37 // 1. Create receiver depending on the test case:37 // 1. Create receiver depending on the test case:
38 const receiverEth = helper.eth.createAccount();38 const receiverEth = helper.eth.createAccount();
39 const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);39 const receiverCrossEth = helper.ethCrossAccount.fromAddress(receiverEth);
modifiedtests/src/eth/nativeFungible.test.tsdiffbeforeafterboth

no syntactic changes

modifiedtests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth
142142
143 async collection(address: string, mode: TCollectionMode, caller?: string, mergeDeprecated = false) {143 async collection(address: string, mode: TCollectionMode, caller?: string, mergeDeprecated = false) {
144 let abi;144 let abi;
145 if (address === '0' && mode === 'ft') {145 if (address === '0x17C4e6453cC49aaAAEaCA894E6d9683e00000000' && mode === 'ft') {
146 abi = nativeFungibleAbi;146 abi = nativeFungibleAbi;
147 } else {147 } else {
148 abi ={148 abi ={