Skip to content

Commit

Permalink
fix: check okay before parsing result
Browse files Browse the repository at this point in the history
  • Loading branch information
friedger authored and hstove committed Jan 26, 2021
1 parent 9093ce5 commit 952a60d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/transactions/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sha256, sha512 } from 'sha.js';
import { ClarityValue, serializeCV } from './clarity';
import { ClarityValue, noneCV, responseErrorCV, serializeCV } from './clarity';
import RIPEMD160 from 'ripemd160-min';
import randombytes from 'randombytes';
import { deserializeCV } from './clarity';
Expand Down Expand Up @@ -182,8 +182,12 @@ export interface ReadOnlyFunctionResponse {
* Converts the response of a read-only function call into its Clarity Value
* @param param
*/
export const parseReadOnlyResponse = ({ result }: ReadOnlyFunctionResponse): ClarityValue => {
return hexToCV(result);
export const parseReadOnlyResponse = ({ okay, result }: ReadOnlyFunctionResponse): ClarityValue => {
if (okay) {
return hexToCV(result);
} else {
return responseErrorCV(noneCV());
}
};

export const validateStacksAddress = (stacksAddress: string): boolean => {
Expand Down

0 comments on commit 952a60d

Please sign in to comment.