Documentation
¶
Index ¶
- Variables
- func AddChainConfig(chain *ChainConfig) bool
- type Callback
- type ChainConfig
- type DcapPortal
- func (p *DcapPortal) BuildTransactOpts(ctx context.Context) (*bind.TransactOpts, error)
- func (p *DcapPortal) CalculateAttestationFee(tx *types.Transaction, callback *Callback, receipt *types.Receipt) *big.Int
- func (p *DcapPortal) CheckQuote(ctx context.Context, quote []byte) (bool, error)
- func (p *DcapPortal) CheckZkProof(ctx context.Context, proof *zkdcap.ZkProof) (bool, error)
- func (p *DcapPortal) Client() *ethclient.Client
- func (p *DcapPortal) EstimateAttestationFee(tx *types.Transaction, callback *Callback) *big.Int
- func (p *DcapPortal) EstimateBaseFeeVerifyAndAttestWithZKProof(ctx context.Context, zkProof *zkdcap.ZkProof) (*big.Int, error)
- func (p *DcapPortal) EstimateBaseFeeVerifyOnChain(ctx context.Context, rawQuote []byte) (*big.Int, error)
- func (p *DcapPortal) GenerateZkProof(ctx context.Context, ty zkdcap.ZkType, quote []byte) (*zkdcap.ZkProof, error)
- func (d *DcapPortal) Pccs() *pccs.Client
- func (p *DcapPortal) PrintAttestationFee(tx *types.Transaction, callback *Callback, receipt *types.Receipt)
- func (p *DcapPortal) VerifyAndAttestOnChain(opts *bind.TransactOpts, rawQuote []byte, callback *Callback) (*types.Transaction, error)
- func (p *DcapPortal) VerifyAndAttestWithZKProof(opts *bind.TransactOpts, zkProof *zkdcap.ZkProof, callback *Callback) (*types.Transaction, error)
- func (p *DcapPortal) WaitTx(ctx context.Context, tx *types.Transaction) <-chan *types.Receipt
- type DcapPortalOption
- type JsonError
Constants ¶
This section is empty.
Variables ¶
var ( ErrValueShouldBeNil = logex.Define("value in TransactOpts should be nil") ErrTransactOptsMissingFrom = logex.Define("TransactOpts missing from") ErrInsuccifientFunds = logex.Define("InsuccifientFunds") DcapError = map[string]string{ "0x1356a63b": "AutomataDcapAttestation: BP_Not_Valid()", "0x1a72054d": "AutomataDcapAttestation: Insuccifient_Funds()", "0xc40a532b": "AutomataDcapAttestation: Withdrawal_Failed()", } )
var ChainArbitrumMainnet = parseChainConfig(arbitrumMainnet)
var ChainArbitrumSepolia = parseChainConfig(arbitrumSepolia)
var ChainAutomataMainnet = parseChainConfig(automataMainnet)
var ChainAutomataTestnet = parseChainConfig(automataTestnet)
var ChainAvalancheCFuji = parseChainConfig(avalancheCFuji)
var ChainAvalancheCMainnet = parseChainConfig(avalancheCMainnet)
var ChainBaseMainnet = parseChainConfig(baseMainnet)
var ChainBaseSepolia = parseChainConfig(baseSepolia)
var ChainBscMainnet = parseChainConfig(bscMainnet)
var ChainBscTestnet = parseChainConfig(bscTestnet)
var ChainEthereumHolesky = parseChainConfig(ethereumHolesky)
var ChainEthereumHoodi = parseChainConfig(ethereumHoodi)
var ChainEthereumMainnet = parseChainConfig(ethereumMainnet)
var ChainEthereumSepolia = parseChainConfig(ethereumSepolia)
var ChainOPMainnet = parseChainConfig(opMainnet)
var ChainOPSepolia = parseChainConfig(opSepolia)
var ChainPolygonPosAmoy = parseChainConfig(polygonPosAmoy)
var ChainPolygonPosMainnet = parseChainConfig(polygonPosMainnet)
var ChainWorldMainnet = parseChainConfig(worldMainnet)
var ChainWorldSepolia = parseChainConfig(worldSepolia)
var Chains = []*ChainConfig{ ChainAutomataMainnet, ChainEthereumMainnet, ChainBaseMainnet, ChainOPMainnet, ChainWorldMainnet, ChainArbitrumMainnet, ChainBscMainnet, ChainAvalancheCMainnet, ChainPolygonPosMainnet, ChainAutomataTestnet, ChainEthereumSepolia, ChainEthereumHolesky, ChainBaseSepolia, ChainOPSepolia, ChainWorldSepolia, ChainArbitrumSepolia, ChainBscTestnet, ChainAvalancheCFuji, ChainPolygonPosAmoy, ChainEthereumHoodi, }
Functions ¶
func AddChainConfig ¶
func AddChainConfig(chain *ChainConfig) bool
Types ¶
type Callback ¶
type Callback struct {
// contains filtered or unexported fields
}
func NewCallback ¶
func NewCallbackFromAbiJSON ¶
func (*Callback) WithParams ¶
type ChainConfig ¶
type ChainConfig struct { ChainId int64 `json:"chain_id"` Name string `json:"name"` Testnet bool `json:"testnet"` OneRpc string `json:"one_rpc"` Endpoint string `json:"endpoint"` EIP1559 bool `json:"eip_1559"` Explorer string `json:"explorer"` DcapPortal common.Address `json:"dcap_portal"` AutomataDcapAttestationFee common.Address `json:"automata_dcap_attestation_fee"` PCCSRouter common.Address `json:"pccs_router"` V3QuoteVerifier common.Address `json:"v3_quote_verifier"` V4QuoteVerifier common.Address `json:"v4_quote_verifier"` PCCS *pccs.ChainConfig `json:"pccs"` }
func ChainConfigFromChainId ¶
func ChainConfigFromChainId(chainId int64) *ChainConfig
type DcapPortal ¶
type DcapPortal struct { Stub *gen.DcapPortal // contains filtered or unexported fields }
DcapPortal represents the main interface for interacting with DCAP attestation
func NewDcapPortal ¶
func NewDcapPortal(ctx context.Context, options ...DcapPortalOption) (*DcapPortal, error)
NewDcapPortal creates a new instance of DcapPortal with the provided options. It will connect to AutomataTestnet(https://explorer-testnet.ata.network) by default
func (*DcapPortal) BuildTransactOpts ¶
func (p *DcapPortal) BuildTransactOpts(ctx context.Context) (*bind.TransactOpts, error)
BuildTransactOpts builds transaction options using the provided private key. Returns error if key transactor creation or options normalization fails.
func (*DcapPortal) CalculateAttestationFee ¶
func (p *DcapPortal) CalculateAttestationFee(tx *types.Transaction, callback *Callback, receipt *types.Receipt) *big.Int
CalculateAttestationFee calculates the actual attestation fee based on the transaction receipt.
func (*DcapPortal) CheckQuote ¶
CheckQuote verifies if a quote is valid by doing a simulated call. Returns true if quote is valid, false otherwise.
func (*DcapPortal) CheckZkProof ¶
CheckZkProof verifies if a ZK proof is valid by doing a simulated call. Returns true if proof is valid, false otherwise.
func (*DcapPortal) Client ¶
func (p *DcapPortal) Client() *ethclient.Client
Client returns the Ethereum client associated with the DcapPortal.
func (*DcapPortal) EstimateAttestationFee ¶
func (p *DcapPortal) EstimateAttestationFee(tx *types.Transaction, callback *Callback) *big.Int
EstimateAttestationFee estimates the attestation fee for a transaction.
func (*DcapPortal) EstimateBaseFeeVerifyAndAttestWithZKProof ¶
func (p *DcapPortal) EstimateBaseFeeVerifyAndAttestWithZKProof(ctx context.Context, zkProof *zkdcap.ZkProof) (*big.Int, error)
EstimateFeeBaseVerifyAndAttestWithZKProof estimates the base fee for ZK proof verification and attestation. The actual fee will be base fee multiplied by gas price.
func (*DcapPortal) EstimateBaseFeeVerifyOnChain ¶
func (p *DcapPortal) EstimateBaseFeeVerifyOnChain(ctx context.Context, rawQuote []byte) (*big.Int, error)
EstimateFeeBaseVerifyOnChain estimates the base fee for quote verification. The actual fee will be base fee multiplied by gas price.
func (*DcapPortal) GenerateZkProof ¶
func (p *DcapPortal) GenerateZkProof(ctx context.Context, ty zkdcap.ZkType, quote []byte) (*zkdcap.ZkProof, error)
GenerateZkProof generates zero-knowledge proof for the given quote. Returns error if zkproof client is not initialized or proof generation fails.
Note: EnableZkProof() should be called before using this function.
func (*DcapPortal) Pccs ¶
func (d *DcapPortal) Pccs() *pccs.Client
Pccs returns the PCCS server instance associated with the DcapPortal.
func (*DcapPortal) PrintAttestationFee ¶
func (p *DcapPortal) PrintAttestationFee(tx *types.Transaction, callback *Callback, receipt *types.Receipt)
PrintAttestationFee prints the attestation fee details for a transaction.
func (*DcapPortal) VerifyAndAttestOnChain ¶
func (p *DcapPortal) VerifyAndAttestOnChain(opts *bind.TransactOpts, rawQuote []byte, callback *Callback) (*types.Transaction, error)
VerifyOnChain submits quote for on-chain verification with callback. Returns transaction hash and error if submission fails.
func (*DcapPortal) VerifyAndAttestWithZKProof ¶
func (p *DcapPortal) VerifyAndAttestWithZKProof(opts *bind.TransactOpts, zkProof *zkdcap.ZkProof, callback *Callback) (*types.Transaction, error)
VerifyAndAttestWithZKProof verifies and attests the ZK proof on chain. Returns transaction hash and error if verification fails.
func (*DcapPortal) WaitTx ¶
func (p *DcapPortal) WaitTx(ctx context.Context, tx *types.Transaction) <-chan *types.Receipt
WaitTx waits for the transaction receipt and returns it through a channel.
type DcapPortalOption ¶
type DcapPortalOption func(context.Context, *DcapPortal) error
func WithChainConfig ¶
func WithChainConfig(chainConfig *ChainConfig) DcapPortalOption
Custom chain config
func WithClient ¶
func WithClient(client *ethclient.Client) DcapPortalOption
Connect to the portal with the provided client
func WithEndpoint ¶
func WithEndpoint(endpoint string) DcapPortalOption
Connect to the portal with the provided endpoint
func WithPrivateKey ¶
func WithPrivateKey(key string) DcapPortalOption
func WithZkProof ¶
func WithZkProof(cfg *zkdcap.ZkProofConfig) DcapPortalOption
Enable zero-knowledge proof functionality cfg can be nil