Skip to content

Commit

Permalink
fix decorator return statement, remove all @query([]) and @update([])
Browse files Browse the repository at this point in the history
  • Loading branch information
lastmjs committed Dec 30, 2024
1 parent 8e8e450 commit dbf0b21
Show file tree
Hide file tree
Showing 20 changed files with 31 additions and 18 deletions.
Binary file modified canister_templates/stable.wasm
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ type Candid = {
};

export default class {
@query([])
@query
opt(): void {}

@query([], CandidVariant)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class {
return (await call(this.canister2Id, 'trap')) as never;
}

@update([])
@update
sendNotification(): void {
return notify(this.canister2Id, 'receiveNotification', {
paramIdlTypes: [IDL.Text],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class {
});
}

@update([])
@update
sendCyclesNotify(): void {
return notify(this.cyclesPrincipal, 'receiveCycles', {
cycles: 1_000_000n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class {
}
}

@update([])
@update
clearall(): void {
this.cell = 0n;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class {
this.counter = n;
}

@update([])
@update
inc(): void {
this.counter += 1n;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { query } from 'azle';

export default class {
@query([])
@query
main(): void {
console.info('Hello World!');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class {
return output;
}

@update([])
@update
clearCompleted(): void {
// NOTE: this syntax isn't supported in Boa. If we revert to using Boa
// we'll need to revert the syntax to:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { candidEncode, notify, Principal, trap, update } from 'azle';

export default class {
@update([])
@update
sendNotification(): void {
return notify(
Principal.fromText(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IDL, query, update } from 'azle';
export default class {
notified: boolean = false;

@update([])
@update
receiveNotification(): void {
this.notified = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class {
return param;
}

@query([])
@query
voidIsNotNull(): void {
print(
'Even though they are both None in Python, for Candid null and void are different.'
Expand Down
2 changes: 1 addition & 1 deletion examples/stable/test/property/ic_api/caller/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default class {
}
}

@update([])
@update
setInspectMessageCaller(): void {
this.inspectMessageCaller = caller();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default class {
}
}

@update([])
@update
setInspectMessageCanisterVersion(): void {
this.inspectMessageCanisterVersion = canisterVersion();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default class {
return certificate !== undefined ? [certificate] : [];
}

@query([])
@query
setDataCertificateInQuery(): void {
setCertifiedData(new Uint8Array([3]));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/stable/test/property/ic_api/id/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default class {
}
}

@update([])
@update
setInspectMessageId(): void {
this.inspectMessageId = id();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export default class {
reject('Rejection with message');
}

@query([])
@query
noError(): void {}
}
2 changes: 1 addition & 1 deletion examples/stable/test/property/ic_api/time/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class {
}
}

@update([])
@update
inspectMessageTime(): void {}

@query([], IDL.Nat64)
Expand Down
8 changes: 7 additions & 1 deletion src/lib/stable/canister_methods/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@ export function query<This, Args extends any[], Return>(
param2?: ClassMethodDecoratorContext | IDL.Type,
param3?: { manual?: boolean }
): any {
decoratorArgumentsHandler('query', 'queries', param1, param2, param3);
return decoratorArgumentsHandler(
'query',
'queries',
param1,
param2,
param3
);
}
8 changes: 7 additions & 1 deletion src/lib/stable/canister_methods/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@ export function update<This, Args extends any[], Return>(
param2?: ClassMethodDecoratorContext | IDL.Type,
param3?: { manual?: boolean }
): any {
decoratorArgumentsHandler('update', 'updates', param1, param2, param3);
return decoratorArgumentsHandler(
'update',
'updates',
param1,
param2,
param3
);
}

0 comments on commit dbf0b21

Please sign in to comment.