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

Update @api3/promise-utils #419

Merged
merged 3 commits into from
Jul 26, 2023
Merged

Update @api3/promise-utils #419

merged 3 commits into from
Jul 26, 2023

Conversation

mcoetzee
Copy link
Collaborator

@mcoetzee mcoetzee commented Jul 25, 2023

Resolves #395

What does this change?

  • updates go() usages to pass a function that returns a promise (instead of just the promise)
  • fixes the type errors in the goEncodeEvmScript() function when calling the fail() function:
Type 'GoResultError<Error>' is not assignable to type 'GoResultError<EncodedEvmScriptError>'.
  • increases the Cypress default command timeout from 10s to 15s (had 3 test failures in a row due to the timeout being hit)

How did you action this task?

W.r.t. the type errors in the goEncodeEvmScript(), instead of passing the EncodedEvmScriptError type argument to the fail() function for each call, I let the type be the broader Error, and used instanceof when using the error when validating the proposal form:

    if (!goRes.success) {
+     if (goRes.error instanceof EncodedEvmScriptError) {
        const { field, value } = goRes.error;
        newErrors[field] = value;
+     } else {
+       // We should always get an EncodedEvmScriptError, but we give the user a message just in case it is not
+       newErrors.generic = 'Failed to encode';
+     }
      foundErrors = true;
    }

@mcoetzee mcoetzee self-assigned this Jul 25, 2023
@mcoetzee mcoetzee marked this pull request as ready for review July 26, 2023 09:32
@mcoetzee mcoetzee requested a review from andreogle July 26, 2023 09:32
Copy link
Member

@andreogle andreogle left a comment

Choose a reason for hiding this comment

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

LGTM :shipit:

const { field, value } = goRes.error;
newErrors[field] = value;
} else {
// We should always get an EncodedEvmScriptError, but we give the user a message just in case it is not
Copy link
Member

Choose a reason for hiding this comment

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

👍🏻

@mcoetzee mcoetzee merged commit 5277a85 into main Jul 26, 2023
4 checks passed
@mcoetzee mcoetzee deleted the update-promise-utils branch July 26, 2023 11:50
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.

Update @api3/promise-utils
2 participants