Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
960e7656
Commit
960e7656
authored
Nov 01, 2021
by
hezhengjun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add para check for mine
parent
6584e084
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
60 additions
and
22 deletions
+60
-22
BridgeBank.sol
plugin/dapp/bridgevmxgo/contracts/BridgeBank/BridgeBank.sol
+1
-1
EvmAssetBank.sol
...in/dapp/bridgevmxgo/contracts/BridgeBank/EvmAssetBank.sol
+2
-2
BridgeBank.go
plugin/dapp/bridgevmxgo/contracts/generated/BridgeBank.go
+0
-0
evmxgodb.go
plugin/dapp/evmxgo/executor/evmxgodb.go
+4
-16
exec.go
plugin/dapp/evmxgo/executor/exec.go
+12
-3
parse.go
plugin/dapp/evmxgo/executor/parse.go
+40
-0
evmxgo.proto
plugin/dapp/evmxgo/proto/evmxgo.proto
+1
-0
evmxgo.pb.go
plugin/dapp/evmxgo/types/evmxgo.pb.go
+0
-0
No files found.
plugin/dapp/bridgevmxgo/contracts/BridgeBank/BridgeBank.sol
View file @
960e7656
...
...
@@ -213,7 +213,7 @@ contract BridgeBank is GoAssetBank, EvmAssetBank {
* @param _amount: value of deposit
*/
function lock(
bytes memory
_recipient,
address
_recipient,
address _token,
uint256 _amount
)
...
...
plugin/dapp/bridgevmxgo/contracts/BridgeBank/EvmAssetBank.sol
View file @
960e7656
...
...
@@ -34,7 +34,7 @@ contract EvmAssetBank {
*/
event LogLock(
address _from,
byte
s _to,
addres
s _to,
address _token,
string _symbol,
uint256 _value,
...
...
@@ -183,7 +183,7 @@ contract EvmAssetBank {
*/
function lockFunds(
address payable _sender,
bytes memory
_recipient,
address
_recipient,
address _token,
string memory _symbol,
uint256 _amount
...
...
plugin/dapp/bridgevmxgo/contracts/generated/BridgeBank.go
View file @
960e7656
This source diff could not be displayed because it is too large. You can
view the blob
instead.
plugin/dapp/evmxgo/executor/evmxgodb.go
View file @
960e7656
...
...
@@ -95,7 +95,6 @@ func (e *evmxgoDB) burn(db dbm.KV, amount int64) ([]*types.KeyValue, []*types.Re
return
kvs
,
logs
,
nil
}
type
evmxgoAction
struct
{
coinsAccount
*
account
.
DB
db
dbm
.
KV
...
...
@@ -115,7 +114,6 @@ func newEvmxgoAction(e *evmxgo, toaddr string, tx *types.Transaction) *evmxgoAct
e
.
GetBlockTime
(),
e
.
GetHeight
(),
dapp
.
ExecAddress
(
string
(
tx
.
Execer
)),
e
.
GetAPI
()}
}
func
getManageKey
(
key
string
,
db
dbm
.
KV
)
([]
byte
,
error
)
{
manageKey
:=
types
.
ManageKey
(
key
)
value
,
err
:=
db
.
Get
([]
byte
(
manageKey
))
...
...
@@ -183,7 +181,6 @@ func loadEvmxgoMintConfig(db dbm.KV, symbol string) (*evmxgotypes.EvmxgoMintConf
return
nil
,
err
// types.ErrBadConfigValue
}
configValue
:=
item
.
GetArr
()
.
Value
if
len
(
configValue
)
<=
0
{
return
nil
,
evmxgotypes
.
ErrEvmxgoSymbolNotConfigValue
...
...
@@ -247,21 +244,11 @@ func AddTokenToAssets(addr string, db dbm.KVDB, symbol string) []*types.KeyValue
return
kv
}
// 同时比较配置symbol与address参数,和parse返回值是否一致
func
check
()
(
address
,
symbol
string
,
amount
int64
,
err
error
)
{
return
""
,
""
,
0
,
err
}
func
parse
()
(
address
,
symbol
string
,
amount
int64
,
err
error
)
{
// 上一个交易是否lock执行成功,如果是,返回实际参数,不是返回error
return
""
,
""
,
0
,
err
}
// 铸币不可控, 也是麻烦。 2选1
// 1. 谁可以发起
// 2. 是否需要审核 这个会增加管理的成本
// 现在实现选择 1
func
(
action
*
evmxgoAction
)
mint
(
mint
*
evmxgotypes
.
EvmxgoMint
)
(
*
types
.
Receipt
,
error
)
{
func
(
action
*
evmxgoAction
)
mint
(
mint
*
evmxgotypes
.
EvmxgoMint
,
tx2lock
*
types
.
Transaction
)
(
*
types
.
Receipt
,
error
)
{
if
mint
==
nil
{
return
nil
,
types
.
ErrInvalidParam
}
...
...
@@ -269,7 +256,9 @@ func (action *evmxgoAction) mint(mint *evmxgotypes.EvmxgoMint) (*types.Receipt,
return
nil
,
types
.
ErrInvalidParam
}
cfg
:=
action
.
api
.
GetConfig
()
parse
()
if
err
:=
checkMinePara
(
mint
,
tx2lock
);
nil
!=
err
{
return
nil
,
err
}
// TODO check()
evmxgodb
,
err
:=
loadEvmxgoDB
(
action
.
db
,
mint
.
GetSymbol
())
...
...
@@ -343,4 +332,3 @@ func (action *evmxgoAction) burn(burn *evmxgotypes.EvmxgoBurn) (*types.Receipt,
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kvs
,
Logs
:
logs
},
nil
}
plugin/dapp/evmxgo/executor/exec.go
View file @
960e7656
package
executor
import
(
"errors"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/types"
evmxgotypes
"github.com/33cn/plugin/plugin/dapp/evmxgo/types"
...
...
@@ -60,11 +62,18 @@ func (e *evmxgo) Exec_TransferToExec(payload *types.AssetsTransferToExec, tx *ty
}
func
(
e
*
evmxgo
)
Exec_Mint
(
payload
*
evmxgotypes
.
EvmxgoMint
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
newEvmxgoAction
(
e
,
""
,
tx
)
return
action
.
mint
(
payload
)
action
:=
newEvmxgoAction
(
e
,
""
,
tx
)
txGroup
,
err
:=
e
.
GetTxGroup
(
index
)
if
nil
!=
err
{
return
nil
,
err
}
if
len
(
txGroup
)
<
2
{
return
nil
,
errors
.
New
(
"Mint tx should be included in lock tx group"
)
}
return
action
.
mint
(
payload
,
txGroup
[
0
])
}
func
(
e
*
evmxgo
)
Exec_Burn
(
payload
*
evmxgotypes
.
EvmxgoBurn
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
newEvmxgoAction
(
e
,
""
,
tx
)
action
:=
newEvmxgoAction
(
e
,
""
,
tx
)
return
action
.
burn
(
payload
)
}
plugin/dapp/evmxgo/executor/parse.go
0 → 100644
View file @
960e7656
package
executor
import
(
"errors"
"github.com/33cn/chain33/types"
bridgevmxgo
"github.com/33cn/plugin/plugin/dapp/bridgevmxgo/contracts/generated"
chain33Abi
"github.com/33cn/plugin/plugin/dapp/evm/executor/abi"
evmxgotypes
"github.com/33cn/plugin/plugin/dapp/evmxgo/types"
)
const
(
LockMethod
=
"lock"
)
//solidity interface: function lock(address _recipient, address _token, uint256 _amount)
func
checkMinePara
(
mint
*
evmxgotypes
.
EvmxgoMint
,
tx2lock
*
types
.
Transaction
)
error
{
unpack
,
err
:=
chain33Abi
.
Unpack
(
tx2lock
.
Payload
,
LockMethod
,
bridgevmxgo
.
BridgeBankABI
)
if
err
!=
nil
{
return
err
}
for
_
,
para
:=
range
unpack
{
switch
para
.
Name
{
case
"_recipient"
:
if
mint
.
Address
!=
para
.
Value
{
return
errors
.
New
(
"Not consitent recipient address"
)
}
case
"_amount"
:
if
mint
.
Amount
!=
para
.
Value
{
return
errors
.
New
(
"Not consitent Amount"
)
}
case
"_token"
:
if
mint
.
Token
!=
para
.
Value
{
return
errors
.
New
(
"Not consitent token Address"
)
}
}
}
return
nil
}
plugin/dapp/evmxgo/proto/evmxgo.proto
View file @
960e7656
...
...
@@ -22,6 +22,7 @@ message EvmxgoMint {
string
symbol
=
1
;
int64
amount
=
2
;
string
address
=
3
;
string
token
=
4
;
}
message
EvmxgoBurn
{
...
...
plugin/dapp/evmxgo/types/evmxgo.pb.go
View file @
960e7656
This diff is collapsed.
Click to expand it.
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