Skip to content

feat: Added transformIdx to the event #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
node-version: [14.x, 16.x, 18.x]

steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install
run: npm ci

- name: Audits
run: npm audit --production

- name: Lints
run: npm run lint:ci

- name: Test
run: npm run test

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
1 change: 1 addition & 0 deletions src/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface Event {
contractHash: Hash | null;
contractPackageHash: Hash | null;
eventId: number;
transformIdx: number;
data: Record<string, CLValue>;
}

Expand Down
5 changes: 4 additions & 1 deletion src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ export class Parser {

const results: ParseResult[] = [];

for (const transform of executionResult.effects) {
for (let i = 0; i < executionResult.effects.length; i++) {
const transform = executionResult.effects[i];

if (!transform.key.dictionary) {
continue;
}
Expand Down Expand Up @@ -168,6 +170,7 @@ export class Parser {
contractPackageHash: null,
name: eventNameWithRemainder.result,
eventId: parseInt(dictionary.key),
transformIdx: i,
data: {},
};

Expand Down
4 changes: 4 additions & 0 deletions test/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ describe('Parser', () => {
expect(events[0].event!.name).toEqual('BallotCast');
expect(events[0].event!.contractHash).toEqual(contractHash);
expect(events[0].event!.contractPackageHash).toEqual(contractPackageHash);
expect(events[0].event!.eventId).toEqual(2);
expect(events[0].event!.transformIdx).toEqual(99);

expect(Object.keys(events[0].event!.data!).length).toEqual(5);

Expand All @@ -75,6 +77,8 @@ describe('Parser', () => {
expect(events[1].event!.name).toEqual('SimpleVotingCreated');
expect(events[1].event!.contractHash).toEqual(contractHash);
expect(events[1].event!.contractPackageHash).toEqual(contractPackageHash);
expect(events[1].event!.eventId).toEqual(3);
expect(events[1].event!.transformIdx).toEqual(115);

expect(Object.keys(events[1].event!.data!).length).toEqual(12);

Expand Down