Skip to content

Commit

Permalink
Merge pull request #200 from ElrondNetwork/fix-endpoint-modifier
Browse files Browse the repository at this point in the history
Fix ABI endpoint definition: attribute "mutability".
  • Loading branch information
andreibancioiu authored Apr 19, 2022
2 parents 58e9cc6 + 76ac79e commit b6cc483
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
## Unreleased
- TBD

## 10.1.2
- [Fix ABI endpoint definition: attribute "mutability"](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/200)

## 10.1.1
- [Add missing package "blake2b" (removed by mistake)](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/199)

Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elrondnetwork/erdjs",
"version": "10.1.1",
"version": "10.1.2",
"description": "Smart Contracts interaction framework",
"main": "out/index.js",
"types": "out/index.d.js",
Expand Down
4 changes: 4 additions & 0 deletions src/smartcontracts/typesystem/abiRegistry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ describe("test abi registry", () => {
let start = lottery.getEndpoint("start");
let getStatus = lottery.getEndpoint("status");
let getLotteryInfo = lottery.getEndpoint("getLotteryInfo");

assert.isFalse(start.modifiers.isReadonly());
assert.isTrue(getStatus.modifiers.isReadonly());
assert.isTrue(getLotteryInfo.modifiers.isReadonly());
assert.instanceOf(start.input[0].type, BytesType);
assert.instanceOf(start.input[1].type, TokenIdentifierType);
assert.instanceOf(start.input[2].type, BigUIntType);
Expand Down
12 changes: 6 additions & 6 deletions src/smartcontracts/typesystem/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class EndpointDefinition {

static fromJSON(json: {
name: string,
storageModifier: string,
mutability: string,
payableInTokens: string[],
inputs: any[],
outputs: []
Expand All @@ -35,18 +35,18 @@ export class EndpointDefinition {

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

return new EndpointDefinition(json.name, input, output, modifiers);
}
}

export class EndpointModifiers {
readonly storageModifier: string;
readonly mutability: string;
readonly payableInTokens: string[];

constructor(storageModifier: string, payableInTokens: string[]) {
this.storageModifier = storageModifier || "";
constructor(mutability: string, payableInTokens: string[]) {
this.mutability = mutability || "";
this.payableInTokens = payableInTokens || [];
}

Expand Down Expand Up @@ -75,7 +75,7 @@ export class EndpointModifiers {
}

isReadonly() {
return this.storageModifier == "readonly";
return this.mutability == "readonly";
}
}

Expand Down

0 comments on commit b6cc483

Please sign in to comment.