codegen

package
v1.15.2 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChainConfigByID = map[string]*ChainConfig{
	"mainnet": {
		DisplayName:      "Ethereum Mainnet",
		ExplorerLink:     "https://etherscan.io",
		FirehoseEndpoint: "mainnet.eth.streamingfast.io:443",
		Network:          "mainnet",
		SupportsCalls:    true,
	},
	"bnb": {
		DisplayName:      "BNB",
		ExplorerLink:     "https://bscscan.com",
		FirehoseEndpoint: "bnb.streamingfast.io:443",
		Network:          "bsc",
		SupportsCalls:    true,
	},
	"polygon": {
		DisplayName:      "Polygon",
		ExplorerLink:     "https://polygonscan.com",
		FirehoseEndpoint: "polygon.streamingfast.io:443",
		Network:          "polygon",
		SupportsCalls:    true,
	},
	"amoy": {
		DisplayName:      "Polygon Amoy Testnet",
		ExplorerLink:     "https://www.okx.com/web3/explorer/amoy",
		FirehoseEndpoint: "amoy.substreams.pinax.network:443",
		Network:          "amoy",
		SupportsCalls:    true,
	},
	"arbitrum": {
		DisplayName:      "Arbitrum",
		ExplorerLink:     "https://arbiscan.io",
		FirehoseEndpoint: "arb-one.streamingfast.io:443",
		Network:          "arbitrum",
		SupportsCalls:    true,
	},
	"holesky": {
		DisplayName:      "Holesky",
		ExplorerLink:     "https://holesky.etherscan.io/",
		FirehoseEndpoint: "holesky.eth.streamingfast.io:443",
		Network:          "holesky",
		SupportsCalls:    true,
	},
	"sepolia": {
		DisplayName:      "Sepolia Testnet",
		ExplorerLink:     "https://sepolia.etherscan.io",
		FirehoseEndpoint: "sepolia.streamingfast.io:443",
		Network:          "sepolia",
		SupportsCalls:    true,
	},
	"optimism": {
		DisplayName:      "Optimism Mainnet",
		ExplorerLink:     "https://optimistic.etherscan.io",
		FirehoseEndpoint: "opt-mainnet.streamingfast.io:443",
		Network:          "optimism",
		SupportsCalls:    false,
	},
	"avalanche": {
		DisplayName:      "Avalanche C-chain",
		ExplorerLink:     "https://subnets.avax.network/c-chain",
		FirehoseEndpoint: "avalanche-mainnet.streamingfast.io:443",
		Network:          "avalanche",
		SupportsCalls:    false,
	},
	"chapel": {
		DisplayName:      "BNB Chapel Testnet",
		ExplorerLink:     "https://testnet.bscscan.com/",
		FirehoseEndpoint: "chapel.substreams.pinax.network:443",
		Network:          "chapel",
		SupportsCalls:    true,
	},
	"injective-mainnet": {
		DisplayName:      "Injective Mainnet",
		ExplorerLink:     "https://explorer.injective.network/",
		FirehoseEndpoint: "mainnet.injective.streamingfast.io:443",
		Network:          "injective-mainnet",
	},
	"injective-testnet": {
		DisplayName:      "Injective Testnet",
		ExplorerLink:     "https://testnet.explorer.injective.network/",
		FirehoseEndpoint: "testnet.injective.streamingfast.io:443",
		Network:          "injective-testnet",
	},
	"starknet-mainnet": {
		DisplayName:      "Starknet Mainnet Transactions",
		ExplorerLink:     "https://starkscan.co/",
		FirehoseEndpoint: "mainnet.starknet.streamingfast.io:443",
		Network:          "starknet-mainnet",
	},
	"starknet-testnet": {
		DisplayName:      "Starknet Testnet Transactions",
		ExplorerLink:     "",
		FirehoseEndpoint: "testnet.starknet.streamingfast.io:443",
		Network:          "starknet-testnet",
	},
	"solana-mainnet-beta": {
		DisplayName:      "Solana Mainnet",
		Network:          "solana-mainnet-beta",
		FirehoseEndpoint: "mainnet.solana.streamingfast.io:443",
	},
	"mantra-testnet": {
		DisplayName:      "Mantra Testnet",
		ExplorerLink:     "",
		FirehoseEndpoint: "testnet.mantra.streamingfast.io:443",
		Network:          "mantra-testnet",
	},
	"mantra-mainnet": {
		DisplayName:      "Mantra Mainnet",
		ExplorerLink:     "",
		FirehoseEndpoint: "mainnet.mantra.streamingfast.io:443",
		Network:          "mantra-mainnet",
	},
	"stellar-testnet": {
		DisplayName:      "Stellar Testnet",
		ExplorerLink:     "",
		FirehoseEndpoint: "testnet.stellar.streamingfast.io:443",
		Network:          "stellar-testnet",
	},
	"stellar-mainnet": {
		DisplayName:      "Stellar Mainnet",
		ExplorerLink:     "",
		FirehoseEndpoint: "mainnet.stellar.streamingfast.io:443",
		Network:          "stellar-mainnet",
	},
	"sei-mainnet": {
		DisplayName:      "Sei Mainnet",
		ExplorerLink:     "https://seitrace.com/",
		FirehoseEndpoint: "evm-mainnet.sei.streamingfast.io:443",
		Network:          "sei-mainnet",
	},
}
View Source
var Cmd = &cobra.Command{Use: "codegen", Short: "Code generator for substreams"}
View Source
var SQLCmd = &cobra.Command{
	Use:   "sql [<manifest_url>]",
	Short: "Generate sql extension from substreams manifest",
	Args:  cobra.RangeArgs(0, 1),
	RunE:  generateSQLEnv,
}
View Source
var SubgraphCmd = &cobra.Command{
	Use:   "subgraph [<manifest_url>]",
	Short: "Generate subgraph dev environment from substreams manifest",
	Args:  cobra.RangeArgs(0, 1),
	RunE:  generateSubgraphEnv,
}

