Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
a6787a63
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a6787a63
编写于
1月 23, 2018
作者:
C
croath
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
accounts/abi: fix the `output` at the beginning instead of making a workaround
上级
88e67c55
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
13 addition
and
51 deletion
+13
-51
accounts/abi/argument.go
accounts/abi/argument.go
+0
-10
accounts/abi/unpack_test.go
accounts/abi/unpack_test.go
+0
-36
mobile/bind.go
mobile/bind.go
+13
-5
未找到文件。
accounts/abi/argument.go
浏览文件 @
a6787a63
...
...
@@ -169,16 +169,6 @@ func (arguments Arguments) unpackAtomic(v interface{}, output []byte) error {
if
err
!=
nil
{
return
err
}
// if we reach this part, there is only one output member from the contract event.
// for mobile, the result type is always a slice.
if
reflect
.
Slice
==
value
.
Kind
()
&&
value
.
Len
()
>=
1
{
//check if it's not a byte slice
if
reflect
.
TypeOf
([]
byte
{})
!=
value
.
Type
()
{
value
=
value
.
Index
(
0
)
.
Elem
()
}
}
return
set
(
value
,
reflect
.
ValueOf
(
marshalledValue
),
arg
)
}
...
...
accounts/abi/unpack_test.go
浏览文件 @
a6787a63
...
...
@@ -287,42 +287,6 @@ func TestUnpack(t *testing.T) {
}
}
var
unpackMobileTests
=
[]
unpackTest
{
{
def
:
`[{"type": "uint256"}]`
,
enc
:
"0000000000000000000000000000000000000000000000000000000000000001"
,
want
:
big
.
NewInt
(
1
),
},
}
func
TestUnpackMobileOnly
(
t
*
testing
.
T
)
{
for
i
,
test
:=
range
unpackMobileTests
{
t
.
Run
(
strconv
.
Itoa
(
i
),
func
(
t
*
testing
.
T
)
{
def
:=
fmt
.
Sprintf
(
`[{ "name" : "method", "outputs": %s}]`
,
test
.
def
)
abi
,
err
:=
JSON
(
strings
.
NewReader
(
def
))
if
err
!=
nil
{
t
.
Fatalf
(
"invalid ABI definition %s: %v"
,
def
,
err
)
}
encb
,
err
:=
hex
.
DecodeString
(
test
.
enc
)
if
err
!=
nil
{
t
.
Fatalf
(
"invalid hex: %s"
+
test
.
enc
)
}
outptr
:=
reflect
.
New
(
reflect
.
TypeOf
(
test
.
want
))
results
:=
make
([]
interface
{},
1
)
copy
(
results
,
[]
interface
{}{
outptr
.
Interface
()})
err
=
abi
.
Unpack
(
&
results
,
"method"
,
encb
)
if
err
:=
test
.
checkError
(
err
);
err
!=
nil
{
t
.
Errorf
(
"test %d (%v) failed: %v"
,
i
,
test
.
def
,
err
)
return
}
out
:=
outptr
.
Elem
()
.
Interface
()
if
!
reflect
.
DeepEqual
(
test
.
want
,
out
)
{
t
.
Errorf
(
"test %d (%v) failed: expected %v, got %v"
,
i
,
test
.
def
,
test
.
want
,
out
)
}
})
}
}
type
methodMultiOutput
struct
{
Int
*
big
.
Int
String
string
...
...
mobile/bind.go
浏览文件 @
a6787a63
...
...
@@ -154,12 +154,20 @@ func (c *BoundContract) GetDeployer() *Transaction {
// Call invokes the (constant) contract method with params as input values and
// sets the output to result.
func
(
c
*
BoundContract
)
Call
(
opts
*
CallOpts
,
out
*
Interfaces
,
method
string
,
args
*
Interfaces
)
error
{
results
:=
make
([]
interface
{},
len
(
out
.
objects
))
copy
(
results
,
out
.
objects
)
if
err
:=
c
.
contract
.
Call
(
&
opts
.
opts
,
&
results
,
method
,
args
.
objects
...
);
err
!=
nil
{
return
err
if
len
(
out
.
objects
)
==
1
{
result
:=
out
.
objects
[
0
]
if
err
:=
c
.
contract
.
Call
(
&
opts
.
opts
,
result
,
method
,
args
.
objects
...
);
err
!=
nil
{
return
err
}
out
.
objects
[
0
]
=
result
}
else
{
results
:=
make
([]
interface
{},
len
(
out
.
objects
))
copy
(
results
,
out
.
objects
)
if
err
:=
c
.
contract
.
Call
(
&
opts
.
opts
,
&
results
,
method
,
args
.
objects
...
);
err
!=
nil
{
return
err
}
copy
(
out
.
objects
,
results
)
}
copy
(
out
.
objects
,
results
)
return
nil
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录