@twin.org/nft-service 0.0.3-next.8 → 0.9.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/models/INftServiceConfig.js.map +1 -1
- package/dist/es/nftRoutes.js +5 -5
- package/dist/es/nftRoutes.js.map +1 -1
- package/dist/es/nftService.js +6 -5
- package/dist/es/nftService.js.map +1 -1
- package/dist/es/restEntryPoints.js +3 -0
- package/dist/es/restEntryPoints.js.map +1 -1
- package/dist/types/models/INftServiceConfig.d.ts +1 -1
- package/dist/types/nftRoutes.d.ts +5 -5
- package/dist/types/nftService.d.ts +6 -5
- package/dist/types/restEntryPoints.d.ts +3 -0
- package/docs/changelog.md +47 -0
- package/docs/open-api/spec.json +9 -9
- package/docs/reference/classes/NftService.md +9 -5
- package/docs/reference/functions/nftBurn.md +1 -1
- package/docs/reference/functions/nftMint.md +1 -1
- package/docs/reference/functions/nftResolve.md +1 -1
- package/docs/reference/functions/nftTransfer.md +1 -1
- package/docs/reference/functions/nftUpdate.md +1 -1
- package/docs/reference/interfaces/INftServiceConfig.md +1 -1
- package/docs/reference/variables/restEntryPoints.md +2 -0
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"INftServiceConfig.js","sourceRoot":"","sources":["../../../src/models/INftServiceConfig.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Configuration for the NFT Service.\n */\nexport interface INftServiceConfig {\n\t/**\n\t *
|
|
1
|
+
{"version":3,"file":"INftServiceConfig.js","sourceRoot":"","sources":["../../../src/models/INftServiceConfig.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Configuration for the NFT Service.\n */\nexport interface INftServiceConfig {\n\t/**\n\t * The default connector namespace to use for NFT operations; defaults to the first registered connector.\n\t */\n\tdefaultNamespace?: string;\n}\n"]}
|
package/dist/es/nftRoutes.js
CHANGED
|
@@ -208,7 +208,7 @@ export function generateRestRoutesNft(baseRouteName, componentName) {
|
|
|
208
208
|
* @param httpRequestContext The request context for the API.
|
|
209
209
|
* @param componentName The name of the component to use in the routes.
|
|
210
210
|
* @param request The request.
|
|
211
|
-
* @returns
|
|
211
|
+
* @returns A created response containing the location header with the new NFT id.
|
|
212
212
|
*/
|
|
213
213
|
export async function nftMint(httpRequestContext, componentName, request) {
|
|
214
214
|
Guards.object(ROUTES_SOURCE, "request", request);
|
|
@@ -230,7 +230,7 @@ export async function nftMint(httpRequestContext, componentName, request) {
|
|
|
230
230
|
* @param httpRequestContext The request context for the API.
|
|
231
231
|
* @param componentName The name of the component to use in the routes.
|
|
232
232
|
* @param request The request.
|
|
233
|
-
* @returns
|
|
233
|
+
* @returns A response containing the resolved NFT data.
|
|
234
234
|
*/
|
|
235
235
|
export async function nftResolve(httpRequestContext, componentName, request) {
|
|
236
236
|
Guards.object(ROUTES_SOURCE, "request", request);
|
|
@@ -249,7 +249,7 @@ export async function nftResolve(httpRequestContext, componentName, request) {
|
|
|
249
249
|
* @param httpRequestContext The request context for the API.
|
|
250
250
|
* @param componentName The name of the component to use in the routes.
|
|
251
251
|
* @param request The request.
|
|
252
|
-
* @returns
|
|
252
|
+
* @returns A no-content response indicating the NFT was burned successfully.
|
|
253
253
|
*/
|
|
254
254
|
export async function nftBurn(httpRequestContext, componentName, request) {
|
|
255
255
|
Guards.object(ROUTES_SOURCE, "request", request);
|
|
@@ -268,7 +268,7 @@ export async function nftBurn(httpRequestContext, componentName, request) {
|
|
|
268
268
|
* @param httpRequestContext The request context for the API.
|
|
269
269
|
* @param componentName The name of the component to use in the routes.
|
|
270
270
|
* @param request The request.
|
|
271
|
-
* @returns
|
|
271
|
+
* @returns A no-content response indicating the NFT was transferred successfully.
|
|
272
272
|
*/
|
|
273
273
|
export async function nftTransfer(httpRequestContext, componentName, request) {
|
|
274
274
|
Guards.object(ROUTES_SOURCE, "request", request);
|
|
@@ -289,7 +289,7 @@ export async function nftTransfer(httpRequestContext, componentName, request) {
|
|
|
289
289
|
* @param httpRequestContext The request context for the API.
|
|
290
290
|
* @param componentName The name of the component to use in the routes.
|
|
291
291
|
* @param request The request.
|
|
292
|
-
* @returns
|
|
292
|
+
* @returns A no-content response indicating the NFT metadata was updated successfully.
|
|
293
293
|
*/
|
|
294
294
|
export async function nftUpdate(httpRequestContext, componentName, request) {
|
|
295
295
|
Guards.object(ROUTES_SOURCE, "request", request);
|
package/dist/es/nftRoutes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nftRoutes.js","sourceRoot":"","sources":["../../src/nftRoutes.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAW1D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE5D;;GAEG;AACH,MAAM,aAAa,GAAG,WAAW,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAW;IAC9B;QACC,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,yDAAyD;KACtE;CACD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,aAAqB,EAAE,aAAqB;IACjF,MAAM,SAAS,GAAkD;QAChE,WAAW,EAAE,SAAS;QACtB,OAAO,EAAE,aAAa;QACtB,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI;QACpB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,GAAG,aAAa,GAAG;QACzB,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,EAAE,CAC9C,OAAO,CAA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AAC,UAAU,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IAE9D,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAgB,aAAa,CAAC,CAAC;IACrE,MAAM,SAAS,CAAC,MAAM,CACrB,OAAO,CAAC,UAAU,CAAC,EAAE,EACrB,OAAO,CAAC,IAAI,CAAC,QAAQ,EACrB,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CACtC,CAAC;IAEF,OAAO;QACN,UAAU,EAAE,cAAc,CAAC,SAAS;KACpC,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tICreatedResponse,\n\tIHttpRequestContext,\n\tINoContentResponse,\n\tIRestRoute,\n\tITag\n} from \"@twin.org/api-models\";\nimport { ContextIdHelper, ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { ComponentFactory, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type {\n\tINftBurnRequest,\n\tINftComponent,\n\tINftMintRequest,\n\tINftResolveRequest,\n\tINftResolveResponse,\n\tINftTransferRequest,\n\tINftUpdateRequest\n} from \"@twin.org/nft-models\";\nimport { HeaderTypes, HttpStatusCode } from \"@twin.org/web\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"nftRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsNft: ITag[] = [\n\t{\n\t\tname: \"NFT\",\n\t\tdescription: \"Endpoints which are modelled to access an NFT contract.\"\n\t}\n];\n\n/**\n * The REST routes for NFT.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesNft(baseRouteName: string, componentName: string): IRestRoute[] {\n\tconst mintRoute: IRestRoute<INftMintRequest, ICreatedResponse> = {\n\t\toperationId: \"nftMint\",\n\t\tsummary: \"Mint an NFT\",\n\t\ttag: tagsNft[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tnftMint(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<INftMintRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"nftMintExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\ttag: \"MY-NFT\",\n\t\t\t\t\t\t\timmutableMetadata: {\n\t\t\t\t\t\t\t\tdocName: \"bill-of-lading\",\n\t\t\t\t\t\t\t\tmimeType: \"application/pdf\",\n\t\t\t\t\t\t\t\tfingerprint: \"0xf0b95a98b3dbc5ce1c9ce59d70af95a97599f100a7296ecdd1eb108bebfa047f\"\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\tdata: \"tst1prctjk5ck0dutnsunnje6u90jk5htx03qznjjmkd6843pzltlgz87srjzzv\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<ICreatedResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"nftMintResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tstatusCode: HttpStatusCode.created,\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t[HeaderTypes.Location]:\n\t\t\t\t\t\t\t\t\t\"nft:iota:aW90YS1uZnQ6dHN0OjB4NzYyYjljNDllYTg2OWUwZWJkYTliYmZhNzY5Mzk0NDdhNDI4ZGNmMTc4YzVkMTVhYjQ0N2UyZDRmYmJiNGViMg==\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst resolveRoute: IRestRoute<INftResolveRequest, INftResolveResponse> = {\n\t\toperationId: \"nftResolve\",\n\t\tsummary: \"Resolve an NFT\",\n\t\ttag: tagsNft[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tnftResolve(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<INftResolveRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"nftResolveExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"nft:iota:aW90YS1uZnQ6dHN0OjB4NzYyYjljNDllYTg2OWUwZWJkYTliYmZhNzY5Mzk0NDdhNDI4ZGNmMTc4YzVkMTVhYjQ0N2UyZDRmYmJiNGViMg==\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INftResolveResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"nftResolveResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tissuer: \"0x85ef62ea94fc4eeeeeddf6acc3b566e988e613081d0b93cc54ed831ed4c18d44\",\n\t\t\t\t\t\t\t\tissuerIdentityId:\n\t\t\t\t\t\t\t\t\t\"0xa1d80bee7fdb4fd91ae45c6e539209f73cb743b7da9db3e21322ea75af1878c0\",\n\t\t\t\t\t\t\t\ttag: \"MY-NFT\",\n\t\t\t\t\t\t\t\timmutableMetadata: {\n\t\t\t\t\t\t\t\t\tdocName: \"bill-of-lading\",\n\t\t\t\t\t\t\t\t\tmimeType: \"application/pdf\",\n\t\t\t\t\t\t\t\t\tfingerprint: \"0xf0b95a98b3dbc5ce1c9ce59d70af95a97599f100a7296ecdd1eb108bebfa047f\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\tdata: \"AAAAA\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst burnRoute: IRestRoute<INftBurnRequest, INoContentResponse> = {\n\t\toperationId: \"nftBurn\",\n\t\tsummary: \"Burn an NFT\",\n\t\ttag: tagsNft[0].name,\n\t\tmethod: \"DELETE\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tnftBurn(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<INftBurnRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"nftBurnExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"nft:iota:aW90YS1uZnQ6dHN0OjB4NzYyYjljNDllYTg2OWUwZWJkYTliYmZhNzY5Mzk0NDdhNDI4ZGNmMTc4YzVkMTVhYjQ0N2UyZDRmYmJiNGViMg==\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst transferRoute: IRestRoute<INftTransferRequest, INoContentResponse> = {\n\t\toperationId: \"nftTransfer\",\n\t\tsummary: \"Transfer an NFT\",\n\t\ttag: tagsNft[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/:id/transfer`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tnftTransfer(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<INftTransferRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"nftTransferExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"nft:iota:aW90YS1uZnQ6dHN0OjB4NzYyYjljNDllYTg2OWUwZWJkYTliYmZhNzY5Mzk0NDdhNDI4ZGNmMTc4YzVkMTVhYjQ0N2UyZDRmYmJiNGViMg==\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\trecipientAddress: \"tst1prctjk5ck0dutnsunnje6u90jk5htx03qznjjmkd6843pzltlgz87srjzzv\",\n\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\tdata: \"AAAAA\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst updateRoute: IRestRoute<INftUpdateRequest, INoContentResponse> = {\n\t\toperationId: \"nftUpdate\",\n\t\tsummary: \"Update an NFT\",\n\t\ttag: tagsNft[0].name,\n\t\tmethod: \"PUT\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tnftUpdate(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<INftUpdateRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"nftUpdateExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"nft:iota:aW90YS1uZnQ6dHN0OjB4NzYyYjljNDllYTg2OWUwZWJkYTliYmZhNzY5Mzk0NDdhNDI4ZGNmMTc4YzVkMTVhYjQ0N2UyZDRmYmJiNGViMg==\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\tdata: \"AAAAA\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [mintRoute, resolveRoute, burnRoute, transferRoute, updateRoute];\n}\n\n/**\n * Mint an NFT.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function nftMint(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: INftMintRequest\n): Promise<ICreatedResponse> {\n\tGuards.object<INftMintRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<INftMintRequest[\"body\"]>(ROUTES_SOURCE, nameof(request.body), request.body);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.body.tag), request.body.tag);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\tconst component = ComponentFactory.get<INftComponent>(componentName);\n\tconst id = await component.mint(\n\t\trequest.body.tag,\n\t\trequest.body.immutableMetadata,\n\t\trequest.body.metadata,\n\t\trequest.body.namespace,\n\t\tcontextIds[ContextIdKeys.Organization]\n\t);\n\treturn {\n\t\tstatusCode: HttpStatusCode.created,\n\t\theaders: {\n\t\t\t[HeaderTypes.Location]: id\n\t\t}\n\t};\n}\n\n/**\n * Resolve an NFT.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function nftResolve(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: INftResolveRequest\n): Promise<INftResolveResponse> {\n\tGuards.object<INftResolveRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<INftResolveRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\tconst component = ComponentFactory.get<INftComponent>(componentName);\n\tconst result = await component.resolve(\n\t\trequest.pathParams.id,\n\t\tcontextIds[ContextIdKeys.Organization]\n\t);\n\treturn {\n\t\tbody: result\n\t};\n}\n\n/**\n * Burn an NFT.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function nftBurn(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: INftBurnRequest\n): Promise<INoContentResponse> {\n\tGuards.object<INftBurnRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<INftBurnRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\tconst component = ComponentFactory.get<INftComponent>(componentName);\n\tawait component.burn(request.pathParams.id, contextIds[ContextIdKeys.Organization]);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Transfer an NFT.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function nftTransfer(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: INftTransferRequest\n): Promise<INoContentResponse> {\n\tGuards.object<INftTransferRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<INftTransferRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\tGuards.object<INftTransferRequest[\"body\"]>(ROUTES_SOURCE, nameof(request.body), request.body);\n\tGuards.stringValue(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.body.recipientAddress),\n\t\trequest.body.recipientAddress\n\t);\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\tconst component = ComponentFactory.get<INftComponent>(componentName);\n\tawait component.transfer(\n\t\trequest.pathParams.id,\n\t\trequest.body.recipientAddress,\n\t\trequest.body.metadata,\n\t\tcontextIds[ContextIdKeys.Organization]\n\t);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Update an NFT.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function nftUpdate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: INftUpdateRequest\n): Promise<INoContentResponse> {\n\tGuards.object<INftUpdateRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<INftUpdateRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\tGuards.object<INftUpdateRequest[\"body\"]>(ROUTES_SOURCE, nameof(request.body), request.body);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body.metadata), request.body.metadata);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\tconst component = ComponentFactory.get<INftComponent>(componentName);\n\tawait component.update(\n\t\trequest.pathParams.id,\n\t\trequest.body.metadata,\n\t\tcontextIds[ContextIdKeys.Organization]\n\t);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"nftRoutes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C,IAAI,CAAC,gBAAgB,EAC7B,OAAO,CAAC,IAAI,CAAC,QAAQ,EACrB,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CACtC,CAAC;IAEF,OAAO;QACN,UAAU,EAAE,cAAc,CAAC,SAAS;KACpC,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC9B,kBAAuC,EACvC,aAAqB,EACrB,OAA0B;IAE1B,MAAM,CAAC,MAAM,CAAoB,aAAa,aAAmB,OAAO,CAAC,CAAC;IAC1E,MAAM,CAAC,MAAM,CACZ,aAAa,wBAEb,OAAO,CAAC,UAAU,CAClB,CAAC;IACF,MAAM,CAAC,WAAW,CAAC,aAAa,2BAAiC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IACxF,MAAM,CAAC,MAAM,CAA4B,aAAa,kBAAwB,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5F,MAAM,CAAC,MAAM,CAAC,aAAa,2BAAiC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEnF,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,aAAa,EAAE,CAAC;IACxD,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IAE9D,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAgB,aAAa,CAAC,CAAC;IACrE,MAAM,SAAS,CAAC,MAAM,CACrB,OAAO,CAAC,UAAU,CAAC,EAAE,EACrB,OAAO,CAAC,IAAI,CAAC,QAAQ,EACrB,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CACtC,CAAC;IAEF,OAAO;QACN,UAAU,EAAE,cAAc,CAAC,SAAS;KACpC,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tICreatedResponse,\n\tIHttpRequestContext,\n\tINoContentResponse,\n\tIRestRoute,\n\tITag\n} from \"@twin.org/api-models\";\nimport { ContextIdHelper, ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { ComponentFactory, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type {\n\tINftBurnRequest,\n\tINftComponent,\n\tINftMintRequest,\n\tINftResolveRequest,\n\tINftResolveResponse,\n\tINftTransferRequest,\n\tINftUpdateRequest\n} from \"@twin.org/nft-models\";\nimport { HeaderTypes, HttpStatusCode } from \"@twin.org/web\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"nftRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsNft: ITag[] = [\n\t{\n\t\tname: \"NFT\",\n\t\tdescription: \"Endpoints which are modelled to access an NFT contract.\"\n\t}\n];\n\n/**\n * The REST routes for NFT.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesNft(baseRouteName: string, componentName: string): IRestRoute[] {\n\tconst mintRoute: IRestRoute<INftMintRequest, ICreatedResponse> = {\n\t\toperationId: \"nftMint\",\n\t\tsummary: \"Mint an NFT\",\n\t\ttag: tagsNft[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tnftMint(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<INftMintRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"nftMintExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\ttag: \"MY-NFT\",\n\t\t\t\t\t\t\timmutableMetadata: {\n\t\t\t\t\t\t\t\tdocName: \"bill-of-lading\",\n\t\t\t\t\t\t\t\tmimeType: \"application/pdf\",\n\t\t\t\t\t\t\t\tfingerprint: \"0xf0b95a98b3dbc5ce1c9ce59d70af95a97599f100a7296ecdd1eb108bebfa047f\"\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\tdata: \"tst1prctjk5ck0dutnsunnje6u90jk5htx03qznjjmkd6843pzltlgz87srjzzv\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<ICreatedResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"nftMintResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tstatusCode: HttpStatusCode.created,\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t[HeaderTypes.Location]:\n\t\t\t\t\t\t\t\t\t\"nft:iota:aW90YS1uZnQ6dHN0OjB4NzYyYjljNDllYTg2OWUwZWJkYTliYmZhNzY5Mzk0NDdhNDI4ZGNmMTc4YzVkMTVhYjQ0N2UyZDRmYmJiNGViMg==\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst resolveRoute: IRestRoute<INftResolveRequest, INftResolveResponse> = {\n\t\toperationId: \"nftResolve\",\n\t\tsummary: \"Resolve an NFT\",\n\t\ttag: tagsNft[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tnftResolve(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<INftResolveRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"nftResolveExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"nft:iota:aW90YS1uZnQ6dHN0OjB4NzYyYjljNDllYTg2OWUwZWJkYTliYmZhNzY5Mzk0NDdhNDI4ZGNmMTc4YzVkMTVhYjQ0N2UyZDRmYmJiNGViMg==\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INftResolveResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"nftResolveResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tissuer: \"0x85ef62ea94fc4eeeeeddf6acc3b566e988e613081d0b93cc54ed831ed4c18d44\",\n\t\t\t\t\t\t\t\tissuerIdentityId:\n\t\t\t\t\t\t\t\t\t\"0xa1d80bee7fdb4fd91ae45c6e539209f73cb743b7da9db3e21322ea75af1878c0\",\n\t\t\t\t\t\t\t\ttag: \"MY-NFT\",\n\t\t\t\t\t\t\t\timmutableMetadata: {\n\t\t\t\t\t\t\t\t\tdocName: \"bill-of-lading\",\n\t\t\t\t\t\t\t\t\tmimeType: \"application/pdf\",\n\t\t\t\t\t\t\t\t\tfingerprint: \"0xf0b95a98b3dbc5ce1c9ce59d70af95a97599f100a7296ecdd1eb108bebfa047f\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\t\tdata: \"AAAAA\"\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst burnRoute: IRestRoute<INftBurnRequest, INoContentResponse> = {\n\t\toperationId: \"nftBurn\",\n\t\tsummary: \"Burn an NFT\",\n\t\ttag: tagsNft[0].name,\n\t\tmethod: \"DELETE\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tnftBurn(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<INftBurnRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"nftBurnExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"nft:iota:aW90YS1uZnQ6dHN0OjB4NzYyYjljNDllYTg2OWUwZWJkYTliYmZhNzY5Mzk0NDdhNDI4ZGNmMTc4YzVkMTVhYjQ0N2UyZDRmYmJiNGViMg==\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst transferRoute: IRestRoute<INftTransferRequest, INoContentResponse> = {\n\t\toperationId: \"nftTransfer\",\n\t\tsummary: \"Transfer an NFT\",\n\t\ttag: tagsNft[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/:id/transfer`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tnftTransfer(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<INftTransferRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"nftTransferExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"nft:iota:aW90YS1uZnQ6dHN0OjB4NzYyYjljNDllYTg2OWUwZWJkYTliYmZhNzY5Mzk0NDdhNDI4ZGNmMTc4YzVkMTVhYjQ0N2UyZDRmYmJiNGViMg==\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\trecipientAddress: \"tst1prctjk5ck0dutnsunnje6u90jk5htx03qznjjmkd6843pzltlgz87srjzzv\",\n\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\tdata: \"AAAAA\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst updateRoute: IRestRoute<INftUpdateRequest, INoContentResponse> = {\n\t\toperationId: \"nftUpdate\",\n\t\tsummary: \"Update an NFT\",\n\t\ttag: tagsNft[0].name,\n\t\tmethod: \"PUT\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tnftUpdate(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<INftUpdateRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"nftUpdateExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"nft:iota:aW90YS1uZnQ6dHN0OjB4NzYyYjljNDllYTg2OWUwZWJkYTliYmZhNzY5Mzk0NDdhNDI4ZGNmMTc4YzVkMTVhYjQ0N2UyZDRmYmJiNGViMg==\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\tdata: \"AAAAA\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [mintRoute, resolveRoute, burnRoute, transferRoute, updateRoute];\n}\n\n/**\n * Mint an NFT.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns A created response containing the location header with the new NFT id.\n */\nexport async function nftMint(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: INftMintRequest\n): Promise<ICreatedResponse> {\n\tGuards.object<INftMintRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<INftMintRequest[\"body\"]>(ROUTES_SOURCE, nameof(request.body), request.body);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.body.tag), request.body.tag);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\tconst component = ComponentFactory.get<INftComponent>(componentName);\n\tconst id = await component.mint(\n\t\trequest.body.tag,\n\t\trequest.body.immutableMetadata,\n\t\trequest.body.metadata,\n\t\trequest.body.namespace,\n\t\tcontextIds[ContextIdKeys.Organization]\n\t);\n\treturn {\n\t\tstatusCode: HttpStatusCode.created,\n\t\theaders: {\n\t\t\t[HeaderTypes.Location]: id\n\t\t}\n\t};\n}\n\n/**\n * Resolve an NFT.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns A response containing the resolved NFT data.\n */\nexport async function nftResolve(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: INftResolveRequest\n): Promise<INftResolveResponse> {\n\tGuards.object<INftResolveRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<INftResolveRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\tconst component = ComponentFactory.get<INftComponent>(componentName);\n\tconst result = await component.resolve(\n\t\trequest.pathParams.id,\n\t\tcontextIds[ContextIdKeys.Organization]\n\t);\n\treturn {\n\t\tbody: result\n\t};\n}\n\n/**\n * Burn an NFT.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns A no-content response indicating the NFT was burned successfully.\n */\nexport async function nftBurn(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: INftBurnRequest\n): Promise<INoContentResponse> {\n\tGuards.object<INftBurnRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<INftBurnRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\tconst component = ComponentFactory.get<INftComponent>(componentName);\n\tawait component.burn(request.pathParams.id, contextIds[ContextIdKeys.Organization]);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Transfer an NFT.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns A no-content response indicating the NFT was transferred successfully.\n */\nexport async function nftTransfer(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: INftTransferRequest\n): Promise<INoContentResponse> {\n\tGuards.object<INftTransferRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<INftTransferRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\tGuards.object<INftTransferRequest[\"body\"]>(ROUTES_SOURCE, nameof(request.body), request.body);\n\tGuards.stringValue(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.body.recipientAddress),\n\t\trequest.body.recipientAddress\n\t);\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\tconst component = ComponentFactory.get<INftComponent>(componentName);\n\tawait component.transfer(\n\t\trequest.pathParams.id,\n\t\trequest.body.recipientAddress,\n\t\trequest.body.metadata,\n\t\tcontextIds[ContextIdKeys.Organization]\n\t);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Update an NFT.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns A no-content response indicating the NFT metadata was updated successfully.\n */\nexport async function nftUpdate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: INftUpdateRequest\n): Promise<INoContentResponse> {\n\tGuards.object<INftUpdateRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<INftUpdateRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\tGuards.object<INftUpdateRequest[\"body\"]>(ROUTES_SOURCE, nameof(request.body), request.body);\n\tGuards.object(ROUTES_SOURCE, nameof(request.body.metadata), request.body.metadata);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\tconst component = ComponentFactory.get<INftComponent>(componentName);\n\tawait component.update(\n\t\trequest.pathParams.id,\n\t\trequest.body.metadata,\n\t\tcontextIds[ContextIdKeys.Organization]\n\t);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n"]}
|
package/dist/es/nftService.js
CHANGED
|
@@ -23,6 +23,7 @@ export class NftService {
|
|
|
23
23
|
/**
|
|
24
24
|
* Create a new instance of NftService.
|
|
25
25
|
* @param options The options for the service.
|
|
26
|
+
* @throws GeneralError If no NFT connectors are registered.
|
|
26
27
|
*/
|
|
27
28
|
constructor(options) {
|
|
28
29
|
const names = NftConnectorFactory.names();
|
|
@@ -33,7 +34,7 @@ export class NftService {
|
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
36
|
* Returns the class name of the component.
|
|
36
|
-
* @returns The class name
|
|
37
|
+
* @returns The class name.
|
|
37
38
|
*/
|
|
38
39
|
className() {
|
|
39
40
|
return NftService.CLASS_NAME;
|
|
@@ -81,7 +82,7 @@ export class NftService {
|
|
|
81
82
|
* Burn an NFT.
|
|
82
83
|
* @param id The id of the NFT to burn in urn format.
|
|
83
84
|
* @param controllerIdentity The identity to perform the nft operation with.
|
|
84
|
-
* @returns
|
|
85
|
+
* @returns A promise that resolves when the NFT has been permanently destroyed.
|
|
85
86
|
*/
|
|
86
87
|
async burn(id, controllerIdentity) {
|
|
87
88
|
Urn.guard(NftService.CLASS_NAME, "id", id);
|
|
@@ -100,7 +101,7 @@ export class NftService {
|
|
|
100
101
|
* @param recipientAddress The recipient address for the NFT.
|
|
101
102
|
* @param metadata Optional mutable data to include during the transfer.
|
|
102
103
|
* @param controllerIdentity The identity to perform the nft operation with.
|
|
103
|
-
* @returns
|
|
104
|
+
* @returns A promise that resolves when the NFT ownership has been transferred.
|
|
104
105
|
*/
|
|
105
106
|
async transfer(id, recipientAddress, metadata, controllerIdentity) {
|
|
106
107
|
Urn.guard(NftService.CLASS_NAME, "id", id);
|
|
@@ -115,11 +116,11 @@ export class NftService {
|
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
/**
|
|
118
|
-
* Update the data of the NFT.
|
|
119
|
+
* Update the mutable data of the NFT.
|
|
119
120
|
* @param id The id of the NFT to update in urn format.
|
|
120
121
|
* @param metadata The mutable data to update.
|
|
121
122
|
* @param controllerIdentity The identity to perform the nft operation with.
|
|
122
|
-
* @returns
|
|
123
|
+
* @returns A promise that resolves when the NFT metadata has been updated.
|
|
123
124
|
*/
|
|
124
125
|
async update(id, metadata, controllerIdentity) {
|
|
125
126
|
Urn.guard(NftService.CLASS_NAME, "id", id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nftService.js","sourceRoot":"","sources":["../../src/nftService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAA0C,MAAM,sBAAsB,CAAC;AAGnG;;G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AC,EAAE,CAAC,CAAC;QAEtC,IAAI,KAAK,CAAC,mBAAmB,EAAE,KAAK,UAAU,CAAC,UAAU,EAAE,CAAC;YAC3D,MAAM,IAAI,YAAY,CAAC,UAAU,CAAC,UAAU,EAAE,mBAAmB,EAAE;gBAClE,SAAS,EAAE,UAAU,CAAC,UAAU;gBAChC,EAAE;aACF,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,mBAAmB,CAAC,GAAG,CAAgB,KAAK,CAAC,eAAe,EAAE,CAAC,CAAC;IACxE,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { GeneralError, Guards, Urn } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { NftConnectorFactory, type INftComponent, type INftConnector } from \"@twin.org/nft-models\";\nimport type { INftServiceConstructorOptions } from \"./models/INftServiceConstructorOptions.js\";\n\n/**\n * Service for performing NFT operations to a connector.\n */\nexport class NftService implements INftComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<NftService>();\n\n\t/**\n\t * The namespace supported by the nft service.\n\t * @internal\n\t */\n\tprivate static readonly _NAMESPACE: string = \"nft\";\n\n\t/**\n\t * The default namespace for the connector to use.\n\t * @internal\n\t */\n\tprivate readonly _defaultNamespace: string;\n\n\t/**\n\t * Create a new instance of NftService.\n\t * @param options The options for the service.\n\t */\n\tconstructor(options?: INftServiceConstructorOptions) {\n\t\tconst names = NftConnectorFactory.names();\n\t\tif (names.length === 0) {\n\t\t\tthrow new GeneralError(NftService.CLASS_NAME, \"noConnectors\");\n\t\t}\n\n\t\tthis._defaultNamespace = options?.config?.defaultNamespace ?? names[0];\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn NftService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Mint an NFT.\n\t * @param tag The tag for the NFT.\n\t * @param immutableMetadata The immutable metadata for the NFT.\n\t * @param metadata The metadata for the NFT.\n\t * @param namespace The namespace of the connector to use for the NFT, defaults to service configured namespace.\n\t * @param controllerIdentity The identity to perform the nft operation with.\n\t * @returns The id of the created NFT in urn format.\n\t */\n\tpublic async mint<T = unknown, U = unknown>(\n\t\ttag: string,\n\t\timmutableMetadata?: T,\n\t\tmetadata?: U,\n\t\tnamespace?: string,\n\t\tcontrollerIdentity?: string\n\t): Promise<string> {\n\t\tGuards.stringValue(NftService.CLASS_NAME, nameof(tag), tag);\n\t\tGuards.stringValue(NftService.CLASS_NAME, nameof(controllerIdentity), controllerIdentity);\n\n\t\ttry {\n\t\t\tconst connectorNamespace = namespace ?? this._defaultNamespace;\n\n\t\t\tconst nftConnector = NftConnectorFactory.get<INftConnector>(connectorNamespace);\n\n\t\t\tconst nftUrn = await nftConnector.mint(controllerIdentity, tag, immutableMetadata, metadata);\n\n\t\t\treturn nftUrn;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(NftService.CLASS_NAME, \"mintFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Resolve an NFT.\n\t * @param id The id of the NFT to resolve.\n\t * @param controllerIdentity The identity to perform the nft operation with.\n\t * @returns The data for the NFT.\n\t */\n\tpublic async resolve<T = unknown, U = unknown>(\n\t\tid: string,\n\t\tcontrollerIdentity?: string\n\t): Promise<{\n\t\tissuer: string;\n\t\tissuerIdentityId: string;\n\t\ttag: string;\n\t\timmutableMetadata?: T;\n\t\tmetadata?: U;\n\t}> {\n\t\tUrn.guard(NftService.CLASS_NAME, nameof(id), id);\n\n\t\ttry {\n\t\t\tconst nftConnector = this.getConnector(id);\n\t\t\tconst result = await nftConnector.resolve<T, U>(id);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(NftService.CLASS_NAME, \"resolveFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Burn an NFT.\n\t * @param id The id of the NFT to burn in urn format.\n\t * @param controllerIdentity The identity to perform the nft operation with.\n\t * @returns Nothing.\n\t */\n\tpublic async burn(id: string, controllerIdentity?: string): Promise<void> {\n\t\tUrn.guard(NftService.CLASS_NAME, nameof(id), id);\n\t\tGuards.stringValue(NftService.CLASS_NAME, nameof(controllerIdentity), controllerIdentity);\n\n\t\ttry {\n\t\t\tconst nftConnector = this.getConnector(id);\n\t\t\tawait nftConnector.burn(controllerIdentity, id);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(NftService.CLASS_NAME, \"burnFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Transfer an NFT.\n\t * @param id The id of the NFT to transfer in urn format.\n\t * @param recipientAddress The recipient address for the NFT.\n\t * @param metadata Optional mutable data to include during the transfer.\n\t * @param controllerIdentity The identity to perform the nft operation with.\n\t * @returns Nothing.\n\t */\n\tpublic async transfer<U = unknown>(\n\t\tid: string,\n\t\trecipientAddress: string,\n\t\tmetadata?: U,\n\t\tcontrollerIdentity?: string\n\t): Promise<void> {\n\t\tUrn.guard(NftService.CLASS_NAME, nameof(id), id);\n\t\tGuards.stringValue(NftService.CLASS_NAME, nameof(recipientAddress), recipientAddress);\n\t\tGuards.stringValue(NftService.CLASS_NAME, nameof(controllerIdentity), controllerIdentity);\n\n\t\ttry {\n\t\t\tconst nftConnector = this.getConnector(id);\n\t\t\tawait nftConnector.transfer(controllerIdentity, id, recipientAddress, metadata);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(NftService.CLASS_NAME, \"transferFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Update the data of the NFT.\n\t * @param id The id of the NFT to update in urn format.\n\t * @param metadata The mutable data to update.\n\t * @param controllerIdentity The identity to perform the nft operation with.\n\t * @returns Nothing.\n\t */\n\tpublic async update<U = unknown>(\n\t\tid: string,\n\t\tmetadata: U,\n\t\tcontrollerIdentity?: string\n\t): Promise<void> {\n\t\tUrn.guard(NftService.CLASS_NAME, nameof(id), id);\n\t\tGuards.object(NftService.CLASS_NAME, nameof(metadata), metadata);\n\t\tGuards.stringValue(NftService.CLASS_NAME, nameof(controllerIdentity), controllerIdentity);\n\n\t\ttry {\n\t\t\tconst nftConnector = this.getConnector(id);\n\t\t\tawait nftConnector.update(controllerIdentity, id, metadata);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(NftService.CLASS_NAME, \"updateFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Get the connector from the uri.\n\t * @param id The id of the NFT in urn format.\n\t * @returns The connector.\n\t * @throws GeneralError If the namespace does not match.\n\t * @internal\n\t */\n\tprivate getConnector(id: string): INftConnector {\n\t\tconst idUri = Urn.fromValidString(id);\n\n\t\tif (idUri.namespaceIdentifier() !== NftService._NAMESPACE) {\n\t\t\tthrow new GeneralError(NftService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: NftService._NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\treturn NftConnectorFactory.get<INftConnector>(idUri.namespaceMethod());\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"nftService.js","sourceRoot":"","sources":["../../src/nftService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAA0C,MAAM,sBAAsB,CAAC;AAGnG;;GAEG;AACH,MAAM,OAAO,UAAU;IACtB;;OAEG;IACI,MAAM,CAAU,UAAU,gBAAgC;IAEjE;;;OAGG;IACK,MAAM,CAAU,UAAU,GAAW,KAAK,CAAC;IAEnD;;;OAGG;IACc,iBAAiB,CAAS;IAE3C;;;;OAIG;IACH,YAAY,OAAuC;QAClD,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAK,EAAE,CAAC;QAC1C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,YAAY,CAAC,UAAU,CAAC,UAAU,EA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stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { GeneralError, Guards, Urn } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { NftConnectorFactory, type INftComponent, type INftConnector } from \"@twin.org/nft-models\";\nimport type { INftServiceConstructorOptions } from \"./models/INftServiceConstructorOptions.js\";\n\n/**\n * Service for performing NFT operations to a connector.\n */\nexport class NftService implements INftComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<NftService>();\n\n\t/**\n\t * The namespace supported by the nft service.\n\t * @internal\n\t */\n\tprivate static readonly _NAMESPACE: string = \"nft\";\n\n\t/**\n\t * The default namespace for the connector to use.\n\t * @internal\n\t */\n\tprivate readonly _defaultNamespace: string;\n\n\t/**\n\t * Create a new instance of NftService.\n\t * @param options The options for the service.\n\t * @throws GeneralError If no NFT connectors are registered.\n\t */\n\tconstructor(options?: INftServiceConstructorOptions) {\n\t\tconst names = NftConnectorFactory.names();\n\t\tif (names.length === 0) {\n\t\t\tthrow new GeneralError(NftService.CLASS_NAME, \"noConnectors\");\n\t\t}\n\n\t\tthis._defaultNamespace = options?.config?.defaultNamespace ?? names[0];\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name.\n\t */\n\tpublic className(): string {\n\t\treturn NftService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Mint an NFT.\n\t * @param tag The tag for the NFT.\n\t * @param immutableMetadata The immutable metadata for the NFT.\n\t * @param metadata The metadata for the NFT.\n\t * @param namespace The namespace of the connector to use for the NFT, defaults to service configured namespace.\n\t * @param controllerIdentity The identity to perform the nft operation with.\n\t * @returns The id of the created NFT in urn format.\n\t */\n\tpublic async mint<T = unknown, U = unknown>(\n\t\ttag: string,\n\t\timmutableMetadata?: T,\n\t\tmetadata?: U,\n\t\tnamespace?: string,\n\t\tcontrollerIdentity?: string\n\t): Promise<string> {\n\t\tGuards.stringValue(NftService.CLASS_NAME, nameof(tag), tag);\n\t\tGuards.stringValue(NftService.CLASS_NAME, nameof(controllerIdentity), controllerIdentity);\n\n\t\ttry {\n\t\t\tconst connectorNamespace = namespace ?? this._defaultNamespace;\n\n\t\t\tconst nftConnector = NftConnectorFactory.get<INftConnector>(connectorNamespace);\n\n\t\t\tconst nftUrn = await nftConnector.mint(controllerIdentity, tag, immutableMetadata, metadata);\n\n\t\t\treturn nftUrn;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(NftService.CLASS_NAME, \"mintFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Resolve an NFT.\n\t * @param id The id of the NFT to resolve.\n\t * @param controllerIdentity The identity to perform the nft operation with.\n\t * @returns The data for the NFT.\n\t */\n\tpublic async resolve<T = unknown, U = unknown>(\n\t\tid: string,\n\t\tcontrollerIdentity?: string\n\t): Promise<{\n\t\tissuer: string;\n\t\tissuerIdentityId: string;\n\t\ttag: string;\n\t\timmutableMetadata?: T;\n\t\tmetadata?: U;\n\t}> {\n\t\tUrn.guard(NftService.CLASS_NAME, nameof(id), id);\n\n\t\ttry {\n\t\t\tconst nftConnector = this.getConnector(id);\n\t\t\tconst result = await nftConnector.resolve<T, U>(id);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(NftService.CLASS_NAME, \"resolveFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Burn an NFT.\n\t * @param id The id of the NFT to burn in urn format.\n\t * @param controllerIdentity The identity to perform the nft operation with.\n\t * @returns A promise that resolves when the NFT has been permanently destroyed.\n\t */\n\tpublic async burn(id: string, controllerIdentity?: string): Promise<void> {\n\t\tUrn.guard(NftService.CLASS_NAME, nameof(id), id);\n\t\tGuards.stringValue(NftService.CLASS_NAME, nameof(controllerIdentity), controllerIdentity);\n\n\t\ttry {\n\t\t\tconst nftConnector = this.getConnector(id);\n\t\t\tawait nftConnector.burn(controllerIdentity, id);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(NftService.CLASS_NAME, \"burnFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Transfer an NFT.\n\t * @param id The id of the NFT to transfer in urn format.\n\t * @param recipientAddress The recipient address for the NFT.\n\t * @param metadata Optional mutable data to include during the transfer.\n\t * @param controllerIdentity The identity to perform the nft operation with.\n\t * @returns A promise that resolves when the NFT ownership has been transferred.\n\t */\n\tpublic async transfer<U = unknown>(\n\t\tid: string,\n\t\trecipientAddress: string,\n\t\tmetadata?: U,\n\t\tcontrollerIdentity?: string\n\t): Promise<void> {\n\t\tUrn.guard(NftService.CLASS_NAME, nameof(id), id);\n\t\tGuards.stringValue(NftService.CLASS_NAME, nameof(recipientAddress), recipientAddress);\n\t\tGuards.stringValue(NftService.CLASS_NAME, nameof(controllerIdentity), controllerIdentity);\n\n\t\ttry {\n\t\t\tconst nftConnector = this.getConnector(id);\n\t\t\tawait nftConnector.transfer(controllerIdentity, id, recipientAddress, metadata);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(NftService.CLASS_NAME, \"transferFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Update the mutable data of the NFT.\n\t * @param id The id of the NFT to update in urn format.\n\t * @param metadata The mutable data to update.\n\t * @param controllerIdentity The identity to perform the nft operation with.\n\t * @returns A promise that resolves when the NFT metadata has been updated.\n\t */\n\tpublic async update<U = unknown>(\n\t\tid: string,\n\t\tmetadata: U,\n\t\tcontrollerIdentity?: string\n\t): Promise<void> {\n\t\tUrn.guard(NftService.CLASS_NAME, nameof(id), id);\n\t\tGuards.object(NftService.CLASS_NAME, nameof(metadata), metadata);\n\t\tGuards.stringValue(NftService.CLASS_NAME, nameof(controllerIdentity), controllerIdentity);\n\n\t\ttry {\n\t\t\tconst nftConnector = this.getConnector(id);\n\t\t\tawait nftConnector.update(controllerIdentity, id, metadata);\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(NftService.CLASS_NAME, \"updateFailed\", undefined, error);\n\t\t}\n\t}\n\n\t/**\n\t * Get the connector from the uri.\n\t * @param id The id of the NFT in urn format.\n\t * @returns The connector.\n\t * @throws GeneralError If the namespace does not match.\n\t * @internal\n\t */\n\tprivate getConnector(id: string): INftConnector {\n\t\tconst idUri = Urn.fromValidString(id);\n\n\t\tif (idUri.namespaceIdentifier() !== NftService._NAMESPACE) {\n\t\t\tthrow new GeneralError(NftService.CLASS_NAME, \"namespaceMismatch\", {\n\t\t\t\tnamespace: NftService._NAMESPACE,\n\t\t\t\tid\n\t\t\t});\n\t\t}\n\n\t\treturn NftConnectorFactory.get<INftConnector>(idUri.namespaceMethod());\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restEntryPoints.js","sourceRoot":"","sources":["../../src/restEntryPoints.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEhE,MAAM,CAAC,MAAM,eAAe,GAA2B;IACtD;QACC,IAAI,EAAE,KAAK;QACX,gBAAgB,EAAE,KAAK;QACvB,IAAI,EAAE,OAAO;QACb,cAAc,EAAE,qBAAqB;KACrC;CACD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestRouteEntryPoint } from \"@twin.org/api-models\";\nimport { generateRestRoutesNft, tagsNft } from \"./nftRoutes.js\";\n\nexport const restEntryPoints: IRestRouteEntryPoint[] = [\n\t{\n\t\tname: \"nft\",\n\t\tdefaultBaseRoute: \"nft\",\n\t\ttags: tagsNft,\n\t\tgenerateRoutes: generateRestRoutesNft\n\t}\n];\n"]}
|
|
1
|
+
{"version":3,"file":"restEntryPoints.js","sourceRoot":"","sources":["../../src/restEntryPoints.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAA2B;IACtD;QACC,IAAI,EAAE,KAAK;QACX,gBAAgB,EAAE,KAAK;QACvB,IAAI,EAAE,OAAO;QACb,cAAc,EAAE,qBAAqB;KACrC;CACD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestRouteEntryPoint } from \"@twin.org/api-models\";\nimport { generateRestRoutesNft, tagsNft } from \"./nftRoutes.js\";\n\n/**\n * REST entry point definitions for the NFT service.\n */\nexport const restEntryPoints: IRestRouteEntryPoint[] = [\n\t{\n\t\tname: \"nft\",\n\t\tdefaultBaseRoute: \"nft\",\n\t\ttags: tagsNft,\n\t\tgenerateRoutes: generateRestRoutesNft\n\t}\n];\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export interface INftServiceConfig {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* The default connector namespace to use for NFT operations; defaults to the first registered connector.
|
|
7
7
|
*/
|
|
8
8
|
defaultNamespace?: string;
|
|
9
9
|
}
|
|
@@ -16,7 +16,7 @@ export declare function generateRestRoutesNft(baseRouteName: string, componentNa
|
|
|
16
16
|
* @param httpRequestContext The request context for the API.
|
|
17
17
|
* @param componentName The name of the component to use in the routes.
|
|
18
18
|
* @param request The request.
|
|
19
|
-
* @returns
|
|
19
|
+
* @returns A created response containing the location header with the new NFT id.
|
|
20
20
|
*/
|
|
21
21
|
export declare function nftMint(httpRequestContext: IHttpRequestContext, componentName: string, request: INftMintRequest): Promise<ICreatedResponse>;
|
|
22
22
|
/**
|
|
@@ -24,7 +24,7 @@ export declare function nftMint(httpRequestContext: IHttpRequestContext, compone
|
|
|
24
24
|
* @param httpRequestContext The request context for the API.
|
|
25
25
|
* @param componentName The name of the component to use in the routes.
|
|
26
26
|
* @param request The request.
|
|
27
|
-
* @returns
|
|
27
|
+
* @returns A response containing the resolved NFT data.
|
|
28
28
|
*/
|
|
29
29
|
export declare function nftResolve(httpRequestContext: IHttpRequestContext, componentName: string, request: INftResolveRequest): Promise<INftResolveResponse>;
|
|
30
30
|
/**
|
|
@@ -32,7 +32,7 @@ export declare function nftResolve(httpRequestContext: IHttpRequestContext, comp
|
|
|
32
32
|
* @param httpRequestContext The request context for the API.
|
|
33
33
|
* @param componentName The name of the component to use in the routes.
|
|
34
34
|
* @param request The request.
|
|
35
|
-
* @returns
|
|
35
|
+
* @returns A no-content response indicating the NFT was burned successfully.
|
|
36
36
|
*/
|
|
37
37
|
export declare function nftBurn(httpRequestContext: IHttpRequestContext, componentName: string, request: INftBurnRequest): Promise<INoContentResponse>;
|
|
38
38
|
/**
|
|
@@ -40,7 +40,7 @@ export declare function nftBurn(httpRequestContext: IHttpRequestContext, compone
|
|
|
40
40
|
* @param httpRequestContext The request context for the API.
|
|
41
41
|
* @param componentName The name of the component to use in the routes.
|
|
42
42
|
* @param request The request.
|
|
43
|
-
* @returns
|
|
43
|
+
* @returns A no-content response indicating the NFT was transferred successfully.
|
|
44
44
|
*/
|
|
45
45
|
export declare function nftTransfer(httpRequestContext: IHttpRequestContext, componentName: string, request: INftTransferRequest): Promise<INoContentResponse>;
|
|
46
46
|
/**
|
|
@@ -48,6 +48,6 @@ export declare function nftTransfer(httpRequestContext: IHttpRequestContext, com
|
|
|
48
48
|
* @param httpRequestContext The request context for the API.
|
|
49
49
|
* @param componentName The name of the component to use in the routes.
|
|
50
50
|
* @param request The request.
|
|
51
|
-
* @returns
|
|
51
|
+
* @returns A no-content response indicating the NFT metadata was updated successfully.
|
|
52
52
|
*/
|
|
53
53
|
export declare function nftUpdate(httpRequestContext: IHttpRequestContext, componentName: string, request: INftUpdateRequest): Promise<INoContentResponse>;
|
|
@@ -11,11 +11,12 @@ export declare class NftService implements INftComponent {
|
|
|
11
11
|
/**
|
|
12
12
|
* Create a new instance of NftService.
|
|
13
13
|
* @param options The options for the service.
|
|
14
|
+
* @throws GeneralError If no NFT connectors are registered.
|
|
14
15
|
*/
|
|
15
16
|
constructor(options?: INftServiceConstructorOptions);
|
|
16
17
|
/**
|
|
17
18
|
* Returns the class name of the component.
|
|
18
|
-
* @returns The class name
|
|
19
|
+
* @returns The class name.
|
|
19
20
|
*/
|
|
20
21
|
className(): string;
|
|
21
22
|
/**
|
|
@@ -45,7 +46,7 @@ export declare class NftService implements INftComponent {
|
|
|
45
46
|
* Burn an NFT.
|
|
46
47
|
* @param id The id of the NFT to burn in urn format.
|
|
47
48
|
* @param controllerIdentity The identity to perform the nft operation with.
|
|
48
|
-
* @returns
|
|
49
|
+
* @returns A promise that resolves when the NFT has been permanently destroyed.
|
|
49
50
|
*/
|
|
50
51
|
burn(id: string, controllerIdentity?: string): Promise<void>;
|
|
51
52
|
/**
|
|
@@ -54,15 +55,15 @@ export declare class NftService implements INftComponent {
|
|
|
54
55
|
* @param recipientAddress The recipient address for the NFT.
|
|
55
56
|
* @param metadata Optional mutable data to include during the transfer.
|
|
56
57
|
* @param controllerIdentity The identity to perform the nft operation with.
|
|
57
|
-
* @returns
|
|
58
|
+
* @returns A promise that resolves when the NFT ownership has been transferred.
|
|
58
59
|
*/
|
|
59
60
|
transfer<U = unknown>(id: string, recipientAddress: string, metadata?: U, controllerIdentity?: string): Promise<void>;
|
|
60
61
|
/**
|
|
61
|
-
* Update the data of the NFT.
|
|
62
|
+
* Update the mutable data of the NFT.
|
|
62
63
|
* @param id The id of the NFT to update in urn format.
|
|
63
64
|
* @param metadata The mutable data to update.
|
|
64
65
|
* @param controllerIdentity The identity to perform the nft operation with.
|
|
65
|
-
* @returns
|
|
66
|
+
* @returns A promise that resolves when the NFT metadata has been updated.
|
|
66
67
|
*/
|
|
67
68
|
update<U = unknown>(id: string, metadata: U, controllerIdentity?: string): Promise<void>;
|
|
68
69
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.9.0-next.1](https://github.com/iotaledger/twin-nft/compare/nft-service-v0.9.0-next.0...nft-service-v0.9.0-next.1) (2026-06-23)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add context id features ([#50](https://github.com/iotaledger/twin-nft/issues/50)) ([56c31c7](https://github.com/iotaledger/twin-nft/commit/56c31c7ba10e3ef8ad44f6463153f90888e64711))
|
|
9
|
+
* add on-chain identity binding to NFT minting ([#58](https://github.com/iotaledger/twin-nft/issues/58)) ([730a16d](https://github.com/iotaledger/twin-nft/commit/730a16d70fc026c920dbede0e4dafc96f37b729a))
|
|
10
|
+
* add validate-locales ([0055a56](https://github.com/iotaledger/twin-nft/commit/0055a56ed166946f1db860aa0725ad53248b3427))
|
|
11
|
+
* eslint migration to flat config ([0e6fc12](https://github.com/iotaledger/twin-nft/commit/0e6fc128c3c8f6cd34db793787437dd4af2c9994))
|
|
12
|
+
* iota rebased release ([bfdd233](https://github.com/iotaledger/twin-nft/commit/bfdd23330e168962f7ad0a6fcd2c9c9a38a11697))
|
|
13
|
+
* move to json integration ([#31](https://github.com/iotaledger/twin-nft/issues/31)) ([89944ba](https://github.com/iotaledger/twin-nft/commit/89944ba05b955944f84419224c3ae63fef28cc23))
|
|
14
|
+
* remove unused namespace ([48d2a92](https://github.com/iotaledger/twin-nft/commit/48d2a926d610fad0b0407311e71a215d15a99aa5))
|
|
15
|
+
* typescript 6 update ([91b94b8](https://github.com/iotaledger/twin-nft/commit/91b94b846ea081b09b2228681776ce30f104a36e))
|
|
16
|
+
* update dependencies ([8660f76](https://github.com/iotaledger/twin-nft/commit/8660f76ca324b0f476e45544cac6bee4b3146c3b))
|
|
17
|
+
* update framework core ([f3496b6](https://github.com/iotaledger/twin-nft/commit/f3496b61bfebbb3479bb92df39ecfa9ac8d90b9b))
|
|
18
|
+
* use shared store mechanism ([#16](https://github.com/iotaledger/twin-nft/issues/16)) ([897bc78](https://github.com/iotaledger/twin-nft/commit/897bc7805248ba1388b2dd03df24c33f1633f344))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* params order modified ([#19](https://github.com/iotaledger/twin-nft/issues/19)) ([c2ceb30](https://github.com/iotaledger/twin-nft/commit/c2ceb3040c12286d4fac09d51db77465366ba89d))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Dependencies
|
|
27
|
+
|
|
28
|
+
* The following workspace dependencies were updated
|
|
29
|
+
* dependencies
|
|
30
|
+
* @twin.org/nft-models bumped from 0.9.0-next.0 to 0.9.0-next.1
|
|
31
|
+
* devDependencies
|
|
32
|
+
* @twin.org/nft-connector-entity-storage bumped from 0.9.0-next.0 to 0.9.0-next.1
|
|
33
|
+
|
|
34
|
+
## [0.0.3-next.9](https://github.com/iotaledger/twin-nft/compare/nft-service-v0.0.3-next.8...nft-service-v0.0.3-next.9) (2026-06-17)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Miscellaneous Chores
|
|
38
|
+
|
|
39
|
+
* **nft-service:** Synchronize repo versions
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Dependencies
|
|
43
|
+
|
|
44
|
+
* The following workspace dependencies were updated
|
|
45
|
+
* dependencies
|
|
46
|
+
* @twin.org/nft-models bumped from 0.0.3-next.8 to 0.0.3-next.9
|
|
47
|
+
* devDependencies
|
|
48
|
+
* @twin.org/nft-connector-entity-storage bumped from 0.0.3-next.8 to 0.0.3-next.9
|
|
49
|
+
|
|
3
50
|
## [0.0.3-next.8](https://github.com/iotaledger/twin-nft/compare/nft-service-v0.0.3-next.7...nft-service-v0.0.3-next.8) (2026-06-11)
|
|
4
51
|
|
|
5
52
|
|
package/docs/open-api/spec.json
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
}
|
|
35
35
|
],
|
|
36
36
|
"requestBody": {
|
|
37
|
-
"description": "
|
|
37
|
+
"description": "Request to mint a new NFT.",
|
|
38
38
|
"required": true,
|
|
39
39
|
"content": {
|
|
40
40
|
"application/json": {
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
],
|
|
159
159
|
"responses": {
|
|
160
160
|
"200": {
|
|
161
|
-
"description": "Response
|
|
161
|
+
"description": "Response returned after resolving an NFT.",
|
|
162
162
|
"content": {
|
|
163
163
|
"application/json": {
|
|
164
164
|
"schema": {
|
|
@@ -339,7 +339,7 @@
|
|
|
339
339
|
"parameters": [
|
|
340
340
|
{
|
|
341
341
|
"name": "id",
|
|
342
|
-
"description": "The id of the NFT to
|
|
342
|
+
"description": "The id of the NFT to update in urn format.",
|
|
343
343
|
"in": "path",
|
|
344
344
|
"required": true,
|
|
345
345
|
"schema": {
|
|
@@ -355,7 +355,7 @@
|
|
|
355
355
|
}
|
|
356
356
|
],
|
|
357
357
|
"requestBody": {
|
|
358
|
-
"description": "
|
|
358
|
+
"description": "Request to update the mutable metadata of an NFT.",
|
|
359
359
|
"required": true,
|
|
360
360
|
"content": {
|
|
361
361
|
"application/json": {
|
|
@@ -464,7 +464,7 @@
|
|
|
464
464
|
}
|
|
465
465
|
],
|
|
466
466
|
"requestBody": {
|
|
467
|
-
"description": "
|
|
467
|
+
"description": "Request to transfer an NFT to a new owner.",
|
|
468
468
|
"required": true,
|
|
469
469
|
"content": {
|
|
470
470
|
"application/json": {
|
|
@@ -606,7 +606,7 @@
|
|
|
606
606
|
"required": [
|
|
607
607
|
"tag"
|
|
608
608
|
],
|
|
609
|
-
"description": "The
|
|
609
|
+
"description": "The request body containing minting parameters."
|
|
610
610
|
},
|
|
611
611
|
"NftResolveResponse": {
|
|
612
612
|
"type": "object",
|
|
@@ -635,7 +635,7 @@
|
|
|
635
635
|
"issuerIdentityId",
|
|
636
636
|
"tag"
|
|
637
637
|
],
|
|
638
|
-
"description": "The
|
|
638
|
+
"description": "The resolved NFT data."
|
|
639
639
|
},
|
|
640
640
|
"NftTransferRequest": {
|
|
641
641
|
"type": "object",
|
|
@@ -651,7 +651,7 @@
|
|
|
651
651
|
"required": [
|
|
652
652
|
"recipientAddress"
|
|
653
653
|
],
|
|
654
|
-
"description": "The
|
|
654
|
+
"description": "The request body containing transfer parameters."
|
|
655
655
|
},
|
|
656
656
|
"NftUpdateRequest": {
|
|
657
657
|
"type": "object",
|
|
@@ -660,7 +660,7 @@
|
|
|
660
660
|
"description": "The metadata for the NFT."
|
|
661
661
|
}
|
|
662
662
|
},
|
|
663
|
-
"description": "The
|
|
663
|
+
"description": "The request body containing update parameters."
|
|
664
664
|
}
|
|
665
665
|
},
|
|
666
666
|
"securitySchemes": {
|
|
@@ -26,6 +26,10 @@ The options for the service.
|
|
|
26
26
|
|
|
27
27
|
`NftService`
|
|
28
28
|
|
|
29
|
+
#### Throws
|
|
30
|
+
|
|
31
|
+
GeneralError If no NFT connectors are registered.
|
|
32
|
+
|
|
29
33
|
## Properties
|
|
30
34
|
|
|
31
35
|
### CLASS\_NAME {#class_name}
|
|
@@ -46,7 +50,7 @@ Returns the class name of the component.
|
|
|
46
50
|
|
|
47
51
|
`string`
|
|
48
52
|
|
|
49
|
-
The class name
|
|
53
|
+
The class name.
|
|
50
54
|
|
|
51
55
|
#### Implementation of
|
|
52
56
|
|
|
@@ -180,7 +184,7 @@ The identity to perform the nft operation with.
|
|
|
180
184
|
|
|
181
185
|
`Promise`\<`void`\>
|
|
182
186
|
|
|
183
|
-
|
|
187
|
+
A promise that resolves when the NFT has been permanently destroyed.
|
|
184
188
|
|
|
185
189
|
#### Implementation of
|
|
186
190
|
|
|
@@ -230,7 +234,7 @@ The identity to perform the nft operation with.
|
|
|
230
234
|
|
|
231
235
|
`Promise`\<`void`\>
|
|
232
236
|
|
|
233
|
-
|
|
237
|
+
A promise that resolves when the NFT ownership has been transferred.
|
|
234
238
|
|
|
235
239
|
#### Implementation of
|
|
236
240
|
|
|
@@ -242,7 +246,7 @@ Nothing.
|
|
|
242
246
|
|
|
243
247
|
> **update**\<`U`\>(`id`, `metadata`, `controllerIdentity?`): `Promise`\<`void`\>
|
|
244
248
|
|
|
245
|
-
Update the data of the NFT.
|
|
249
|
+
Update the mutable data of the NFT.
|
|
246
250
|
|
|
247
251
|
#### Type Parameters
|
|
248
252
|
|
|
@@ -274,7 +278,7 @@ The identity to perform the nft operation with.
|
|
|
274
278
|
|
|
275
279
|
`Promise`\<`void`\>
|
|
276
280
|
|
|
277
|
-
|
|
281
|
+
A promise that resolves when the NFT metadata has been updated.
|
|
278
282
|
|
|
279
283
|
#### Implementation of
|
|
280
284
|
|
|
@@ -8,4 +8,4 @@ Configuration for the NFT Service.
|
|
|
8
8
|
|
|
9
9
|
> `optional` **defaultNamespace?**: `string`
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
The default connector namespace to use for NFT operations; defaults to the first registered connector.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/nft-service",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.9.0-next.1",
|
|
4
4
|
"description": "NFT service orchestration with REST route generation.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/api-models": "next",
|
|
18
|
-
"@twin.org/context": "next",
|
|
19
|
-
"@twin.org/core": "next",
|
|
20
|
-
"@twin.org/entity": "next",
|
|
21
|
-
"@twin.org/nameof": "next",
|
|
22
|
-
"@twin.org/nft-models": "0.0
|
|
23
|
-
"@twin.org/web": "next"
|
|
17
|
+
"@twin.org/api-models": "0.9.0-next.1",
|
|
18
|
+
"@twin.org/context": "0.9.0-next.1",
|
|
19
|
+
"@twin.org/core": "0.9.0-next.1",
|
|
20
|
+
"@twin.org/entity": "0.9.0-next.1",
|
|
21
|
+
"@twin.org/nameof": "0.9.0-next.1",
|
|
22
|
+
"@twin.org/nft-models": "0.9.0-next.1",
|
|
23
|
+
"@twin.org/web": "0.9.0-next.1"
|
|
24
24
|
},
|
|
25
25
|
"main": "./dist/es/index.js",
|
|
26
26
|
"types": "./dist/types/index.d.ts",
|