Functions

func ParseFS added in v1.10.0

func ParseFS(myFuncs template.FuncMap, fsys fs.FS, pattern string) (*template.Template, error)

func ToMarkdown added in v1.10.1

func ToMarkdown(input string) string

Types

type ChainConfig added in v1.10.0

type ChainConfig struct {
	ID               string // Public
	DisplayName      string // Public
	ExplorerLink     string
	ApiEndpoint      string
	FirehoseEndpoint string
	Network          string
	SupportsCalls    bool
}

type EntityInfo added in v1.10.1

type EntityInfo struct {
	HasAnID     bool
	IDFieldName string
}

type EntityType added in v1.10.1

type EntityType interface {
	ToEntityTypeOut() string
}

type OutputType added in v1.10.1

type OutputType string
const (
	Subgraph OutputType = "subgraph"
	Sql      OutputType = "sql"
)

func (OutputType) String added in v1.10.1

func (t OutputType) String() string

type Project added in v1.10.0

type Project struct {
	Name             string
	Network          string
	Module           *pbsubstreams.Module
	OutputDescriptor *descriptorpb.DescriptorProto

	EntityTypes     []EntityType
	EntityInfo      EntityInfo
	SpkgProjectName string
	ManifestPath    string
	OutputType      OutputType
	Flavor          string
	// contains filtered or unexported fields
}

func NewProject added in v1.10.0

func NewProject(
	name string,
	spkgProjectName string,
	network, manifestPath string,
	module *pbsubstreams.Module,
	outputDescriptor *descriptorpb.DescriptorProto,
	protoTypeMapping map[string]*descriptorpb.DescriptorProto,
	outputType OutputType,
	flavor string,
) *Project

func (*Project) AddClickHouseSQLType added in v1.10.1

func (p *Project) AddClickHouseSQLType(name string, field *descriptorpb.FieldDescriptorProto)

func (*Project) AddPostgreSQLType added in v1.10.1

func (p *Project) AddPostgreSQLType(name string, field *descriptorpb.FieldDescriptorProto)

func (*Project) AddSubgraphEntityType added in v1.10.1

func (p *Project) AddSubgraphEntityType(name string, field *descriptorpb.FieldDescriptorProto)

func (*Project) BuildOutputEntity added in v1.10.1

func (p *Project) BuildOutputEntity() error

func (*Project) ChainEndpoint added in v1.10.0

func (p *Project) ChainEndpoint() (string, error)

func (*Project) DatabaseChangeImportVersion added in v1.10.1

