From 21bec1345a71df8fd22d03f206f7f75363a08e49 Mon Sep 17 00:00:00 2001 From: danielailie Date: Mon, 14 Oct 2024 17:12:21 +0300 Subject: [PATCH 1/2] Add title to abi endpoint --- src/smartcontracts/typesystem/abiRegistry.spec.ts | 8 ++++++++ src/smartcontracts/typesystem/abiRegistry.ts | 2 +- src/smartcontracts/typesystem/endpoint.ts | 7 ++++++- src/testdata/lottery-esdt.abi.json | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/smartcontracts/typesystem/abiRegistry.spec.ts b/src/smartcontracts/typesystem/abiRegistry.spec.ts index e7b43117d..4832690f4 100644 --- a/src/smartcontracts/typesystem/abiRegistry.spec.ts +++ b/src/smartcontracts/typesystem/abiRegistry.spec.ts @@ -203,4 +203,12 @@ describe("test abi registry", () => { assert.deepEqual(enumType.variants[1].name, "interrupted"); assert.deepEqual(enumType.variants[1].discriminant, 1); }); + + it("should load abi with title for endpoint", async () => { + const registry = await loadAbiRegistry("src/testdata/lottery-esdt.abi.json"); + + const endpoint = registry.getEndpoint("createLotteryPool"); + + assert.equal(endpoint.title, "Create lottery pool"); + }); }); diff --git a/src/smartcontracts/typesystem/abiRegistry.ts b/src/smartcontracts/typesystem/abiRegistry.ts index 25162de22..538c7d148 100644 --- a/src/smartcontracts/typesystem/abiRegistry.ts +++ b/src/smartcontracts/typesystem/abiRegistry.ts @@ -214,7 +214,7 @@ function mapEndpoint(endpoint: EndpointDefinition, mapper: TypeMapper): Endpoint (e) => new EndpointParameterDefinition(e.name, e.description, mapper.mapType(e.type)), ); - return new EndpointDefinition(endpoint.name, newInput, newOutput, endpoint.modifiers); + return new EndpointDefinition(endpoint.name, newInput, newOutput, endpoint.modifiers, endpoint.title); } function mapEvent(event: EventDefinition, mapper: TypeMapper): EventDefinition { diff --git a/src/smartcontracts/typesystem/endpoint.ts b/src/smartcontracts/typesystem/endpoint.ts index 9868b72dd..90f5de39c 100644 --- a/src/smartcontracts/typesystem/endpoint.ts +++ b/src/smartcontracts/typesystem/endpoint.ts @@ -6,6 +6,7 @@ const DescriptionPlaceholder = "N / A"; export class EndpointDefinition { readonly name: string; + readonly title: string; readonly input: EndpointParameterDefinition[] = []; readonly output: EndpointParameterDefinition[] = []; readonly modifiers: EndpointModifiers; @@ -15,8 +16,10 @@ export class EndpointDefinition { input: EndpointParameterDefinition[], output: EndpointParameterDefinition[], modifiers: EndpointModifiers, + title?: string, ) { this.name = name; + this.title = title || ""; this.input = input || []; this.output = output || []; this.modifiers = modifiers; @@ -28,6 +31,7 @@ export class EndpointDefinition { static fromJSON(json: { name: string; + title?: string; onlyOwner?: boolean; mutability: string; payableInTokens: string[]; @@ -36,6 +40,7 @@ export class EndpointDefinition { }): EndpointDefinition { json.name = json.name == null ? NamePlaceholder : json.name; json.onlyOwner = json.onlyOwner || false; + json.title = json.title || ""; json.payableInTokens = json.payableInTokens || []; json.inputs = json.inputs || []; json.outputs = json.outputs || []; @@ -44,7 +49,7 @@ export class EndpointDefinition { let output = json.outputs.map((param) => EndpointParameterDefinition.fromJSON(param)); let modifiers = new EndpointModifiers(json.mutability, json.payableInTokens, json.onlyOwner); - return new EndpointDefinition(json.name, input, output, modifiers); + return new EndpointDefinition(json.name, input, output, modifiers, json.title); } } diff --git a/src/testdata/lottery-esdt.abi.json b/src/testdata/lottery-esdt.abi.json index a9fa48c5e..53be0bbed 100644 --- a/src/testdata/lottery-esdt.abi.json +++ b/src/testdata/lottery-esdt.abi.json @@ -68,6 +68,7 @@ }, { "name": "createLotteryPool", + "title": "Create lottery pool", "mutability": "mutable", "inputs": [ { From adc447a4d950c2b3ca47274558e89cc99e2769a8 Mon Sep 17 00:00:00 2001 From: danielailie Date: Mon, 14 Oct 2024 17:51:40 +0300 Subject: [PATCH 2/2] Bump version --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6c2d1a491..7a3ce04fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@multiversx/sdk-core", - "version": "13.8.0", + "version": "13.9.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@multiversx/sdk-core", - "version": "13.8.0", + "version": "13.9.0", "license": "MIT", "dependencies": { "@multiversx/sdk-transaction-decoder": "1.0.2", diff --git a/package.json b/package.json index a7e6e8b26..985a883c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@multiversx/sdk-core", - "version": "13.8.0", + "version": "13.9.0", "description": "MultiversX SDK for JavaScript and TypeScript", "author": "MultiversX", "homepage": "https://multiversx.com",