-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create util module and move batch check in there
- Loading branch information
Showing
2 changed files
with
36 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright (c) 2018-2022, BOTLabs GmbH. | ||
* | ||
* This source code is licensed under the BSD 4-Clause "Original" license | ||
* found in the LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import type { Extrinsic } from '@polkadot/types/interfaces' | ||
|
||
import { ConfigService } from '@kiltprotocol/config' | ||
import { GenericExtrinsic } from '@polkadot/types' | ||
|
||
/** | ||
* Checks wheather the provided extrinsic is one of the potential batch extrinsics. | ||
* | ||
* @param extrinsic The input [[Extrinsic]]. | ||
* | ||
* @returns True if the extrinsic is a batch extrinsic, false otherwise. | ||
*/ | ||
export function isBatch( | ||
extrinsic: Extrinsic | ||
): extrinsic is GenericExtrinsic< | ||
| typeof api.tx.utility.batch.args | ||
| typeof api.tx.utility.batchAll.args | ||
| typeof api.tx.utility.forceBatch.args | ||
> { | ||
const api = ConfigService.get('api') | ||
|
||
return ( | ||
api.tx.utility.batch.is(extrinsic) || | ||
api.tx.utility.batchAll.is(extrinsic) || | ||
api.tx.utility.forceBatch.is(extrinsic) | ||
) | ||
} |