Skip to content

Apply Operations types#97

Open
Sotatek-Patrick-Vu wants to merge 20 commits into
chore/regenfrom
feat/ApplyOperationTypes
Open

Apply Operations types#97
Sotatek-Patrick-Vu wants to merge 20 commits into
chore/regenfrom
feat/ApplyOperationTypes

Conversation

@Sotatek-Patrick-Vu
Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread src/main/java/org/cardanofoundation/signify/app/aiding/IdentifierController.java Outdated
Comment thread src/main/java/org/cardanofoundation/signify/app/aiding/IdentifierController.java Outdated
Comment thread src/main/java/org/cardanofoundation/signify/app/aiding/IdentifierController.java Outdated
Comment thread src/main/java/org/cardanofoundation/signify/app/aiding/IdentifierController.java Outdated
Comment thread src/main/java/org/cardanofoundation/signify/app/coring/Operations.java Outdated
Comment thread src/test/java/org/cardanofoundation/signify/app/OperationsTest.java
Comment thread src/test/java/org/cardanofoundation/signify/e2e/utils/TestUtils.java Outdated
Comment thread src/test/java/org/cardanofoundation/signify/e2e/utils/TestUtils.java Outdated
Comment thread src/test/java/org/cardanofoundation/signify/e2e/MultisigJoinTest.java Outdated
Comment thread src/main/java/org/cardanofoundation/signify/app/coring/OperationDeserializer.java Outdated
Comment thread src/main/java/org/cardanofoundation/signify/app/aiding/IdentifierController.java Outdated
Comment thread build.gradle
Comment thread src/test/java/org/cardanofoundation/signify/e2e/utils/TestUtils.java Outdated
Comment thread src/main/java/org/cardanofoundation/signify/app/coring/OperationDeserializer.java Outdated
Comment thread src/main/java/org/cardanofoundation/signify/app/coring/Operations.java Outdated
Comment thread src/test/java/org/cardanofoundation/signify/e2e/utils/TestUtils.java Outdated
Comment thread src/main/java/org/cardanofoundation/signify/app/aiding/IdentifierController.java Outdated
Comment thread src/main/java/org/cardanofoundation/signify/app/aiding/IdentifierController.java Outdated
Comment thread src/main/java/org/cardanofoundation/signify/app/aiding/IdentifierController.java Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many of the operations in this class can be more specific. ExchangeOperation, KelOperation etc

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed MultisigUtils for specifying op types

Comment thread src/test/java/org/cardanofoundation/signify/e2e/utils/TestUtils.java Outdated
opResponse1 = (HashMap<String, Object>) op1.getResponse();
EventResult rpyResult1 = client1.identifiers().addEndRole(
var icpResult1 = client1.identifiers().create("alice", kargs1);
Operation op1 = waitOperation(client1, icpResult1.op());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use waitOperation with CompletedWitnessOperation.class? (same in other places in the tests)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or perhaps we need a waitForCompleted an throw an error if it's the error variant

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about this:

public static <T extends Operation> T waitForCompleted(
            SignifyClient client,
            Operation op,
            Class<T> completedType
    ) throws Exception {
        Operation result = waitOperation(client, op);
        if (completedType.isInstance(result)) {
            return completedType.cast(result);
        }
        if (result.getClass().getSimpleName().startsWith("Failed")) {
            throw new IllegalStateException("Operation failed: " + result);
        }
        throw new IllegalStateException("Unexpected operation result type: " + result.getClass());
    }

}

then using it

CompletedWitnessOperation op = waitForCompleted(client2, icpResult2.op(), CompletedWitnessOperation.class);
aid2Prefix = op.getResponse().getI();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps waitForCompleted(client2, icpResult.op(), WitnessOperation.class

So it'll always be a WitnessOperation, but we throw an error if it's not a Completed* version

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In your example, you could have FailedCredentialOperation and would get the operation failed instead of unexpected operation result exception

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants