Skip to content

Commit 4e5674c

Browse files
committed
* Removed commented code un schema.graphql
* Created stake.ts file in types directory * Throwing error when the transaction fails in `optimizedBulkCreate`
1 parent f1aec93 commit 4e5674c

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

schema.graphql

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -758,14 +758,6 @@ type EventRelayMiningDifficultyUpdated @entity {
758758
event: Event!
759759
}
760760

761-
#message EventRelayMiningDifficultyUpdated {
762-
# string service_id = 1;
763-
# string prev_target_hash_hex_encoded = 2;
764-
# string new_target_hash_hex_encoded = 3;
765-
# uint64 prev_num_relays_ema = 4;
766-
# uint64 new_num_relays_ema = 5;
767-
#}
768-
769761
type Gateway @entity {
770762
# id is the address of the gateway
771763
id: ID!

src/mappings/indexer.manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
EventByType,
3636
MessageByType,
3737
} from "./types/common";
38+
import { GetIdFromEventAttribute, RecordGetId } from "./types/stake";
3839
import { optimizedBulkCreate } from "./utils/db";
3940
import { getBlockId } from "./utils/ids";
4041
import { stringify } from "./utils/json";
@@ -366,7 +367,6 @@ function groupConnectedComponents(arrays: string[][]): string[][] {
366367
return result;
367368
}
368369

369-
type GetIdFromEventAttribute = (attributes: CosmosEvent["event"]["attributes"]) => string | Array<string>;
370370

371371
/*
372372
This function is used to call handlers in order to avoid updating the same entity twice or more at the same time
@@ -375,7 +375,7 @@ This function is used to call handlers in order to avoid updating the same entit
375375
for messages it is the path of the decodedMsg to get the entity id
376376
for events it is a function that receives the attributes and returns the entity id
377377
*/
378-
async function indexStakeEntity(data: Array<CosmosEvent | CosmosMessage>, getEntityIdArg: Record<string, string | GetIdFromEventAttribute>) {
378+
async function indexStakeEntity(data: Array<CosmosEvent | CosmosMessage>, getEntityIdArg: RecordGetId) {
379379
// this is to handle events where more than one stake entity is updated
380380
// like in _handleTransferApplicationEndEvent handler
381381
const entitiesUpdatedAtSameDatum: Array<Array<string>> = [];

src/mappings/types/stake.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { CosmosEvent } from "@subql/types-cosmos";
2+
3+
export type GetIdFromEventAttribute = (attributes: CosmosEvent["event"]["attributes"]) => string | Array<string>;
4+
5+
export type RecordGetId = Record<string, string | GetIdFromEventAttribute>

src/mappings/utils/db.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,9 @@ export async function optimizedBulkCreate(modelName: string, docs: Array<any>, t
156156
});
157157

158158
await transaction.commit()
159-
} catch {
159+
} catch (e) {
160160
await transaction.rollback()
161+
throw e
161162
}
162163

163164
// Update and log progress after successful batch creation

0 commit comments

Comments
 (0)