Skip to content

Commit

Permalink
quick fix for blob bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Jan 30, 2024
1 parent f285131 commit 19cb47d
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion property_tests/arbitraries/canister_arb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import { InitMethod } from './canister_methods/init_method_arb';
import { PostUpgradeMethod } from './canister_methods/post_upgrade_arb';
import { PreUpgradeMethod } from './canister_methods/pre_upgrade_method_arb';
import { CorrespondingJSType } from './candid/corresponding_js_type';
import { TextClass, FloatClass } from '@dfinity/candid/lib/cjs/idl';
import {
TextClass,
FloatClass,
FixedNatClass,
VecClass
} from '@dfinity/candid/lib/cjs/idl';

TextClass.prototype.valueToString = (x): string => {
return `"${escapeForBash(x)}"`;
Expand All @@ -24,6 +29,26 @@ FloatClass.prototype.valueToString = (x): string => {
return floatString + '.0';
};

// Remove this when it is no longer necessary
// TODO https://github.com/demergent-labs/azle/issues/1597
VecClass.prototype.valueToString = function (x): string {
const elements = Array.from(x).map((e): string => {
// @ts-ignore
return this._type.valueToString(e);
});
return 'vec {' + elements.join('; ') + '}';
};

// Remove this when it is no longer necessary
// TODO https://github.com/demergent-labs/azle/issues/1597
FixedNatClass.prototype.valueToString = function (x): string {
const natString = x.toString();
if (this._bits === 8) {
return `${natString}: nat8`;
}
return natString;
};

export type Canister = {
initArgs: string[] | undefined;
postUpgradeArgs: string[] | undefined;
Expand Down

0 comments on commit 19cb47d

Please sign in to comment.