Documentation ¶
Overview ¶
package credit implements a credit resolution, allowing accounts to be credited with a given amount.
Index ¶
Constants ¶
const CreditAccountEventType = "credit_account"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountCreditResolution ¶
type AccountCreditResolution struct { // Account is the account to be credited. // This can be an Ethereum address (decoded from hex), a validator ed25519 public key, // or any other custom account identifier implemented in an auth extension. Account []byte // Amount is the amount to be credited to the account. // It uses a big.Int to allow for arbitrary precision, and to allow for uint256 values, // which are commonly used in token contracts on Ethereum. Amount *big.Int // TxHash is the hash of the Ethereum transaction that emitted the EVM event to credit the account. // This ensures that, even if the same account is credited the same amount multiple times, // that each credit resolution is unique. It is critical that all resolutions in Kwil are // unique, as they are idempotent for the lifetime of the entire network. TxHash []byte }
AccountCreditResolution is a resolution that allows accounts to be credited with a given amount. It is used by both the credit_account resolution and the eth_deposit_oracle. It can be serialized and deserialized to be passed around the network. The amount cannot be negative, as this will fail RLP encoding.
func (*AccountCreditResolution) MarshalBinary ¶
func (a *AccountCreditResolution) MarshalBinary() ([]byte, error)
MarshalBinary marshals the AccountCreditResolution to binary. We do not use the popular json.Marshal library because we need this serialization to be deterministic. Kwil contains a serialization library that uses Ethereum's RLP encoding, which is deterministic and used for all serialization in Kwil.
func (*AccountCreditResolution) UnmarshalBinary ¶
func (a *AccountCreditResolution) UnmarshalBinary(data []byte) error
UnmarshalBinary unmarshals the AccountCreditResolution from binary. It is the inverse of MarshalBinary, and uses the same serialization library.