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
36 changes: 36 additions & 0 deletions contracts/shipment/src/error_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,42 @@ pub fn error_info(error: NavinError) -> ContractErrorInfo {
NoRetry,
"Proposal salt was already used in a prior proposal; replay attack prevented.",
),
NavinError::InvalidShipmentParticipants => (
57,
InvalidInput,
NoRetry,
"Shipment sender, receiver, and carrier must be three distinct addresses.",
),
NavinError::InvalidShipmentDeadline => (
58,
InvalidInput,
NoRetry,
"Shipment deadline must be strictly in the future.",
),
NavinError::InvalidPaymentMilestones => (
59,
InvalidInput,
NoRetry,
"Payment milestone structure is invalid; each percentage must be 1-100.",
),
NavinError::DuplicatePaymentMilestone => (
60,
InvalidInput,
NoRetry,
"Payment milestone checkpoint names must be unique.",
),
NavinError::InvalidTokenAddress => (
61,
InvalidInput,
NoRetry,
"Shipment token address is invalid for this shipment.",
),
NavinError::InvalidPaymentMilestoneName => (
62,
InvalidInput,
NoRetry,
"Payment milestone checkpoint name has an invalid format.",
),
};

ContractErrorInfo {
Expand Down
12 changes: 12 additions & 0 deletions contracts/shipment/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,16 @@ pub enum NavinError {
CircularDependency = 55,
/// Proposal salt was already used in a prior proposal; replay attack prevented.
ProposalSaltReused = 56,
/// Shipment sender, receiver, and carrier addresses must be distinct.
InvalidShipmentParticipants = 57,
/// Shipment deadline must be strictly in the future.
InvalidShipmentDeadline = 58,
/// Payment milestone list is malformed or contains invalid percentages.
InvalidPaymentMilestones = 59,
/// Payment milestone checkpoint names must be unique.
DuplicatePaymentMilestone = 60,
/// Shipment token address is invalid.
InvalidTokenAddress = 61,
/// Payment milestone checkpoint name has an invalid format.
InvalidPaymentMilestoneName = 62,
}
29 changes: 26 additions & 3 deletions contracts/shipment/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ pub fn emit_shipment_created(
shipment_id: u64,
sender: &Address,
receiver: &Address,
token_address: &Address,
data_hash: &BytesN<32>,
) {
let event_counter = next_event_counter(env, shipment_id);
Expand All @@ -121,6 +122,7 @@ pub fn emit_shipment_created(
shipment_id,
sender.clone(),
receiver.clone(),
token_address.clone(),
data_hash.clone(),
EVENT_SCHEMA_VERSION,
event_counter,
Expand Down Expand Up @@ -285,7 +287,13 @@ pub fn emit_milestone_recorded(
/// // events::emit_escrow_deposited(&env, 1, &company_addr, 1000);
/// ```
#[allow(dead_code)]
pub fn emit_escrow_deposited(env: &Env, shipment_id: u64, from: &Address, amount: i128) {
pub fn emit_escrow_deposited(
env: &Env,
shipment_id: u64,
from: &Address,
token_address: &Address,
amount: i128,
) {
let event_counter = next_event_counter(env, shipment_id);
let idempotency_key = generate_idempotency_key(
env,
Expand All @@ -299,6 +307,7 @@ pub fn emit_escrow_deposited(env: &Env, shipment_id: u64, from: &Address, amount
(
shipment_id,
from.clone(),
token_address.clone(),
amount,
EVENT_SCHEMA_VERSION,
event_counter,
Expand Down Expand Up @@ -336,7 +345,13 @@ pub fn emit_escrow_deposited(env: &Env, shipment_id: u64, from: &Address, amount
/// ```rust
/// // events::emit_escrow_released(&env, 1, &carrier_addr, 1000);
/// ```
pub fn emit_escrow_released(env: &Env, shipment_id: u64, to: &Address, amount: i128) {
pub fn emit_escrow_released(
env: &Env,
shipment_id: u64,
to: &Address,
token_address: &Address,
amount: i128,
) {
let event_counter = next_event_counter(env, shipment_id);
let idempotency_key = generate_idempotency_key(
env,
Expand All @@ -350,6 +365,7 @@ pub fn emit_escrow_released(env: &Env, shipment_id: u64, to: &Address, amount: i
(
shipment_id,
to.clone(),
token_address.clone(),
amount,
EVENT_SCHEMA_VERSION,
event_counter,
Expand Down Expand Up @@ -387,7 +403,13 @@ pub fn emit_escrow_released(env: &Env, shipment_id: u64, to: &Address, amount: i
/// ```rust
/// // events::emit_escrow_refunded(&env, 1, &company_addr, 1000);
/// ```
pub fn emit_escrow_refunded(env: &Env, shipment_id: u64, to: &Address, amount: i128) {
pub fn emit_escrow_refunded(
env: &Env,
shipment_id: u64,
to: &Address,
token_address: &Address,
amount: i128,
) {
let event_counter = next_event_counter(env, shipment_id);
let idempotency_key = generate_idempotency_key(
env,
Expand All @@ -401,6 +423,7 @@ pub fn emit_escrow_refunded(env: &Env, shipment_id: u64, to: &Address, amount: i
(
shipment_id,
to.clone(),
token_address.clone(),
amount,
EVENT_SCHEMA_VERSION,
event_counter,
Expand Down
Loading
Loading