diff --git a/.gitignore b/.gitignore index fa66ee4..5635fc9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ +.snfoundry_cache target -.snfoundry_cache/https___starknet_mainnet_public_blastapi_io_rpc_v0_7_631894_v3.json +.DS_Store +Scarb.lock +snfoundry_cache/https___starknet_mainnet_public_blastapi_io_rpc_v0_7_631894_v3.json \ No newline at end of file diff --git a/Scarb.toml b/Scarb.toml index af13f50..0578744 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -23,6 +23,15 @@ snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v casm = true sierra = true +[scripts] +test = "snforge test" + +[[tool.snforge.fork]] +name = "SEPOLIA_LATEST" +url = "https://starknet-sepolia.public.blastapi.io/rpc/v0_7" +block_id.tag = "latest" +# block_id.number = "325081" + [[tool.snforge.fork]] name = "Mainnet" url = "https://starknet-mainnet.public.blastapi.io/rpc/v0_7" diff --git a/src/campaign.cairo b/src/campaign.cairo index 6e4a4b8..6ddf5b6 100644 --- a/src/campaign.cairo +++ b/src/campaign.cairo @@ -127,6 +127,7 @@ mod TokengiverCampaign { let new_campaign = Campaign { campaign_address, campaign_owner: caller, metadata_URI: "", token_id, }; + self.campaign.write(campaign_address, new_campaign); self.campaigns.write(count, campaign_address); self.count.write(count); @@ -139,6 +140,7 @@ mod TokengiverCampaign { token_giver_nft_address: nft_address } ); + campaign_address } diff --git a/tests/test_token_giver_nft.cairo b/tests/test_token_giver_nft.cairo index 3581c81..5376d67 100644 --- a/tests/test_token_giver_nft.cairo +++ b/tests/test_token_giver_nft.cairo @@ -1,7 +1,7 @@ use core::num::traits::zero::Zero; use core::starknet::SyscallResultTrait; use core::traits::{TryInto, Into}; -use starknet::{ContractAddress}; +use starknet::{ContractAddress, ClassHash, get_block_timestamp}; // use snforge_std::{declare, ContractClassTrait, CheatTarget, start_prank, stop_prank,}; use snforge_std::{ declare, start_cheat_caller_address, stop_cheat_caller_address, ContractClassTrait, @@ -13,6 +13,7 @@ use tokengiver::interfaces::ITokenGiverNft::{ ITokenGiverNftDispatcher, ITokenGiverNftDispatcherTrait }; use tokengiver::base::errors::Errors::ALREADY_MINTED; +use tokengiver::interfaces::ICampaign::{ICampaignDispatcher, ICampaignDispatcherTrait}; const ADMIN: felt252 = 'ADMIN'; const USER_ONE: felt252 = 'BOB'; @@ -27,6 +28,48 @@ fn __setup__() -> ContractAddress { return (nft_contract_address); } +fn deploy_campaign_contract() -> ContractAddress { + let nft_class_hash = declare("TokenGiverNFT").unwrap().contract_class(); + + let mut constructor_calldata: Array = ArrayTrait::new(); + nft_class_hash.serialize(ref constructor_calldata); + + let contract = declare("TokengiverCampaign").unwrap().contract_class(); + let (contract_address, _) = contract.deploy(@constructor_calldata).unwrap(); + + contract_address +} + +// #[test] +// #[fork("SEPOLIA_LATEST")] +// fn test_create_campaign() { +// let campaign_contract_address = deploy_campaign_contract(); +// let campaign_contract = ICampaignDispatcher { contract_address: campaign_contract_address }; + +// // Using Sepolia V2 (Audited contract) + +// let registry_hash: ClassHash = starknet::class_hash_const::< +// 0x046163525551f5a50ed027548e86e1ad023c44e0eeb0733f0dab2fb1fdc31ed0 +// >(); +// let registry_hash_in_felt: felt252 = registry_hash.into(); + +// let implementation_hash = starknet::class_hash_const::< +// 0x45d67b8590561c9b54e14dd309c9f38c4e2c554dd59414021f9d079811621bd +// >(); +// let implementation_hash_in_felt: felt252 = implementation_hash.into(); + +// let salt = get_block_timestamp(); +// let salt_in_felt: felt252 = salt.into(); + +// let recipient: ContractAddress = starknet::contract_address_const::< +// 0x01526C92E52c337b7B04d1307c6080Ece3a17071F2F0295197cEa8d077c6FF80 +// >(); + +// campaign_contract +// .create_campaign( +// registry_hash_in_felt, implementation_hash_in_felt, salt_in_felt, recipient +// ); +// } // #[test] // fn test_metadata() {