Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOB-2208 - Prepare for MPC operation changes #684

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extension FB_UD_MPC {
enum OperationReadyResponse {
case txReady(txId: String)
case signed(signature: String)
case finished(txHash: String)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ extension FB_UD_MPC.MPCConnectionService: MPCWalletProviderSubServiceProtocol {
case .signed(let signature):
logMPC("It took \(Date().timeIntervalSince(start)) to sign message")
return signature
case .finished:
logMPC("It took \(Date().timeIntervalSince(start)) to sign message")
throw MPCConnectionServiceError.incorrectOperationState
}
}
}
Expand Down Expand Up @@ -306,6 +309,9 @@ extension FB_UD_MPC.MPCConnectionService: MPCWalletProviderSubServiceProtocol {
operationId: operationId)
logMPC("It took \(Date().timeIntervalSince(start)) to finish tx")
return txHash
case .finished(let txHash):
logMPC("It took \(Date().timeIntervalSince(start)) to finish tx")
return txHash
case .signed:
logMPC("It took \(Date().timeIntervalSince(start)) to finish tx")
throw MPCConnectionServiceError.incorrectOperationState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,12 @@ extension FB_UD_MPC {
}
return .txReady(txId: transactionId)
} else {
guard let signature = operation.result?.signature else {
throw MPCNetworkServiceError.missingSignatureInSignTransactionOperation
if let signature = operation.result?.signature {
return .signed(signature: signature)
} else if let txHash = operation.transaction?.id {
return .finished(txHash: txHash)
}
return .signed(signature: signature)
throw MPCNetworkServiceError.completedTransactionMissingResultValue
}
}

Expand All @@ -345,10 +347,10 @@ extension FB_UD_MPC {
let operation = try await waitForOperationStatuses(accessToken: accessToken,
operationId: operationId,
statuses: [.processing, .completed])
guard let signature = operation.transaction?.id else {
guard let txHash = operation.transaction?.id else {
throw MPCNetworkServiceError.missingTxIdInTransactionOperation
}
return signature
return txHash
}

func fetchCryptoPortfolioForMPC(wallet: String, accessToken: String) async throws -> [WalletTokenPortfolio] {
Expand Down Expand Up @@ -469,6 +471,7 @@ extension FB_UD_MPC {
case waitForKeyOperationStatusTimeout
case missingVendorIdInSignTransactionOperation
case missingSignatureInSignTransactionOperation
case completedTransactionMissingResultValue
case missingTxIdInTransactionOperation
case badRequestData
case operationFailed
Expand Down