added functions for defaults
@@ -92,8 +92,92 @@ const (
DefaultEmulatorConfigName = "default"
PrivateKeyField = "privateKey"
KMSContextField = "resourceName"
+ DefaultEmulatorServiceAccountName = "emulator-account"
)
+// DefaultEmulatorNetwork get default emulator network
+func DefaultEmulatorNetwork() Network {
+ return Network{
+ Name: "emulator",
+ Host: "127.0.0.1:3569",
+ ChainID: flow.Emulator,
+ }
+}
+
+// DefaultTestnetNetwork get default testnet network
+func DefaultTestnetNetwork() Network {
+ return Network{
+ Name: "testnet",
+ Host: "access.devnet.nodes.onflow.org:9000",
+ ChainID: flow.Testnet,
+ }
+}
+
+// DefaultMainnetNetwork get default mainnet network
+func DefaultMainnetNetwork() Network {
+ return Network{
+ Name: "mainnet",
+ Host: "access.mainnet.nodes.onflow.org:9000",
+ ChainID: flow.Testnet,
+ }
+}
+
+// DefaultNetworks gets all default networks
+func DefaultNetworks() Networks {
+ return Networks{
+ DefaultEmulatorNetwork(),
+ DefaultTestnetNetwork(),
+ DefaultMainnetNetwork(),
+ }
+}
+
+// DefaultEmulator gets default emulator
+func DefaultEmulator() Emulator {
+ return Emulator{
+ Name: "default",
+ ServiceAccount: DefaultEmulatorServiceAccountName,
+ Port: 3569,
+ }
+}
+
+// DefaultContracts get all standard contracts
+func StandardContracts() Contracts {
+ return Contracts{
+ Contract{
+ Name: "FlowToken",
+ Source: "",
+ Network: DefaultTestnetNetwork().Name,
+ Alias: "0x7e60df042a9c0868",
+ },
+ Contract{
+ Name: "FlowToken",
+ Source: "",
+ Network: DefaultEmulatorNetwork().Name,
+ Alias: "0x0ae53cb6e3f42a79",
+ },
+ Contract{
+ Name: "FlowToken",
+ Source: "",
+ Network: DefaultMainnetNetwork().Name,
+ Alias: "0x1654653399040a61",
+ },
+ }
+}
+
+// DefaultConfig gets default configuration
+func DefaultConfig() *Config {
+ return &Config{
+ Emulators: DefaultEmulators(),
+ Networks: DefaultNetworks(),
+ Contracts: StandardContracts(),
+ }
+}
+
+// DefaultEmulators gets all default emulators
+func DefaultEmulators() Emulators {
+ return Emulators{DefaultEmulator()}
+}
+
// IsAlias checks if contract has an alias
func (c *Contract) IsAlias() bool {
return c.Alias != ""
