aboutsummaryrefslogtreecommitdiff
path: root/plugin/evm
diff options
context:
space:
mode:
authoraaronbuchwald <aaron.buchwald56@gmail.com>2020-12-15 21:31:57 -0500
committerGitHub <noreply@github.com>2020-12-15 21:31:57 -0500
commit3f055c40405b44ba1e606578c08b1e8f0ca7e026 (patch)
tree6569bcfe3a62f3804a4f90b803b3d0d6cd96d732 /plugin/evm
parent2d0a37c6490dc9a4ec36ee4ebbed01c790f0426a (diff)
parent7c758da302baf80775876008958ec77055ab953a (diff)
Merge pull request #56 from ava-labs/mc-transfer
Mc transfer
Diffstat (limited to 'plugin/evm')
-rw-r--r--plugin/evm/export_tx.go3
-rw-r--r--plugin/evm/import_tx.go3
-rw-r--r--plugin/evm/vm.go8
3 files changed, 12 insertions, 2 deletions
diff --git a/plugin/evm/export_tx.go b/plugin/evm/export_tx.go
index 2735573..2ebfeff 100644
--- a/plugin/evm/export_tx.go
+++ b/plugin/evm/export_tx.go
@@ -240,8 +240,8 @@ func (vm *VM) newExportTx(
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 == vm.ctx.AVAXAssetID {
+ log.Info("crosschain C->X", "from", from.Address, "amount", from.Amount, "assetID", "AVAX")
amount := new(big.Int).Mul(
new(big.Int).SetUint64(from.Amount), x2cRate)
if state.GetBalance(from.Address).Cmp(amount) < 0 {
@@ -250,6 +250,7 @@ func (tx *UnsignedExportTx) EVMStateTransfer(vm *VM, state *state.StateDB) error
state.SubBalance(from.Address, amount)
} else {
amount := new(big.Int).SetUint64(from.Amount)
+ log.Info("crosschain C->X", "from", from.Address, "amount", from.Amount, "assetID", from.AssetID)
if state.GetBalanceMultiCoin(from.Address, common.Hash(from.AssetID)).Cmp(amount) < 0 {
return errInsufficientFunds
}
diff --git a/plugin/evm/import_tx.go b/plugin/evm/import_tx.go
index 1ec394c..d6b4b7d 100644
--- a/plugin/evm/import_tx.go
+++ b/plugin/evm/import_tx.go
@@ -270,12 +270,13 @@ func (vm *VM) newImportTx(
// accounts accordingly with the imported EVMOutputs
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)
if to.AssetID == vm.ctx.AVAXAssetID {
+ log.Info("crosschain X->C", "to", to.Address, "amount", to.Amount, "assetID", "AVAX")
amount := new(big.Int).Mul(
new(big.Int).SetUint64(to.Amount), x2cRate)
state.AddBalance(to.Address, amount)
} else {
+ log.Info("crosschain X->C", "to", to.Address, "amount", to.Amount, "assetID", to.AssetID)
amount := new(big.Int).SetUint64(to.Amount)
state.AddBalanceMultiCoin(to.Address, common.Hash(to.AssetID), amount)
}
diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go
index c9bdad9..9f5607a 100644
--- a/plugin/evm/vm.go
+++ b/plugin/evm/vm.go
@@ -239,6 +239,14 @@ func (vm *VM) Initialize(
return err
}
+ // If Mainnet or Fuji ChainID is present then switch
+ // manually set the config
+ switch {
+ case g.Config.ChainID.Cmp(params.AvalancheMainnetChainID) == 0:
+ g.Config.ApricotBlockTimestamp = params.AvalancheMainnetApricotTimestamp
+ case g.Config.ChainID.Cmp(params.AvalancheFujiChainID) == 0:
+ g.Config.ApricotBlockTimestamp = params.AvalancheFujiApricotTimestamp
+ }
vm.acceptedDB = prefixdb.New([]byte(acceptedPrefix), db)
vm.chainID = g.Config.ChainID