-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from 0x19/path-fix
Ability to compile from json mappings
- Loading branch information
Showing
7 changed files
with
375 additions
and
57 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
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,35 @@ | ||
package solc | ||
|
||
import "encoding/json" | ||
|
||
// Source represents the content of a Solidity source file. | ||
type Source struct { | ||
Content string `json:"content"` // The content of the Solidity source file. | ||
} | ||
|
||
// Settings defines the configuration settings for the Solidity compiler. | ||
type Settings struct { | ||
Optimizer Optimizer `json:"optimizer"` // Configuration for the optimizer. | ||
EVMVersion string `json:"evmVersion,omitempty"` // The version of the Ethereum Virtual Machine to target. Optional. | ||
Remappings []string `json:"remappings,omitempty"` // List of remappings for library addresses. Optional. | ||
OutputSelection map[string]map[string][]string `json:"outputSelection"` // Specifies the type of information to output (e.g., ABI, AST). | ||
} | ||
|
||
// Optimizer represents the configuration for the Solidity compiler's optimizer. | ||
type Optimizer struct { | ||
Enabled bool `json:"enabled"` // Indicates whether the optimizer is enabled. | ||
Runs int `json:"runs"` // Specifies the number of optimization runs. | ||
} | ||
|
||
// CompilerJsonConfig represents the JSON configuration for the Solidity compiler. | ||
type CompilerJsonConfig struct { | ||
Language string `json:"language"` // Specifies the language version (e.g., "Solidity"). | ||
Sources map[string]Source `json:"sources"` // Map of source file names to their content. | ||
Settings Settings `json:"settings"` // Compiler settings. | ||
} | ||
|
||
// ToJSON converts the CompilerJsonConfig to its JSON representation. | ||
// It returns the JSON byte array or an error if the conversion fails. | ||
func (c *CompilerJsonConfig) ToJSON() ([]byte, error) { | ||
return json.Marshal(c) | ||
} |
Oops, something went wrong.