Add codegen step to security workflow and fix prettier formatting

This commit is contained in:
2026-02-13 01:51:37 +03:00
parent 62550b442b
commit 0b0519bff8
6 changed files with 44 additions and 26 deletions
+3
View File
@@ -37,6 +37,9 @@ jobs:
- name: Install dependencies
run: yarn install --immutable
- name: Generate types
run: ./node_modules/.bin/subql codegen pezkuwi.yaml
- name: Build
run: ./node_modules/.bin/subql build pezkuwi.yaml
+9 -6
View File
@@ -53,7 +53,8 @@ export async function cachedRewardDestination(
},
} = event;
let accountAddress = accountId.toString();
destinationByAddress[accountAddress] = destination as unknown as RewardDestination;
destinationByAddress[accountAddress] =
destination as unknown as RewardDestination;
});
} else {
const allAccountsInBlock = allEventsInBlock.map((event) => {
@@ -68,7 +69,9 @@ export async function cachedRewardDestination(
// looks like accountAddress not related to events so just try to query payee directly
if (allAccountsInBlock.length === 0) {
rewardDestinationByAddress[blockId] = {};
return (await api.query.staking.payee(accountAddress)) as unknown as RewardDestination;
return (await api.query.staking.payee(
accountAddress,
)) as unknown as RewardDestination;
}
const payees = await api.queryMulti(
@@ -81,7 +84,9 @@ export async function cachedRewardDestination(
// something went wrong, so just query for single accountAddress
if (rewardDestinations.length !== allAccountsInBlock.length) {
const payee = (await api.query.staking.payee(accountAddress)) as unknown as RewardDestination;
const payee = (await api.query.staking.payee(
accountAddress,
)) as unknown as RewardDestination;
destinationByAddress[accountAddress] = payee;
rewardDestinationByAddress[blockId] = destinationByAddress;
return payee;
@@ -212,9 +217,7 @@ export async function getPoolMembers(
const members: [string, any][] = (
await api.query.nominationPools.poolMembers.entries()
)
.filter(
([_key, member]) => (member as Option<any>).isSome,
)
.filter(([_key, member]) => (member as Option<any>).isSome)
.map(([accountId, member]) => [
accountId.args[0].toString(),
(member as Option<any>).unwrap(),
+19 -9
View File
@@ -18,7 +18,7 @@ type TransferData = {
};
export async function handleHistoryElement(
extrinsic: SubstrateExtrinsic
extrinsic: SubstrateExtrinsic,
): Promise<void> {
const { isSigned } = extrinsic.extrinsic;
@@ -36,7 +36,7 @@ function createHistoryElement(
extrinsic: SubstrateExtrinsic,
address: string,
suffix: string = "",
hash?: string
hash?: string,
) {
let extrinsicHash = hash || extrinsic.extrinsic.hash.toString();
let blockNum = extrinsic.block.block.header.number.toNumber();
@@ -59,7 +59,7 @@ function createHistoryElement(
async function saveFailedTransfers(
transfers: Array<TransferData>,
extrinsic: SubstrateExtrinsic
extrinsic: SubstrateExtrinsic,
): Promise<void> {
for (const { isTransferAll, transfer } of transfers) {
const elementFrom = createHistoryElement(extrinsic, transfer.from, `-from`);
@@ -79,7 +79,7 @@ async function saveExtrinsic(extrinsic: SubstrateExtrinsic): Promise<void> {
const element = createHistoryElement(
extrinsic,
extrinsic.extrinsic.signer.toString(),
"-extrinsic"
"-extrinsic",
);
element.extrinsic = {
@@ -93,7 +93,7 @@ async function saveExtrinsic(extrinsic: SubstrateExtrinsic): Promise<void> {
}
function findFailedTransferCalls(
extrinsic: SubstrateExtrinsic
extrinsic: SubstrateExtrinsic,
): Array<TransferData> | null {
if (extrinsic.success) {
return null;
@@ -104,7 +104,7 @@ function findFailedTransferCalls(
const createTransfer = (
isTransferAll: boolean,
address: string,
amount: bigint
amount: bigint,
): TransferData => {
return {
isTransferAll,
@@ -121,7 +121,7 @@ function findFailedTransferCalls(
let transferCalls = determineTransferCallsArgs(
extrinsic.extrinsic.method,
createTransfer
createTransfer,
);
if (transferCalls.length == 0) {
@@ -133,11 +133,21 @@ function findFailedTransferCalls(
function determineTransferCallsArgs(
causeCall: any,
createTransfer: (isTransferAll: boolean, address: string, amount: bigint) => TransferData
createTransfer: (
isTransferAll: boolean,
address: string,
amount: bigint,
) => TransferData,
): Array<TransferData> {
if (isNativeTransfer(causeCall)) {
const [destinationAddress, amount] = causeCall.args;
return [createTransfer(false, destinationAddress.toString(), (amount as any).toBigInt())];
return [
createTransfer(
false,
destinationAddress.toString(),
(amount as any).toBigInt(),
),
];
} else if (isNativeTransferAll(causeCall)) {
const [destinationAddress] = causeCall.args;
return [createTransfer(true, destinationAddress.toString(), BigInt(0))];
+8 -6
View File
@@ -70,12 +70,14 @@ async function processEraStakersPaged(
const pageNumber = (pageId as any).toNumber();
const validatorIdString = validatorId.toString();
const others: IndividualExposure[] = exposure.others.map(({ who, value }: any) => {
return {
who: who.toString(),
value: value.toString(),
} as IndividualExposure;
});
const others: IndividualExposure[] = exposure.others.map(
({ who, value }: any) => {
return {
who: who.toString(),
value: value.toString(),
} as IndividualExposure;
},
);
(accumulator[validatorIdString] = accumulator[validatorIdString] || {})[
pageNumber
+2 -4
View File
@@ -145,8 +145,7 @@ export async function handlePoolUnbondingSlash(
).unwrap();
const pool =
(unbondingPools.withEra as any).get(eraIdNumber) ??
unbondingPools.noEra;
(unbondingPools.withEra as any).get(eraIdNumber) ?? unbondingPools.noEra;
await handleRelaychainPooledStakingSlash(
unbondingSlashEvent,
@@ -155,8 +154,7 @@ export async function handlePoolUnbondingSlash(
(slash as any).toBigInt(),
(member: any): bigint => {
return (
((member.unbondingEras as any).get(eraIdNumber))?.toBigInt() ??
BigInt(0)
(member.unbondingEras as any).get(eraIdNumber)?.toBigInt() ?? BigInt(0)
);
},
);
+3 -1
View File
@@ -60,7 +60,9 @@ function extractArgsFromPayoutValidator(
return [sender, (eraRaw as any).toNumber()];
}
export async function handleRewarded(rewardEvent: SubstrateEvent): Promise<void> {
export async function handleRewarded(
rewardEvent: SubstrateEvent,
): Promise<void> {
await handleReward(rewardEvent);
}