Documentation ¶
Index ¶
- Variables
- func Compare(pr PreparedReport, ar AttestedReport) error
- func GetOperatorPrivateKey(filename string) (ed25519.PrivateKey, error)
- func ReadReport(report any, reader io.Reader) error
- type AttestedReport
- type AttestedTx
- type Custodian
- type KeyPolicy
- type KeyStatement
- type KeyStatementPrincipal
- type PrepareTx
- type PreparedReport
- type SettlementClient
- type Tx
- type WorkerConfig
Constants ¶
This section is empty.
Variables ¶
var ( PrepareStream = preparePrefix + payout SubmitStream = submitPrefix + payout PrepareConfigStream = preparePrefix + "config" SubmitConfigStream = submitPrefix + "config" )
var ( // ErrDuplicateDepositDestination indicates that a report contains duplicate deposit destinations. ErrDuplicateDepositDestination = errors.New("duplicate deposit destination") )
Functions ¶
func Compare ¶
func Compare(pr PreparedReport, ar AttestedReport) error
Compare takes a prepared and attested report and validates that both contain the same number of transactions, that there is only a single deposit destination per transaction and that the total sum of BAT is the same in each report.
func GetOperatorPrivateKey ¶
func GetOperatorPrivateKey(filename string) (ed25519.PrivateKey, error)
GetOperatorPrivateKey - get the private key from the file specified
Types ¶
type AttestedReport ¶
type AttestedReport []*AttestedTx
AttestedReport is the report of payouts after being prepared
func (AttestedReport) EnsureUniqueDest ¶
func (r AttestedReport) EnsureUniqueDest() error
func (AttestedReport) IsAttested ¶
func (ar AttestedReport) IsAttested() (bool, error)
IsAttested allows the caller to validate if the transactions within the report are attested
func (AttestedReport) Submit ¶
func (ar AttestedReport) Submit(ctx context.Context, key ed25519.PrivateKey, client SettlementClient) error
Submit performs a submission of approval from an operator to the settlement client
func (AttestedReport) SumBAT ¶
func (ar AttestedReport) SumBAT() decimal.Decimal
SumBAT sums the total amount of BAT in the report.
type AttestedTx ¶
type AttestedTx struct { Tx Version string `json:"version"` State string `json:"state"` DocumentID string `json:"documentId"` AttestationDocument string `json:"attestationDocument"` // base64 encoded }
An AttestedTx is a transaction that has been attested by an enclave
func (*AttestedTx) UnmarshalJSON ¶
func (at *AttestedTx) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom json unmarshaling
type KeyPolicy ¶
type KeyPolicy struct { Version *string Statement []KeyStatement }
type KeyStatement ¶
type KeyStatement struct { Sid string Effect string Principal KeyStatementPrincipal Action []string Condition map[string]interface{} }
type KeyStatementPrincipal ¶
type KeyStatementPrincipal struct {
AWS interface{}
}
type PrepareTx ¶
type PrepareTx Tx
func (*PrepareTx) GetCustodian ¶
GetCustodian returns the custodian of the transaction
func (*PrepareTx) UnmarshalJSON ¶
UnmarshalJSON implements custom json unmarshaling (convert altcurrency) for Tx
type PreparedReport ¶
type PreparedReport []*PrepareTx
PreparedReport is the report of payouts prior to being prepared
func (PreparedReport) EnsureUniqueDest ¶
func (r PreparedReport) EnsureUniqueDest() error
func (PreparedReport) Prepare ¶
func (r PreparedReport) Prepare(ctx context.Context, client SettlementClient) error
Prepare performs a preparation of transactions for a payout to the settlement client
func (PreparedReport) SumBAT ¶
func (r PreparedReport) SumBAT() decimal.Decimal
SumBAT sums the total amount of BAT in the report.
type SettlementClient ¶
type SettlementClient interface { ConfigureWorker(context.Context, string, *WorkerConfig) error PrepareTransactions(context.Context, ...*PrepareTx) error SubmitTransactions(context.Context, httpsignature.ParameterizedSignator, ...*AttestedTx) error }
SettlementClient describes functionality of the settlement client
func NewSettlementClient ¶
func NewSettlementClient(env string, config map[string]string) (SettlementClient, error)
NewSettlementClient instantiates a new SettlementClient for use by tooling
type Tx ¶
type Tx struct { To string `json:"to"` Amount decimal.Decimal `json:"amount"` ID string `json:"idempotencyKey"` Custodian Custodian `json:"custodian"` DryRun *string `json:"dryRun" ion:"-"` }
Tx - this is the tx going to prepare workers from report
func (*Tx) GetCustodian ¶
GetCustodian returns the custodian of the transaction
func (*Tx) MarshalJSON ¶
MarshalJSON implements custom json marshaling (output json naming differences) for Tx
type WorkerConfig ¶
type WorkerConfig struct { PayoutID string `json:"payoutId"` ConsumerGroup string `json:"consumerGroup"` Stream string `json:"stream"` Count int `json:"count"` }
WorkerConfig defines the settlement worker configuration structure
func (WorkerConfig) MarshalBinary ¶
func (wc WorkerConfig) MarshalBinary() (data []byte, err error)
MarshalBinary implements encoding.BinaryMarshaler required for go-redis