Skip to content

Commit

Permalink
refactored Contract attributes. (#68)
Browse files Browse the repository at this point in the history
- `Code` -> `Runtime`
- `DeployCode` -> `Constructor`

Co-authored-by: lmittmann <[email protected]>
  • Loading branch information
lmittmann and lmittmann authored Sep 9, 2024
1 parent 5531dd1 commit d5a0a0a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ func (c *Compiler) Compile(dir, contract string, opts ...Option) (*Contract, err
for conName, c := range conMap {
if conName == contract {
con = &Contract{
Code: c.EVM.DeployedBytecode.Object,
DeployCode: c.EVM.Bytecode.Object,
Runtime: c.EVM.DeployedBytecode.Object,
Constructor: c.EVM.Bytecode.Object,
Code: c.EVM.DeployedBytecode.Object,
DeployCode: c.EVM.Bytecode.Object,
}
break
}
Expand Down
6 changes: 4 additions & 2 deletions compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ func TestCompile(t *testing.T) {
Name: "test1",
ContractName: "Test1",
WantContract: &solc.Contract{
Code: b("0x6080604052348015600f57600080fd5b506004361060285760003560e01c8063f8a8fd6d14602d575b600080fd5b602a60405190815260200160405180910390f3fea26469706673582212209fce876a231310a49ee9848a2e6b937a9c3e07fb578272f974a37d4289160fee64736f6c63430008110033"),
DeployCode: b("0x6080604052348015600f57600080fd5b50607780601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063f8a8fd6d14602d575b600080fd5b602a60405190815260200160405180910390f3fea26469706673582212209fce876a231310a49ee9848a2e6b937a9c3e07fb578272f974a37d4289160fee64736f6c63430008110033"),
Runtime: b("0x6080604052348015600f57600080fd5b506004361060285760003560e01c8063f8a8fd6d14602d575b600080fd5b602a60405190815260200160405180910390f3fea26469706673582212209fce876a231310a49ee9848a2e6b937a9c3e07fb578272f974a37d4289160fee64736f6c63430008110033"),
Constructor: b("0x6080604052348015600f57600080fd5b50607780601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063f8a8fd6d14602d575b600080fd5b602a60405190815260200160405180910390f3fea26469706673582212209fce876a231310a49ee9848a2e6b937a9c3e07fb578272f974a37d4289160fee64736f6c63430008110033"),
Code: b("0x6080604052348015600f57600080fd5b506004361060285760003560e01c8063f8a8fd6d14602d575b600080fd5b602a60405190815260200160405180910390f3fea26469706673582212209fce876a231310a49ee9848a2e6b937a9c3e07fb578272f974a37d4289160fee64736f6c63430008110033"),
DeployCode: b("0x6080604052348015600f57600080fd5b50607780601d6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063f8a8fd6d14602d575b600080fd5b602a60405190815260200160405180910390f3fea26469706673582212209fce876a231310a49ee9848a2e6b937a9c3e07fb578272f974a37d4289160fee64736f6c63430008110033"),
},
},
{
Expand Down
6 changes: 4 additions & 2 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import (

// Contract represents a compiled contract.
type Contract struct {
Code []byte // The bytecode of the contract after deployment.
DeployCode []byte // The bytecode to deploy the contract.
Runtime []byte // The runtime bytecode of the contract.
Constructor []byte // The constructor bytecode of the contract.
Code []byte // Deprecated: The bytecode of the contract after deployment.
DeployCode []byte // Deprecated: The bytecode to deploy the contract.
}

// lang represents the language of the source code.
Expand Down

0 comments on commit d5a0a0a

Please sign in to comment.