Skip to content
Open
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
33 changes: 33 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,45 @@ We follow a strict **Modular Commit** philosophy to ensure history is readable a
# Frontend
cd frontend && npm run lint
```
Cross-contract flows (governance budget paid out by the treasury, treasury
funds streamed through payroll or vested) live in `contracts/integration_tests`:
```bash
cd contracts && cargo test -p integration_tests
```
5. **Commit**: Follow the commit guidelines above.
6. **Pull Request**: Submit a PR with:
- Reference the issue number (e.g., "Closes SC-4")
- Description of changes
- Testing notes

## 🚰 Testnet Setup

`scripts/fund-testnet.sh` creates development accounts as stellar CLI identities
and funds each one with XLM from [Friendbot](https://friendbot.stellar.org).
Secret keys stay in the CLI keystore, so nothing sensitive lands in the repo.

```bash
# Fund the default accounts: orbitpay-admin, orbitpay-employer,
# orbitpay-employee-1, orbitpay-employee-2
./scripts/fund-testnet.sh

# Fund your own set of accounts (the first one is the token issuer)
./scripts/fund-testnet.sh alice bob carol

# Also issue a test token for payroll/vesting testing: deploys its Stellar
# Asset Contract, adds trustlines and mints 1,000 tokens to every account
# except the issuer
./scripts/fund-testnet.sh --token OPAY

