Skip to content

Commit

Permalink
feat: add auditsnapshotaccrual
Browse files Browse the repository at this point in the history
  • Loading branch information
gridcat committed Jul 7, 2021
1 parent 23988a9 commit 046c4c9
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/RPC/Developer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
import { AuditSnapshot, AuditSnapshotDetailed } from '../contracts/auditSnapshot';
import { RPCBase } from '../RPCBase';
import { CPID } from '../types';

export class Developer extends RPCBase {
public async auditSnapshotAccrual(cpid: CPID, detailed: false): Promise<AuditSnapshot>;

public async auditSnapshotAccrual(cpid: CPID, detailed: true): Promise<AuditSnapshotDetailed>;

/**
* Report accrual snapshot deltas for the specified CPID.
*
* @param {CPID} cpid
* @param {boolean} detailed
* @returns {(Promise<AuditSnapshot | AuditSnapshotDetailed>)}
* @memberof Developer
*/
public async auditSnapshotAccrual(cpid: CPID, detailed: boolean): Promise<AuditSnapshot | AuditSnapshotDetailed> {
return this.call('auditsnapshotaccrual', cpid, detailed);
}
}
34 changes: 34 additions & 0 deletions src/contracts/auditSnapshot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
interface Audit {
boundary: string;
lowTime: number;
highHeight: number;
highTime: number;
magnitudeAtLow: number;
accrual: {
period: number;
accumulated: number;
claimed: number;
}
}

interface BeaconTimestamp {
ctxHash: string;
timestamp: number;
}

export interface AuditSnapshot {
cpid: string;
accrualAccountExists: boolean;
latestBeaconTimestamp: BeaconTimestamp;
originalBeaconTimestamp: BeaconTimestamp;
renewals: number;
accrualByAudit: number;
accrualByGetAccrual: number;
newbieCorrection: number;
accrualLastPeriod: number;
}

export interface AuditSnapshotDetailed extends AuditSnapshot {
beaconChain: BeaconTimestamp[];
audit: Audit[];
}

0 comments on commit 046c4c9

Please sign in to comment.