api3dao / api3-dao-dashboard

API3 DAO dashboard
api3.eth/
14 stars 10 forks source link

Update @api3/promise-utils #419

Closed mcoetzee closed 1 year ago

mcoetzee commented 1 year ago

Resolves #395

What does this change?

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;
    }