Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,26 @@ jobs:

- name: Install Stellar CLI
run: |
wget https://github.com/stellar/stellar-cli/releases/download/v25.1.0/stellar-cli-25.1.0-x86_64-unknown-linux-gnu.tar.gz
tar -xzf stellar-cli-25.1.0-x86_64-unknown-linux-gnu.tar.gz
sudo mv stellar-cli-25.1.0-x86_64-unknown-linux-gnu/stellar /usr/local/bin/
set -euo pipefail

VERSION="25.1.0"
ARCHIVE="stellar-cli-${VERSION}-x86_64-unknown-linux-gnu.tar.gz"
URL="https://github.com/stellar/stellar-cli/releases/download/v${VERSION}/${ARCHIVE}"

wget "${URL}" -O "${ARCHIVE}"

# Package layout has changed across versions; locate the binary from the archive contents.
BIN_PATH="$(tar -tzf "${ARCHIVE}" | grep -E '(^|/)stellar(-cli)?$' | head -n 1 || true)"
if [ -z "${BIN_PATH}" ]; then
echo "Could not locate stellar CLI binary in ${ARCHIVE}"
tar -tzf "${ARCHIVE}"
exit 1
fi

tar -xzf "${ARCHIVE}"

sudo install -m 0755 "${BIN_PATH}" /usr/local/bin/stellar
stellar --version

- name: Build Contract
run: cargo build --target wasm32-unknown-unknown --release
Expand Down
19 changes: 15 additions & 4 deletions contracts/vesting_contracts/src/factory.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use soroban_sdk::{contract, contractimpl, contractmeta, contracttype, Map, Address, BytesN, Env, Vec};
use soroban_sdk::{
contract, contractimpl, contractmeta, contracttype, Address, BytesN, Env, Map, Vec,
};

// Contract metadata for the factory
contractmeta!(
Expand All @@ -18,7 +20,7 @@ enum DataKey {
#[contractimpl]
impl VestingFactory {
/// Initialize the factory with the WASM hash of the vesting contract
pub fn initialize(env: Env, wasm_hash: BytesN<32>) {
pub fn initialize_factory(env: Env, wasm_hash: BytesN<32>) {
// Store the WASM hash for future deployments
env.storage().instance().set(&DataKey::WasmHash, &wasm_hash);

Expand All @@ -31,15 +33,24 @@ impl VestingFactory {

/// Deploy a new vesting contract for an organization
/// Only allows deployment if token is whitelisted
pub fn deploy_new_vault_contract(env: Env, admin: Address, initial_supply: i128, token: Address) -> Address {
pub fn deploy_new_vault_contract(
env: Env,
admin: Address,
initial_supply: i128,
token: Address,
) -> Address {
let _wasm_hash: BytesN<32> = env
.storage()
.instance()
.get(&DataKey::WasmHash)
.unwrap_or_else(|| panic!("Factory not initialized - WASM hash not set"));

// Check token whitelist
let whitelist: Map<Address, bool> = env.storage().instance().get(&crate::WhitelistDataKey::WhitelistedTokens).unwrap_or(Map::new(&env));
let whitelist: Map<Address, bool> = env
.storage()
.instance()
.get(&crate::WhitelistDataKey::WhitelistedTokens)
.unwrap_or(Map::new(&env));
if !whitelist.get(token.clone()).unwrap_or(false) {
panic!("Token not whitelisted");
}
Expand Down
Loading
Loading