Skip to content
Open
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
20 changes: 20 additions & 0 deletions packages/cre-sdk/src/sdk/don-info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export type Environment = {
chainSelector: bigint
registryAddress: string
}

export type Zone = {
environment: Environment
donID: number
}

export function productionEnvironment(): Environment {
return {
chainSelector: 5009297550715157269n,
registryAddress: '0x76c9cf548b4179F8901cda1f8623568b58215E62',
}
}

export function zoneFromEnvironment(environment: Environment, donID: number): Zone {
return { environment, donID }
}
54 changes: 53 additions & 1 deletion packages/cre-sdk/src/sdk/errors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Mode, type SecretRequest } from '@cre/generated/sdk/v1alpha/sdk_pb'
import type { SecretRequest } from '@cre/generated/sdk/v1alpha/sdk_pb'

export class DonModeError extends Error {
constructor() {
Expand All @@ -25,3 +25,55 @@ export class SecretsError extends Error {
this.name = 'SecretsError'
}
}

export class NullReportError extends Error {
constructor() {
super('null report')
this.name = 'NullReportError'
}
}

export class WrongSignatureCountError extends Error {
constructor() {
super('wrong number of signatures')
this.name = 'WrongSignatureCountError'
}
}

export class ParseSignatureError extends Error {
constructor() {
super('failed to parse signature')
this.name = 'ParseSignatureError'
}
}

export class RecoverSignerError extends Error {
constructor() {
super('failed to recover signer address from signature')
this.name = 'RecoverSignerError'
}
}

export class UnknownSignerError extends Error {
constructor() {
super('invalid signature')
this.name = 'UnknownSignerError'
}
}

export class DuplicateSignerError extends Error {
constructor() {
super('duplicate signer')
this.name = 'DuplicateSignerError'
}
}

export class RawReportTooShortError extends Error {
constructor(
public readonly need: number,
public readonly got: number,
) {
super(`raw report too short to contain metadata header: need ${need} bytes, got ${got}`)
this.name = 'RawReportTooShortError'
}
}
2 changes: 2 additions & 0 deletions packages/cre-sdk/src/sdk/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from './cre'
export * from './don-info'
export * from './errors'
export * from './report'
export type * from './runtime'
export * from './runtime'
Expand Down
13 changes: 13 additions & 0 deletions packages/cre-sdk/src/sdk/report-internals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { Address } from 'viem'

// Do not re-export in index.ts to avoid exposing it to the public API.
// This is public to allow the cache to be cleared in the tests.

export type DonInfo = {
f: number
signers: Map<Address, number>
}

// Do not re-export in index.ts to avoid exposing it to the public API.
// donInfoCache exists outside Report to allow testing to clear the cache.
export var donInfoCache = new Map<string, DonInfo>()
600 changes: 600 additions & 0 deletions packages/cre-sdk/src/sdk/report.test.ts

Large diffs are not rendered by default.

Loading
Loading