This repository has been archived by the owner on Aug 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
/
EosioSerializationProviderProtocol.swift
79 lines (69 loc) · 4.33 KB
/
EosioSerializationProviderProtocol.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//
// EosioSerializationProviderProtocol.swift
// EosioSwift
//
// Created by Steve McCoole on 3/1/19.
// Copyright (c) 2017-2019 block.one and its contributors. All rights reserved.
//
import Foundation
/// The protocol to which serialization provider implementations must conform.
/// Serialization providers are responsible for ABI-driven transaction and action
/// serialization and deserialization between JSON and binary data representations.
public protocol EosioSerializationProviderProtocol {
/// Used to hold errors.
var error: String? { get }
/// Initializer for the `EosioSerializationProviderProtocol`.
init()
/// The method signature for general serialization requests to conforming serialization providers.
/// Carries out JSON to binary conversion using ABIs.
///
/// - Parameters:
/// - contract: An optional `String` representing contract name for the serialize action lookup for this conversion.
/// - name: An optional `String` representing an action name that is used in conjunction with contract (above) to derive the serialize type name.
/// - type: An optional `String` representing the type name for the action lookup for this serialize conversion.
/// - json: The JSON data `String` to serialize to binary.
/// - abi: A `String` representation of the ABI to use for conversion.
/// - Returns: A `String` of binary serialized data.
/// - Throws: If the data cannot be serialized for any reason.
func serialize(contract: String?, name: String, type: String?, json: String, abi: String) throws -> String
/// The method signature for general deserialization requests to conforming serialization providers.
/// Carries out binary to JSON conversion using ABIs.
///
/// - Parameters:
/// - contract: An optional `String` representing contract name for the deserialize action lookup for this conversion.
/// - name: An optional `String` representing an action name that is used in conjunction with contract (above) to derive the deserialize type name.
/// - type: An optional `String` representing the type name for the action lookup for this deserialize conversion.
/// - hex: The binary data `String` to deserialize to a JSON String.
/// - abi: A `String` representation of the ABI to use for conversion.
/// - Returns: A `String` of JSON data.
/// - Throws: If the data cannot be deserialized for any reason.
func deserialize(contract: String?, name: String, type: String?, hex: String, abi: String) throws -> String
/// The method signature for transaction serialization requests to conforming serialization providers.
/// Convert JSON Transaction data representation to binary `String` representation of Transaction data.
///
/// - Parameter json: The JSON representation of Transaction data to serialize.
/// - Returns: A binary `String` representation of Transaction data.
/// - Throws: If the data cannot be serialized for any reason.
func serializeTransaction(json: String) throws -> String
/// The method signature for transaction deserialization requests to conforming serialization providers.
/// Converts a binary `String` representation of Transaction data to JSON `String` of Transaction data.
///
/// - Parameter hex: The binary Transaction data `String` to deserialize.
/// - Returns: A `String` of JSON Transaction data.
/// - Throws: If the data cannot be deserialized for any reason.
func deserializeTransaction(hex: String) throws -> String
/// The method signature for ABI serialization requests to conforming serialization providers.
/// Convert JSON ABI to a `String` binary representation of data.
///
/// - Parameter json: The JSON data `String` to serialize.
/// - Returns: A `String` representation of binary data.
/// - Throws: If the data cannot be serialized for any reason.
func serializeAbi(json: String) throws -> String
/// The method signature for ABI deserialization requests to conforming serialization providers.
/// Converts a binary `String` hex representation of an ABI to a JSON `String`.
///
/// - Parameter hex: The binary data `String` to deserialize.
/// - Returns: A `String` of JSON data.
/// - Throws: If the data cannot be deserialized for any reason.
func deserializeAbi(hex: String) throws -> String
}