-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dev_issues
* master: update Define RPC methods (#238)
- Loading branch information
Showing
8 changed files
with
257 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,5 @@ contents.xcworkspacedata | |
launch.json | ||
settings.json | ||
c_cpp_properties.json | ||
|
||
Tools/openrpc.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import Blockchain | ||
import Foundation | ||
import Utils | ||
|
||
public enum StateHandlers { | ||
public static let handlers: [any RPCHandler.Type] = [ | ||
GetKeys.self, | ||
GetStorage.self, | ||
] | ||
|
||
public static func getHandlers(source: ChainDataSource) -> [any RPCHandler] { | ||
[ | ||
GetKeys(source: source), | ||
GetStorage(source: source), | ||
] | ||
} | ||
|
||
public struct GetKeys: RPCHandler { | ||
public typealias Request = Request4<Data32, UInt32, Data32?, Data32?> | ||
public typealias Response = [String] | ||
|
||
public static var method: String { "state_getKeys" } | ||
public static var requestNames: [String] { ["prefix", "count", "startKey", "blockHash"] } | ||
public static var summary: String? { "Returns the keys of the state." } | ||
|
||
private let source: ChainDataSource | ||
|
||
init(source: ChainDataSource) { | ||
self.source = source | ||
} | ||
|
||
public func handle(request _: Request) async throws -> Response? { | ||
// TODO: implement | ||
[] | ||
} | ||
} | ||
|
||
public struct GetStorage: RPCHandler { | ||
public typealias Request = Request2<Data32, Data32?> | ||
public typealias Response = [String] | ||
|
||
public static var method: String { "state_getStorage" } | ||
public static var requestNames: [String] { ["key", "blockHash"] } | ||
public static var summary: String? { "Returns the storage entry for a key for blockHash or best head." } | ||
|
||
private let source: ChainDataSource | ||
|
||
init(source: ChainDataSource) { | ||
self.source = source | ||
} | ||
|
||
public func handle(request _: Request) async throws -> Response? { | ||
// TODO: implement | ||
[] | ||
} | ||
} | ||
} |
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
Oops, something went wrong.