From c81487a7d3346e6ca6755d67a05fabffe9d5a9d0 Mon Sep 17 00:00:00 2001 From: David Edey Date: Thu, 6 Jul 2023 04:06:38 +0100 Subject: [PATCH 1/3] WIP --- .../src/scenarios/radiswap.rs | 67 +++++++++++++++++-- 1 file changed, 61 insertions(+), 6 deletions(-) diff --git a/transaction-scenarios/src/scenarios/radiswap.rs b/transaction-scenarios/src/scenarios/radiswap.rs index 7ce367f0b48..64f4a55759e 100644 --- a/transaction-scenarios/src/scenarios/radiswap.rs +++ b/transaction-scenarios/src/scenarios/radiswap.rs @@ -8,7 +8,7 @@ use radix_engine_interface::*; use crate::internal_prelude::*; pub struct RadiswapScenarioConfig { - pub radiswap_owner: VirtualAccount, + pub radiswap_dapp_definition_account: VirtualAccount, pub storing_account: VirtualAccount, pub user_account_1: VirtualAccount, pub user_account_2: VirtualAccount, @@ -18,7 +18,7 @@ pub struct RadiswapScenarioConfig { impl Default for RadiswapScenarioConfig { fn default() -> Self { Self { - radiswap_owner: secp256k1_account_1(), + radiswap_dapp_definition_account: ed25519_account_for_private_key(891231), storing_account: secp256k1_account_2(), user_account_1: secp256k1_account_3(), user_account_2: ed25519_account_1(), @@ -29,6 +29,7 @@ impl Default for RadiswapScenarioConfig { #[derive(Default)] pub struct RadiswapScenarioState { + owner_badge: State, radiswap_package: State, pool_1: PoolData, pool_2: PoolData, @@ -149,6 +150,62 @@ impl ScenarioCreator for RadiswapScenarioCreator { Ok(()) }, ) + .successful_transaction_with_result_handler( + |core, config, state| { + core.next_transaction_with_faucet_lock_fee( + "radiswap-create-owner-badge-and-dapp-definition-account", + |builder| { + let definition_account = config.radiswap_dapp_definition_account.address; + builder + .create_non_fungible_resource( + // TODO: Once we can use address reservation with resource creation, + // we can set the owner badge to be its own owner + OwnerRole::None, + NonFungibleIdType::Integer, + true, + NonFungibleResourceRoles::default(), + metadata! { + init { + "name" => "Radiswap dApp Owner Badge", updatable; + "description" => "The owner badge for the Radiswap dApp", updatable; + "tags" => vec!["badge", "dex", "pool", "radiswap"], updatable; + "info_url" => Url::of("https://www.radixdlt.com/"), updatable; + } + }, + Some([ + (NonFungibleLocalId::integer(1), ()) + ]), + ) + .try_deposit_batch_or_abort(definition_account) + .set_metadata( + definition_account, + "account_type", + "dapp definition" + ) + .set_metadata( + definition_account, + "name", + "Radiswap dApp Definition" + ) + .set_metadata( + definition_account, + "claimed_websites", + vec![Origin::of("https://radiswap.radixdlt.com/")] + ) + }, + vec![] + ) + }, + |core, config, state, result| { + let new_resources = result.new_resource_addresses(); + state.owner_badge.set(NonFungibleGlobalId::new( + new_resources[0], + NonFungibleLocalId::integer(1) + )); + + Ok(()) + }, + ) .successful_transaction_with_result_handler( |core, config, state| { let code = include_bytes!("../../../assets/radiswap.wasm"); @@ -177,9 +234,7 @@ impl ScenarioCreator for RadiswapScenarioCreator { "tags" => vec!["dex".to_owned(), "pool".to_owned(), "radiswap".to_owned()], locked; }, radix_engine::types::OwnerRole::Fixed(rule!(require( - NonFungibleGlobalId::from_public_key( - &config.radiswap_owner.public_key - ) + state.owner_badge.get()? ))), ).call_function( lookup.named_address("radiswap_package"), @@ -368,7 +423,7 @@ impl ScenarioCreator for RadiswapScenarioCreator { .finalize(|core, config, state| { Ok(ScenarioOutput { interesting_addresses: DescribedAddresses::new() - .add("radiswap_owner", &config.radiswap_owner) + .add("radiswap_owner", &config.radiswap_dapp_definition_account) .add("storing_account", &config.storing_account) .add("user_account_1", &config.user_account_1) .add("user_account_2", &config.user_account_2) From 600d0de0e0a8e391565d99059ea845e89379a27b Mon Sep 17 00:00:00 2001 From: David Edey Date: Thu, 6 Jul 2023 14:38:50 +0100 Subject: [PATCH 2/3] feature: Update to radiswap --- radix-engine-common/src/macros.rs | 2 +- .../api/node_modules/metadata/invocations.rs | 40 ++++++ .../src/scenarios/radiswap.rs | 119 ++++++++++++++++-- 3 files changed, 152 insertions(+), 9 deletions(-) diff --git a/radix-engine-common/src/macros.rs b/radix-engine-common/src/macros.rs index d3703bde50a..10a4d3117eb 100644 --- a/radix-engine-common/src/macros.rs +++ b/radix-engine-common/src/macros.rs @@ -234,7 +234,7 @@ macro_rules! scrypto_args { #[macro_export] macro_rules! manifest_args { - ($($args: expr),*) => {{ + ($($args: expr),*$(,)?) => {{ use ::sbor::Encoder; let mut buf = ::sbor::rust::vec::Vec::new(); let mut encoder = $crate::data::manifest::ManifestEncoder::new(&mut buf, $crate::data::manifest::MANIFEST_SBOR_V1_MAX_DEPTH); diff --git a/radix-engine-interface/src/api/node_modules/metadata/invocations.rs b/radix-engine-interface/src/api/node_modules/metadata/invocations.rs index 83b5fc75589..3b772196368 100644 --- a/radix-engine-interface/src/api/node_modules/metadata/invocations.rs +++ b/radix-engine-interface/src/api/node_modules/metadata/invocations.rs @@ -235,6 +235,30 @@ macro_rules! impl_metadata_val { Some(self.to_metadata_value()) } } + + impl ToMetadataEntry for &[$rust_type] { + fn to_metadata_entry(self) -> Option { + Some(<$rust_type as SingleMetadataVal>::to_array_metadata_value( + self.iter().cloned().collect(), + )) + } + } + + impl ToMetadataEntry for [$rust_type; N] { + fn to_metadata_entry(self) -> Option { + Some(<$rust_type as SingleMetadataVal>::to_array_metadata_value( + self.into_iter().collect(), + )) + } + } + + impl ToMetadataEntry for &[$rust_type; N] { + fn to_metadata_entry(self) -> Option { + Some(<$rust_type as SingleMetadataVal>::to_array_metadata_value( + self.iter().cloned().collect(), + )) + } + } }; } @@ -261,6 +285,22 @@ macro_rules! impl_metadata_val_alias { )) } } + + impl<$($($generic,)+)? const N: usize> ToMetadataEntry for [$alias_rust_type; N] { + fn to_metadata_entry(self) -> Option { + Some(<$metadata_rust_type as SingleMetadataVal>::to_array_metadata_value( + self.iter().map(|x| (*x).into()).collect() + )) + } + } + + impl<$($($generic,)+)? const N: usize> ToMetadataEntry for &[$alias_rust_type; N] { + fn to_metadata_entry(self) -> Option { + Some(<$metadata_rust_type as SingleMetadataVal>::to_array_metadata_value( + self.iter().map(|x| (*x).into()).collect() + )) + } + } }; } diff --git a/transaction-scenarios/src/scenarios/radiswap.rs b/transaction-scenarios/src/scenarios/radiswap.rs index d10003aac6b..a0b101c2824 100644 --- a/transaction-scenarios/src/scenarios/radiswap.rs +++ b/transaction-scenarios/src/scenarios/radiswap.rs @@ -169,7 +169,7 @@ impl ScenarioCreator for RadiswapScenarioCreator { "name" => "Radiswap dApp Owner Badge", updatable; "description" => "The owner badge for the Radiswap dApp", updatable; "tags" => vec!["badge", "dex", "pool", "radiswap"], updatable; - "info_url" => Url::of("https://www.radixdlt.com/"), updatable; + "info_url" => Url::of("https://radiswap.radixdlt.com/"), updatable; } }, Some([ @@ -190,7 +190,7 @@ impl ScenarioCreator for RadiswapScenarioCreator { .set_metadata( definition_account, "claimed_websites", - vec![Origin::of("https://radiswap.radixdlt.com/")] + vec![Origin::of("https://radiswap.radixdlt.com")] ) }, vec![] @@ -213,6 +213,9 @@ impl ScenarioCreator for RadiswapScenarioCreator { "../../../assets/radiswap.rpd" )) .unwrap(); + let owner_role = radix_engine::types::OwnerRole::Fixed(rule!(require( + state.owner_badge.get()? + ))); core.next_transaction_with_faucet_lock_fee_fallible( "radiswap-publish-and-create-pools", |builder| { @@ -233,22 +236,28 @@ impl ScenarioCreator for RadiswapScenarioCreator { "description" => "A package of the logic of a Uniswap v2 style DEX.".to_owned(), locked; "tags" => vec!["dex".to_owned(), "pool".to_owned(), "radiswap".to_owned()], locked; }, - radix_engine::types::OwnerRole::Fixed(rule!(require( - state.owner_badge.get()? - ))), + owner_role.clone(), ).call_function( lookup.named_address("radiswap_package"), "Radiswap", "new", - manifest_args!(OwnerRole::None, state.pool_1.resource_1.unwrap(), state.pool_1.resource_2.unwrap()) + manifest_args!( + owner_role.clone(), + state.pool_1.resource_1.get()?, + state.pool_1.resource_2.get()?, + ) ) .call_function( lookup.named_address("radiswap_package"), "Radiswap", "new", - manifest_args!(OwnerRole::None, state.pool_2.resource_1.unwrap(), state.pool_2.resource_2.unwrap()) + manifest_args!( + owner_role.clone(), + state.pool_2.resource_1.get()?, + state.pool_2.resource_2.get()?, + ) ) - .try_deposit_batch_or_abort(config.storing_account.address) + .try_deposit_batch_or_abort(config.radiswap_dapp_definition_account.address) .done() }, vec![], @@ -420,6 +429,100 @@ impl ScenarioCreator for RadiswapScenarioCreator { ) } ) + .successful_transaction( + |core, config, state| { + let definition = GlobalAddress::from(config.radiswap_dapp_definition_account.address); + let radiswap_1 = GlobalAddress::from(state.pool_1.radiswap.get()?); + let pool_1 = GlobalAddress::from(state.pool_1.pool.get()?); + let pool_unit_1 = GlobalAddress::from(state.pool_1.pool_unit.get()?); + let radiswap_2 = GlobalAddress::from(state.pool_2.radiswap.get()?); + let pool_2 = GlobalAddress::from(state.pool_2.pool.get()?); + let pool_unit_2 = GlobalAddress::from(state.pool_2.pool_unit.get()?); + fn add_metadata( + builder: ManifestBuilder, + address: GlobalAddress, + name: &'static str, + description: &'static str, + ) -> ManifestBuilder { + builder + .set_metadata(address, "name", name) + .set_metadata(address, "description", description) + .set_metadata(address, "tags", ["badge", "dex", "pool", "radiswap"]) + .set_metadata(address, "info_url", Url::of("https://radiswap.radixdlt.com/")) + } + core.next_transaction_with_faucet_lock_fee_fallible( + "radiswap-set-two-way-linking", + |builder| { + builder + .create_proof_from_account_of_non_fungibles( + config.radiswap_dapp_definition_account.address, + state.owner_badge.get()?.resource_address(), + btreeset!( + state.owner_badge.get()?.local_id().clone() + ), + ) + // Set up two-way-linking + .set_metadata( + definition, + "claimed_entities", + vec![ + radiswap_1, + pool_1, + pool_unit_1, + radiswap_2, + pool_2, + pool_unit_2, + ] + ) + .set_metadata(radiswap_1, "dapp_definitions", [definition]) + .set_metadata(pool_1, "dapp_definitions", [definition]) + .set_metadata(pool_unit_1, "dapp_definitions", [definition]) + .set_metadata(radiswap_2, "dapp_definitions", [definition]) + .set_metadata(pool_2, "dapp_definitions", [definition]) + .set_metadata(pool_unit_2, "dapp_definitions", [definition]) + // Set up other metadata which has been missed + .then(|builder| add_metadata( + builder, + radiswap_1, + "Radiswap 1 - XRD/BTC: Component", + "[EXAMPLE] A Radiswap component between test tokens \"XRD\" and \"BTC\"", + )) + .then(|builder| add_metadata( + builder, + pool_1, + "Radiswap 1 - XRD/BTC: Pool", + "[EXAMPLE] The underyling pool between test tokens \"XRD\" and \"BTC\"", + )) + .then(|builder| add_metadata( + builder, + pool_unit_1, + "Radiswap 1 - XRD/BTC: Pool Units", + "[EXAMPLE] The pool units resource for the underlying pool between test tokens \"XRD\" and \"BTC\"", + )) + .then(|builder| add_metadata( + builder, + radiswap_2, + "Radiswap 2 - ETH/ETC: Component", + "[EXAMPLE] A Radiswap dApp between test tokens \"ETH\" and \"ETC\"", + )) + .then(|builder| add_metadata( + builder, + pool_2, + "Radiswap 2 - ETH/ETC: Pool", + "[EXAMPLE] The underyling pool between test tokens \"ETH\" and \"ETC\"", + )) + .then(|builder| add_metadata( + builder, + pool_unit_2, + "Radiswap 2 - ETH/ETC: Pool Units", + "[EXAMPLE] The pool units resource for the underlying pool between test tokens \"ETH\" and \"ETC\"", + )) + .done() + }, + vec![&config.radiswap_dapp_definition_account.key], + ) + } + ) .finalize(|core, config, state| { Ok(ScenarioOutput { interesting_addresses: DescribedAddresses::new() From a32317c61dcfa1afb9c4d9f24d2cd3787f8d95cb Mon Sep 17 00:00:00 2001 From: David Edey Date: Thu, 6 Jul 2023 14:54:20 +0100 Subject: [PATCH 3/3] feat: Finish off radiswap changes --- ...wner-badge-and-dapp-definition-account.rtm | 131 ++++++++ ...f2df2e27a45cdf3f2b021075e5dbd945925a.blob} | Bin ...03--radiswap-publish-and-create-pools.rtm} | 30 +- ...ty.rtm => 004--radiswap-add-liquidity.rtm} | 4 +- ...tm => 005--radiswap-distribute-tokens.rtm} | 17 +- ...kens.rtm => 006--radiswap-swap-tokens.rtm} | 2 +- ...ns.rtm => 007--radiswap-remove-tokens.rtm} | 6 +- .../008--radiswap-set-two-way-linking.rtm | 279 ++++++++++++++++++ .../src/scenarios/radiswap.rs | 39 ++- 9 files changed, 470 insertions(+), 38 deletions(-) create mode 100644 transaction-scenarios/generated-examples/radiswap/002--radiswap-create-owner-badge-and-dapp-definition-account.rtm rename transaction-scenarios/generated-examples/radiswap/{002--radiswap-publish-and-create-pools-959501fa0352184aa66864c67220f2df2e27a45cdf3f2b021075e5dbd945925a.blob => 003--radiswap-publish-and-create-pools-959501fa0352184aa66864c67220f2df2e27a45cdf3f2b021075e5dbd945925a.blob} (100%) rename transaction-scenarios/generated-examples/radiswap/{002--radiswap-publish-and-create-pools.rtm => 003--radiswap-publish-and-create-pools.rtm} (97%) rename transaction-scenarios/generated-examples/radiswap/{003--radiswap-add-liquidity.rtm => 004--radiswap-add-liquidity.rtm} (91%) rename transaction-scenarios/generated-examples/radiswap/{004--radiswap-distribute-tokens.rtm => 005--radiswap-distribute-tokens.rtm} (86%) rename transaction-scenarios/generated-examples/radiswap/{005--radiswap-swap-tokens.rtm => 006--radiswap-swap-tokens.rtm} (89%) rename transaction-scenarios/generated-examples/radiswap/{006--radiswap-remove-tokens.rtm => 007--radiswap-remove-tokens.rtm} (68%) create mode 100644 transaction-scenarios/generated-examples/radiswap/008--radiswap-set-two-way-linking.rtm diff --git a/transaction-scenarios/generated-examples/radiswap/002--radiswap-create-owner-badge-and-dapp-definition-account.rtm b/transaction-scenarios/generated-examples/radiswap/002--radiswap-create-owner-badge-and-dapp-definition-account.rtm new file mode 100644 index 00000000000..22df3e1b28c --- /dev/null +++ b/transaction-scenarios/generated-examples/radiswap/002--radiswap-create-owner-badge-and-dapp-definition-account.rtm @@ -0,0 +1,131 @@ +CALL_METHOD + Address("component_sim1cptxxxxxxxxxfaucetxxxxxxxxx000527798379xxxxxxxxxhkrefh") + "lock_fee" + Decimal("5000") +; +CREATE_NON_FUNGIBLE_RESOURCE_WITH_INITIAL_SUPPLY + Enum<0u8>() + Enum<1u8>() + true + Tuple( + Tuple( + Array(), + Array(), + Array() + ), + Enum<0u8>( + 66u8 + ), + Array() + ) + Map( + NonFungibleLocalId("#1#") => Tuple( + Tuple() + ) + ) + Tuple( + Enum<0u8>(), + Enum<0u8>(), + Enum<0u8>(), + Enum<0u8>(), + Enum<0u8>(), + Enum<0u8>(), + Enum<0u8>() + ) + Tuple( + Map( + "description" => Tuple( + Enum<1u8>( + Enum<0u8>( + "[EXAMPLE] The owner badge for the Radiswap dApp and associated entities" + ) + ), + false + ), + "info_url" => Tuple( + Enum<1u8>( + Enum<13u8>( + "https://radiswap.radixdlt.com/" + ) + ), + false + ), + "name" => Tuple( + Enum<1u8>( + Enum<0u8>( + "Radiswap - dApp Owner Badge" + ) + ), + false + ), + "tags" => Tuple( + Enum<1u8>( + Enum<128u8>( + Array( + "badge", + "dex", + "pool", + "radiswap" + ) + ) + ), + false + ) + ), + Map() + ) + Enum<0u8>() +; +CALL_METHOD + Address("account_sim129uea6ms5wjstpze559am5ddw293cr2nxeqrha4ae4536dlw5x8whd") + "try_deposit_batch_or_abort" + Expression("ENTIRE_WORKTOP") +; +SET_METADATA + Address("account_sim129uea6ms5wjstpze559am5ddw293cr2nxeqrha4ae4536dlw5x8whd") + "account_type" + Enum<0u8>( + "dapp definition" + ) +; +SET_METADATA + Address("account_sim129uea6ms5wjstpze559am5ddw293cr2nxeqrha4ae4536dlw5x8whd") + "name" + Enum<0u8>( + "Radiswap dApp Definition" + ) +; +SET_METADATA + Address("account_sim129uea6ms5wjstpze559am5ddw293cr2nxeqrha4ae4536dlw5x8whd") + "description" + Enum<0u8>( + "[EXAMPLE] The Radiswap dApp definition account" + ) +; +SET_METADATA + Address("account_sim129uea6ms5wjstpze559am5ddw293cr2nxeqrha4ae4536dlw5x8whd") + "tags" + Enum<128u8>( + Array( + "dex", + "pool", + "radiswap" + ) + ) +; +SET_METADATA + Address("account_sim129uea6ms5wjstpze559am5ddw293cr2nxeqrha4ae4536dlw5x8whd") + "info_url" + Enum<13u8>( + "https://radiswap.radixdlt.com/" + ) +; +SET_METADATA + Address("account_sim129uea6ms5wjstpze559am5ddw293cr2nxeqrha4ae4536dlw5x8whd") + "claimed_websites" + Enum<142u8>( + Array( + "https://radiswap.radixdlt.com" + ) + ) +; diff --git a/transaction-scenarios/generated-examples/radiswap/002--radiswap-publish-and-create-pools-959501fa0352184aa66864c67220f2df2e27a45cdf3f2b021075e5dbd945925a.blob b/transaction-scenarios/generated-examples/radiswap/003--radiswap-publish-and-create-pools-959501fa0352184aa66864c67220f2df2e27a45cdf3f2b021075e5dbd945925a.blob similarity index 100% rename from transaction-scenarios/generated-examples/radiswap/002--radiswap-publish-and-create-pools-959501fa0352184aa66864c67220f2df2e27a45cdf3f2b021075e5dbd945925a.blob rename to transaction-scenarios/generated-examples/radiswap/003--radiswap-publish-and-create-pools-959501fa0352184aa66864c67220f2df2e27a45cdf3f2b021075e5dbd945925a.blob diff --git a/transaction-scenarios/generated-examples/radiswap/002--radiswap-publish-and-create-pools.rtm b/transaction-scenarios/generated-examples/radiswap/003--radiswap-publish-and-create-pools.rtm similarity index 97% rename from transaction-scenarios/generated-examples/radiswap/002--radiswap-publish-and-create-pools.rtm rename to transaction-scenarios/generated-examples/radiswap/003--radiswap-publish-and-create-pools.rtm index 282647c1408..67dd2134b82 100644 --- a/transaction-scenarios/generated-examples/radiswap/002--radiswap-publish-and-create-pools.rtm +++ b/transaction-scenarios/generated-examples/radiswap/003--radiswap-publish-and-create-pools.rtm @@ -19,7 +19,7 @@ PUBLISH_PACKAGE_ADVANCED Enum<0u8>( Enum<0u8>( Enum<0u8>( - NonFungibleGlobalId("resource_sim1nfxxxxxxxxxxsecpsgxxxxxxxxx004638826440xxxxxxxxxwj8qq5:[4bacc54ffcf223a81aac5f9e4fa22fe33a266eb6b372f583daf7252b3e]") + NonFungibleGlobalId("resource_sim1ntkean2wr5ut4uakv85rvamw58thkc93njxwa0j8hyq62u77tgmg94:#1#") ) ) ) @@ -650,7 +650,7 @@ PUBLISH_PACKAGE_ADVANCED "description" => Tuple( Enum<1u8>( Enum<0u8>( - "A package of the logic of a Uniswap v2 style DEX." + "[EXAMPLE] A package of the logic of a Uniswap v2 style DEX." ) ), true @@ -684,7 +684,17 @@ CALL_FUNCTION NamedAddress("radiswap_package") "Radiswap" "new" - Enum<0u8>() + Enum<1u8>( + Enum<2u8>( + Enum<0u8>( + Enum<0u8>( + Enum<0u8>( + NonFungibleGlobalId("resource_sim1ntkean2wr5ut4uakv85rvamw58thkc93njxwa0j8hyq62u77tgmg94:#1#") + ) + ) + ) + ) + ) Address("resource_sim1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxakj8n3") Address("resource_sim1th47ntgk0vvcujeeucmtzhmnch00ems7su7akeszjutt582tqw8cnx") ; @@ -692,12 +702,22 @@ CALL_FUNCTION NamedAddress("radiswap_package") "Radiswap" "new" - Enum<0u8>() + Enum<1u8>( + Enum<2u8>( + Enum<0u8>( + Enum<0u8>( + Enum<0u8>( + NonFungibleGlobalId("resource_sim1ntkean2wr5ut4uakv85rvamw58thkc93njxwa0j8hyq62u77tgmg94:#1#") + ) + ) + ) + ) + ) Address("resource_sim1thvtyk4j7ry44p2fq5ucjwfay2n7d9gcl2huyv0hwpj0ffjehs3tcd") Address("resource_sim1themku2nqm2ktjmz529wr786ckk8cyn9cljhfe8c4c8zqslrkp5dcl") ; CALL_METHOD - Address("account_sim168qgdkgfqxpnswu38wy6fy5v0q0um52zd0umuely5t9xrf88t3unc0") + Address("account_sim129uea6ms5wjstpze559am5ddw293cr2nxeqrha4ae4536dlw5x8whd") "try_deposit_batch_or_abort" Expression("ENTIRE_WORKTOP") ; diff --git a/transaction-scenarios/generated-examples/radiswap/003--radiswap-add-liquidity.rtm b/transaction-scenarios/generated-examples/radiswap/004--radiswap-add-liquidity.rtm similarity index 91% rename from transaction-scenarios/generated-examples/radiswap/003--radiswap-add-liquidity.rtm rename to transaction-scenarios/generated-examples/radiswap/004--radiswap-add-liquidity.rtm index cac2f05da34..62d49720057 100644 --- a/transaction-scenarios/generated-examples/radiswap/003--radiswap-add-liquidity.rtm +++ b/transaction-scenarios/generated-examples/radiswap/004--radiswap-add-liquidity.rtm @@ -34,7 +34,7 @@ TAKE_ALL_FROM_WORKTOP Bucket("pool_1_resource_2") ; CALL_METHOD - Address("component_sim1cqwku3d24lstwsek08ewvv9qdmhm8pt8f7u8jwrzcn7w0jz4rtu60r") + Address("component_sim1cqyd2zdufz4q5nlpghs360g9p6xqvyxxjg90kgcjsfmaynuh8l37yc") "add_liquidity" Bucket("pool_1_resource_1") Bucket("pool_1_resource_2") @@ -48,7 +48,7 @@ TAKE_ALL_FROM_WORKTOP Bucket("pool_2_resource_2") ; CALL_METHOD - Address("component_sim1cqnla0fn3rzf5meej4p79q73swldyrxjghgwaqnlg430339v5k669v") + Address("component_sim1cqhz2fug707hss8n6evw744g2tgvl0nh7wmex5z3uyzl39c0ynevmq") "add_liquidity" Bucket("pool_2_resource_1") Bucket("pool_2_resource_2") diff --git a/transaction-scenarios/generated-examples/radiswap/004--radiswap-distribute-tokens.rtm b/transaction-scenarios/generated-examples/radiswap/005--radiswap-distribute-tokens.rtm similarity index 86% rename from transaction-scenarios/generated-examples/radiswap/004--radiswap-distribute-tokens.rtm rename to transaction-scenarios/generated-examples/radiswap/005--radiswap-distribute-tokens.rtm index 0f9fe5ce738..df4e9f7c309 100644 --- a/transaction-scenarios/generated-examples/radiswap/004--radiswap-distribute-tokens.rtm +++ b/transaction-scenarios/generated-examples/radiswap/005--radiswap-distribute-tokens.rtm @@ -7,6 +7,11 @@ CALL_METHOD Address("component_sim1cptxxxxxxxxxfaucetxxxxxxxxx000527798379xxxxxxxxxhkrefh") "free" ; +CALL_METHOD + Address("account_sim168qgdkgfqxpnswu38wy6fy5v0q0um52zd0umuely5t9xrf88t3unc0") + "try_deposit_batch_or_abort" + Expression("ENTIRE_WORKTOP") +; CALL_METHOD Address("account_sim168qgdkgfqxpnswu38wy6fy5v0q0um52zd0umuely5t9xrf88t3unc0") "withdraw" @@ -34,13 +39,13 @@ CALL_METHOD CALL_METHOD Address("account_sim168qgdkgfqxpnswu38wy6fy5v0q0um52zd0umuely5t9xrf88t3unc0") "withdraw" - Address("resource_sim1t4qz77wu6zty77edrm3yngrs8nkwhhj3782zunfakd3zggulmcmqpd") + Address("resource_sim1thal498nmv4ldpz0lvjcvaw9kvy0d3khyd549w7tlc5qmfhcudedlg") Decimal("333") ; CALL_METHOD Address("account_sim168qgdkgfqxpnswu38wy6fy5v0q0um52zd0umuely5t9xrf88t3unc0") "withdraw" - Address("resource_sim1t57p0xtvaw5u3q25d7m0pk2036w6tgv7t65vam8f2hcrp7c4vn2puh") + Address("resource_sim1thl65g9v2h4axeh9chsqksf6u06qn8r3sls9jfzdepderur83rxv08") Decimal("333") ; CALL_METHOD @@ -75,13 +80,13 @@ CALL_METHOD CALL_METHOD Address("account_sim168qgdkgfqxpnswu38wy6fy5v0q0um52zd0umuely5t9xrf88t3unc0") "withdraw" - Address("resource_sim1t4qz77wu6zty77edrm3yngrs8nkwhhj3782zunfakd3zggulmcmqpd") + Address("resource_sim1thal498nmv4ldpz0lvjcvaw9kvy0d3khyd549w7tlc5qmfhcudedlg") Decimal("333") ; CALL_METHOD Address("account_sim168qgdkgfqxpnswu38wy6fy5v0q0um52zd0umuely5t9xrf88t3unc0") "withdraw" - Address("resource_sim1t57p0xtvaw5u3q25d7m0pk2036w6tgv7t65vam8f2hcrp7c4vn2puh") + Address("resource_sim1thl65g9v2h4axeh9chsqksf6u06qn8r3sls9jfzdepderur83rxv08") Decimal("333") ; CALL_METHOD @@ -116,13 +121,13 @@ CALL_METHOD CALL_METHOD Address("account_sim168qgdkgfqxpnswu38wy6fy5v0q0um52zd0umuely5t9xrf88t3unc0") "withdraw" - Address("resource_sim1t4qz77wu6zty77edrm3yngrs8nkwhhj3782zunfakd3zggulmcmqpd") + Address("resource_sim1thal498nmv4ldpz0lvjcvaw9kvy0d3khyd549w7tlc5qmfhcudedlg") Decimal("333") ; CALL_METHOD Address("account_sim168qgdkgfqxpnswu38wy6fy5v0q0um52zd0umuely5t9xrf88t3unc0") "withdraw" - Address("resource_sim1t57p0xtvaw5u3q25d7m0pk2036w6tgv7t65vam8f2hcrp7c4vn2puh") + Address("resource_sim1thl65g9v2h4axeh9chsqksf6u06qn8r3sls9jfzdepderur83rxv08") Decimal("333") ; CALL_METHOD diff --git a/transaction-scenarios/generated-examples/radiswap/005--radiswap-swap-tokens.rtm b/transaction-scenarios/generated-examples/radiswap/006--radiswap-swap-tokens.rtm similarity index 89% rename from transaction-scenarios/generated-examples/radiswap/005--radiswap-swap-tokens.rtm rename to transaction-scenarios/generated-examples/radiswap/006--radiswap-swap-tokens.rtm index a8c3d63a7ae..f3d04bf7a70 100644 --- a/transaction-scenarios/generated-examples/radiswap/005--radiswap-swap-tokens.rtm +++ b/transaction-scenarios/generated-examples/radiswap/006--radiswap-swap-tokens.rtm @@ -14,7 +14,7 @@ TAKE_ALL_FROM_WORKTOP Bucket("input") ; CALL_METHOD - Address("component_sim1cqwku3d24lstwsek08ewvv9qdmhm8pt8f7u8jwrzcn7w0jz4rtu60r") + Address("component_sim1cqyd2zdufz4q5nlpghs360g9p6xqvyxxjg90kgcjsfmaynuh8l37yc") "swap" Bucket("input") ; diff --git a/transaction-scenarios/generated-examples/radiswap/006--radiswap-remove-tokens.rtm b/transaction-scenarios/generated-examples/radiswap/007--radiswap-remove-tokens.rtm similarity index 68% rename from transaction-scenarios/generated-examples/radiswap/006--radiswap-remove-tokens.rtm rename to transaction-scenarios/generated-examples/radiswap/007--radiswap-remove-tokens.rtm index c3b8e442127..69d05312c44 100644 --- a/transaction-scenarios/generated-examples/radiswap/006--radiswap-remove-tokens.rtm +++ b/transaction-scenarios/generated-examples/radiswap/007--radiswap-remove-tokens.rtm @@ -6,15 +6,15 @@ CALL_METHOD CALL_METHOD Address("account_sim168j3paqgngj74yzaljq4n422rtsmupaec3wnqq5425fd85cnd8xmdz") "withdraw" - Address("resource_sim1t4qz77wu6zty77edrm3yngrs8nkwhhj3782zunfakd3zggulmcmqpd") + Address("resource_sim1thal498nmv4ldpz0lvjcvaw9kvy0d3khyd549w7tlc5qmfhcudedlg") Decimal("100") ; TAKE_ALL_FROM_WORKTOP - Address("resource_sim1t4qz77wu6zty77edrm3yngrs8nkwhhj3782zunfakd3zggulmcmqpd") + Address("resource_sim1thal498nmv4ldpz0lvjcvaw9kvy0d3khyd549w7tlc5qmfhcudedlg") Bucket("pool_units") ; CALL_METHOD - Address("component_sim1cqwku3d24lstwsek08ewvv9qdmhm8pt8f7u8jwrzcn7w0jz4rtu60r") + Address("component_sim1cqyd2zdufz4q5nlpghs360g9p6xqvyxxjg90kgcjsfmaynuh8l37yc") "remove_liquidity" Bucket("pool_units") ; diff --git a/transaction-scenarios/generated-examples/radiswap/008--radiswap-set-two-way-linking.rtm b/transaction-scenarios/generated-examples/radiswap/008--radiswap-set-two-way-linking.rtm new file mode 100644 index 00000000000..f7c81714079 --- /dev/null +++ b/transaction-scenarios/generated-examples/radiswap/008--radiswap-set-two-way-linking.rtm @@ -0,0 +1,279 @@ +CALL_METHOD + Address("component_sim1cptxxxxxxxxxfaucetxxxxxxxxx000527798379xxxxxxxxxhkrefh") + "lock_fee" + Decimal("5000") +; +CALL_METHOD + Address("account_sim129uea6ms5wjstpze559am5ddw293cr2nxeqrha4ae4536dlw5x8whd") + "create_proof_of_non_fungibles" + Address("resource_sim1ntkean2wr5ut4uakv85rvamw58thkc93njxwa0j8hyq62u77tgmg94") + Array( + NonFungibleLocalId("#1#") + ) +; +SET_METADATA + Address("account_sim129uea6ms5wjstpze559am5ddw293cr2nxeqrha4ae4536dlw5x8whd") + "claimed_entities" + Enum<136u8>( + Array
( + Address("component_sim1cqyd2zdufz4q5nlpghs360g9p6xqvyxxjg90kgcjsfmaynuh8l37yc"), + Address("pool_sim1ckhcusnuz96jflrhncdckesejgfwf60g3jt4uhsyqwhwxuhw76e77c"), + Address("resource_sim1thal498nmv4ldpz0lvjcvaw9kvy0d3khyd549w7tlc5qmfhcudedlg"), + Address("component_sim1cqhz2fug707hss8n6evw744g2tgvl0nh7wmex5z3uyzl39c0ynevmq"), + Address("pool_sim1ckvrv5q0e08f77nchs9ul0pm27uyjh04q6q4xys80mpsjzp42fw9jn"), + Address("resource_sim1thl65g9v2h4axeh9chsqksf6u06qn8r3sls9jfzdepderur83rxv08") + ) + ) +; +SET_METADATA + Address("component_sim1cqyd2zdufz4q5nlpghs360g9p6xqvyxxjg90kgcjsfmaynuh8l37yc") + "dapp_definitions" + Enum<136u8>( + Array
( + Address("account_sim129uea6ms5wjstpze559am5ddw293cr2nxeqrha4ae4536dlw5x8whd") + ) + ) +; +SET_METADATA + Address("pool_sim1ckhcusnuz96jflrhncdckesejgfwf60g3jt4uhsyqwhwxuhw76e77c") + "dapp_definitions" + Enum<136u8>( + Array
( + Address("account_sim129uea6ms5wjstpze559am5ddw293cr2nxeqrha4ae4536dlw5x8whd") + ) + ) +; +SET_METADATA + Address("resource_sim1thal498nmv4ldpz0lvjcvaw9kvy0d3khyd549w7tlc5qmfhcudedlg") + "dapp_definitions" + Enum<136u8>( + Array
( + Address("account_sim129uea6ms5wjstpze559am5ddw293cr2nxeqrha4ae4536dlw5x8whd") + ) + ) +; +SET_METADATA + Address("component_sim1cqhz2fug707hss8n6evw744g2tgvl0nh7wmex5z3uyzl39c0ynevmq") + "dapp_definitions" + Enum<136u8>( + Array
( + Address("account_sim129uea6ms5wjstpze559am5ddw293cr2nxeqrha4ae4536dlw5x8whd") + ) + ) +; +SET_METADATA + Address("pool_sim1ckvrv5q0e08f77nchs9ul0pm27uyjh04q6q4xys80mpsjzp42fw9jn") + "dapp_definitions" + Enum<136u8>( + Array
( + Address("account_sim129uea6ms5wjstpze559am5ddw293cr2nxeqrha4ae4536dlw5x8whd") + ) + ) +; +SET_METADATA + Address("resource_sim1thl65g9v2h4axeh9chsqksf6u06qn8r3sls9jfzdepderur83rxv08") + "dapp_definitions" + Enum<136u8>( + Array
( + Address("account_sim129uea6ms5wjstpze559am5ddw293cr2nxeqrha4ae4536dlw5x8whd") + ) + ) +; +SET_METADATA + Address("component_sim1cqyd2zdufz4q5nlpghs360g9p6xqvyxxjg90kgcjsfmaynuh8l37yc") + "name" + Enum<0u8>( + "Radiswap 1 - XRD/BTC: Component" + ) +; +SET_METADATA + Address("component_sim1cqyd2zdufz4q5nlpghs360g9p6xqvyxxjg90kgcjsfmaynuh8l37yc") + "description" + Enum<0u8>( + "[EXAMPLE] A Radiswap component between test tokens "XRD" and "BTC"" + ) +; +SET_METADATA + Address("component_sim1cqyd2zdufz4q5nlpghs360g9p6xqvyxxjg90kgcjsfmaynuh8l37yc") + "tags" + Enum<128u8>( + Array( + "badge", + "dex", + "pool", + "radiswap" + ) + ) +; +SET_METADATA + Address("component_sim1cqyd2zdufz4q5nlpghs360g9p6xqvyxxjg90kgcjsfmaynuh8l37yc") + "info_url" + Enum<13u8>( + "https://radiswap.radixdlt.com/" + ) +; +SET_METADATA + Address("pool_sim1ckhcusnuz96jflrhncdckesejgfwf60g3jt4uhsyqwhwxuhw76e77c") + "name" + Enum<0u8>( + "Radiswap 1 - XRD/BTC: Pool" + ) +; +SET_METADATA + Address("pool_sim1ckhcusnuz96jflrhncdckesejgfwf60g3jt4uhsyqwhwxuhw76e77c") + "description" + Enum<0u8>( + "[EXAMPLE] The underyling pool between test tokens "XRD" and "BTC"" + ) +; +SET_METADATA + Address("pool_sim1ckhcusnuz96jflrhncdckesejgfwf60g3jt4uhsyqwhwxuhw76e77c") + "tags" + Enum<128u8>( + Array( + "badge", + "dex", + "pool", + "radiswap" + ) + ) +; +SET_METADATA + Address("pool_sim1ckhcusnuz96jflrhncdckesejgfwf60g3jt4uhsyqwhwxuhw76e77c") + "info_url" + Enum<13u8>( + "https://radiswap.radixdlt.com/" + ) +; +SET_METADATA + Address("resource_sim1thal498nmv4ldpz0lvjcvaw9kvy0d3khyd549w7tlc5qmfhcudedlg") + "name" + Enum<0u8>( + "Radiswap 1 - XRD/BTC: Pool Units" + ) +; +SET_METADATA + Address("resource_sim1thal498nmv4ldpz0lvjcvaw9kvy0d3khyd549w7tlc5qmfhcudedlg") + "description" + Enum<0u8>( + "[EXAMPLE] The pool units resource for the underlying pool between test tokens "XRD" and "BTC"" + ) +; +SET_METADATA + Address("resource_sim1thal498nmv4ldpz0lvjcvaw9kvy0d3khyd549w7tlc5qmfhcudedlg") + "tags" + Enum<128u8>( + Array( + "badge", + "dex", + "pool", + "radiswap" + ) + ) +; +SET_METADATA + Address("resource_sim1thal498nmv4ldpz0lvjcvaw9kvy0d3khyd549w7tlc5qmfhcudedlg") + "info_url" + Enum<13u8>( + "https://radiswap.radixdlt.com/" + ) +; +SET_METADATA + Address("component_sim1cqhz2fug707hss8n6evw744g2tgvl0nh7wmex5z3uyzl39c0ynevmq") + "name" + Enum<0u8>( + "Radiswap 2 - ETH/ETC: Component" + ) +; +SET_METADATA + Address("component_sim1cqhz2fug707hss8n6evw744g2tgvl0nh7wmex5z3uyzl39c0ynevmq") + "description" + Enum<0u8>( + "[EXAMPLE] A Radiswap dApp between test tokens "ETH" and "ETC"" + ) +; +SET_METADATA + Address("component_sim1cqhz2fug707hss8n6evw744g2tgvl0nh7wmex5z3uyzl39c0ynevmq") + "tags" + Enum<128u8>( + Array( + "badge", + "dex", + "pool", + "radiswap" + ) + ) +; +SET_METADATA + Address("component_sim1cqhz2fug707hss8n6evw744g2tgvl0nh7wmex5z3uyzl39c0ynevmq") + "info_url" + Enum<13u8>( + "https://radiswap.radixdlt.com/" + ) +; +SET_METADATA + Address("pool_sim1ckvrv5q0e08f77nchs9ul0pm27uyjh04q6q4xys80mpsjzp42fw9jn") + "name" + Enum<0u8>( + "Radiswap 2 - ETH/ETC: Pool" + ) +; +SET_METADATA + Address("pool_sim1ckvrv5q0e08f77nchs9ul0pm27uyjh04q6q4xys80mpsjzp42fw9jn") + "description" + Enum<0u8>( + "[EXAMPLE] The underyling pool between test tokens "ETH" and "ETC"" + ) +; +SET_METADATA + Address("pool_sim1ckvrv5q0e08f77nchs9ul0pm27uyjh04q6q4xys80mpsjzp42fw9jn") + "tags" + Enum<128u8>( + Array( + "badge", + "dex", + "pool", + "radiswap" + ) + ) +; +SET_METADATA + Address("pool_sim1ckvrv5q0e08f77nchs9ul0pm27uyjh04q6q4xys80mpsjzp42fw9jn") + "info_url" + Enum<13u8>( + "https://radiswap.radixdlt.com/" + ) +; +SET_METADATA + Address("resource_sim1thl65g9v2h4axeh9chsqksf6u06qn8r3sls9jfzdepderur83rxv08") + "name" + Enum<0u8>( + "Radiswap 2 - ETH/ETC: Pool Units" + ) +; +SET_METADATA + Address("resource_sim1thl65g9v2h4axeh9chsqksf6u06qn8r3sls9jfzdepderur83rxv08") + "description" + Enum<0u8>( + "[EXAMPLE] The pool units resource for the underlying pool between test tokens "ETH" and "ETC"" + ) +; +SET_METADATA + Address("resource_sim1thl65g9v2h4axeh9chsqksf6u06qn8r3sls9jfzdepderur83rxv08") + "tags" + Enum<128u8>( + Array( + "badge", + "dex", + "pool", + "radiswap" + ) + ) +; +SET_METADATA + Address("resource_sim1thl65g9v2h4axeh9chsqksf6u06qn8r3sls9jfzdepderur83rxv08") + "info_url" + Enum<13u8>( + "https://radiswap.radixdlt.com/" + ) +; diff --git a/transaction-scenarios/src/scenarios/radiswap.rs b/transaction-scenarios/src/scenarios/radiswap.rs index a0b101c2824..1b5e7952554 100644 --- a/transaction-scenarios/src/scenarios/radiswap.rs +++ b/transaction-scenarios/src/scenarios/radiswap.rs @@ -166,9 +166,9 @@ impl ScenarioCreator for RadiswapScenarioCreator { NonFungibleResourceRoles::default(), metadata! { init { - "name" => "Radiswap dApp Owner Badge", updatable; - "description" => "The owner badge for the Radiswap dApp", updatable; - "tags" => vec!["badge", "dex", "pool", "radiswap"], updatable; + "name" => "Radiswap - dApp Owner Badge", updatable; + "description" => "[EXAMPLE] The owner badge for the Radiswap dApp and associated entities", updatable; + "tags" => ["badge", "dex", "pool", "radiswap"], updatable; "info_url" => Url::of("https://radiswap.radixdlt.com/"), updatable; } }, @@ -177,23 +177,18 @@ impl ScenarioCreator for RadiswapScenarioCreator { ]), ) .try_deposit_batch_or_abort(definition_account) - .set_metadata( - definition_account, - "account_type", - "dapp definition" - ) - .set_metadata( - definition_account, - "name", - "Radiswap dApp Definition" - ) + .set_metadata(definition_account, "account_type", "dapp definition") + .set_metadata(definition_account, "name", "Radiswap dApp Definition") + .set_metadata(definition_account, "description", "[EXAMPLE] The Radiswap dApp definition account") + .set_metadata(definition_account, "tags", ["dex", "pool", "radiswap"]) + .set_metadata(definition_account, "info_url", Url::of("https://radiswap.radixdlt.com/")) .set_metadata( definition_account, "claimed_websites", - vec![Origin::of("https://radiswap.radixdlt.com")] + [Origin::of("https://radiswap.radixdlt.com")] ) }, - vec![] + vec![&config.radiswap_dapp_definition_account.key] ) }, |core, config, state, result| { @@ -232,9 +227,9 @@ impl ScenarioCreator for RadiswapScenarioCreator { code.to_vec(), schema, metadata_init! { - "name" => "Radiswap Package".to_owned(), locked; - "description" => "A package of the logic of a Uniswap v2 style DEX.".to_owned(), locked; - "tags" => vec!["dex".to_owned(), "pool".to_owned(), "radiswap".to_owned()], locked; + "name" => "Radiswap Package", locked; + "description" => "[EXAMPLE] A package of the logic of a Uniswap v2 style DEX.".to_owned(), locked; + "tags" => ["dex", "pool", "radiswap"], locked; }, owner_role.clone(), ).call_function( @@ -346,7 +341,8 @@ impl ScenarioCreator for RadiswapScenarioCreator { core.next_transaction_with_faucet_lock_fee_fallible( "radiswap-distribute-tokens", |mut builder| { - builder = builder.get_free_xrd_from_faucet(); + builder = builder.get_free_xrd_from_faucet() + .try_deposit_batch_or_abort(config.storing_account.address); for destination_account in [&config.user_account_1, &config.user_account_2, &config.user_account_3] { for resource_address in [ @@ -457,7 +453,7 @@ impl ScenarioCreator for RadiswapScenarioCreator { .create_proof_from_account_of_non_fungibles( config.radiswap_dapp_definition_account.address, state.owner_badge.get()?.resource_address(), - btreeset!( + &btreeset!( state.owner_badge.get()?.local_id().clone() ), ) @@ -526,7 +522,8 @@ impl ScenarioCreator for RadiswapScenarioCreator { .finalize(|core, config, state| { Ok(ScenarioOutput { interesting_addresses: DescribedAddresses::new() - .add("radiswap_owner", &config.radiswap_dapp_definition_account) + .add("radiswap_dapp_definition_account", &config.radiswap_dapp_definition_account) + .add("radiswap_dapp_owner_badge", state.owner_badge.get()?) .add("storing_account", &config.storing_account) .add("user_account_1", &config.user_account_1) .add("user_account_2", &config.user_account_2)