# Choose the minted amount in stroops (7 decimals)
./scripts/fund-testnet.sh --token OPAY --amount 50000000000
```

The script is safe to re-run. Accounts that already hold the Friendbot starting
balance are skipped, and an existing token contract is reused. Pass the printed
token contract ID as the `token` argument to `create_stream` or `create_schedule`,
and the account names as `--source-account` to `stellar contract invoke`.

## 🗂 PR Review Checklist

Before submitting, ensure:
Expand Down
15 changes: 13 additions & 2 deletions contracts/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ members = [
"contracts/payroll_stream",
"contracts/vesting",
"contracts/governance",
"integration_tests",
]

[workspace.dependencies]
Expand Down
4 changes: 2 additions & 2 deletions contracts/contracts/governance/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![no_std]
use soroban_sdk::{contract, contractimpl, Address, Env, Symbol, Vec, symbol_short};

mod errors;
pub mod errors;
mod storage;
mod types;
pub mod types;

use errors::GovernanceError;
use storage::{
Expand Down
9 changes: 2 additions & 7 deletions contracts/contracts/payroll_stream/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![no_std]
use soroban_sdk::{contract, contractimpl, symbol_short, token, Address, Env, Vec};

mod errors;
pub mod errors;
mod storage;
mod types;
pub mod types;

use errors::StreamError;
use storage::{
Expand Down Expand Up @@ -72,8 +72,6 @@ impl PayrollStreamContract {

token_client.transfer(&sender, &contract_address, &total_amount);

token::Client::new(&env, &token).transfer(&sender, &env.current_contract_address(), &total_amount);

let stream_id = get_stream_count(&env);
let stream = PayrollStream {
id: stream_id,
Expand Down Expand Up @@ -227,9 +225,6 @@ impl PayrollStreamContract {
stream.status = StreamStatus::Completed;
}

token::Client::new(&env, &stream.token)
.transfer(&env.current_contract_address(), &recipient, &claimable);

set_stream(&env, stream_id, &stream);
token_client.transfer(&contract_address, &recipient, &claimable);

Expand Down
77 changes: 0 additions & 77 deletions contracts/contracts/payroll_stream/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ fn test_create_stream_transfers_tokens_and_saves_stream() {
let token_client = create_token_client(&env, &token);

token_admin_client.mint(&sender, &10000);

let token_admin = Address::generate(&env);
let token_contract = create_token_contract(&env, &token_admin);
let token_client = create_token_client(&env, &token_contract.address);
token_contract.mint(&sender, &10000);

client.initialize(&admin);

Expand All @@ -65,14 +60,6 @@ fn test_create_stream_transfers_tokens_and_saves_stream() {
});

let stream_id = client.create_stream(&sender, &recipient, &token, &10000, &1000, &2000);
let stream_id = client.create_stream(
&sender,
&recipient,
&token_contract.address,
&10000_i128,
&1000_u64,
&2000_u64,
);

assert_eq!(stream_id, 0);
assert_eq!(token_client.balance(&sender), 0);
Expand Down Expand Up @@ -109,9 +96,6 @@ fn test_create_stream_fails_without_balance_and_does_not_persist() {
assert_eq!(client.get_stream_count(), 0);
assert_eq!(token_client.balance(&sender), 5000);
assert_eq!(token_client.balance(&client.address), 0);

assert_eq!(token_client.balance(&sender), 0);
assert_eq!(token_client.balance(&client.address), 10000);
}

#[test]
Expand Down Expand Up @@ -172,10 +156,6 @@ fn test_calculate_claimable() {
let token = token_admin_client.address.clone();

token_admin_client.mint(&sender, &10000);

let token_admin = Address::generate(&env);
let token_contract = create_token_contract(&env, &token_admin);
token_contract.mint(&sender, &10000);

client.initialize(&admin);

Expand All @@ -184,14 +164,6 @@ fn test_calculate_claimable() {
});

let stream_id = client.create_stream(&sender, &recipient, &token, &10000, &1000, &2000);
let stream_id = client.create_stream(
&sender,
&recipient,
&token_contract.address,
&10000_i128,
&1000_u64,
&2000_u64,
);

env.ledger().with_mut(|li| {
li.timestamp = 1500;
Expand All @@ -213,11 +185,6 @@ fn test_claim_transfers_tokens_and_prevents_double_claim() {
let token_client = create_token_client(&env, &token);

token_admin_client.mint(&sender, &10000);

let token_admin = Address::generate(&env);
let token_contract = create_token_contract(&env, &token_admin);
let token_client = create_token_client(&env, &token_contract.address);
token_contract.mint(&sender, &10000);

client.initialize(&admin);

Expand Down Expand Up @@ -296,19 +263,6 @@ fn test_claim_rejects_when_claimable_is_zero() {

let stream_id = client.create_stream(&sender, &recipient, &token, &10000, &1000, &2000);
client.claim(&recipient, &stream_id);
let stream_id = client.create_stream(
&sender,
&recipient,
&token_contract.address,
&10000_i128,
&1000_u64,
&2000_u64,
);

client.cancel_stream(&sender, &stream_id);

assert_eq!(token_client.balance(&sender), 10000);
assert_eq!(token_client.balance(&recipient), 0);
}

#[test]
Expand All @@ -323,9 +277,6 @@ fn test_cancel_stream_settles_midway() {
let token_client = create_token_client(&env, &token);

token_admin_client.mint(&sender, &10000);
let token_contract = create_token_contract(&env, &token_admin);
let token_client = create_token_client(&env, &token_contract.address);
token_contract.mint(&sender, &10000);

client.initialize(&admin);

Expand All @@ -334,14 +285,6 @@ fn test_cancel_stream_settles_midway() {
});

let stream_id = client.create_stream(&sender, &recipient, &token, &10000, &1000, &2000);
let stream_id = client.create_stream(
&sender,
&recipient,
&token_contract.address,
&10000_i128,
&1000_u64,
&2000_u64,
);

env.ledger().with_mut(|li| {
li.timestamp = 1500;
Expand Down Expand Up @@ -428,9 +371,6 @@ fn test_cancel_stream_after_end() {
let token_client = create_token_client(&env, &token);

token_admin_client.mint(&sender, &10000);
let token_contract = create_token_contract(&env, &token_admin);
let token_client = create_token_client(&env, &token_contract.address);
token_contract.mint(&sender, &10000);

client.initialize(&admin);

Expand All @@ -439,14 +379,6 @@ fn test_cancel_stream_after_end() {
});

let stream_id = client.create_stream(&sender, &recipient, &token, &10000, &1000, &2000);
let stream_id = client.create_stream(
&sender,
&recipient,
&token_contract.address,
&10000_i128,
&1000_u64,
&2000_u64,
);

env.ledger().with_mut(|li| {
li.timestamp = 2500;
Expand Down Expand Up @@ -649,11 +581,6 @@ fn test_multiple_concurrent_streams() {
assert_eq!(token_client.balance(&recipient2), 2500);
}

fn create_token_contract<'a>(e: &Env, admin: &Address) -> token::StellarAssetClient<'a> {
let contract_addr = e.register_stellar_asset_contract_v2(admin.clone()).address();
token::StellarAssetClient::new(e, &contract_addr)
}

#[test]
fn test_cancel_after_partial_claim() {
let (env, admin, client) = setup_env();
Expand Down Expand Up @@ -734,7 +661,3 @@ fn test_claim_multiple_times_progression() {
let stream = client.get_stream(&stream_id);
assert_eq!(stream.status, StreamStatus::Completed);
}

fn create_token_client<'a>(e: &Env, contract_addr: &Address) -> token::Client<'a> {
token::Client::new(e, contract_addr)
}
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@
"val": {
"i128": {
"hi": 0,
"lo": 2500
"lo": 5000
}
}
},
Expand All @@ -416,7 +416,7 @@
"symbol": "last_claim_time"
},
"val": {
"u64": 1250
"u64": 1500
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
[],
[],
[],
[],
[]
],
"ledger": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@
"symbol": "last_claim_time"
},
"val": {
"u64": 3000
"u64": 2000
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@
]
],
[],
[],
[],
[]
],
"ledger": {
Expand Down
4 changes: 2 additions & 2 deletions contracts/contracts/treasury/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![no_std]
use soroban_sdk::{contract, contractimpl, symbol_short, token, Address, Env, Symbol, Vec};

mod errors;
pub mod errors;
mod storage;
mod types;
pub mod types;

use errors::TreasuryError;
use storage::{
Expand Down
4 changes: 2 additions & 2 deletions contracts/contracts/vesting/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![no_std]
use soroban_sdk::{contract, contractimpl, Address, Env, Symbol, Vec, symbol_short, token};

mod errors;
pub mod errors;
mod storage;
mod types;
pub mod types;

use errors::VestingError;
use storage::{
Expand Down
13 changes: 13 additions & 0 deletions contracts/integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "integration_tests"
version = "0.1.0"
edition = "2021"
publish = false
description = "Cross-contract integration tests for the OrbitPay contracts"

[dev-dependencies]
soroban-sdk = { workspace = true, features = ["testutils"] }
governance = { path = "../contracts/governance" }
payroll_stream = { path = "../contracts/payroll_stream" }
treasury = { path = "../contracts/treasury" }
vesting = { path = "../contracts/vesting" }
Loading
Loading