mirror of
https://github.com/hanzoai/swift-sdk.git
synced 2026-10-30 18:20:19 +00:00
The projection these were generated from predated the compute migration, so they described /v1/visor — which the API serves at zero paths now. No /v1/visor path survives here.
89 lines
5.1 KiB
Swift
89 lines
5.1 KiB
Swift
//
|
|
// Receipt.swift
|
|
//
|
|
// Generated by openapi-generator
|
|
// https://openapi-generator.tech
|
|
//
|
|
|
|
import Foundation
|
|
|
|
public struct Receipt: Sendable, Codable, ParameterConvertible, Hashable {
|
|
|
|
/** Amount is what actually moved, as an exact 18-decimal-place USD string. It is NOT the atomic-unit figure the client signed: the challenge quotes the asset's own units (USDC's 6 dp) and truncates to fit them, while the ledger moves this exact value. */
|
|
public var amount: String?
|
|
/** From is the payer's EVM address: the account that signed the EIP-3009 authorization, recovered from the signature rather than taken on trust. */
|
|
public var from: String?
|
|
/** ID is the settle-once key: \"x402_\" + keccak(from|nonce) in hex. It is DERIVED, not minted, so a client that re-submits the same authorization addresses the same settlement and is served again for free rather than charged twice. It is also the id GET /v1/x402/settlements/:id takes. */
|
|
public var id: String?
|
|
/** Network is the CAIP-2 identifier the payment was settled under, e.g. \"eip155:36963\". Its eip155 reference is the chain id in the EIP-712 domain the payer signed, so it is not a label — changing it invalidates the signature. */
|
|
public var network: String?
|
|
/** Nonce is the client-chosen nonce from the authorization, hex — up to 32 bytes, left-padded to the contract's bytes32. It is the replay anchor: the token contract refuses a second on-chain transfer for one (from, nonce), and this rail refuses a second settlement for the same pair, so a ledger settlement inherits the identical guarantee. */
|
|
public var nonce: String?
|
|
/** Payee is the recipient's EVM address — the `payTo` the challenge advertised and the authorization named. A payment to any other address never settles. */
|
|
public var payee: String?
|
|
/** PayeeOrg is the tenant that owns the recipient wallet, resolved at settlement. It is who got PAID, as Payer is who paid. */
|
|
public var payeeOrg: String?
|
|
/** Payer is the payer ORG — the tenant whose ledger was debited — and not an address. It is the org the request was authenticated as, so it answers who is billed, which the payer address alone cannot. */
|
|
public var payer: String?
|
|
/** Resource is what was paid for, in the same spelling the price table and the challenge used: the request path for a priced route, \"tool:<id>\" for a priced tool. */
|
|
public var resource: String?
|
|
/** SettledAt is when this settlement was CLAIMED, in unix seconds — the moment the authorization was accepted, which is also the moment the time window it carried stopped applying. A settlement finished later by reconciliation keeps this instant. */
|
|
public var settledAt: Int64?
|
|
/** SettledVia is which rail moved the money: \"ledger\", the live default, or \"chain\" when the authorization is broadcast. Those two values and no others. */
|
|
public var settledVia: String?
|
|
/** TxHash is the chain transaction hash, present only for a \"chain\" settlement. Empty on a ledger settlement — that is the normal case today, and it means the money moved without a chain, not that it failed. The wire's PAYMENT-RESPONSE `transaction` falls back to ID when this is empty. */
|
|
public var txHash: String?
|
|
|
|
public init(amount: String? = nil, from: String? = nil, id: String? = nil, network: String? = nil, nonce: String? = nil, payee: String? = nil, payeeOrg: String? = nil, payer: String? = nil, resource: String? = nil, settledAt: Int64? = nil, settledVia: String? = nil, txHash: String? = nil) {
|
|
self.amount = amount
|
|
self.from = from
|
|
self.id = id
|
|
self.network = network
|
|
self.nonce = nonce
|
|
self.payee = payee
|
|
self.payeeOrg = payeeOrg
|
|
self.payer = payer
|
|
self.resource = resource
|
|
self.settledAt = settledAt
|
|
self.settledVia = settledVia
|
|
self.txHash = txHash
|
|
}
|
|
|
|
public enum CodingKeys: String, CodingKey, CaseIterable {
|
|
case amount
|
|
case from
|
|
case id
|
|
case network
|
|
case nonce
|
|
case payee
|
|
case payeeOrg
|
|
case payer
|
|
case resource
|
|
case settledAt
|
|
case settledVia
|
|
case txHash
|
|
}
|
|
|
|
// Encodable protocol methods
|
|
|
|
public func encode(to encoder: Encoder) throws {
|
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
try container.encodeIfPresent(amount, forKey: .amount)
|
|
try container.encodeIfPresent(from, forKey: .from)
|
|
try container.encodeIfPresent(id, forKey: .id)
|
|
try container.encodeIfPresent(network, forKey: .network)
|
|
try container.encodeIfPresent(nonce, forKey: .nonce)
|
|
try container.encodeIfPresent(payee, forKey: .payee)
|
|
try container.encodeIfPresent(payeeOrg, forKey: .payeeOrg)
|
|
try container.encodeIfPresent(payer, forKey: .payer)
|
|
try container.encodeIfPresent(resource, forKey: .resource)
|
|
try container.encodeIfPresent(settledAt, forKey: .settledAt)
|
|
try container.encodeIfPresent(settledVia, forKey: .settledVia)
|
|
try container.encodeIfPresent(txHash, forKey: .txHash)
|
|
}
|
|
}
|
|
|
|
|
|
@available(iOS 13, tvOS 13, watchOS 6, macOS 10.15, *)
|
|
extension Receipt: Identifiable {}
|