Skip to content

Commit

Permalink
Merge pull request #1534 from multiversx/multi-proxy-config
Browse files Browse the repository at this point in the history
Proxy multi sc-config
  • Loading branch information
BiancaIalangi authored Apr 5, 2024
2 parents 99455b5 + 39d96f0 commit 0957bbe
Show file tree
Hide file tree
Showing 26 changed files with 249 additions and 102 deletions.
4 changes: 3 additions & 1 deletion contracts/examples/adder/sc-config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[settings]
proxy-paths = ["src/adder_proxy.rs"]

[[proxy]]
path = "src/adder_proxy.rs"
4 changes: 2 additions & 2 deletions contracts/examples/crowdfunding-esdt/sc-config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[settings]
proxy-paths = ["src/crowdfunding_esdt_proxy.rs"]
[[proxy]]
path = "src/crowdfunding_esdt_proxy.rs"
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
[settings]
proxy-paths = ["../kitty-ownership/src/kitty_genetic_alg_proxy.rs"]
[[proxy]]
path = "../kitty-ownership/src/kitty_genetic_alg_proxy.rs"
[[proxy.path-rename]]
from = "kitty::kitty"
to = "kitty"
[[proxy.path-rename]]
from = "kitty_genes"
to = "kitty"
16 changes: 11 additions & 5 deletions contracts/examples/crypto-kitties/kitty-ownership/sc-config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
[settings]
proxy-paths = [
"../kitty-auction/src/kitty_ownership_proxy.rs",
"../../crypto-zombies/src/kitty_ownership_proxy.rs",
]
[[proxy]]
path = "../kitty-auction/src/kitty_ownership_proxy.rs"
[[proxy.path-rename]]
from = "kitty::kitty"
to = "kitty"

[[proxy]]
path = "../../crypto-zombies/src/kitty_ownership_proxy.rs"
[[proxy.path-rename]]
from = "kitty::kitty"
to = "kitty"
4 changes: 2 additions & 2 deletions contracts/examples/crypto-zombies/sc-config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[settings]
proxy-paths = ["src/proxy_crypto_zombies.rs"]
[[proxy]]
path = "src/proxy_crypto_zombies.rs"
4 changes: 2 additions & 2 deletions contracts/examples/digital-cash/sc-config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[settings]
proxy-paths = ["src/digital_cash_proxy.rs"]
[[proxy]]
path = "src/digital_cash_proxy.rs"
4 changes: 3 additions & 1 deletion contracts/examples/multisig/sc-config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[settings]
proxy-paths = ["src/multisig_proxy.rs"]
main = "main"

[contracts.main]
Expand All @@ -15,3 +14,6 @@ name = "multisig-view"
external-view = true
add-unlabelled = false
add-labels = ["multisig-external-view"]

[[proxy]]
path = "src/multisig_proxy.rs"
4 changes: 2 additions & 2 deletions contracts/examples/seed-nft-minter/sc-config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[settings]
proxy-paths = ["../rewards-distribution/src/seed_nft_minter_proxy.rs"]
[[proxy]]
path = "../rewards-distribution/src/seed_nft_minter_proxy.rs"
9 changes: 7 additions & 2 deletions contracts/feature-tests/abi-tester/sc-config.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Abi-tester multi-contract config, used for testing.

[settings]
proxy-paths = ["src/abi_proxy.rs"]
main = "main"

[contracts.main]
Expand All @@ -12,4 +11,10 @@ name = "abi-tester-ev"
external-view = true
add-unlabelled = false
add-labels = ["test-external-view"]
add-endpoints = ["payable_any_token", "label_a"] # labels can be bypassed, endpoints added directly
add-endpoints = [
"payable_any_token",
"label_a",
] # labels can be bypassed, endpoints added directly

[[proxy]]
path = "src/abi_proxy.rs"
10 changes: 8 additions & 2 deletions contracts/feature-tests/abi-tester/src/abi_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,10 @@ pub enum AbiEnum {
Nothing,
Something(i32),
SomethingMore(u8, OnlyShowsUpAsNested08),
SomeStruct { a: u16, b: OnlyShowsUpAsNested09 },
SomeStruct {
a: u16,
b: OnlyShowsUpAsNested09,
},
}

