//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `external/sign`. Version: `0.1`.
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
///The custodian context that owns the account. Act scope in this context decides who may manage the account and who may consume it; the account's keys are derived in this context's key space.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "AccountContextId",
/// "description": "The custodian context that owns the account. Act scope in this context decides who may manage the account and who may consume it; the account's keys are derived in this context's key space.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct AccountContextId(::std::string::String);
impl ::std::ops::Deref for AccountContextId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<AccountContextId> for ::std::string::String {
fn from(value: AccountContextId) -> Self {
value.0
}
}
impl ::std::str::FromStr for AccountContextId {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 256usize {
return Err("longer than 256 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for AccountContextId {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for AccountContextId {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for AccountContextId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for AccountContextId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///The account's identifier within its context, chosen by whoever creates it. Lowercase letters, digits and hyphens, so that it can be embedded in a certificate subject, a token subject or a provider-side condition without escaping. Unique per context; never reused after deletion while anything that names it (a provider-side trust policy, an audit row) may still exist.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "AccountId",
/// "description": "The account's identifier within its context, chosen by whoever creates it. Lowercase letters, digits and hyphens, so that it can be embedded in a certificate subject, a token subject or a provider-side condition without escaping. Unique per context; never reused after deletion while anything that names it (a provider-side trust policy, an audit row) may still exist.",
/// "type": "string",
/// "maxLength": 64,
/// "minLength": 1,
/// "pattern": "^[a-z0-9][a-z0-9-]*$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct AccountId(::std::string::String);
impl ::std::ops::Deref for AccountId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<AccountId> for ::std::string::String {
fn from(value: AccountId) -> Self {
value.0
}
}
impl ::std::str::FromStr for AccountId {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 64usize {
return Err("longer than 64 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| ::regress::Regex::new("^[a-z0-9][a-z0-9-]*$").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[a-z0-9][a-z0-9-]*$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for AccountId {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for AccountId {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for AccountId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for AccountId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Ext",
/// "description": "Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.",
/// "type": "object",
/// "minProperties": 1,
/// "additionalProperties": true,
/// "propertyNames": {
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
/// }
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct Ext(pub ::std::collections::HashMap<ExtKey, ::serde_json::Value>);
impl ::std::ops::Deref for Ext {
type Target = ::std::collections::HashMap<ExtKey, ::serde_json::Value>;
fn deref(&self) -> &::std::collections::HashMap<ExtKey, ::serde_json::Value> {
&self.0
}
}
impl ::std::convert::From<Ext> for ::std::collections::HashMap<ExtKey, ::serde_json::Value> {
fn from(value: Ext) -> Self {
value.0
}
}
impl ::std::convert::From<::std::collections::HashMap<ExtKey, ::serde_json::Value>> for Ext {
fn from(value: ::std::collections::HashMap<ExtKey, ::serde_json::Value>) -> Self {
Self(value)
}
}
///`ExtKey`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ExtKey(::std::string::String);
impl ::std::ops::Deref for ExtKey {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ExtKey> for ::std::string::String {
fn from(value: ExtKey) -> Self {
value.0
}
}
impl ::std::str::FromStr for ExtKey {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ExtKey {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Have a sui-signer external account sign an allow-listed Sui transaction. The custodian builds the digest; no caller-supplied digest or bytes-to-sign are accepted. The outer document members are owned by the framework — SPEC §6.3.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/external/sign/0.1",
/// "title": "Payload",
/// "description": "Have a sui-signer external account sign an allow-listed Sui transaction. The custodian builds the digest; no caller-supplied digest or bytes-to-sign are accepted. The outer document members are owned by the framework — SPEC §6.3.",
/// "type": "object",
/// "required": [
/// "account",
/// "context",
/// "txBytes"
/// ],
/// "properties": {
/// "account": {
/// "$ref": "#/definitions/AccountId"
/// },
/// "context": {
/// "$ref": "#/definitions/AccountContextId"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "txBytes": {
/// "description": "The unsigned transaction: BCS-encoded Sui `TransactionData`, standard base64 as Sui tooling emits it. Bounded at 128 KiB decoded, Sui's own transaction size limit.",
/// "type": "string",
/// "maxLength": 174764,
/// "minLength": 4,
/// "pattern": "^[A-Za-z0-9+/]+={0,2}$"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
pub account: AccountId,
pub context: AccountContextId,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///The unsigned transaction: BCS-encoded Sui `TransactionData`, standard base64 as Sui tooling emits it. Bounded at 128 KiB decoded, Sui's own transaction size limit.
#[serde(rename = "txBytes")]
pub tx_bytes: PayloadTxBytes,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///The unsigned transaction: BCS-encoded Sui `TransactionData`, standard base64 as Sui tooling emits it. Bounded at 128 KiB decoded, Sui's own transaction size limit.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The unsigned transaction: BCS-encoded Sui `TransactionData`, standard base64 as Sui tooling emits it. Bounded at 128 KiB decoded, Sui's own transaction size limit.",
/// "type": "string",
/// "maxLength": 174764,
/// "minLength": 4,
/// "pattern": "^[A-Za-z0-9+/]+={0,2}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadTxBytes(::std::string::String);
impl ::std::ops::Deref for PayloadTxBytes {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadTxBytes> for ::std::string::String {
fn from(value: PayloadTxBytes) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadTxBytes {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 174764usize {
return Err("longer than 174764 characters".into());
}
if value.chars().count() < 4usize {
return Err("shorter than 4 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| ::regress::Regex::new("^[A-Za-z0-9+/]+={0,2}$").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[A-Za-z0-9+/]+={0,2}$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadTxBytes {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for PayloadTxBytes {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for PayloadTxBytes {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for PayloadTxBytes {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`Response`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "type": "object",
/// "required": [
/// "digest",
/// "signature"
/// ],
/// "properties": {
/// "digest": {
/// "description": "The transaction digest the custodian computed, base58 as Sui displays it, so the caller can match it to the transaction it submits.",
/// "type": "string",
/// "maxLength": 64,
/// "minLength": 32,
/// "pattern": "^[1-9A-HJ-NP-Za-km-z]+$"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "signature": {
/// "description": "Sui serialized signature, base64: the scheme flag (0x02 for secp256r1), the 64-byte signature and the 33-byte compressed public key.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 4,
/// "pattern": "^[A-Za-z0-9+/]+={0,2}$"
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
///The transaction digest the custodian computed, base58 as Sui displays it, so the caller can match it to the transaction it submits.
pub digest: ResponseDigest,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Sui serialized signature, base64: the scheme flag (0x02 for secp256r1), the 64-byte signature and the 33-byte compressed public key.
pub signature: ResponseSignature,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///The transaction digest the custodian computed, base58 as Sui displays it, so the caller can match it to the transaction it submits.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The transaction digest the custodian computed, base58 as Sui displays it, so the caller can match it to the transaction it submits.",
/// "type": "string",
/// "maxLength": 64,
/// "minLength": 32,
/// "pattern": "^[1-9A-HJ-NP-Za-km-z]+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseDigest(::std::string::String);
impl ::std::ops::Deref for ResponseDigest {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseDigest> for ::std::string::String {
fn from(value: ResponseDigest) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseDigest {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 64usize {
return Err("longer than 64 characters".into());
}
if value.chars().count() < 32usize {
return Err("shorter than 32 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^[1-9A-HJ-NP-Za-km-z]+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[1-9A-HJ-NP-Za-km-z]+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ResponseDigest {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ResponseDigest {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ResponseDigest {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ResponseDigest {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Sui serialized signature, base64: the scheme flag (0x02 for secp256r1), the 64-byte signature and the 33-byte compressed public key.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Sui serialized signature, base64: the scheme flag (0x02 for secp256r1), the 64-byte signature and the 33-byte compressed public key.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 4,
/// "pattern": "^[A-Za-z0-9+/]+={0,2}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseSignature(::std::string::String);
impl ::std::ops::Deref for ResponseSignature {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseSignature> for ::std::string::String {
fn from(value: ResponseSignature) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseSignature {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 256usize {
return Err("longer than 256 characters".into());
}
if value.chars().count() < 4usize {
return Err("shorter than 4 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| ::regress::Regex::new("^[A-Za-z0-9+/]+={0,2}$").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[A-Za-z0-9+/]+={0,2}$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ResponseSignature {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ResponseSignature {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ResponseSignature {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ResponseSignature {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Payload {
account: ::std::result::Result<super::AccountId, ::std::string::String>,
context: ::std::result::Result<super::AccountContextId, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
tx_bytes: ::std::result::Result<super::PayloadTxBytes, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
account: Err("no value supplied for account".to_string()),
context: Err("no value supplied for context".to_string()),
ext: Ok(Default::default()),
tx_bytes: Err("no value supplied for tx_bytes".to_string()),
}
}
}
impl Payload {
pub fn account<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::AccountId>,
T::Error: ::std::fmt::Display,
{
self.account = value
.try_into()
.map_err(|e| format!("error converting supplied value for account: {e}"));
self
}
pub fn context<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::AccountContextId>,
T::Error: ::std::fmt::Display,
{
self.context = value
.try_into()
.map_err(|e| format!("error converting supplied value for context: {e}"));
self
}
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
pub fn tx_bytes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadTxBytes>,
T::Error: ::std::fmt::Display,
{
self.tx_bytes = value
.try_into()
.map_err(|e| format!("error converting supplied value for tx_bytes: {e}"));
self
}
}
impl ::std::convert::TryFrom<Payload> for super::Payload {
type Error = super::error::ConversionError;
fn try_from(value: Payload) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
account: value.account?,
context: value.context?,
ext: value.ext?,
tx_bytes: value.tx_bytes?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
account: Ok(value.account),
context: Ok(value.context),
ext: Ok(value.ext),
tx_bytes: Ok(value.tx_bytes),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
digest: ::std::result::Result<super::ResponseDigest, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
signature: ::std::result::Result<super::ResponseSignature, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
digest: Err("no value supplied for digest".to_string()),
ext: Ok(Default::default()),
signature: Err("no value supplied for signature".to_string()),
}
}
}
impl Response {
pub fn digest<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseDigest>,
T::Error: ::std::fmt::Display,
{
self.digest = value
.try_into()
.map_err(|e| format!("error converting supplied value for digest: {e}"));
self
}
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
pub fn signature<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseSignature>,
T::Error: ::std::fmt::Display,
{
self.signature = value
.try_into()
.map_err(|e| format!("error converting supplied value for signature: {e}"));
self
}
}
impl ::std::convert::TryFrom<Response> for super::Response {
type Error = super::error::ConversionError;
fn try_from(value: Response) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
digest: value.digest?,
ext: value.ext?,
signature: value.signature?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
digest: Ok(value.digest),
ext: Ok(value.ext),
signature: Ok(value.signature),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/external/sign/0.1";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"AccountContextId\": {\n \"description\": \"The custodian context that owns the account. Act scope in this context decides who may manage the account and who may consume it; the account's keys are derived in this context's key space.\",\n \"maxLength\": 256,\n \"minLength\": 1,\n \"title\": \"AccountContextId\",\n \"type\": \"string\"\n },\n \"AccountId\": {\n \"description\": \"The account's identifier within its context, chosen by whoever creates it. Lowercase letters, digits and hyphens, so that it can be embedded in a certificate subject, a token subject or a provider-side condition without escaping. Unique per context; never reused after deletion while anything that names it (a provider-side trust policy, an audit row) may still exist.\",\n \"maxLength\": 64,\n \"minLength\": 1,\n \"pattern\": \"^[a-z0-9][a-z0-9-]*$\",\n \"title\": \"AccountId\",\n \"type\": \"string\"\n },\n \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"properties\": {\n \"digest\": {\n \"description\": \"The transaction digest the custodian computed, base58 as Sui displays it, so the caller can match it to the transaction it submits.\",\n \"maxLength\": 64,\n \"minLength\": 32,\n \"pattern\": \"^[1-9A-HJ-NP-Za-km-z]+$\",\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"signature\": {\n \"description\": \"Sui serialized signature, base64: the scheme flag (0x02 for secp256r1), the 64-byte signature and the 33-byte compressed public key.\",\n \"maxLength\": 256,\n \"minLength\": 4,\n \"pattern\": \"^[A-Za-z0-9+/]+={0,2}$\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"signature\",\n \"digest\"\n ],\n \"title\": \"External — Sign — response payload\",\n \"type\": \"object\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/external/sign/0.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"Have a sui-signer external account sign an allow-listed Sui transaction. The custodian builds the digest; no caller-supplied digest or bytes-to-sign are accepted. The outer document members are owned by the framework — SPEC §6.3.\",\n \"properties\": {\n \"account\": {\n \"$ref\": \"#/$defs/AccountId\"\n },\n \"context\": {\n \"$ref\": \"#/$defs/AccountContextId\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"txBytes\": {\n \"description\": \"The unsigned transaction: BCS-encoded Sui `TransactionData`, standard base64 as Sui tooling emits it. Bounded at 128 KiB decoded, Sui's own transaction size limit.\",\n \"maxLength\": 174764,\n \"minLength\": 4,\n \"pattern\": \"^[A-Za-z0-9+/]+={0,2}$\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"context\",\n \"account\",\n \"txBytes\"\n ],\n \"title\": \"External — Sign — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/external/sign/0.1#response";
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"AccountContextId\": {\n \"description\": \"The custodian context that owns the account. Act scope in this context decides who may manage the account and who may consume it; the account's keys are derived in this context's key space.\",\n \"maxLength\": 256,\n \"minLength\": 1,\n \"title\": \"AccountContextId\",\n \"type\": \"string\"\n },\n \"AccountId\": {\n \"description\": \"The account's identifier within its context, chosen by whoever creates it. Lowercase letters, digits and hyphens, so that it can be embedded in a certificate subject, a token subject or a provider-side condition without escaping. Unique per context; never reused after deletion while anything that names it (a provider-side trust policy, an audit row) may still exist.\",\n \"maxLength\": 64,\n \"minLength\": 1,\n \"pattern\": \"^[a-z0-9][a-z0-9-]*$\",\n \"title\": \"AccountId\",\n \"type\": \"string\"\n },\n \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"properties\": {\n \"digest\": {\n \"description\": \"The transaction digest the custodian computed, base58 as Sui displays it, so the caller can match it to the transaction it submits.\",\n \"maxLength\": 64,\n \"minLength\": 32,\n \"pattern\": \"^[1-9A-HJ-NP-Za-km-z]+$\",\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"signature\": {\n \"description\": \"Sui serialized signature, base64: the scheme flag (0x02 for secp256r1), the 64-byte signature and the 33-byte compressed public key.\",\n \"maxLength\": 256,\n \"minLength\": 4,\n \"pattern\": \"^[A-Za-z0-9+/]+={0,2}$\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"signature\",\n \"digest\"\n ],\n \"title\": \"External — Sign — response payload\",\n \"type\": \"object\"\n }\n },\n \"$ref\": \"#/$defs/Response\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\n}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// The extended error codes this specification declares (SPEC §7.3 item 9,
/// §8.5), in declaration order. Empty when it declares none.
pub const ERROR_CODES: &[crate::DeclaredErrorCode] = &[
error_codes::NOT_FOUND,
error_codes::NOT_ACTIVE,
error_codes::NOT_BOUND,
error_codes::RATE_LIMITED,
error_codes::NOT_SIGN_ONLY,
error_codes::UNDECODABLE,
error_codes::SENDER_MISMATCH,
error_codes::CALL_NOT_ALLOWED,
error_codes::OBJECT_NOT_ALLOWED,
error_codes::GAS_BUDGET_EXCEEDED,
error_codes::COIN_OUT_EXCEEDED,
error_codes::WRONG_NETWORK,
];
/// One constant per extended error code this specification declares
/// (SPEC §7.3 item 9), named for its local part.
///
/// Emit these rather than a string literal: the code is read from the
/// specification, so it cannot name a code the specification never
/// declared.
pub mod error_codes {
/// `external:notFound`
///
/// No account with this id exists in the named context that the caller may see. See the family conventions §2.
///
/// Declared `retryable: false`.
pub const NOT_FOUND: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "external:notFound",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `external:notActive`
///
/// The account is `suspended` or `archived` and cannot be used.
///
/// Declared `retryable: false`.
pub const NOT_ACTIVE: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "external:notActive",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `external:notBound`
///
/// The caller is not the consumer of any binding on this account.
///
/// Declared `retryable: false`.
pub const NOT_BOUND: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "external:notBound",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `external:rateLimited`
///
/// The binding's rate is exhausted. `details.retryAfterSeconds` says when to try again.
///
/// Declared `retryable: true`.
/// Declares a `detailsSchema` for the error's `details` member.
pub const RATE_LIMITED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "external:rateLimited",
retryable: true,
details_schema: ::core::option::Option::Some(
"{\"additionalProperties\":false,\"properties\":{\"retryAfterSeconds\":{\"minimum\":1,\"type\":\"integer\"}},\"required\":[\"retryAfterSeconds\"],\"type\":\"object\"}",
),
};
/// `external/sign:notSignOnly`
///
/// The account's model is not `sui-signer`.
///
/// Declared `retryable: false`.
pub const NOT_SIGN_ONLY: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "external/sign:notSignOnly",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `external/sign:undecodable`
///
/// `txBytes` is not a BCS-encoded Sui `TransactionData` of a kind the custodian decodes (only programmable transactions are signed).
///
/// Declared `retryable: false`.
pub const UNDECODABLE: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "external/sign:undecodable",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `external/sign:senderMismatch`
///
/// The transaction's sender, or its gas owner, is not the account's address. Sponsored transactions are not signed.
///
/// Declared `retryable: false`.
pub const SENDER_MISMATCH: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "external/sign:senderMismatch",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `external/sign:callNotAllowed`
///
/// A command calls a Move function, or uses a command kind, the account does not allow. `details` names the first one.
///
/// Declared `retryable: false`.
/// Declares a `detailsSchema` for the error's `details` member.
pub const CALL_NOT_ALLOWED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "external/sign:callNotAllowed",
retryable: false,
details_schema: ::core::option::Option::Some(
"{\"additionalProperties\":false,\"properties\":{\"commandIndex\":{\"minimum\":0,\"type\":\"integer\"},\"commandKind\":{\"maxLength\":64,\"type\":\"string\"},\"function\":{\"maxLength\":128,\"type\":\"string\"},\"module\":{\"maxLength\":128,\"type\":\"string\"},\"package\":{\"maxLength\":66,\"type\":\"string\"}},\"type\":\"object\"}",
),
};
/// `external/sign:objectNotAllowed`
///
/// The transaction takes a shared object the account does not allow.
///
/// Declared `retryable: false`.
pub const OBJECT_NOT_ALLOWED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "external/sign:objectNotAllowed",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `external/sign:gasBudgetExceeded`
///
/// The gas budget exceeds the account's per-transaction cap, or would take the rolling 24-hour total past its daily cap.
///
/// Declared `retryable: false`.
pub const GAS_BUDGET_EXCEEDED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "external/sign:gasBudgetExceeded",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `external/sign:coinOutExceeded`
///
/// The transaction would move a coin out of the account's address beyond its per-transaction cap, or a coin type the account may not spend at all.
///
/// Declared `retryable: false`.
pub const COIN_OUT_EXCEEDED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "external/sign:coinOutExceeded",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `external/sign:wrongNetwork`
///
/// The transaction's expiration or referenced objects are inconsistent with the account's network.
///
/// Declared `retryable: false`.
pub const WRONG_NETWORK: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "external/sign:wrongNetwork",
retryable: false,
details_schema: ::core::option::Option::None,
};
}