-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from novasamatech/feature/runtime-api-in-v15
Add support for runtime api for v15
- Loading branch information
Showing
9 changed files
with
146 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
SubstrateSdk/Classes/Runtime/Metadata/RuntimeApi/RuntimeApiMetadata.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Foundation | ||
import BigInt | ||
|
||
public struct RuntimeApiMetadata { | ||
public let name: String | ||
public let methods: [RuntimeApiMethodMetadata] | ||
public let docs: [String] | ||
} | ||
|
||
extension RuntimeApiMetadata: ScaleCodable { | ||
public func encode(scaleEncoder: ScaleEncoding) throws { | ||
try name.encode(scaleEncoder: scaleEncoder) | ||
try methods.encode(scaleEncoder: scaleEncoder) | ||
try docs.encode(scaleEncoder: scaleEncoder) | ||
} | ||
|
||
public init(scaleDecoder: ScaleDecoding) throws { | ||
name = try String(scaleDecoder: scaleDecoder) | ||
methods = try [RuntimeApiMethodMetadata](scaleDecoder: scaleDecoder) | ||
docs = try [String](scaleDecoder: scaleDecoder) | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
SubstrateSdk/Classes/Runtime/Metadata/RuntimeApi/RuntimeApiMetadataMethod.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import Foundation | ||
import BigInt | ||
|
||
public struct RuntimeApiMethodMetadata { | ||
public let name: String | ||
public let inputs: [RuntimeApiMethodParamMetadata] | ||
public let output: SiLookupId | ||
public let docs: [String] | ||
} | ||
|
||
extension RuntimeApiMethodMetadata: ScaleCodable { | ||
public func encode(scaleEncoder: ScaleEncoding) throws { | ||
try name.encode(scaleEncoder: scaleEncoder) | ||
try inputs.encode(scaleEncoder: scaleEncoder) | ||
try BigUInt(output).encode(scaleEncoder: scaleEncoder) | ||
try docs.encode(scaleEncoder: scaleEncoder) | ||
} | ||
|
||
public init(scaleDecoder: ScaleDecoding) throws { | ||
name = try String(scaleDecoder: scaleDecoder) | ||
inputs = try [RuntimeApiMethodParamMetadata](scaleDecoder: scaleDecoder) | ||
output = try SiLookupId(BigUInt(scaleDecoder: scaleDecoder)) | ||
docs = try [String](scaleDecoder: scaleDecoder) | ||
} | ||
} | ||
|
||
public struct RuntimeApiMethodParamMetadata { | ||
public let name: String | ||
public let paramType: SiLookupId | ||
} | ||
|
||
extension RuntimeApiMethodParamMetadata: ScaleCodable { | ||
public func encode(scaleEncoder: ScaleEncoding) throws { | ||
try name.encode(scaleEncoder: scaleEncoder) | ||
try BigUInt(paramType).encode(scaleEncoder: scaleEncoder) | ||
} | ||
|
||
public init(scaleDecoder: ScaleDecoding) throws { | ||
name = try String(scaleDecoder: scaleDecoder) | ||
paramType = try SiLookupId(BigUInt(scaleDecoder: scaleDecoder)) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
SubstrateSdk/Classes/Runtime/Metadata/RuntimeApi/RuntimeApiQueryResult.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Foundation | ||
|
||
public struct RuntimeApiQueryResult { | ||
public let callName: String | ||
public let method: RuntimeApiMethodMetadata | ||
|
||
public init(callName: String, method: RuntimeApiMethodMetadata) { | ||
self.callName = callName | ||
self.method = method | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters