-
Notifications
You must be signed in to change notification settings - Fork 0
/
attendance.ts
44 lines (38 loc) · 1.08 KB
/
attendance.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { ethers } from 'ethers'
import { abi } from '@relicprotocol/contracts/abi/IAttendanceProver.json'
import { Prover } from '@relicprotocol/types'
import { RelicClient } from '../client'
export interface AttendanceParams {
account: string
eventId: ethers.BigNumberish
code: string
}
export class AttendanceProver implements Prover {
readonly client: RelicClient
readonly contract: ethers.Contract
constructor(client: RelicClient) {
this.client = client
this.contract = new ethers.Contract(
client.addresses.attendanceProver,
abi,
client.provider
)
}
async prove(params: AttendanceParams): Promise<ethers.PopulatedTransaction> {
const proof = await this.client.api.attendanceProof(
params.account,
params.eventId,
params.code
)
return await this.contract.populateTransaction.claim(
proof.account,
proof.eventId,
proof.number,
proof.signatureInner,
proof.signatureOuter
)
}
fee(): Promise<ethers.BigNumber> {
return this.client.reliquary.getFee(this.contract.address)
}
}