-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
1,685 additions
and
467 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/fatih/color" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var authCmd = &cobra.Command{ | ||
Use: "auth", | ||
Short: "Login command for Substreams development", | ||
RunE: runAuthE, | ||
SilenceUsage: true, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(authCmd) | ||
} | ||
|
||
func runAuthE(cmd *cobra.Command, args []string) error { | ||
localDevelopment := os.Getenv("LOCAL_DEVELOPMENT") | ||
|
||
fmt.Println("Open this link to authenticate on The Graph Market:") | ||
if localDevelopment == "true" { | ||
color.Blue("http://localhost:3000/auth/substreams-devenv") | ||
} else { | ||
color.Blue("https://thegraph.market/auth/substreams-devenv") | ||
} | ||
|
||
fmt.Println() | ||
fmt.Print("Then paste the token here: ") | ||
|
||
var token string | ||
_, err := fmt.Scanln(&token) | ||
if err != nil { | ||
return fmt.Errorf("error reading token: %w", err) | ||
} | ||
|
||
if token == "" { | ||
return fmt.Errorf("token cannot be empty") | ||
} | ||
|
||
fmt.Println() | ||
fmt.Println("Writing `./.substreams.env`") | ||
fmt.Println() | ||
fmt.Println("Please add `.substreams.env` to your `.gitignore`.") | ||
fmt.Println() | ||
|
||
err = os.WriteFile(".substreams.env", []byte(fmt.Sprintf("export SUBSTREAMS_API_TOKEN=%s\n", token)), 0644) | ||
if err != nil { | ||
return fmt.Errorf("writing .substreams.env file: %w", err) | ||
} | ||
|
||
fmt.Println("Load credentials in current terminal with:") | ||
color.Blue(" . ./.substreams.env") | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "github.com/streamingfast/substreams/codegen" | ||
|
||
func init() { | ||
rootCmd.AddCommand(codegen.Cmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package codegen | ||
|
||
type ChainConfig struct { | ||
ID string // Public | ||
DisplayName string // Public | ||
ExplorerLink string | ||
ApiEndpoint string | ||
FirehoseEndpoint string | ||
Network string | ||
SupportsCalls bool | ||
} | ||
|
||
var ChainConfigByID = map[string]*ChainConfig{ | ||
"mainnet": { | ||
DisplayName: "Ethereum Mainnet", | ||
ExplorerLink: "https://etherscan.io", | ||
ApiEndpoint: "https://api.etherscan.io", | ||
FirehoseEndpoint: "mainnet.eth.streamingfast.io:443", | ||
Network: "mainnet", | ||
SupportsCalls: true, | ||
}, | ||
"bnb": { | ||
DisplayName: "BNB", | ||
ExplorerLink: "https://bscscan.com", | ||
ApiEndpoint: "https://api.bscscan.com", | ||
FirehoseEndpoint: "bnb.streamingfast.io:443", | ||
Network: "bsc", | ||
SupportsCalls: true, | ||
}, | ||
"polygon": { | ||
DisplayName: "Polygon", | ||
ExplorerLink: "https://polygonscan.com", | ||
ApiEndpoint: "https://api.polygonscan.com", | ||
FirehoseEndpoint: "polygon.streamingfast.io:443", | ||
Network: "polygon", | ||
SupportsCalls: true, | ||
}, | ||
"amoy": { | ||
DisplayName: "Polygon Amoy Testnet", | ||
ExplorerLink: "https://www.okx.com/web3/explorer/amoy", | ||
ApiEndpoint: "", | ||
FirehoseEndpoint: "amoy.substreams.pinax.network:443", | ||
Network: "amoy", | ||
SupportsCalls: true, | ||
}, | ||
"arbitrum": { | ||
DisplayName: "Arbitrum", | ||
ExplorerLink: "https://arbiscan.io", | ||
ApiEndpoint: "https://api.arbiscan.io", | ||
FirehoseEndpoint: "arb-one.streamingfast.io:443", | ||
Network: "arbitrum", | ||
SupportsCalls: true, | ||
}, | ||
"holesky": { | ||
DisplayName: "Holesky", | ||
ExplorerLink: "https://holesky.etherscan.io/", | ||
ApiEndpoint: "https://api-holesky.etherscan.io", | ||
FirehoseEndpoint: "holesky.eth.streamingfast.io:443", | ||
Network: "holesky", | ||
SupportsCalls: true, | ||
}, | ||
"sepolia": { | ||
DisplayName: "Sepolia Testnet", | ||
ExplorerLink: "https://sepolia.etherscan.io", | ||
ApiEndpoint: "https://api-sepolia.etherscan.io", | ||
FirehoseEndpoint: "sepolia.streamingfast.io:443", | ||
Network: "sepolia", | ||
SupportsCalls: true, | ||
}, | ||
"optimism": { | ||
DisplayName: "Optimism Mainnet", | ||
ExplorerLink: "https://optimistic.etherscan.io", | ||
ApiEndpoint: "https://api-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", | ||
ApiEndpoint: "", | ||
FirehoseEndpoint: "avalanche-mainnet.streamingfast.io:443", | ||
Network: "avalanche", | ||
SupportsCalls: false, | ||
}, | ||
"chapel": { | ||
DisplayName: "BNB Chapel Testnet", | ||
ExplorerLink: "https://testnet.bscscan.com/", | ||
ApiEndpoint: "", | ||
FirehoseEndpoint: "chapel.substreams.pinax.network:443", | ||
Network: "chapel", | ||
SupportsCalls: true, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package codegen | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var Cmd = &cobra.Command{Use: "codegen", Short: "Code generator for substreams"} | ||
|
||
func init() { | ||
SubgraphCmd.Flags().Bool("with-dev-env", false, "generate graph node dev environment") | ||
|
||
Cmd.AddCommand(SubgraphCmd) | ||
Cmd.AddCommand(SQLCmd) | ||
} |
Oops, something went wrong.