#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)]
Expand Down Expand Up @@ -504,5 +507,8 @@ pub enum ExplicitDiscriminantMixed {
Unit,
Tuple(u16),
Five,
Struct { a: u8, b: u16 },
Struct {
a: u8,
b: u16,
},
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[settings]
proxy-paths = ["../parent/src/child_proxy.rs"]
[[proxy]]
path = "../parent/src/child_proxy.rs"
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[settings]
proxy-paths = ["src/self_proxy.rs"]
[[proxy]]
path = "src/self_proxy.rs"
14 changes: 9 additions & 5 deletions contracts/feature-tests/composability/vault/sc-config.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
[settings]
main = "main"
proxy-paths = [
"../forwarder/src/vault_proxy.rs",
"../promises-features/src/vault_proxy.rs",
"../recursive-caller/src/vault_proxy.rs"
]

[contracts.main]
name = "vault"
Expand All @@ -20,3 +15,12 @@ add-labels = ["promises-endpoint"]
name = "vault-upgrade"
add-unlabelled = false
add-labels = ["upgrade"]

[[proxy]]
path = "../forwarder/src/vault_proxy.rs"

[[proxy]]
path = "../promises-features/src/vault_proxy.rs"

[[proxy]]
path = "../recursive-caller/src/vault_proxy.rs"
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[settings]
main = "erc1155"
proxy-paths = ["../erc1155-marketplace/src/erc1155_proxy.rs"]

[[proxy]]
path = "../erc1155-marketplace/src/erc1155_proxy.rs"

# the only purpose of this config is to specify the allocator
[contracts.erc1155]
Expand Down
10 changes: 6 additions & 4 deletions contracts/feature-tests/erc-style-contracts/erc20/sc-config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[settings]
proxy-paths = [
"../crowdfunding-erc20/src/erc20_proxy.rs",
"../lottery-erc20/src/erc20_proxy.rs",
]

[[proxy]]
path = "../crowdfunding-erc20/src/erc20_proxy.rs"

[[proxy]]
path = "../lottery-erc20/src/erc20_proxy.rs"
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[settings]
proxy-paths = ["tests/pmf_proxy.rs"]
main = "main"

[contracts.main]
name = "panic-message-features"
panic-message = true

[[proxy]]
path = "tests/pmf_proxy.rs"
2 changes: 1 addition & 1 deletion framework/meta/src/cmd/contract/generate_proxy.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod proxy_crate_gen;
pub mod proxy_gen_main;
mod proxy_generator;
mod proxy_naming;
mod proxy_process_type_name;
18 changes: 9 additions & 9 deletions framework/meta/src/cmd/contract/generate_proxy/proxy_gen_main.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
use crate::cmd::contract::sc_config::ProxyConfigSerde;

use super::{
super::meta_config::MetaConfig, proxy_crate_gen::create_file, proxy_generator::ProxyGenerator,
};

const OUTPUT_PROXY_PATH: &str = "/output/proxy.rs";

impl MetaConfig {
pub fn generate_proxy(&mut self) {
write_proxy_with_explicit_path(OUTPUT_PROXY_PATH, self);
let proxy_paths = self.sc_config.proxy_paths.clone();
for path in proxy_paths {
write_proxy_with_explicit_path(&path, self);
let default_proxy = ProxyConfigSerde::new();
write_proxy_with_explicit_path(&default_proxy, self);
for proxy_config in self.sc_config.proxy_configs.clone() {
write_proxy_with_explicit_path(&proxy_config, self);
}
}
}

fn write_proxy_with_explicit_path(path: &str, meta_config: &mut MetaConfig) {
let mut file = create_file(path);
let mut proxy_generator = ProxyGenerator::new(meta_config, &mut file);
fn write_proxy_with_explicit_path(proxy_config: &ProxyConfigSerde, meta_config: &mut MetaConfig) {
let mut file = create_file(&proxy_config.path);
let mut proxy_generator = ProxyGenerator::new(meta_config, &mut file, proxy_config);
proxy_generator.write_proxy_to_file();
}
Loading

0 comments on commit 0957bbe

Please sign in to comment.