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

ABW-2048 Handle Reserved Instructions #762

Merged
merged 1 commit into from
Sep 15, 2023
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
@@ -1,5 +1,5 @@

import ClientPrelude
import EngineKit

// MARK: - TransactionFailure
public enum TransactionFailure: Sendable, LocalizedError, Equatable {
Expand Down Expand Up @@ -51,6 +51,9 @@ extension TransactionFailure {
case .failedToSubmit:
return (errorKind: .failedToSubmitTransaction, message: nil)

case .failedToPrepareTXReview(.manifestWithReservedInstructions):
return (errorKind: .failedToPrepareTransaction, message: self.errorDescription)

// case let .failedToSubmit(error):
// switch error {
// case .failedToSubmitTX:
Expand Down Expand Up @@ -82,6 +85,7 @@ extension TransactionFailure {
case failedToRetrieveTXReceipt(String)
case failedToExtractTXReceiptBytes(Error)
case failedToGenerateTXReview(Error)
case manifestWithReservedInstructions([ReservedInstruction])

public var errorDescription: String? {
switch self {
Expand All @@ -95,6 +99,8 @@ extension TransactionFailure {
return "ET failed to generate TX review: \(error.localizedDescription)"
case let .failedToRetrieveTXReceipt(message):
return "Failed to retrive TX receipt from gateway: \(message)"
case .manifestWithReservedInstructions:
return "Transaction Manifest contains forbidden instructions"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ extension TransactionClient {
/// Analyze the manifest
let analyzedManifestToReview = try request.manifestToSign.analyzeExecution(transactionReceipt: receiptBytes)

guard analyzedManifestToReview.reservedInstructions.isEmpty else {
throw TransactionFailure.failedToPrepareTXReview(.manifestWithReservedInstructions(analyzedManifestToReview.reservedInstructions))
}

/// Get all of the expected signing factors.
let signingFactors = try await {
if let nonEmpty = NonEmpty<Set<EntityPotentiallyVirtual>>(transactionSigners.intentSignerEntitiesOrEmpty()) {
Expand Down
Loading