Skip to content

Commit

Permalink
fixed naming in services
Browse files Browse the repository at this point in the history
  • Loading branch information
ypopovych committed Nov 21, 2023
1 parent 56b7738 commit 00fd2e2
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Sources/TesseractClient/Protocols/SubstrateService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public final class SubstrateService: Service, TesseractShared.SubstrateService {
}.result.castError(TesseractError.self).get()
}

public func signTransation(
public func signTransaction(
type: TesseractShared.SubstrateAccountType, path: String,
extrinsic: Data, metadata: Data, types: Data
) async throws -> Data {
Expand Down
10 changes: 6 additions & 4 deletions Sources/TesseractService/Protocols/SubstrateService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private func substrate_service_get_account(
) -> CFuture_SubstrateGetAccountResponse {
CFuture_SubstrateGetAccountResponse {
await this.unowned((any SubstrateServiceResult).self).castError().asyncFlatMap {
await $0.getAccount(
await $0.getAccountRes(
type: TesseractShared.SubstrateAccountType(cvalue: accountType)
)
}
Expand All @@ -58,9 +58,11 @@ private func substrate_service_sign(
let types = types.copied()
return CFutureData {
await this.unowned((any SubstrateServiceResult).self).castError().asyncFlatMap {
await $0.signTransation(type: TesseractShared.SubstrateAccountType(cvalue: type),
path: path, extrinsic: extrinsic,
metadata: metadata, types: types)
await $0.signTransactionRes(
type: TesseractShared.SubstrateAccountType(cvalue: type),
path: path, extrinsic: extrinsic,
metadata: metadata, types: types
)
}
}
}
2 changes: 1 addition & 1 deletion Sources/TesseractService/Protocols/TestService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private func test_service_sign(this: UnsafePointer<CTesseract.TestService>!,
let req = req.copied()
return CFutureString {
await this.unowned((any TestServiceResult).self).castError().asyncFlatMap {
await $0.signTransaction(req: req)
await $0.signTransactionRes(req: req)
}
}
}
18 changes: 9 additions & 9 deletions Sources/TesseractShared/Protocols/SubstrateService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public struct SubstrateGetAccountResponse {
}

public protocol SubstrateServiceResult {
func getAccount(
func getAccountRes(
type: SubstrateAccountType
) async -> Result<SubstrateGetAccountResponse, TesseractError>

func signTransation(
func signTransactionRes(
type: SubstrateAccountType, path: String,
extrinsic: Data, metadata: Data, types: Data
) async -> Result<Data, TesseractError>
Expand All @@ -43,28 +43,28 @@ public protocol SubstrateService: SubstrateServiceResult {
type: SubstrateAccountType
) async throws -> SubstrateGetAccountResponse

func signTransation(
func signTransaction(
type: SubstrateAccountType, path: String,
extrinsic: Data, metadata: Data, types: Data
) async throws -> Data
}

public extension SubstrateService {
func getAccount(
func getAccountRes(
type: SubstrateAccountType
) async -> Result<SubstrateGetAccountResponse, TesseractError> {
await Result { try await getAccount(type: type) }
}

func signTransation(
func signTransactionRes(
type: SubstrateAccountType, path: String,
extrinsic: Data, metadata: Data, types: Data
) async -> Result<Data, TesseractError> {
await Result {
try await signTransation(type: type, path: path,
extrinsic: extrinsic,
metadata: metadata,
types: types)
try await signTransaction(type: type, path: path,
extrinsic: extrinsic,
metadata: metadata,
types: types)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/TesseractShared/Protocols/TestService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import TesseractTransportsShared
#endif

public protocol TestServiceResult {
func signTransaction(req: String) async -> Result<String, TesseractError>
func signTransactionRes(req: String) async -> Result<String, TesseractError>
}

public protocol TestService: TestServiceResult {
func signTransaction(req: String) async throws -> String
}

public extension TestService {
func signTransaction(req: String) async -> Result<String, TesseractError> {
func signTransactionRes(req: String) async -> Result<String, TesseractError> {
await Result { try await signTransaction(req: req) }
}
}
Expand Down

0 comments on commit 00fd2e2

Please sign in to comment.