func (p *Project) DatabaseChangeImportVersion() string

func (*Project) GetModuleName added in v1.10.0

func (p *Project) GetModuleName() string

func (*Project) GetOutputProtoPath added in v1.10.0

func (p *Project) GetOutputProtoPath() string

func (*Project) GetOutputProtobufPath added in v1.10.0

func (p *Project) GetOutputProtobufPath() string

func (*Project) GetRustOutputProtobufPath added in v1.10.1

func (p *Project) GetRustOutputProtobufPath() string

func (*Project) HasExampleEntity added in v1.10.0

func (p *Project) HasExampleEntity() bool

func (*Project) ModuleInitialBlock added in v1.10.1

func (p *Project) ModuleInitialBlock() uint64

func (*Project) OutputName added in v1.10.0

func (p *Project) OutputName() string

func (*Project) ProtoOutputName added in v1.10.0

func (p *Project) ProtoOutputName() string

func (*Project) ProtoOutputNameToSnake added in v1.10.0

func (p *Project) ProtoOutputNameToSnake() string

func (*Project) Render added in v1.10.0

func (p *Project) Render(withDevEnv bool) (projectFiles map[string][]byte, err error)

func (*Project) SQLExtensionName added in v1.10.1

func (p *Project) SQLExtensionName() string

func (*Project) SQLImportVersion added in v1.10.1

func (p *Project) SQLImportVersion() string

func (*Project) SpkgNameWithoutExt added in v1.10.1

func (p *Project) SpkgNameWithoutExt() string

func (*Project) SubstreamsKebabName added in v1.10.0

func (p *Project) SubstreamsKebabName() string

type ProtoGenerator

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

func NewProtoGenerator

func NewProtoGenerator(outputPath string, excludedPaths []string, generateMod bool) *ProtoGenerator

func (*ProtoGenerator) GenerateProto added in v0.1.0

func (g *ProtoGenerator) GenerateProto(pkg *pbsubstreams.Package) error

type SQLEntityType added in v1.10.1

type SQLEntityType struct {
	Name string
	Type SQLType
}

func (*SQLEntityType) ToEntityTypeOut added in v1.10.1

func (e *SQLEntityType) ToEntityTypeOut() string

func (*SQLEntityType) ToSQLType added in v1.10.1

func (e *SQLEntityType) ToSQLType() string

type SQLType added in v1.10.1

type SQLType string
var (
	PostgresSqlText    SQLType = "TEXT"
	PostgresSqlBoolean SQLType = "BOOL"
	PostgresSqlInt     SQLType = "Int"
	PostgresSqlDecimal SQLType = "DECIMAL"
	PostgresSqlBytes   SQLType = "BYTEA"
	ClickhouseString   SQLType = "String"
	ClickhouseBoolean  SQLType = "Bool"
	ClickhouseUInt32   SQLType = "UInt32"
	ClickhouseInt32    SQLType = "Int32"
	ClickhouseUInt64   SQLType = "UInt64"
	ClickhouseInt64    SQLType = "Int64"
	ClickhouseDecimal  SQLType = "Decimal64(%d)"
)

type SubgraphEntityType added in v1.10.1

type SubgraphEntityType struct {
	Name string
	Type SubgraphType
}

func (*SubgraphEntityType) ToEntityTypeOut added in v1.10.1

func (e *SubgraphEntityType) ToEntityTypeOut() string

func (*SubgraphEntityType) ToGraphQLType added in v1.10.1

func (e *SubgraphEntityType) ToGraphQLType() string

type SubgraphType added in v1.10.1

type SubgraphType string
var (
	SubgraphBytes      SubgraphType = "Bytes"
	SubgraphString     SubgraphType = "String"
	SubgraphBoolean    SubgraphType = "Boolean"
	SubgraphInt        SubgraphType = "Int"
	SubgraphInt8       SubgraphType = "Int8"
	SubgraphBigInt     SubgraphType = "BigInt"
	SubgraphBigDecimal SubgraphType = "BigDecimal"
	SubgraphTimestamp  SubgraphType = "Timestamp" // this is an alias for i64
)

func (SubgraphType) String added in v1.10.1

func (t SubgraphType) String() string

Jump to

Keyboard shortcuts

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