Skip to content

Commit

Permalink
types: add new variants for ExecutionStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed Aug 20, 2024
1 parent 784ab7b commit bd233b6
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions crates/sui-sdk/src/types/execution_status.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use super::Address;
use super::Digest;
use super::Identifier;
use super::ObjectId;
Expand Down Expand Up @@ -167,6 +168,18 @@ pub enum ExecutionError {

/// Requested shared object has been deleted
InputObjectDeleted,

/// Certificate is cancelled due to congestion on shared objects
ExecutionCancelledDueToSharedObjectCongestion { congested_objects: Vec<ObjectId> },

/// Address is denied for this coin type
AddressDeniedForCoin { address: Address, coin_type: String },

/// Coin type is globally paused for use
CoinTypeGlobalPause { coin_type: String },

/// Certificate is cancelled because randomness could not be generated this epoch
ExecutionCancelledDueToRandomnessUnavailable,
}

#[derive(Eq, PartialEq, Clone, Debug)]
Expand Down Expand Up @@ -459,6 +472,20 @@ mod serialization {
SuiMoveVerificationTimedout,
SharedObjectOperationNotAllowed,
InputObjectDeleted,
ExecutionCancelledDueToSharedObjectCongestion {
congested_objects: Vec<ObjectId>,
},

AddressDeniedForCoin {
address: Address,
coin_type: String,
},

CoinTypeGlobalPause {
coin_type: String,
},

ExecutionCancelledDueToRandomnessUnavailable,
}

#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
Expand Down Expand Up @@ -528,6 +555,20 @@ mod serialization {
SuiMoveVerificationTimedout,
SharedObjectOperationNotAllowed,
InputObjectDeleted,
ExecutionCancelledDueToSharedObjectCongestion {
congested_objects: Vec<ObjectId>,
},

AddressDeniedForCoin {
address: Address,
coin_type: String,
},

CoinTypeGlobalPause {
coin_type: String,
},

ExecutionCancelledDueToRandomnessUnavailable,
}

impl Serialize for ExecutionError {
Expand Down Expand Up @@ -632,6 +673,20 @@ mod serialization {
ReadableExecutionError::SharedObjectOperationNotAllowed
}
Self::InputObjectDeleted => ReadableExecutionError::InputObjectDeleted,
Self::ExecutionCancelledDueToSharedObjectCongestion { congested_objects } => {
ReadableExecutionError::ExecutionCancelledDueToSharedObjectCongestion {
congested_objects,
}
}
Self::AddressDeniedForCoin { address, coin_type } => {
ReadableExecutionError::AddressDeniedForCoin { address, coin_type }
}
Self::CoinTypeGlobalPause { coin_type } => {
ReadableExecutionError::CoinTypeGlobalPause { coin_type }
}
Self::ExecutionCancelledDueToRandomnessUnavailable => {
ReadableExecutionError::ExecutionCancelledDueToRandomnessUnavailable
}
};
readable.serialize(serializer)
} else {
Expand Down Expand Up @@ -727,6 +782,20 @@ mod serialization {
BinaryExecutionError::SharedObjectOperationNotAllowed
}
Self::InputObjectDeleted => BinaryExecutionError::InputObjectDeleted,
Self::ExecutionCancelledDueToSharedObjectCongestion { congested_objects } => {
BinaryExecutionError::ExecutionCancelledDueToSharedObjectCongestion {
congested_objects,
}
}
Self::AddressDeniedForCoin { address, coin_type } => {
BinaryExecutionError::AddressDeniedForCoin { address, coin_type }
}
Self::CoinTypeGlobalPause { coin_type } => {
BinaryExecutionError::CoinTypeGlobalPause { coin_type }
}
Self::ExecutionCancelledDueToRandomnessUnavailable => {
BinaryExecutionError::ExecutionCancelledDueToRandomnessUnavailable
}
};
binary.serialize(serializer)
}
Expand Down Expand Up @@ -835,6 +904,18 @@ mod serialization {
Self::SharedObjectOperationNotAllowed
}
ReadableExecutionError::InputObjectDeleted => Self::InputObjectDeleted,
ReadableExecutionError::ExecutionCancelledDueToSharedObjectCongestion {
congested_objects,
} => Self::ExecutionCancelledDueToSharedObjectCongestion { congested_objects },
ReadableExecutionError::AddressDeniedForCoin { address, coin_type } => {
Self::AddressDeniedForCoin { address, coin_type }
}
ReadableExecutionError::CoinTypeGlobalPause { coin_type } => {
Self::CoinTypeGlobalPause { coin_type }
}
ReadableExecutionError::ExecutionCancelledDueToRandomnessUnavailable => {
Self::ExecutionCancelledDueToRandomnessUnavailable
}
})
} else {
BinaryExecutionError::deserialize(deserializer).map(|binary| match binary {
Expand Down Expand Up @@ -929,6 +1010,18 @@ mod serialization {
Self::SharedObjectOperationNotAllowed
}
BinaryExecutionError::InputObjectDeleted => Self::InputObjectDeleted,
BinaryExecutionError::ExecutionCancelledDueToSharedObjectCongestion {
congested_objects,
} => Self::ExecutionCancelledDueToSharedObjectCongestion { congested_objects },
BinaryExecutionError::AddressDeniedForCoin { address, coin_type } => {
Self::AddressDeniedForCoin { address, coin_type }
}
BinaryExecutionError::CoinTypeGlobalPause { coin_type } => {
Self::CoinTypeGlobalPause { coin_type }
}
BinaryExecutionError::ExecutionCancelledDueToRandomnessUnavailable => {
Self::ExecutionCancelledDueToRandomnessUnavailable
}
})
}
}
Expand Down

0 comments on commit bd233b6

Please sign in to comment.