Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nucleo
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nelson Lombardo
nucleo
Commits
25c7403c
Commit
25c7403c
authored
4 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Patches
Plain Diff
soportar JSON que solamente tiene un ABI
parent
bd7bc6e7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/libbfa/__init__.py
+23
-9
23 additions, 9 deletions
bin/libbfa/__init__.py
with
23 additions
and
9 deletions
bin/libbfa/__init__.py
+
23
−
9
View file @
25c7403c
...
@@ -286,7 +286,6 @@ class CompiledContract:
...
@@ -286,7 +286,6 @@ class CompiledContract:
# Did read give us json, or should we compile it?
# Did read give us json, or should we compile it?
if
self
.
json
is
None
:
if
self
.
json
is
None
:
self
.
compile
()
self
.
compile
()
self
.
writetextfile
()
def
dockerargs
(
self
):
def
dockerargs
(
self
):
return
[
return
[
...
@@ -313,7 +312,14 @@ class CompiledContract:
...
@@ -313,7 +312,14 @@ class CompiledContract:
# Make a copy with a fixed name
# Make a copy with a fixed name
# Mostly so people can use symlinks to the source files
# Mostly so people can use symlinks to the source files
# which won't work when we call docker.
# which won't work when we call docker.
with
open
(
'
{}.sol
'
.
format
(
self
.
name
),
'
r
'
)
as
infile
:
candidate_sol
=
'
{}.sol
'
.
format
(
self
.
name
)
if
os
.
path
.
exists
(
self
.
name
):
filename
=
self
.
name
elif
os
.
path
.
exists
(
candidate_sol
):
filename
=
candidate_sol
else
:
filename
=
self
.
name
with
open
(
filename
,
'
r
'
)
as
infile
:
with
open
(
'
contract.sol
'
,
'
w
'
)
as
outfile
:
with
open
(
'
contract.sol
'
,
'
w
'
)
as
outfile
:
outfile
.
write
(
infile
.
read
())
outfile
.
write
(
infile
.
read
())
try
:
try
:
...
@@ -324,14 +330,17 @@ class CompiledContract:
...
@@ -324,14 +330,17 @@ class CompiledContract:
txt
=
solc
.
stdout
txt
=
solc
.
stdout
output
=
txt
.
decode
(
'
utf-8
'
)
output
=
txt
.
decode
(
'
utf-8
'
)
self
.
json
=
json
.
loads
(
output
)
self
.
json
=
json
.
loads
(
output
)
self
.
writetextfile
()
def
readtextfile
(
self
):
def
readtextfile
(
self
):
filename
=
self
.
name
+
'
.compiled.json
'
for
filename
in
(
'
{}.compiled.json
'
.
format
(
self
.
name
),
self
.
name
):
try
:
if
os
.
path
.
exists
(
filename
):
with
open
(
filename
,
'
rt
'
,
encoding
=
'
utf-8
'
)
as
infile
:
with
open
(
filename
,
'
rt
'
,
encoding
=
'
utf-8
'
)
as
infile
:
output
=
infile
.
read
()
output
=
infile
.
read
()
except
FileNotFoundError
:
break
return
if
output
is
None
:
print
(
"
File not found.
"
,
file
=
sys
.
stderr
)
raise
FileNotFound
if
len
(
output
)
<
2
:
if
len
(
output
)
<
2
:
print
(
"
The JSON file is too small ({} bytes read from {}).
"
.
format
(
len
(
output
),
filename
),
file
=
sys
.
stderr
)
print
(
"
The JSON file is too small ({} bytes read from {}).
"
.
format
(
len
(
output
),
filename
),
file
=
sys
.
stderr
)
raise
NameError
raise
NameError
...
@@ -372,7 +381,12 @@ class CompiledContract:
...
@@ -372,7 +381,12 @@ class CompiledContract:
def
abi
(
self
):
def
abi
(
self
):
# Old method which also works, but our own class has a nicer __str__:
# Old method which also works, but our own class has a nicer __str__:
# return json.loads(self.json['contracts'][where]['abi'])
# return json.loads(self.json['contracts'][where]['abi'])
return
Abi
(
json
.
loads
(
self
.
_where
()[
'
abi
'
]))
where
=
self
.
_where
()
if
type
(
where
)
is
str
:
where
=
json
.
loads
(
where
)
if
(
type
(
where
)
is
dict
)
and
'
abi
'
in
where
:
where
=
where
[
'
abi
'
]
return
Abi
(
where
)
def
instance
(
self
,
*
args
,
**
kwargs
):
def
instance
(
self
,
*
args
,
**
kwargs
):
addr
=
kwargs
.
get
(
'
address
'
)
addr
=
kwargs
.
get
(
'
address
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment