Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
change arbitrum dac keyset handler (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
torztomasz authored Mar 8, 2024
1 parent 6429980 commit fe5c3fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ describe(ArbitrumDACKeysetHandler.name, () => {
expect(value).toEqual({
field: 'someName',
value: {
threshold: 4,
keyCount: 7,
requiredSignatures: 4,
membersCount: 7,
},
})
})
Expand All @@ -83,8 +83,8 @@ describe(ArbitrumDACKeysetHandler.name, () => {
expect(value).toEqual({
field: 'someName',
value: {
threshold: 0,
keyCount: 0,
requiredSignatures: 0,
membersCount: 0,
},
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,26 @@ export class ArbitrumDACKeysetHandler implements ClassicHandler {
blockNumber,
)

const { threshold, keyCount } = decodeLastEvent(events)
const { requiredSignatures, membersCount } = decodeLastEvent(events)

return {
field: this.field,
value: {
threshold: threshold,
keyCount: keyCount,
requiredSignatures,
membersCount,
},
}
}
}

function decodeLastEvent(events: providers.Log[]): {
threshold: number
keyCount: number
requiredSignatures: number
membersCount: number
} {
if (events.length === 0) {
return {
threshold: 0,
keyCount: 0,
requiredSignatures: 0,
membersCount: 0,
}
}

Expand All @@ -72,11 +72,13 @@ function decodeLastEvent(events: providers.Log[]): {

// NOTE(radomski): Schema is not public, but we know that the first 8 bytes are the threshold and the next 8 are the keyCount
const keysetBytes = Bytes.fromHex(decodedEvent.keysetBytes as string)
const threshold = keysetBytes.slice(0, 8).toNumber()
const keyCount = keysetBytes.slice(8, 16).toNumber()
const assummedHonestMembers = keysetBytes.slice(0, 8).toNumber()
const membersCount = keysetBytes.slice(8, 16).toNumber()

const requiredSignatures = membersCount - assummedHonestMembers + 1

return {
threshold,
keyCount,
requiredSignatures,
membersCount,
}
}

0 comments on commit fe5c3fd

Please sign in to comment.