OZSmartAccountAuthPayloadCodec
public enum OZSmartAccountAuthPayloadCodec
Codec for reading and writing OZSmartAccountAuthPayload to/from SCValXDR.
Handles the AuthPayload format accepted by the OpenZeppelin Smart Account contract,
which is a named struct (Map-based) with fields context_rule_ids and signers. The
outer struct map keys are inserted in alphabetical order (matching the Soroban Rust
#[contracttype] derive convention); the inner dynamic-Map signer entries are sorted
by lowercase-hex of their XDR-encoded keys so the encoding is deterministic.
-
Reads an
OZSmartAccountAuthPayloadfrom itsSCValXDRrepresentation.Accepts
SCValXDR.void(returns an empty payload) orSCValXDR.map(the full payload). Throws when the input is not Void or Map, or when a signer entry has a value that is not aBytesScVal.Throws
SmartAccountTransactionException.SigningFailedwhen the input shape is wrong.Declaration
Swift
public static func read(_ signatureScVal: SCValXDR) throws -> OZSmartAccountAuthPayloadParameters
signatureScValThe ScVal stored in the authorization entry credentials signature field.
Return Value
The decoded
OZSmartAccountAuthPayload. -
Writes an
OZSmartAccountAuthPayloadto itsSCValXDRrepresentation.Builds the outer map with exactly two entries in alphabetical insertion order (
context_rule_ids, thensigners), matching the Soroban Rust#[contracttype]derive ordering for the contract’sAuthPayloadstruct. Inner signer entries are sorted by lowercase-hex of their XDR-encoded keys so the encoding is deterministic and the host-side dynamic-Map ordering check is satisfied.Throws
SmartAccountTransactionException.SigningFailedwhen XDR encoding of a signer key fails.Declaration
Swift
public static func write(_ payload: OZSmartAccountAuthPayload) throws -> SCValXDRParameters
payloadPayload to encode.
Return Value
The
SCValXDRrepresentation of the payload. -
Upserts a signer entry in the payload.
If a signer matching
signeralready exists (compared by signer type and field values), the old entry is removed before the new one is appended. The payload’ssignerslist is mutated in place.Declaration
Swift
public static func upsertSigner( payload: OZSmartAccountAuthPayload, signer: any OZSmartAccountSigner, signatureBytes: Data )Parameters
payloadPayload to update.
signerSigner to add or replace.
signatureBytesSignature bytes from
OZSmartAccountSignature.toAuthPayloadBytes(). -
Parses an
OZSmartAccountSignerfrom itsSCValXDRrepresentation.Supported formats:
Vec([Symbol("Delegated"), Address(...)])returns anOZDelegatedSigner.Vec([Symbol("External"), Address(...), Bytes(...)])returns anOZExternalSigner.
Throws
SmartAccountTransactionException.SigningFailedwhen the shape is unrecognised.Declaration
Swift
public static func signerFromScVal(_ scVal: SCValXDR) throws -> any OZSmartAccountSignerParameters
scValThe ScVal to parse.
Return Value
The parsed signer.
View on GitHub
Install in Dash