From 9290cbbc8fdce852d2a48589fd424c910db6b8ee Mon Sep 17 00:00:00 2001 From: Tupui <23188539+tupui@users.noreply.github.com> Date: Fri, 26 Jul 2024 01:56:32 +0200 Subject: [PATCH] Integrate Soroban Domain --- ...86732773ab5f0c159dcf039be202b4ecb8af8.wasm | Bin 0 -> 24403 bytes contracts/versioning/src/lib.rs | 24 +++++++-- contracts/versioning/src/test.rs | 48 ++++++++++++++++-- 3 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 contracts/domain_3ebbeec072f4996958d4318656186732773ab5f0c159dcf039be202b4ecb8af8.wasm diff --git a/contracts/domain_3ebbeec072f4996958d4318656186732773ab5f0c159dcf039be202b4ecb8af8.wasm b/contracts/domain_3ebbeec072f4996958d4318656186732773ab5f0c159dcf039be202b4ecb8af8.wasm new file mode 100644 index 0000000000000000000000000000000000000000..c500f5752bad60c4fc11f90cc681c2067e70612d GIT binary patch literal 24403 zcmeHvYmi*Wbzb+qciywu3y?}ckcoPRNVF)E)a-jfxx&3Gz93Q|2tpL1lnpGf0|JZ1 zJ_q0;1z?Bd5`<*MhGN-f5=Mq&*fOqr>`u~TLemxCn! zp-QR3eBbHrnLC34Nn7$i53qCl_Uk@m?mua17&^2-h_g{Cj=3KB{Xf!1t(pkI4713Q@BkQK@BJ!5 znKjcg>ZBe z^SIuLvB&ka%A)=_%Bz6F{=?|MDs#@c8e%)AhtN8Q*|NZP4CNW%9EE$H%;oa=e4!YG z_!NUurrfuwuRkvLZO(1E?e;An>D#h7pZg1H%U}G+N5Wuh7zA5OVT8^>)E@?_e230c znEAXa_w{Yl`p#|JqKsbD`FtkSYIF9Ea7`!8=7uV*spOBpV6V*|!8P|gdQ0|r{rJN2 zsX#?X=Z`kj6Ps7+jr|LU57(Dh_8(f9KYa8VwL5oW@tNi6nYwzibYgL4x>4WXn44Kq zdy4G4TtBq1Jfoi4Tm3kNy`m{=PDYyS{eQx&nGsR!|DgERR1=QSNGMF^_Qu3Z&ss_o1dbm%a zB1p0*Oz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a/contracts/versioning/src/lib.rs b/contracts/versioning/src/lib.rs index d8e2635..fa4be1c 100755 --- a/contracts/versioning/src/lib.rs +++ b/contracts/versioning/src/lib.rs @@ -1,12 +1,14 @@ #![no_std] +const CONTRACT_DOMAIN_ID: &str = "CATRNPHYKNXAPNLHEYH55REB6YSAJLGCPA4YM6L3WUKSZOPI77M2UMKI"; + use soroban_sdk::{ - contract, contractimpl, contracttype, panic_with_error, symbol_short, Address, Bytes, BytesN, - Env, String, Vec, + contract, contractimpl, contracttype, panic_with_error, symbol_short, vec, Address, Bytes, + BytesN, Env, String, Symbol, Val, Vec, }; use soroban_sdk::{contracterror, contractmeta}; -contractmeta!(key = "Description", val = "Soroban Versioning"); +contractmeta!(key = "Description", val = "Tansu - Soroban Versioning"); #[contracterror] #[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] @@ -97,6 +99,22 @@ impl Versioning { panic_with_error!(&env, &ContractErrors::ProjectAlreadyExist); } else { auth_maintainers(&env, &maintainer, &project.maintainers); + + let contract_domain_id_str = String::from_str(&env, CONTRACT_DOMAIN_ID); + let contract_domain_id = Address::from_string(&contract_domain_id_str); + let tld = Bytes::from_slice(&env, &[120, 108, 109]); // xlm + env.invoke_contract::<()>( + &contract_domain_id, + &Symbol::new(&env, "set_record"), + vec![ + &env, + name_b.to_val(), + tld.to_val(), + maintainer.to_val(), + maintainer.to_val(), + Val::from_i32(31536000).into(), + ], + ); env.storage().persistent().set(&key_, &project); env.events() diff --git a/contracts/versioning/src/test.rs b/contracts/versioning/src/test.rs index c56ba45..76e1a39 100755 --- a/contracts/versioning/src/test.rs +++ b/contracts/versioning/src/test.rs @@ -1,17 +1,56 @@ #![cfg(test)] -use super::{ContractErrors, Versioning, VersioningClient}; +use super::{ContractErrors, Versioning, VersioningClient, CONTRACT_DOMAIN_ID}; use soroban_sdk::testutils::Address as _; -use soroban_sdk::{symbol_short, testutils::Events, vec, Address, Bytes, Env, IntoVal, String}; +use soroban_sdk::{ + symbol_short, testutils::Events, token, vec, Address, Bytes, Env, IntoVal, String, Vec, +}; // use soroban_sdk::testutils::arbitrary::std::println; +mod contract_domain { + soroban_sdk::contractimport!( + file = "../domain_3ebbeec072f4996958d4318656186732773ab5f0c159dcf039be202b4ecb8af8.wasm" + ); +} + #[test] fn test() { let env = Env::default(); env.mock_all_auths(); - let contract_admin = Address::generate(&env); + // setup for Soroban Domain + let contract_domain_id_str = String::from_str(&env, CONTRACT_DOMAIN_ID); + let contract_domain_id = Address::from_string(&contract_domain_id_str); + env.register_contract_wasm(&contract_domain_id, contract_domain::WASM); + let contract_domain = contract_domain::Client::new(&env, &contract_domain_id); + + let adm: Address = Address::generate(&env); + let node_rate: u128 = 100; + let min_duration: u64 = 31536000; + let allowed_tlds: Vec = Vec::from_array( + &env, + [ + Bytes::from_slice(&env, "xlm".as_bytes()), + Bytes::from_slice(&env, "stellar".as_bytes()), + Bytes::from_slice(&env, "wallet".as_bytes()), + Bytes::from_slice(&env, "dao".as_bytes()), + ], + ); + let issuer: Address = Address::generate(&env); + let token_address = env.register_stellar_asset_contract(issuer.clone()); + let col_asset_client = token::TokenClient::new(&env, &token_address); + let col_asset_stellar = token::StellarAssetClient::new(&env, &token_address); + + contract_domain.init( + &adm, + &node_rate, + &col_asset_client.address.clone(), + &min_duration, + &allowed_tlds, + ); + // setup for Tansu + let contract_admin = Address::generate(&env); let contract_id = env.register_contract(None, Versioning); let contract = VersioningClient::new(&env, &contract_id); @@ -24,6 +63,9 @@ fn test() { let mando = Address::generate(&env); let maintainers = vec![&env, grogu.clone(), mando.clone()]; + let genesis_amount: i128 = 1_000_000_000 * 10_000_000; + col_asset_stellar.mint(&grogu, &genesis_amount); + let id = contract.register(&grogu, &name, &maintainers, &url, &hash); let expected_id = [