aboutsummaryrefslogtreecommitdiff
path: root/plugin/evm/export_tx.go
diff options
context:
space:
mode:
authorDan Laine <[email protected]>2020-10-30 12:55:53 -0400
committerDan Laine <[email protected]>2020-10-30 12:55:53 -0400
commit5b12d3fa21635145cb8a752b56477e22fca77a5b (patch)
treeb789cd27fc5a0795057f1c1ccbf17834a8af18c0 /plugin/evm/export_tx.go
parent4023ae20cb2b7cd228a68670bc55a6c9cdbabc36 (diff)
remove these ID calls: Key(), Bytes(), Equals(), NewID(), IsZero()v0.3.11-update-idupdate-id
Diffstat (limited to 'plugin/evm/export_tx.go')
-rw-r--r--plugin/evm/export_tx.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/plugin/evm/export_tx.go b/plugin/evm/export_tx.go
index d099eb2..74e36b6 100644
--- a/plugin/evm/export_tx.go
+++ b/plugin/evm/export_tx.go
@@ -17,6 +17,7 @@ import (
safemath "github.com/ava-labs/avalanchego/utils/math"
"github.com/ava-labs/avalanchego/vms/components/avax"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
)
@@ -52,15 +53,15 @@ func (tx *UnsignedExportTx) Verify(
return errNilTx
case tx.syntacticallyVerified: // already passed syntactic verification
return nil
- case tx.DestinationChain.IsZero():
+ case tx.DestinationChain == ids.Empty:
return errWrongChainID
- case !tx.DestinationChain.Equals(avmID):
+ case tx.DestinationChain != avmID:
return errWrongChainID
case len(tx.ExportedOutputs) == 0:
return errNoExportOutputs
case tx.NetworkID != ctx.NetworkID:
return errWrongNetworkID
- case !ctx.ChainID.Equals(tx.BlockchainID):
+ case ctx.ChainID != tx.BlockchainID:
return errWrongBlockchainID
}
@@ -177,13 +178,13 @@ func (vm *VM) newExportTx(
to ids.ShortID, // Address of chain recipient
keys []*crypto.PrivateKeySECP256K1R, // Pay the fee and provide the tokens
) (*Tx, error) {
- if !vm.ctx.XChainID.Equals(chainID) {
+ if vm.ctx.XChainID != chainID {
return nil, errWrongChainID
}
var toBurn uint64
var err error
- if assetID.Equals(vm.ctx.AVAXAssetID) {
+ if assetID == vm.ctx.AVAXAssetID {
toBurn, err = safemath.Add64(amount, vm.txFee)
if err != nil {
return nil, errOverflowExport
@@ -198,7 +199,7 @@ func (vm *VM) newExportTx(
}
// burn non-AVAX
- if !assetID.Equals(vm.ctx.AVAXAssetID) {
+ if assetID != vm.ctx.AVAXAssetID {
ins2, signers2, err := vm.GetSpendableFunds(keys, assetID, amount)
if err != nil {
return nil, fmt.Errorf("couldn't generate tx inputs/outputs: %w", err)
@@ -242,7 +243,7 @@ func (tx *UnsignedExportTx) EVMStateTransfer(vm *VM, state *state.StateDB) error
addrs := map[[20]byte]uint64{}
for _, from := range tx.Ins {
log.Info("crosschain C->X", "addr", from.Address, "amount", from.Amount)
- if from.AssetID.Equals(vm.ctx.AVAXAssetID) {
+ if from.AssetID == vm.ctx.AVAXAssetID {
amount := new(big.Int).Mul(
new(big.Int).SetUint64(from.Amount), x2cRate)
if state.GetBalance(from.Address).Cmp(amount) < 0 {
@@ -251,11 +252,10 @@ func (tx *UnsignedExportTx) EVMStateTransfer(vm *VM, state *state.StateDB) error
state.SubBalance(from.Address, amount)
} else {
amount := new(big.Int).SetUint64(from.Amount)
- assetID := from.AssetID.Key()
- if state.GetBalanceMultiCoin(from.Address, assetID).Cmp(amount) < 0 {
+ if state.GetBalanceMultiCoin(from.Address, common.Hash(from.AssetID)).Cmp(amount) < 0 {
return errInsufficientFunds
}
- state.SubBalanceMultiCoin(from.Address, assetID, amount)
+ state.SubBalanceMultiCoin(from.Address, common.Hash(from.AssetID), amount)
}
if state.GetNonce(from.Address) != from.Nonce {
return errInvalidNonce