Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
新注册的用户请输入邮箱并保存,随后登录邮箱激活账号。后续可直接使用邮箱登录!
Open sidebar
bao xinyu
vm-native
Commits
3e4f2f03
Commit
3e4f2f03
authored
Mar 06, 2023
by
baoxinyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
params
parent
6220d580
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
12 deletions
+28
-12
transfer/transfer_manager.go
transfer/transfer_manager.go
+28
-12
No files found.
transfer/transfer_manager.go
View file @
3e4f2f03
package
transfer
package
transfer
import
(
import
(
"chainmaker.org/chainmaker/pb-go/v2/vm"
"chainmaker.org/chainmaker/pb-go/v2/syscontract"
vmPb
"chainmaker.org/chainmaker/pb-go/v2/vm"
"chainmaker.org/chainmaker/protocol/v2"
"chainmaker.org/chainmaker/protocol/v2"
"chainmaker.org/chainmaker/vm-native/v2/common"
"chainmaker.org/chainmaker/vm-native/v2/common"
"encoding/json"
"encoding/json"
...
@@ -9,10 +10,25 @@ import (
...
@@ -9,10 +10,25 @@ import (
"strconv"
"strconv"
)
)
const
contractName
=
"transfer"
var
contractName
=
syscontract
.
Pallet_Transfer
.
String
()
const
empty
=
""
const
empty
=
""
// AccountManagerRuntime comment at next version
const
(
Method_INIT
=
"init"
Method_TRANSFER
=
"transfer"
)
const
(
InitParams_BALANCE
=
"balance"
InitParams_STARTINDEX
=
"startIndex"
InitParams_ENDINDEX
=
"endIndex"
)
const
(
TransferParams_FROM
=
"f"
TransferParams_TO
=
"t"
TransferParams_Trans
=
"b"
)
type
TransferManagerRuntime
struct
{
type
TransferManagerRuntime
struct
{
log
protocol
.
Logger
log
protocol
.
Logger
}
}
...
@@ -54,9 +70,9 @@ func registerTransferContractMethods(log protocol.Logger) map[string]common.Cont
...
@@ -54,9 +70,9 @@ func registerTransferContractMethods(log protocol.Logger) map[string]common.Cont
methodMap
:=
make
(
map
[
string
]
common
.
ContractFunc
,
64
)
methodMap
:=
make
(
map
[
string
]
common
.
ContractFunc
,
64
)
gasAccountRuntime
:=
&
TransferManagerRuntime
{
log
:
log
}
gasAccountRuntime
:=
&
TransferManagerRuntime
{
log
:
log
}
methodMap
[
"init"
]
=
common
.
WrapResultFunc
(
methodMap
[
Method_INIT
]
=
common
.
WrapResultFunc
(
gasAccountRuntime
.
Init
)
gasAccountRuntime
.
Init
)
methodMap
[
"transfer"
]
=
common
.
WrapResultFunc
(
methodMap
[
Method_TRANSFER
]
=
common
.
WrapResultFunc
(
gasAccountRuntime
.
Transfer
)
gasAccountRuntime
.
Transfer
)
return
methodMap
return
methodMap
...
@@ -65,9 +81,9 @@ func registerTransferContractMethods(log protocol.Logger) map[string]common.Cont
...
@@ -65,9 +81,9 @@ func registerTransferContractMethods(log protocol.Logger) map[string]common.Cont
func
(
t
*
TransferManagerRuntime
)
Init
(
txSimContext
protocol
.
TxSimContext
,
func
(
t
*
TransferManagerRuntime
)
Init
(
txSimContext
protocol
.
TxSimContext
,
params
map
[
string
][]
byte
)
([]
byte
,
error
)
{
params
map
[
string
][]
byte
)
([]
byte
,
error
)
{
balance
:=
string
(
params
[
"balance"
])
balance
:=
string
(
params
[
InitParams_BALANCE
])
startIndex
:=
string
(
params
[
"startIndex"
])
// 分批创建账户 - start index
startIndex
:=
string
(
params
[
InitParams_STARTINDEX
])
// 分批创建账户 - start index
endIndex
:=
string
(
params
[
"endIndex"
])
// 分批创建账户 - end index
endIndex
:=
string
(
params
[
InitParams_ENDINDEX
])
// 分批创建账户 - end index
start
,
_
:=
strconv
.
Atoi
(
startIndex
)
start
,
_
:=
strconv
.
Atoi
(
startIndex
)
end
,
_
:=
strconv
.
Atoi
(
endIndex
)
end
,
_
:=
strconv
.
Atoi
(
endIndex
)
...
@@ -81,10 +97,10 @@ func (t *TransferManagerRuntime) Init(txSimContext protocol.TxSimContext,
...
@@ -81,10 +97,10 @@ func (t *TransferManagerRuntime) Init(txSimContext protocol.TxSimContext,
func
(
t
*
TransferManagerRuntime
)
Transfer
(
txSimContext
protocol
.
TxSimContext
,
func
(
t
*
TransferManagerRuntime
)
Transfer
(
txSimContext
protocol
.
TxSimContext
,
params
map
[
string
][]
byte
)
([]
byte
,
error
)
{
params
map
[
string
][]
byte
)
([]
byte
,
error
)
{
from
:=
string
(
params
[
"f"
])
from
:=
string
(
params
[
TransferParams_FROM
])
to
:=
string
(
params
[
"f"
])
to
:=
string
(
params
[
TransferParams_TO
])
trans
,
_
:=
strconv
.
Atoi
(
string
(
"t"
))
trans
,
_
:=
strconv
.
Atoi
(
string
(
params
[
TransferParams_Trans
]
))
keys
:=
[]
*
vm
.
BatchKey
{
keys
:=
[]
*
vm
Pb
.
BatchKey
{
{
from
,
empty
,
nil
,
contractName
},
{
from
,
empty
,
nil
,
contractName
},
{
to
,
empty
,
nil
,
contractName
},
{
to
,
empty
,
nil
,
contractName
},
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment