aboutsummaryrefslogtreecommitdiff
path: root/plugin/evm
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/evm')
-rw-r--r--plugin/evm/export_tx.go5
-rw-r--r--plugin/evm/import_tx.go5
2 files changed, 6 insertions, 4 deletions
diff --git a/plugin/evm/export_tx.go b/plugin/evm/export_tx.go
index 8b512df..f210352 100644
--- a/plugin/evm/export_tx.go
+++ b/plugin/evm/export_tx.go
@@ -229,14 +229,15 @@ 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)
- amount := new(big.Int).Mul(
- new(big.Int).SetUint64(from.Amount), x2cRate)
if from.AssetID.Equals(vm.ctx.AVAXAssetID) {
+ amount := new(big.Int).Mul(
+ new(big.Int).SetUint64(from.Amount), x2cRate)
if state.GetBalance(from.Address).Cmp(amount) < 0 {
return errInsufficientFunds
}
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 {
return errInsufficientFunds
diff --git a/plugin/evm/import_tx.go b/plugin/evm/import_tx.go
index 261e68f..381d114 100644
--- a/plugin/evm/import_tx.go
+++ b/plugin/evm/import_tx.go
@@ -272,11 +272,12 @@ func (vm *VM) newImportTx(
func (tx *UnsignedImportTx) EVMStateTransfer(vm *VM, state *state.StateDB) error {
for _, to := range tx.Outs {
log.Info("crosschain X->C", "addr", to.Address, "amount", to.Amount)
- amount := new(big.Int).Mul(
- new(big.Int).SetUint64(to.Amount), x2cRate)
if to.AssetID.Equals(vm.ctx.AVAXAssetID) {
+ amount := new(big.Int).Mul(
+ new(big.Int).SetUint64(to.Amount), x2cRate)
state.AddBalance(to.Address, amount)
} else {
+ amount := new(big.Int).SetUint64(to.Amount)
state.AddBalanceMultiCoin(to.Address, to.AssetID.Key(), amount)
}
}