difftreelog
Merge pull request #961 from UniqueNetwork/test/send_value_to_contract_with_evm_call
in: master
Send value to contract with evm call
3 files changed
Cargo.lockdiffbeforeafterboth2777[[package]]2777[[package]]2778name = "fc-consensus"2778name = "fc-consensus"2779version = "2.0.0-dev"2779version = "2.0.0-dev"2780source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42#4f7a610defd7623aa147d83c83cbc42f907ce8bb"2780source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42-1#cf3f4f309c7b053c29a619b78fd27b744cbe020a"2781dependencies = [2781dependencies = [2782 "async-trait",2782 "async-trait",2783 "fc-db",2783 "fc-db",2794[[package]]2794[[package]]2795name = "fc-db"2795name = "fc-db"2796version = "2.0.0-dev"2796version = "2.0.0-dev"2797source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42#4f7a610defd7623aa147d83c83cbc42f907ce8bb"2797source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42-1#cf3f4f309c7b053c29a619b78fd27b744cbe020a"2798dependencies = [2798dependencies = [2799 "fp-storage",2799 "fp-storage",2800 "kvdb-rocksdb",2800 "kvdb-rocksdb",2813[[package]]2813[[package]]2814name = "fc-mapping-sync"2814name = "fc-mapping-sync"2815version = "2.0.0-dev"2815version = "2.0.0-dev"2816source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42#4f7a610defd7623aa147d83c83cbc42f907ce8bb"2816source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42-1#cf3f4f309c7b053c29a619b78fd27b744cbe020a"2817dependencies = [2817dependencies = [2818 "fc-db",2818 "fc-db",2819 "fc-storage",2819 "fc-storage",2834[[package]]2834[[package]]2835name = "fc-rpc"2835name = "fc-rpc"2836version = "2.0.0-dev"2836version = "2.0.0-dev"2837source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42#4f7a610defd7623aa147d83c83cbc42f907ce8bb"2837source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42-1#cf3f4f309c7b053c29a619b78fd27b744cbe020a"2838dependencies = [2838dependencies = [2839 "ethereum",2839 "ethereum",2840 "ethereum-types",2840 "ethereum-types",2883[[package]]2883[[package]]2884name = "fc-rpc-core"2884name = "fc-rpc-core"2885version = "1.1.0-dev"2885version = "1.1.0-dev"2886source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42#4f7a610defd7623aa147d83c83cbc42f907ce8bb"2886source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42-1#cf3f4f309c7b053c29a619b78fd27b744cbe020a"2887dependencies = [2887dependencies = [2888 "ethereum",2888 "ethereum",2889 "ethereum-types",2889 "ethereum-types",2896[[package]]2896[[package]]2897name = "fc-storage"2897name = "fc-storage"2898version = "1.0.0-dev"2898version = "1.0.0-dev"2899source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42#4f7a610defd7623aa147d83c83cbc42f907ce8bb"2899source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42-1#cf3f4f309c7b053c29a619b78fd27b744cbe020a"2900dependencies = [2900dependencies = [2901 "ethereum",2901 "ethereum",2902 "ethereum-types",2902 "ethereum-types",3048[[package]]3048[[package]]3049name = "fp-account"3049name = "fp-account"3050version = "1.0.0-dev"3050version = "1.0.0-dev"3051source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42#4f7a610defd7623aa147d83c83cbc42f907ce8bb"3051source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42-1#cf3f4f309c7b053c29a619b78fd27b744cbe020a"3052dependencies = [3052dependencies = [3053 "hex",3053 "hex",3054 "impl-serde",3054 "impl-serde",3066[[package]]3066[[package]]3067name = "fp-consensus"3067name = "fp-consensus"3068version = "2.0.0-dev"3068version = "2.0.0-dev"3069source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42#4f7a610defd7623aa147d83c83cbc42f907ce8bb"3069source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42-1#cf3f4f309c7b053c29a619b78fd27b744cbe020a"3070dependencies = [3070dependencies = [3071 "ethereum",3071 "ethereum",3072 "parity-scale-codec",3072 "parity-scale-codec",3078[[package]]3078[[package]]3079name = "fp-ethereum"3079name = "fp-ethereum"3080version = "1.0.0-dev"3080version = "1.0.0-dev"3081source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42#4f7a610defd7623aa147d83c83cbc42f907ce8bb"3081source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42-1#cf3f4f309c7b053c29a619b78fd27b744cbe020a"3082dependencies = [3082dependencies = [3083 "ethereum",3083 "ethereum",3084 "ethereum-types",3084 "ethereum-types",3092[[package]]3092[[package]]3093name = "fp-evm"3093name = "fp-evm"3094version = "3.0.0-dev"3094version = "3.0.0-dev"3095source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42#4f7a610defd7623aa147d83c83cbc42f907ce8bb"3095source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42-1#cf3f4f309c7b053c29a619b78fd27b744cbe020a"3096dependencies = [3096dependencies = [3097 "evm",3097 "evm",3098 "frame-support",3098 "frame-support",3108[[package]]3108[[package]]3109name = "fp-rpc"3109name = "fp-rpc"3110version = "3.0.0-dev"3110version = "3.0.0-dev"3111source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42#4f7a610defd7623aa147d83c83cbc42f907ce8bb"3111source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42-1#cf3f4f309c7b053c29a619b78fd27b744cbe020a"3112dependencies = [3112dependencies = [3113 "ethereum",3113 "ethereum",3114 "ethereum-types",3114 "ethereum-types",3125[[package]]3125[[package]]3126name = "fp-self-contained"3126name = "fp-self-contained"3127version = "1.0.0-dev"3127version = "1.0.0-dev"3128source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42#4f7a610defd7623aa147d83c83cbc42f907ce8bb"3128source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42-1#cf3f4f309c7b053c29a619b78fd27b744cbe020a"3129dependencies = [3129dependencies = [3130 "frame-support",3130 "frame-support",3131 "parity-scale-codec",3131 "parity-scale-codec",3137[[package]]3137[[package]]3138name = "fp-storage"3138name = "fp-storage"3139version = "2.0.0"3139version = "2.0.0"3140source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42#4f7a610defd7623aa147d83c83cbc42f907ce8bb"3140source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42-1#cf3f4f309c7b053c29a619b78fd27b744cbe020a"3141dependencies = [3141dependencies = [3142 "parity-scale-codec",3142 "parity-scale-codec",3143 "serde",3143 "serde",6278[[package]]6278[[package]]6279name = "pallet-base-fee"6279name = "pallet-base-fee"6280version = "1.0.0"6280version = "1.0.0"6281source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42#4f7a610defd7623aa147d83c83cbc42f907ce8bb"6281source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42-1#cf3f4f309c7b053c29a619b78fd27b744cbe020a"6282dependencies = [6282dependencies = [6283 "fp-evm",6283 "fp-evm",6284 "frame-support",6284 "frame-support",6542[[package]]6542[[package]]6543name = "pallet-ethereum"6543name = "pallet-ethereum"6544version = "4.0.0-dev"6544version = "4.0.0-dev"6545source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42#4f7a610defd7623aa147d83c83cbc42f907ce8bb"6545source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42-1#cf3f4f309c7b053c29a619b78fd27b744cbe020a"6546dependencies = [6546dependencies = [6547 "ethereum",6547 "ethereum",6548 "ethereum-types",6548 "ethereum-types",6565[[package]]6565[[package]]6566name = "pallet-evm"6566name = "pallet-evm"6567version = "6.0.0-dev"6567version = "6.0.0-dev"6568source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42#4f7a610defd7623aa147d83c83cbc42f907ce8bb"6568source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42-1#cf3f4f309c7b053c29a619b78fd27b744cbe020a"6569dependencies = [6569dependencies = [6570 "environmental",6570 "environmental",6571 "evm",6571 "evm",6644[[package]]6644[[package]]6645name = "pallet-evm-precompile-simple"6645name = "pallet-evm-precompile-simple"6646version = "2.0.0-dev"6646version = "2.0.0-dev"6647source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42#4f7a610defd7623aa147d83c83cbc42f907ce8bb"6647source = "git+https://github.com/uniquenetwork/unique-frontier?branch=unique-polkadot-v0.9.42-1#cf3f4f309c7b053c29a619b78fd27b744cbe020a"6648dependencies = [6648dependencies = [6649 "fp-evm",6649 "fp-evm",6650 "ripemd",6650 "ripemd",Cargo.tomldiffbeforeafterboth--- a/Cargo.toml
+++ b/Cargo.toml
@@ -65,19 +65,19 @@
unique-runtime = { path = "runtime/unique" }
# Frontier (Unique patches over the Parity version)
-fc-consensus = { git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42" }
-fc-db = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42" }
-fc-mapping-sync = { git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42" }
-fc-rpc = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42" }
-fc-rpc-core = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42" }
-fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42" }
-fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42" }
-fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42" }
-fp-storage = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42" }
-pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42" }
-pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42" }
-pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42" }
-pallet-evm-precompile-simple = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42" }
+fc-consensus = { git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42-1" }
+fc-db = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42-1" }
+fc-mapping-sync = { git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42-1" }
+fc-rpc = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42-1" }
+fc-rpc-core = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42-1" }
+fp-evm = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42-1" }
+fp-rpc = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42-1" }
+fp-self-contained = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42-1" }
+fp-storage = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42-1" }
+pallet-base-fee = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42-1" }
+pallet-ethereum = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42-1" }
+pallet-evm = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42-1" }
+pallet-evm-precompile-simple = { default-features = false, git = "https://github.com/uniquenetwork/unique-frontier", branch = "unique-polkadot-v0.9.42-1" }
# Parity
codec = { default-features = false, features = ['derive'], package = 'parity-scale-codec', version = "3.2.2" }
tests/src/eth/transferValue.test.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/eth/transferValue.test.ts
@@ -0,0 +1,64 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+import {IKeyringPair} from '@polkadot/types/types';
+import {itEth, usingEthPlaygrounds} from './util';
+import {expect} from 'chai';
+
+describe('Send value to contract', () => {
+ let donor: IKeyringPair;
+
+ before(async () => {
+ await usingEthPlaygrounds(async (_helper, privateKey) => {
+ donor = await privateKey({url: import.meta.url});
+ });
+ });
+
+ itEth('Send to and from contract', async ({helper}) => {
+ const contractOwner = await helper.eth.createAccountWithBalance(donor, 600n);
+ const [buyer, receiver] = await helper.arrange.createAccounts([600n, 600n], donor);
+ const receiverMirror = helper.address.substrateToEth(receiver.address);
+ const contract = await helper.ethContract.deployByCode(
+ contractOwner,
+ 'Test',
+ `
+ // SPDX-License-Identifier: UNLICENSED
+ pragma solidity 0.8.17;
+
+ contract Test {
+ function send() public payable {
+ if (msg.value < 1000000000000000000)
+ revert("Not enough gold");
+ }
+
+ function withdraw(address to) public {
+ payable(to).transfer(1000000000000000000);
+ }
+ }
+ `,
+ );
+
+ const balanceBefore = await helper.balance.getSubstrate(buyer.address);
+ await helper.eth.sendEVM(buyer, contract.options.address, contract.methods.send().encodeABI(), '2000000000000000000');
+ const balanceAfter = await helper.balance.getSubstrate(buyer.address);
+ expect(balanceBefore - balanceAfter > 2000000000000000000n).to.be.true;
+ expect(await helper.balance.getEthereum(contract.options.address)).to.be.equal(2000000000000000000n);
+
+ await helper.eth.sendEVM(buyer, contract.options.address, contract.methods.withdraw(receiverMirror).encodeABI(), '0');
+ expect(await helper.balance.getEthereum(receiverMirror)).to.be.equal(1000000000000000000n);
+ expect(await helper.balance.getEthereum(contract.options.address)).to.be.equal(1000000000000000000n);
+ });
+});
\ No newline at end of file