Skip to content

Commit

Permalink
New version of contract
Browse files Browse the repository at this point in the history
  • Loading branch information
nalnir committed Sep 12, 2023
1 parent 264cd23 commit f683dbd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 109 deletions.
96 changes: 10 additions & 86 deletions dao/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 15,7 @@ pub trait DaoContractTrait {
voting_power: u32,
proposal_power: u32,
shareholders: Map<Address, i128>,
// shareholders: Vec<Map<Address, i128>>,
) -> u32;
// fn init(
// env: Env,
// gov_token_salt: BytesN<32>,
// token_wasm_hash: BytesN<32>,
// gov_token_name: String,
// gov_token_symbol: String,
// voting_power: u32,
// proposal_power: u32,
// // shareholders: Vec<(Address, i128)>,
// ) -> (Address, Val);
) -> Address ;
}

#[contract]
Expand All @@ -43,8 32,7 @@ impl DaoContractTrait for DaoContract {
voting_power: u32,
proposal_power: u32,
shareholders: Map<Address, i128>,
// shareholders: Vec<Map<Address, i128>>,
) -> u32 {
) -> Address {
can_init_contract(&env);
// Deploy the contract using the installed WASM code with given hash.
let id = env.deployer().with_current_contract(gov_token_salt.to_val()).deploy(token_wasm_hash.to_val());
Expand Down Expand Up @@ -73,85 61,21 @@ impl DaoContractTrait for DaoContract {
for (shareholder_address, amount) in shareholders.iter() {
let shareholder_address_raw: Val = shareholder_address.to_val();

let auth_args: Vec<Val> = vec![&env, shareholder_address_raw, true.into_val(&env)] as Vec<Val>;
let auth_args: Vec<Val> = vec![&env, shareholder_address_raw, true.into_val(&env)];
let auth_res: Val = env.invoke_contract(&id, &authorize_fn, auth_args);

let mint_args: Vec<Val> =
vec![&env, shareholder_address_raw, amount.into_val(&env)] as Vec<Val>;
let mint_res: Val = env.invoke_contract(&id, &mint_fn, mint_args);
}

// set_core_state(
// &env,
// &CoreState {
// governance_token: id.clone(),
// },
// );
set_core_state(
&env,
&CoreState {
governance_token: id.clone(),
},
);

// (id, res)
// voting_power
voting_power
id
}

// fn init(
// env: Env,
// gov_token_salt: BytesN<32>,
// token_wasm_hash: BytesN<32>,
// gov_token_name: String,
// gov_token_symbol: String,
// voting_power: u32,
// proposal_power: u32,
// // shareholders: Vec<(Address, i128)>,
// ) -> (Address, Val) {
// can_init_contract(&env);
// // Deploy the contract using the installed WASM code with given hash.
// let id = env
// .deployer()
// .with_current_contract(gov_token_salt)
// .deploy(token_wasm_hash);

// let init_fn: Symbol = Symbol::new(&env, "initialize");
// let admin: Val = env.current_contract_address().to_val();
// let init_args: Vec<Val> = vec![
// &env,
// admin,
// 18u32.into(),
// gov_token_name.into(),
// gov_token_symbol.into()
// ] as Vec<Val>;

// // Invoke the init function with the given arguments.
// let res: Val = env.invoke_contract(&id, &init_fn, init_args);

// let mint_fn: Symbol = symbol_short!("mint");
// let authorize_fn: Symbol = symbol_short!("set_auth");

// let set_proposal_power_fn: Symbol = symbol_short!("set_p_pow");
// let set_voting_power_fn: Symbol = symbol_short!("set_v_pow");
// let proposal_power_res: Val = env.invoke_contract(&id, &set_proposal_power_fn, vec![&env, proposal_power.into_val(&env)] as Vec<Val>);
// let voting_power_res: Val = env.invoke_contract(&id, &set_voting_power_fn, vec![&env, voting_power.into_val(&env)] as Vec<Val>);
// // for shareholder in shareholders {
// // match shareholder {
// // (shareholder_address, amount) => {
// // let shareholder_address_raw: Val = shareholder_address.to_val();

// // let auth_args: Vec<Val> = vec![&env, shareholder_address_raw, true.into_val(&env)] as Vec<Val>;
// // let auth_res: Val = env.invoke_contract(&id, &authorize_fn, auth_args);

// // let mint_args: Vec<Val> =
// // vec![&env, shareholder_address_raw, amount.into_val(&env)] as Vec<Val>;
// // let mint_res: Val = env.invoke_contract(&id, &mint_fn, mint_args);
// // }
// // }
// // }
// set_core_state(
// &env,
// &CoreState {
// governance_token: id.clone(),
// },
// );

// (id, res)
// }

}
31 changes: 8 additions & 23 deletions deployer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 33,7 @@ impl Deployer {
mod test;

// soroban contract install --wasm ../dao/target/wasm32-unknown-unknown/release/governance.wasm
// dao-wasm-hash -> 9d3ccc7dd7438b7fa288a2fbc11fa5ca5ca429f883a420e3b103028d790ca017
// dao-wasm-hash -> 03810087d14392d780e1dd64b2707f2e2b29ca92c97aca9838c554f4ed317eb4

// soroban contract install --wasm ../token/target/wasm32-unknown-unknown/release/soroban_token_contract.wasm
// token-wasm-hash -> da729cbad2913399edabfc09a8dba948df7b830a5b855fdb196c7a48c3c9fbc1
Expand All @@ -42,31 42,16 @@ mod test;
// --wasm target/wasm32-unknown-unknown/release/soroban_deployer_contract.wasm \
// --source juico \
// --network futurenet
// deployer_contract_id -> CCC2W6D57JZKJ2BH2JY43QRRLT3ABB72424EVL5WFFWC642BGAPF66DN

// fds
// dao_contract_id -> CABTZLCXPKKR72VAF5GFBWAJQVWTFIMF6LJALSCXKZMUAEJKNEMPOMB4
// deployer_contract_id -> CB5WUJCGKOURLISFS2QW5OCDJGCNXXEWYVGZSFPHKCS6LQIPBHT5JB2M

// soroban contract deploy \
// --wasm target/wasm32-unknown-unknown/release/soroban_token_contract.wasm \
// --wasm target/wasm32-unknown-unknown/release/governance.wasm \
// --source juico \
// --network futurenet
// token_contract_id -> CDDPNPFJE6BZA5LZVKVB3EYNO5O2NVUHH443IN6VDGLXEUE7EML6PKE4
// dao_contract_id -> CAH3OL4WGP25M75SI5DXSNRLNSDWFF5MHQ5CUEHLVFOERZ47ZDUYOMDI

// soroban contract invoke \
// --id CC6IKYRGAYWJ6YWTAINLK75PH352ZMADMCVDEUEYAQQXGNZTXNDIZUFQ \
// soroban contract deploy \
// --wasm target/wasm32-unknown-unknown/release/soroban_token_contract.wasm \
// --source juico \
// --network futurenet \
// -- deploy \
// --salt 123 \
// --wasm_hash 55bc5b52c43a1f4eff4da6c8cedd3b37c11b370d40aaf46ca82bbf9305dbd852 \
// --init_fn init \
// --init_args '[
// {"bytes": "[208, 220, 176, 14, 34, 226, 1, 253, 110, 83, 177, 108, 63, 62, 47, 140, 186, 41, 115, 216, 41, 109, 168, 171, 43, 214, 47, 108, 181, 213, 106, 41]"},
// {"bytes": "[96, 167, 52, 132, 177, 54, 228, 62, 164, 11, 113, 104, 80, 162, 208, 174, 71, 15, 0, 201, 116, 123, 249, 8, 210, 140, 247, 169, 227, 123, 214, 246]"},
// {"bytes": "[11, 0]"},
// {"bytes": "[11]"},
// {"u32": 5},
// {"u32": 5},
// {"vec": [{"address": "GB4ZLIQWAWNH3VKEFD2LXCYL4WYHYOGRG333457ZRYSANSQM3AFPCX7E", "i128": 10}]}
// ]'
// --network futurenet
// token_contract_id -> CCFQHSCOX7XW3ANGET2M6VDIHQCBPF4MJFHOKEBKX2CEOCNVW24P6YPQ

0 comments on commit f683dbd

Please sign in to comment.