OperationService
public class OperationService
Several classes need to use pieces of the forge-sign-parse-preapply-inject flow. This class abstracts those functions away so that it can be shared throughout the library.
-
The configuration object containing all the necessary settings to connect and communicate with the Tezos node
Declaration
Swift
public let config: TezosNodeClientConfig -
The
NetworkServiceobject that will perform all the networking callsDeclaration
Swift
public let networkService: NetworkService
-
Init a
TezosNodeClientwith aTezosNodeClientConfig.Declaration
Swift
public init(config: TezosNodeClientConfig = TezosNodeClientConfig(withDefaultsForNetworkType: .mainnet), networkService: NetworkService)Parameters
configA configuration object containing all the necessary settings to connect and communicate with the Tezos node.
-
When using remote forging, every
Operationneeds to be Forged, Parsed, Signed, Preapply’d and Injected to make its way into the blockchain. This function will complete all of those steps and return an OperationID or an Error.Declaration
Swift
public func remoteForgeParseSignPreapplyInject(operationMetadata: OperationMetadata, operationPayload: OperationPayload, wallet: Wallet, completion: @escaping ((Result<String, KukaiError>) -> Void))Parameters
operationMetadataThe latest
OperationMetadatafrom the TezosNodeClientoperationPayloadThe
OperationPayloadgenerated by theOperationFactorywalletThe
Walletthat will sign the operationcompletionCompletion block either returning a String containing an OperationHash of the injected Operation, or an Error
-
When using local forging, every
Operationneeds to be Forged, Signed, Preapply’d and Injected to make its way into the blockchain. This function will complete all of those steps and return an OperationID or an Error.Declaration
Swift
public func localForgeSignPreapplyInject(operationMetadata: OperationMetadata, operationPayload: OperationPayload, wallet: Wallet, completion: @escaping ((Result<String, KukaiError>) -> Void))Parameters
operationMetadataThe latest
OperationMetadatafrom the TezosNodeClientoperationPayloadThe
OperationPayloadgenerated by theOperationFactorywalletThe
Walletthat will sign the operationcompletionCompletion block either returning a String containing an OperationHash of the injected Operation, or an Error
-
preapplyAndInject(forgedOperation:signature: signatureCurve: operationPayload: operationMetadata: completion: ) Preapply and Inject wrapped up as one function, for situations like Ledger Wallets, where signing is a complately different process, and must be done elsewhere
Declaration
Swift
public func preapplyAndInject(forgedOperation: String, signature: [UInt8], signatureCurve: EllipticalCurve, operationPayload: OperationPayload, operationMetadata: OperationMetadata, completion: @escaping ((Result<String, KukaiError>) -> Void))Parameters
forgedOperationThe forged operation hex without a watermark.
signatureBinary representation of the signed operation forge.
signatureCurveThe curve used to sign the forge.
operationPayloadThe payload to be sent.
operationMetadataThe metadata required to send the payload.
completioncallback with a forged hash or an error.
-
Forge an
OperationPayloadremotely, so it can be sent to the RPC.Declaration
Swift
public func remoteForge(operationPayload: OperationPayload, completion: @escaping ((Result<String, KukaiError>) -> Void))Parameters
operationPayloadcreated from
OperationFactory.operationPayload().walletThe
Walletobject that will sign the operations.completioncallback with a forged hash or an error.
-
Parse a forged
OperationPayloadon a different server to ensure nobody maliciously tampared with the request.Declaration
Swift
public func remoteParse(forgeResult: Result<String, KukaiError>, operationMetadata: OperationMetadata, operationPayload: OperationPayload, completion: @escaping ((Result<String, KukaiError>) -> Void))Parameters
forgeResultThe
Resultobject from theforge(...)function.operationMetadatafetched from
getOperationMetadata(...).operationPayloadthe
OperationPayloadto compare against to ensure it matches.completioncallback which just returns success or failure with an error.
-
Preapply a signed
OperationPayloadto check for any errors.Declaration
Swift
public func preapply(operationPayload: OperationPayload, completion: @escaping ((Result<[OperationResponse], KukaiError>) -> Void))Parameters
operationMetadataFetched from
getOperationMetadata(...).operationPayloadAn
OperationPayloadthat has had a signature and a protcol added to it.completionCallback which just returns success or failure with an error.
-
Inject a signed bytes to become part of the next block on the blockchain
Declaration
Swift
public func inject(signedBytes: String, handlePreapplyResult: Result<[OperationResponse], KukaiError>?, completion: @escaping ((Result<String, KukaiError>) -> Void))Parameters
signedBytesThe result of the forge operation (as a string) with the signature (as a hex string) appended on.
handlePreapplyResultOptionally pass in the result of the preapply function to reduce the indentation required to perform the full set of operations. Any error will be returned via the injection Result object.
Install in Dash