sourcify

package
v0.7.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package sourcify implements a client for the Sourcify Server API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SourceFile added in v0.2.10

type SourceFile struct {
	Name    string `json:"name"`
	Path    string `json:"path"`
	Content string `json:"content"`
}

type SourcifyClient

type SourcifyClient struct {
	// contains filtered or unexported fields
}

SourcifyClient is a client for interacting with the Sourcify Server API, providing methods to fetch and parse contract data for supported Oasis runtimes.

func NewClient

func NewClient(serverUrl string, chain common.ChainName, logger *log.Logger) (*SourcifyClient, error)

NewClient returns a new Sourcify API client.

func (*SourcifyClient) GetContractSourceFiles

func (s *SourcifyClient) GetContractSourceFiles(ctx context.Context, runtime common.Runtime, address ethCommon.Address) ([]SourceFile, json.RawMessage, error)

GetContractSourceFiles returns the source files for the given contract address that is verified on sourcify. The first return argument are the source files returned in a list of maps, where each map contains the following keys: - "name": The name of the source file. - "content": The content of the source file. - "path": The path of the source file. The second return argument is the metadata.json file content as a raw JSON message.

See https://docs.sourcify.dev/docs/api/#/Contract%20Lookup/get-contract for more details.

Note: This uses the free, public server API. If it turns out to be unreliable, we could use the repository API (vis IPFS proxy) instead, e.g.: - https://docs.sourcify.dev/docs/api/repository/get-file-repository/ - http://ipfs.default:8080/ipns/repo.sourcify.dev/contracts/full_match/23294/0x0a0b58b5e6d8f2c0f4c4b6e7a0c8f0b1b4b3b2b1/

func (*SourcifyClient) GetVerifiedContractAddresses

func (s *SourcifyClient) GetVerifiedContractAddresses(ctx context.Context, runtime common.Runtime) (map[ethCommon.Address]VerificationLevel, error)

GetVerifiedContractAddresses returns a list of all verified contract addresses for the given runtime.

API docs: https://docs.sourcify.dev/docs/api/#/Contract%20Lookup/get-v2-contracts-chainId

Note: This uses the free, public server API. If it turns out to be unreliable, we could use the repository API (vis IPFS proxy) instead, e.g.: http://ipfs.default:8080/ipns/repo.sourcify.dev/contracts/full_match/23294

type VerificationLevel added in v0.2.10

type VerificationLevel string

Level of contract verification, as defined by Sourcify. Keep values in sync with the `sourcify_level` postgres ENUM.

const (
	VerificationLevelPartial VerificationLevel = "partial"
	VerificationLevelFull    VerificationLevel = "full"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL