RPCSession

public class RPCSession

A session that handles communication with the Solana JSON-RPC API.

  • Start a networked JSON-RPC session with a given node’s URL.

    Declaration

    Swift

    public init(url: URL)
  • Start a JSON-RPC session with a custom RPCRequestAdaptor conforming object. Use this initializer to build a custom debugging or testing pipeline.

    Declaration

    Swift

    public init(adaptor: RPCRequestAdaptor)
  • The active RPC Request Adapter used on this RPC Session. An RPCRequestAdaptor determines how RPC responses are sent through the Solana SDK. To build a custom debugging or testing pipeline, you can provide your own RPCRequestAdaptor conforming object.

    Declaration

    Swift

    public let requestAdaptor: RPCRequestAdaptor
  • Creates an automatically-connecting Combine publisher that responds to a given request. Since the request has not already been wrapped with TaggedRPCRequest, this will create an identifier and its tags without user intervention.

    Declaration

    Swift

    public func publisher<Request: RPCRequest>(for unwrappedRequest: Request)
        -> AnyPublisher<TaggedRPCResponse<Request.Response, SolanaNodeError>, Error>
  • Creates an automatically-connecting Combine publisher that responds to a given request.

    Declaration

    Swift

    public func publisher<Request: RPCRequest>(for request: TaggedRPCRequest<Request>)
        -> AnyPublisher<TaggedRPCResponse<Request.Response, SolanaNodeError>, Error>
  • Creates an automatically-connecting Combine publisher that emits signals from a web socket task created for a given request. Since the request has not already been wrapped with TaggedRPCRequest, this will create an identifier and its tags internally.

    Declaration

    Swift

    public func webSocketPublisher<Request: WebSocketRequest>(for untaggedRequest: Request)
    -> AnyPublisher<URLSessionWebSocketTask.Message, WebSocketError>
  • Creates an automatically-connecting Combine publisher that emits signals from a web socket task created for a given request.

    Declaration

    Swift

    public func webSocketPublisher<Request: WebSocketRequest>(for taggedRequest: TaggedRPCRequest<Request>)
    -> AnyPublisher<URLSessionWebSocketTask.Message, WebSocketError>
  • When Transaction Safe Mode is enabled, the framework will attempt to validate transactions before they are submitted to the chain. If a transaction is potentially dangerous or has inconsistent signatures, the framework will trigger a precondition failure, abort the action, and allow you to investigate the error.

    By default, Transaction Safe Mode is enabled when your app is built in a debug setting and disabled in production.

    Declaration

    Swift

    public var transactionSafeModeEnabled: Bool