Skip to content

Commit 13b4d1c

Browse files
authored
Merge pull request #506 from multiversx/TOOL-272-add-title-to-abi-endpoints
Add title to abi endpoint
2 parents 6f76303 + adc447a commit 13b4d1c

File tree

6 files changed

+19
-5
lines changed

6 files changed

+19
-5
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@multiversx/sdk-core",
3-
"version": "13.8.0",
3+
"version": "13.9.0",
44
"description": "MultiversX SDK for JavaScript and TypeScript",
55
"author": "MultiversX",
66
"homepage": "https://multiversx.com",

src/smartcontracts/typesystem/abiRegistry.spec.ts

+8
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,12 @@ describe("test abi registry", () => {
203203
assert.deepEqual(enumType.variants[1].name, "interrupted");
204204
assert.deepEqual(enumType.variants[1].discriminant, 1);
205205
});
206+
207+
it("should load abi with title for endpoint", async () => {
208+
const registry = await loadAbiRegistry("src/testdata/lottery-esdt.abi.json");
209+
210+
const endpoint = registry.getEndpoint("createLotteryPool");
211+
212+
assert.equal(endpoint.title, "Create lottery pool");
213+
});
206214
});

src/smartcontracts/typesystem/abiRegistry.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ function mapEndpoint(endpoint: EndpointDefinition, mapper: TypeMapper): Endpoint
214214
(e) => new EndpointParameterDefinition(e.name, e.description, mapper.mapType(e.type)),
215215
);
216216

217-
return new EndpointDefinition(endpoint.name, newInput, newOutput, endpoint.modifiers);
217+
return new EndpointDefinition(endpoint.name, newInput, newOutput, endpoint.modifiers, endpoint.title);
218218
}
219219

220220
function mapEvent(event: EventDefinition, mapper: TypeMapper): EventDefinition {

src/smartcontracts/typesystem/endpoint.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const DescriptionPlaceholder = "N / A";
66

77
export class EndpointDefinition {
88
readonly name: string;
9+
readonly title: string;
910
readonly input: EndpointParameterDefinition[] = [];
1011
readonly output: EndpointParameterDefinition[] = [];
1112
readonly modifiers: EndpointModifiers;
@@ -15,8 +16,10 @@ export class EndpointDefinition {
1516
input: EndpointParameterDefinition[],
1617
output: EndpointParameterDefinition[],
1718
modifiers: EndpointModifiers,
19+
title?: string,
1820
) {
1921
this.name = name;
22+
this.title = title || "";
2023
this.input = input || [];
2124
this.output = output || [];
2225
this.modifiers = modifiers;
@@ -28,6 +31,7 @@ export class EndpointDefinition {
2831

2932
static fromJSON(json: {
3033
name: string;
34+
title?: string;
3135
onlyOwner?: boolean;
3236
mutability: string;
3337
payableInTokens: string[];
@@ -36,6 +40,7 @@ export class EndpointDefinition {
3640
}): EndpointDefinition {
3741
json.name = json.name == null ? NamePlaceholder : json.name;
3842
json.onlyOwner = json.onlyOwner || false;
43+
json.title = json.title || "";
3944
json.payableInTokens = json.payableInTokens || [];
4045
json.inputs = json.inputs || [];
4146
json.outputs = json.outputs || [];
@@ -44,7 +49,7 @@ export class EndpointDefinition {
4449
let output = json.outputs.map((param) => EndpointParameterDefinition.fromJSON(param));
4550
let modifiers = new EndpointModifiers(json.mutability, json.payableInTokens, json.onlyOwner);
4651

47-
return new EndpointDefinition(json.name, input, output, modifiers);
52+
return new EndpointDefinition(json.name, input, output, modifiers, json.title);
4853
}
4954
}
5055

src/testdata/lottery-esdt.abi.json

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
},
6969
{
7070
"name": "createLotteryPool",
71+
"title": "Create lottery pool",
7172
"mutability": "mutable",
7273
"inputs": [
7374
{

0 commit comments

Comments
 (0)