-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add call ethereumXcm.forceTransactAs (to create contracts from runtime) * add pallet-moonbeam-foreign-assets skeleton * inject solidity bytecode * add freeze/unfreeze calls * refactor foreign assets pallet: create evm module * implement all evm calls * encode create args * build contract initcode: support 0x prefix * fix ethereum-xcm rust tests * pallet moonbeam-foreign-assets: prepare rust tests * add pallet moonbeam-foreign-assets for moonbase runtime * disable creation of foreign assets from pallet asset manager * fix matcher, remove useless genericity * rustfmt * improve build script: support direct copy of hex calldata * improve solidity impl: disable transfer & approve when paused * refactor evm foreign pallet: create AssetStatus & rename types * forbid old AssetsIds (with filter) and rework freeze mechanism * fix rust compilation for pallet-moonbeam-foreign-assets alone * fix: calldata need hex bytecode * wip * Revert "fix: calldata need hex bytecode" This reverts commit 67fc5be. * recompile solidity contract with solc 0.8.26+commit8a97fa7a * rust tests: fix pov ratio and storage ratio * fix rust tests compilation * fix constructor args encoding * test freeze/unfreeze * rewrite rust moonbase test asset_can_be_registered * estimate crate gas limit with manual binary search * determine gas limit for freeze/unfreeze * use branch moonbeam-polkadot-v1.11.0 * add calls force_burn and force_mint @ define gas limit for mint/burn * add transfer call * fix benchmarks compilation * add feature insecure_zero_ed for new pallet rust tests * improve benchmarks: create max foreign assets for worst case scenario * create weight info fns for freeze/unfreeze * add foreign asset migrator precompile * fix tracing compilation * add EvmForeignassets to CurrencyIdToLocation convertion * remove useless calls and rework rust tests * rustfmt * fix copyright: new code should be own by MBF * AssetsTransactors: for some reason Erc20XcmBridge should be at the end * fix moonbase rust integration tests * allow FastGeneralAdmin & 5/9 techCommittee to manage evm foreign assets * rustfmt * rename some fns/events and remove unused code * ticker -> symbol * change base implementation of registerForeignAsset() * re-arrange tests in test-assets (WIP) * review suggestions * create v4 locations for foreign assets testing * basic testing for evm foreign assets pallet * ForeignAssetTypeChanged -> ForeignAssetXcmLocationChanged * mockAssetBalance wip * fix mockAssetBalance * restore old foreign asset helpers * allow creation of old foreign assets * fix imports * use old foreign assets for xcm fees runtime api tests * remove Mytoken.sol (fail to compile on CI) and use parseAbi instead * fix some ts tests * fix more ts tests * remove test specific to substrate assets mechanism (is_sufficient) * fix ts imports * prettier * remove unused imports * prettier again * prettier * prettier --------- Co-authored-by: Gonza Montiel <gon.montiel@gmail.com>
- Loading branch information
1 parent
20ba7fe
commit 3b954cf
Showing
98 changed files
with
3,417 additions
and
1,127 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
[package] | ||
name = "pallet-moonbeam-foreign-assets" | ||
authors = { workspace = true } | ||
edition = "2021" | ||
version = "0.1.0" | ||
|
||
[dependencies] | ||
ethereum-types = { workspace = true } | ||
log = { workspace = true } | ||
|
||
# Substrate | ||
frame-support = { workspace = true } | ||
frame-system = { workspace = true } | ||
parity-scale-codec = { workspace = true, features = [ "derive" ] } | ||
precompile-utils = { workspace = true } | ||
precompile-utils-macro = { workspace = true } | ||
scale-info = { workspace = true, features = [ "derive" ] } | ||
sp-io = { workspace = true } | ||
sp-runtime = { workspace = true } | ||
sp-std = { workspace = true } | ||
|
||
# Frontier | ||
fp-evm = { workspace = true } | ||
pallet-evm = { workspace = true, features = ["forbid-evm-reentrancy"] } | ||
|
||
# Polkadot | ||
xcm = { workspace = true } | ||
xcm-executor = { workspace = true } | ||
|
||
# Benchmarks | ||
frame-benchmarking = { workspace = true, optional = true } | ||
|
||
[build-dependencies] | ||
hex = { workspace = true, features = [ "std" ] } | ||
|
||
[dev-dependencies] | ||
hex = { workspace = true } | ||
pallet-balances = { workspace = true, features = [ "insecure_zero_ed", "std" ] } | ||
pallet-timestamp = { workspace = true, features = [ "std" ] } | ||
sp-core = { workspace = true, features = [ "std" ] } | ||
|
||
[features] | ||
default = [ "std" ] | ||
std = [ | ||
"ethereum-types/std", | ||
"frame-benchmarking/std", | ||
"frame-support/std", | ||
"frame-system/std", | ||
"precompile-utils/std", | ||
"precompile-utils/testing", | ||
"pallet-evm/std", | ||
"parity-scale-codec/std", | ||
"scale-info/std", | ||
"sp-io/std", | ||
"sp-runtime/std", | ||
"sp-std/std", | ||
"xcm/std", | ||
"xcm-executor/std" | ||
] | ||
|
||
runtime-benchmarks = [ "frame-benchmarking"] | ||
try-runtime = [ "frame-support/try-runtime" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2024 Moonbeam Foundation. | ||
// This file is part of Moonbeam. | ||
|
||
// Moonbeam 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. | ||
|
||
// Moonbeam 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 Moonbeam. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
use std::fs::File; | ||
use std::io::prelude::*; | ||
|
||
// Length of encoded constructor parameters | ||
const PARAMS_LEN: usize = 256; | ||
|
||
fn main() { | ||
let hex_str = include_str!("resources/foreign_erc20_initcode.hex"); | ||
let prefix_0x = hex_str.chars().nth(1) == Some('x'); | ||
let bytecode = if prefix_0x { | ||
hex::decode(&hex_str[2..]) | ||
} else { | ||
hex::decode(hex_str) | ||
} | ||
.expect("fail to decode hexadecimal string in file foreign_erc20_initcode.hex"); | ||
|
||
// The encoded parameters at the end of the initializer bytecode should be removed, | ||
// (the runtime will append the constructor parameters dynamically). | ||
let bytecode_end = if bytecode.len() > PARAMS_LEN { | ||
bytecode.len() - PARAMS_LEN | ||
} else { | ||
0 | ||
}; | ||
|
||
let mut file = File::create("resources/foreign_erc20_initcode.bin") | ||
.expect("Fail to create file resources/foreign_erc20_initcode.bin"); | ||
file.write_all(&bytecode[..bytecode_end]) | ||
.expect("fail to write bytecode in /foreign_erc20_initcode.bin"); | ||
} |
Oops, something went wrong.