git.delta.rocks / unique-network / refs/commits / 1ae3db3366fb

difftreelog

Style fix

str-mv2022-04-11parent: #e476c16.patch.diff
in: master

5 files changed

modifiedpallets/unique/src/sponsorship.rsdiffbeforeafterboth
29 CollectionId, FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, MetaUpdatePermission,29 CollectionId, FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, MetaUpdatePermission,
30 NFT_SPONSOR_TRANSFER_TIMEOUT, REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, TokenId,30 NFT_SPONSOR_TRANSFER_TIMEOUT, REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, TokenId,
31};31};
32use sp_runtime::traits::Saturating;
32use pallet_common::{CollectionHandle};33use pallet_common::{CollectionHandle};
33use pallet_evm::account::CrossAccountId;34use pallet_evm::account::CrossAccountId;
3435
316 {317 {
317 let collection = <CollectionHandle<T>>::try_get(collection_id).ok()?;318 let collection = <CollectionHandle<T>>::try_get(collection_id).ok()?;
318
319 // preliminary sponsoring correctness check
320 match collection.sponsorship {319 let _ = collection.sponsorship.sponsor()?;
321 SponsorshipState::Disabled | SponsorshipState::Unconfirmed(_) => return None,
322 _ => (),
323 }
324320
325 // sponsor timeout321 // sponsor timeout
326 let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;322 let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
343 };339 };
344340
345 if let Some(last_tx_block) = last_tx_block {341 if let Some(last_tx_block) = last_tx_block {
346 let timeout = last_tx_block + limit.into();
347 if block_number < timeout {
348 return Some((timeout - block_number).into());342 return Some(
349 }343 last_tx_block
350 return Some(0);344 .saturating_add(limit.into())
345 .saturating_sub(block_number)
346 .into(),
347 );
351 }348 }
352349
353 let token_exists = match collection.mode {350 let token_exists = match collection.mode {
modifiedtests/src/interfaces/augment-api-rpc.tsdiffbeforeafterboth
626 /**626 /**
627 * nextSponsored transaction627 * nextSponsored transaction
628 **/628 **/
629 nextSponsored: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, account: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<u64>>>;629 nextSponsored: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, account: AccountId | string | Uint8Array | { Substrate: any } | { Ethereum: any } | string | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<u64>>>;
630 };630 };
631 web3: {631 web3: {
632 /**632 /**
modifiedtests/src/interfaces/unique/definitions.tsdiffbeforeafterboth
55 collectionById: fun('Get collection by specified id', [collectionParam], 'Option<UpDataStructsCollection>'),55 collectionById: fun('Get collection by specified id', [collectionParam], 'Option<UpDataStructsCollection>'),
56 collectionStats: fun('Get collection stats', [], 'UpDataStructsCollectionStats'),56 collectionStats: fun('Get collection stats', [], 'UpDataStructsCollectionStats'),
57 allowed: fun('Check if user is allowed to use collection', [collectionParam, crossAccountParam()], 'bool'),57 allowed: fun('Check if user is allowed to use collection', [collectionParam, crossAccountParam()], 'bool'),
58 nextSponsored: fun('Check if user is allowed to use collection', [collectionParam, crossAccountParam(), tokenParam], 'Option<u64>'),58 nextSponsored: fun('Get number of blocks when sponsored transaction is available', [collectionParam, crossAccountParam(), tokenParam], 'Option<u64>'),
59 effectiveCollectionLimits: fun('Get effective collection limits', [collectionParam], 'Option<UpDataStructsCollectionLimits>'),59 effectiveCollectionLimits: fun('Get effective collection limits', [collectionParam], 'Option<UpDataStructsCollectionLimits>'),
60 },60 },
61};61};
addedtests/src/nextSponsoring.test.tsdiffbeforeafterboth

no changes

modifiedtests/src/util/helpers.tsdiffbeforeafterboth
608 });608 });
609}609}
610
611export async function getNextSponsored(
612 api: ApiPromise,
613 collectionId: number,
614 account: string | CrossAccountId,
615 tokenId: number,
616): Promise<number> {
617 return Number((await api.rpc.unique.nextSponsored(collectionId, account, tokenId)).unwrapOr(-1));
618}
610619
611export async function toggleContractAllowlistExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, value = true) {620export async function toggleContractAllowlistExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, value = true) {
612 await usingApi(async (api) => {621 await usingApi(async (api) => {