Skip to content

Commit

Permalink
Merge pull request #73 from moonstream-to/fix-missing-utils
Browse files Browse the repository at this point in the history
Add file.
  • Loading branch information
Andrei-Dolgolev authored Sep 30, 2024
2 parents 493acb9 + f245bab commit 9e24685
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
23 changes: 23 additions & 0 deletions blockchain/common/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package common

import (
"fmt"
"strings"

"github.com/ethereum/go-ethereum/accounts/abi"
)

func GetABI(abistr string) (*abi.ABI, error) {
// Retrieve or create AbiEntry
// ...

parsedABI, err := abi.JSON(strings.NewReader(abistr))
if err != nil {
fmt.Println("string: ", abistr)
fmt.Println("Error parsing ABI: ", err)
return nil, err
}

return &parsedABI, nil

}
94 changes: 94 additions & 0 deletions blockchain/settings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package blockchain

import (
"fmt"
"os"
)

var BlockchainURLs map[string]string

func CheckVariablesForBlockchains() error {

MOONSTREAM_NODE_ETHEREUM_A_EXTERNAL_URI := os.Getenv("MOONSTREAM_NODE_ETHEREUM_A_EXTERNAL_URI")
if MOONSTREAM_NODE_ETHEREUM_A_EXTERNAL_URI == "" {
return fmt.Errorf("MOONSTREAM_NODE_ETHEREUM_A_EXTERNAL_URI environment variable is required")
}
MOONSTREAM_NODE_SEPOLIA_A_EXTERNAL_URI := os.Getenv("MOONSTREAM_NODE_SEPOLIA_A_EXTERNAL_URI")
if MOONSTREAM_NODE_SEPOLIA_A_EXTERNAL_URI == "" {
return fmt.Errorf("MOONSTREAM_NODE_SEPOLIA_A_EXTERNAL_URI environment variable is required")
}
MOONSTREAM_NODE_POLYGON_A_EXTERNAL_URI := os.Getenv("MOONSTREAM_NODE_POLYGON_A_EXTERNAL_URI")
if MOONSTREAM_NODE_POLYGON_A_EXTERNAL_URI == "" {
return fmt.Errorf("MOONSTREAM_NODE_POLYGON_A_EXTERNAL_URI environment variable is required")
}
MOONSTREAM_NODE_ARBITRUM_ONE_A_EXTERNAL_URI := os.Getenv("MOONSTREAM_NODE_ARBITRUM_ONE_A_EXTERNAL_URI")
if MOONSTREAM_NODE_ARBITRUM_ONE_A_EXTERNAL_URI == "" {
return fmt.Errorf("MOONSTREAM_NODE_ARBITRUM_ONE_A_EXTERNAL_URI environment variable is required")
}
MOONSTREAM_NODE_ARBITRUM_SEPOLIA_A_EXTERNAL_URI := os.Getenv("MOONSTREAM_NODE_ARBITRUM_SEPOLIA_A_EXTERNAL_URI")
if MOONSTREAM_NODE_ARBITRUM_SEPOLIA_A_EXTERNAL_URI == "" {
return fmt.Errorf("MOONSTREAM_NODE_ARBITRUM_SEPOLIA_A_EXTERNAL_URI environment variable is required")
}
MOONSTREAM_NODE_GAME7_ORBIT_ARBITRUM_SEPOLIA_A_EXTERNAL_URI := os.Getenv("MOONSTREAM_NODE_GAME7_ORBIT_ARBITRUM_SEPOLIA_A_EXTERNAL_URI")
if MOONSTREAM_NODE_GAME7_ORBIT_ARBITRUM_SEPOLIA_A_EXTERNAL_URI == "" {
return fmt.Errorf("MOONSTREAM_NODE_GAME7_ORBIT_ARBITRUM_SEPOLIA_A_EXTERNAL_URI environment variable is required")
}
MOONSTREAM_NODE_XAI_A_EXTERNAL_URI := os.Getenv("MOONSTREAM_NODE_XAI_A_EXTERNAL_URI")
if MOONSTREAM_NODE_XAI_A_EXTERNAL_URI == "" {
return fmt.Errorf("MOONSTREAM_NODE_XAI_A_EXTERNAL_URI environment variable is required")
}
MOONSTREAM_NODE_XAI_SEPOLIA_A_EXTERNAL_URI := os.Getenv("MOONSTREAM_NODE_XAI_SEPOLIA_A_EXTERNAL_URI")
if MOONSTREAM_NODE_XAI_SEPOLIA_A_EXTERNAL_URI == "" {
return fmt.Errorf("MOONSTREAM_NODE_XAI_SEPOLIA_A_EXTERNAL_URI environment variable is required")
}
MOONSTREAM_NODE_MANTLE_A_EXTERNAL_URI := os.Getenv("MOONSTREAM_NODE_MANTLE_A_EXTERNAL_URI")
if MOONSTREAM_NODE_MANTLE_A_EXTERNAL_URI == "" {
return fmt.Errorf("MOONSTREAM_NODE_MANTLE_A_EXTERNAL_URI environment variable is required")
}
MOONSTREAM_NODE_MANTLE_SEPOLIA_A_EXTERNAL_URI := os.Getenv("MOONSTREAM_NODE_MANTLE_SEPOLIA_A_EXTERNAL_URI")
if MOONSTREAM_NODE_MANTLE_SEPOLIA_A_EXTERNAL_URI == "" {
return fmt.Errorf("MOONSTREAM_NODE_MANTLE_SEPOLIA_A_EXTERNAL_URI environment variable is required")
}
MOONSTREAM_NODE_IMX_ZKEVM_A_EXTERNAL_URI := os.Getenv("MOONSTREAM_NODE_IMX_ZKEVM_A_EXTERNAL_URI")
if MOONSTREAM_NODE_IMX_ZKEVM_A_EXTERNAL_URI == "" {
return fmt.Errorf("MOONSTREAM_NODE_IMX_ZKEVM_A_EXTERNAL_URI environment variable is required")
}
MOONSTREAM_NODE_IMX_ZKEVM_SEPOLIA_A_EXTERNAL_URI := os.Getenv("MOONSTREAM_NODE_IMX_ZKEVM_SEPOLIA_A_EXTERNAL_URI")
if MOONSTREAM_NODE_IMX_ZKEVM_SEPOLIA_A_EXTERNAL_URI == "" {
return fmt.Errorf("MOONSTREAM_NODE_IMX_ZKEVM_SEPOLIA_A_EXTERNAL_URI environment variable is required")
}
MOONSTREAM_NODE_GAME7_TESTNET_A_EXTERNAL_URI := os.Getenv("MOONSTREAM_NODE_GAME7_TESTNET_A_EXTERNAL_URI")
if MOONSTREAM_NODE_GAME7_TESTNET_A_EXTERNAL_URI == "" {
return fmt.Errorf("MOONSTREAM_NODE_GAME7_TESTNET_A_EXTERNAL_URI environment variable is required")
}

MOONSTREAM_NODE_B3_A_EXTERNAL_URI := os.Getenv("MOONSTREAM_NODE_B3_A_EXTERNAL_URI")
if MOONSTREAM_NODE_B3_A_EXTERNAL_URI == "" {
return fmt.Errorf("MOONSTREAM_NODE_B3_A_EXTERNAL_URI environment variable is required")
}

MOONSTREAM_NODE_B3_SEPOLIA_A_EXTERNAL_URI := os.Getenv("MOONSTREAM_NODE_B3_SEPOLIA_A_EXTERNAL_URI")
if MOONSTREAM_NODE_B3_SEPOLIA_A_EXTERNAL_URI == "" {
return fmt.Errorf("MOONSTREAM_NODE_B3_SEPOLIA_A_EXTERNAL_URI environment variable is required")
}

BlockchainURLs = map[string]string{
"ethereum": MOONSTREAM_NODE_ETHEREUM_A_EXTERNAL_URI,
"sepolia": MOONSTREAM_NODE_SEPOLIA_A_EXTERNAL_URI,
"polygon": MOONSTREAM_NODE_POLYGON_A_EXTERNAL_URI,
"arbitrum_one": MOONSTREAM_NODE_ARBITRUM_ONE_A_EXTERNAL_URI,
"arbitrum_sepolia": MOONSTREAM_NODE_ARBITRUM_SEPOLIA_A_EXTERNAL_URI,
"game7_orbit_arbitrum_sepolia": MOONSTREAM_NODE_GAME7_ORBIT_ARBITRUM_SEPOLIA_A_EXTERNAL_URI,
"game7_testnet": MOONSTREAM_NODE_GAME7_TESTNET_A_EXTERNAL_URI,
"xai": MOONSTREAM_NODE_XAI_A_EXTERNAL_URI,
"xai_sepolia": MOONSTREAM_NODE_XAI_SEPOLIA_A_EXTERNAL_URI,
"mantle": MOONSTREAM_NODE_MANTLE_A_EXTERNAL_URI,
"mantle_sepolia": MOONSTREAM_NODE_MANTLE_SEPOLIA_A_EXTERNAL_URI,
"imx_zkevm": MOONSTREAM_NODE_IMX_ZKEVM_A_EXTERNAL_URI,
"imx_zkevm_sepolia": MOONSTREAM_NODE_IMX_ZKEVM_SEPOLIA_A_EXTERNAL_URI,
"b3": MOONSTREAM_NODE_B3_A_EXTERNAL_URI,
"b3_sepolia": MOONSTREAM_NODE_B3_SEPOLIA_A_EXTERNAL_URI,
}

return nil
}

0 comments on commit 9e24685

Please sign in to comment.