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
29 changes: 13 additions & 16 deletions backend/.well-known/stellar.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
# SEP-0001 Stellar Metadata for PayD

VERSION = "2.0.0"
NETWORK_PASSPHRASE = "Test SDF Network ; September 2015"
HORIZON_URL = "https://horizon-testnet.stellar.org"

ACCOUNTS = []

[DOCUMENTATION]
ORG_NAME = "PayD"
ORG_DBA = "PayD"
ORG_URL = "https://payd.example.com"
ORG_DESCRIPTION = "PayD is a Stellar-based cross-border payroll platform enabling organizations to pay employees using digital assets."
ORG_LOG_URL = "https://payd.example.com/logo.png"

[CONTACT]
ORG_SUPPORT_EMAIL = "support@payd.example.com"
ORG_DESCRIPTION = "PayD is a decentralized payroll and payment platform built on Stellar and Soroban."
ORG_LOGO = "https://payd.example.com/logo.png"
ORG_OFFICIAL_EMAIL = "security@payd.example.com"

[[CURRENCIES]]
code = "ORGUSD"
issuer = "GD7TPWEDZCAD3TTMI7OGEDHHVH4QIJPKKXWKT3NIXOFMVA5QJ4BEBVLF"
display_decimal = 2
name = "PayD Organizational Dollar"
desc = "A stablecoin pegged to USD for payroll disbursements within the PayD platform."
status = "live"
conditions = "This asset is used for payroll and requires authorization from the issuer."
issuer = "GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5"
display_decimals = 2
name = "Org USD"
desc = "Organization-issued USD-denominated payroll asset for PayD deployments."
conditions = "Issued for payroll, escrow, and settlement flows in approved PayD deployments."
is_asset_anchored = true
anchor_asset_type = "other"
anchor_asset_type = "fiat"
anchor_asset = "USD"
funding_methods = "Direct issuance to distribution accounts."
35 changes: 23 additions & 12 deletions contracts/asset_path_payment/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![no_std]

use soroban_sdk::{
contract, contractimpl, contracttype, contracterror, contractevent,
Address, Env, String, Symbol, Vec, symbol_short, token
Address, Env, String, Symbol, Vec, contract, contracterror, contractevent, contractimpl,
contracttype, symbol_short, token,
};

/// Errors for path payment operations
Expand Down Expand Up @@ -123,7 +123,9 @@ impl AssetPathPaymentContract {
panic!("Already initialized");
}
env.storage().persistent().set(&DataKey::Admin, &admin);
env.storage().persistent().set(&DataKey::PaymentCount, &0u64);
env.storage()
.persistent()
.set(&DataKey::PaymentCount, &0u64);
Self::bump_core_ttl(&env);
}

Expand Down Expand Up @@ -171,14 +173,20 @@ impl AssetPathPaymentContract {
// Transfer source tokens to contract (escrow)
let token_client = token::Client::new(&env, &source_asset);
let contract_addr = env.current_contract_address();

token_client.transfer(&from, &contract_addr, &source_amount);

// Increment payment counter
Self::bump_core_ttl(&env);
let mut count: u64 = env.storage().persistent().get(&DataKey::PaymentCount).unwrap_or(0);
let mut count: u64 = env
.storage()
.persistent()
.get(&DataKey::PaymentCount)
.unwrap_or(0);
count += 1;
env.storage().persistent().set(&DataKey::PaymentCount, &count);
env.storage()
.persistent()
.set(&DataKey::PaymentCount, &count);
env.storage().persistent().extend_ttl(
&DataKey::PaymentCount,
PERSISTENT_TTL_THRESHOLD,
Expand Down Expand Up @@ -238,7 +246,8 @@ impl AssetPathPaymentContract {
Self::require_admin(&env);

let key = DataKey::Payment(payment_id);
let mut record: PathPaymentRecord = env.storage()
let mut record: PathPaymentRecord = env
.storage()
.temporary()
.get(&key)
.ok_or(PathPaymentError::PaymentNotFound)?;
Expand All @@ -253,7 +262,7 @@ impl AssetPathPaymentContract {
record.error_message = Some(String::from_str(&env, "Destination amount below minimum"));
record.partial_failure = true;
env.storage().temporary().set(&key, &record);

PathPaymentFailed {
payment_id,
error_code: PathPaymentError::SlippageExceeded as u32,
Expand Down Expand Up @@ -298,7 +307,8 @@ impl AssetPathPaymentContract {
Self::require_admin(&env);

let key = DataKey::Payment(payment_id);
let mut record: PathPaymentRecord = env.storage()
let mut record: PathPaymentRecord = env
.storage()
.temporary()
.get(&key)
.ok_or(PathPaymentError::PaymentNotFound)?;
Expand Down Expand Up @@ -328,7 +338,7 @@ impl AssetPathPaymentContract {
pub fn get_payment(env: Env, payment_id: u64) -> Option<PathPaymentRecord> {
let key = DataKey::Payment(payment_id);
let record: Option<PathPaymentRecord> = env.storage().temporary().get(&key);

if record.is_some() {
env.storage().temporary().extend_ttl(
&key,
Expand All @@ -343,7 +353,7 @@ impl AssetPathPaymentContract {
pub fn get_payment_count(env: Env) -> u64 {
let key = DataKey::PaymentCount;
let count = env.storage().persistent().get(&key).unwrap_or(0);

if env.storage().persistent().has(&key) {
env.storage().persistent().extend_ttl(
&key,
Expand Down Expand Up @@ -375,7 +385,8 @@ impl AssetPathPaymentContract {

/// Require admin authorization
fn require_admin(env: &Env) {
let admin: Address = env.storage()
let admin: Address = env
.storage()
.persistent()
.get(&DataKey::Admin)
.expect("Admin not set; contract may not be initialized");
Expand Down
Loading
Loading