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

fix: updating boolean values in static box #580

Merged
merged 2 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/lib/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3909,8 +3909,10 @@ export default class Compiler {
const storageProp = this.storageProps[storageName!];

const { type, valueType } = storageProp;
let action: 'set' | 'replace' = type === 'box' && !this.isDynamicType(valueType) ? 'replace' : 'set';

let action: 'set' | 'replace' =
type === 'box' && !this.isDynamicType(valueType) && !typeInfoToABIString(valueType).includes('bool')
? 'replace'
: 'set';
if (valueType.kind === 'base') action = 'set';
// Honestly not sure why I needed to add this after b89ddc6c24d6102f9e890a0e76222de7e0ca79b5 (0.67.2)
// But it works...
Expand Down
6 changes: 6 additions & 0 deletions tests/abi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -974,4 +974,10 @@ describe('ABI', function () {
false,
]);
});

test('boolUpdateInObjectInBox', async () => {
const { appClient } = await compileAndCreate('boolUpdateInObjectInBox');

expect(await runMethod(appClient, 'boolUpdateInObjectInBox')).toEqual(true);
});
});
16 changes: 16 additions & 0 deletions tests/contracts/abi.algo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1711,3 +1711,19 @@ class ABITestNestedArrayAlongsideBoolean extends Contract {
return o;
}
}

export type T13 = {
value: uint64;
bool: boolean;
};

class ABITestBoolUpdateInObjectInBox extends Contract {
boxes = BoxMap<bytes, T13>();

boolUpdateInObjectInBox(): boolean {
this.boxes('bRef').value = { value: 0, bool: false };
this.boxes('bRef').value.bool = true;

return this.boxes('bRef').value.bool;
}
}