Skip to content

Commit

Permalink
fix endpoint modifier only-owner
Browse files Browse the repository at this point in the history
  • Loading branch information
michavie committed Oct 6, 2023
1 parent df4ddc2 commit 78cf27f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/smartcontracts/typesystem/endpoint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ describe("test endpoint", () => {
it('should handle an only-owner modifier', async () => {
const actual = EndpointDefinition.fromJSON({
name: 'foo',
ownerOnly: true,
onlyOwner: true,
mutability: 'payable',
payableInTokens: [],
inputs: [],
outputs: [],
})

assert.isTrue(actual.modifiers.ownerOnly)
assert.isTrue(actual.modifiers.isOwnerOnly())
assert.isTrue(actual.modifiers.onlyOwner)
assert.isTrue(actual.modifiers.isOnlyOwner())
})
});
16 changes: 8 additions & 8 deletions src/smartcontracts/typesystem/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ export class EndpointDefinition {

static fromJSON(json: {
name: string,
ownerOnly?: boolean
onlyOwner?: boolean
mutability: string,
payableInTokens: string[],
inputs: any[],
outputs: any[]
}): EndpointDefinition {
json.name = json.name == null ? NamePlaceholder : json.name;
json.ownerOnly = json.ownerOnly || false;
json.onlyOwner = json.onlyOwner || false;
json.payableInTokens = json.payableInTokens || [];
json.inputs = json.inputs || [];
json.outputs = json.outputs || [];

let input = json.inputs.map(param => EndpointParameterDefinition.fromJSON(param));
let output = json.outputs.map(param => EndpointParameterDefinition.fromJSON(param));
let modifiers = new EndpointModifiers(json.mutability, json.payableInTokens, json.ownerOnly);
let modifiers = new EndpointModifiers(json.mutability, json.payableInTokens, json.onlyOwner);

return new EndpointDefinition(json.name, input, output, modifiers);
}
Expand All @@ -46,12 +46,12 @@ export class EndpointDefinition {
export class EndpointModifiers {
readonly mutability: string;
readonly payableInTokens: string[];
readonly ownerOnly: boolean;
readonly onlyOwner: boolean;

constructor(mutability: string, payableInTokens: string[], ownerOnly?: boolean) {
constructor(mutability: string, payableInTokens: string[], onlyOwner?: boolean) {
this.mutability = mutability || "";
this.payableInTokens = payableInTokens || [];
this.ownerOnly = ownerOnly || false;
this.onlyOwner = onlyOwner || false;
}

isPayableInEGLD(): boolean {
Expand Down Expand Up @@ -82,8 +82,8 @@ export class EndpointModifiers {
return this.mutability == "readonly";
}

isOwnerOnly() {
return this.ownerOnly;
isOnlyOwner() {
return this.onlyOwner;
}
}

Expand Down

0 comments on commit 78cf27f

Please sign in to comment.