@twin.org/nft-rest-client 0.0.2-next.8 → 0.0.3-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/index.js +4 -0
- package/dist/es/index.js.map +1 -0
- package/dist/{esm/index.mjs → es/nftRestClient.js} +13 -8
- package/dist/es/nftRestClient.js.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/nftRestClient.d.ts +6 -1
- package/docs/changelog.md +19 -0
- package/docs/reference/classes/NftRestClient.md +19 -1
- package/package.json +6 -8
- package/dist/cjs/index.cjs +0 -114
package/dist/es/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,oBAAoB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./nftRestClient.js\";\n"]}
|
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
import { BaseRestClient } from '@twin.org/api-core';
|
|
2
|
-
import { Guards, Urn } from '@twin.org/core';
|
|
3
|
-
import { HeaderTypes } from '@twin.org/web';
|
|
4
|
-
|
|
5
1
|
// Copyright 2024 IOTA Stiftung.
|
|
6
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { BaseRestClient } from "@twin.org/api-core";
|
|
4
|
+
import { Guards, Urn } from "@twin.org/core";
|
|
5
|
+
import { HeaderTypes } from "@twin.org/web";
|
|
7
6
|
/**
|
|
8
7
|
* Client for performing NFT through to REST endpoints.
|
|
9
8
|
*/
|
|
10
|
-
class NftRestClient extends BaseRestClient {
|
|
9
|
+
export class NftRestClient extends BaseRestClient {
|
|
11
10
|
/**
|
|
12
11
|
* Runtime name for the class.
|
|
13
12
|
*/
|
|
14
13
|
static CLASS_NAME = "NftRestClient";
|
|
15
14
|
/**
|
|
16
|
-
* Create a new instance of
|
|
15
|
+
* Create a new instance of NftRestClient.
|
|
17
16
|
* @param config The configuration for the client.
|
|
18
17
|
*/
|
|
19
18
|
constructor(config) {
|
|
20
19
|
super("NftRestClient", config, "nft");
|
|
21
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns the class name of the component.
|
|
23
|
+
* @returns The class name of the component.
|
|
24
|
+
*/
|
|
25
|
+
className() {
|
|
26
|
+
return NftRestClient.CLASS_NAME;
|
|
27
|
+
}
|
|
22
28
|
/**
|
|
23
29
|
* Mint an NFT.
|
|
24
30
|
* @param tag The tag for the NFT.
|
|
@@ -108,5 +114,4 @@ class NftRestClient extends BaseRestClient {
|
|
|
108
114
|
});
|
|
109
115
|
}
|
|
110
116
|
}
|
|
111
|
-
|
|
112
|
-
export { NftRestClient };
|
|
117
|
+
//# sourceMappingURL=nftRestClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nftRestClient.js","sourceRoot":"","sources":["../../src/nftRestClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAW7C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,cAAc;IAChD;;OAEG;IACI,MAAM,CAAU,UAAU,mBAAmC;IAEpE;;;OAGG;IACH,YAAY,MAA6B;QACxC,KAAK,kBAA0B,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,aAAa,CAAC,UAAU,CAAC;IACjC,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,IAAI,CAChB,GAAW,EACX,iBAAqB,EACrB,QAAY,EACZ,SAAkB;QAElB,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,UAAU,SAAe,GAAG,CAAC,CAAC;QAE/D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAoC,GAAG,EAAE,MAAM,EAAE;YACjF,IAAI,EAAE;gBACL,GAAG;gBACH,iBAAiB;gBACjB,QAAQ;gBACR,SAAS;aACT;SACD,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,OAAO,CACnB,EAAU;QAQV,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,UAAU,QAAc,EAAE,CAAC,CAAC;QAE7D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAA0C,MAAM,EAAE,KAAK,EAAE;YACzF,UAAU,EAAE;gBACX,EAAE;aACF;SACD,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,IAMf,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,IAAI,CAAC,EAAU;QAC3B,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,UAAU,QAAc,EAAE,CAAC,CAAC;QAEpD,MAAM,IAAI,CAAC,KAAK,CAAyB,MAAM,EAAE,QAAQ,EAAE;YAC1D,UAAU,EAAE;gBACX,EAAE;aACF;SACD,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,QAAQ,CACpB,EAAU,EACV,iBAAyB,EACzB,gBAAwB,EACxB,QAAY;QAEZ,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,UAAU,QAAc,EAAE,CAAC,CAAC;QAC7D,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,UAAU,uBAA6B,iBAAiB,CAAC,CAAC;QAC3F,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,UAAU,sBAA4B,gBAAgB,CAAC,CAAC;QAEzF,MAAM,IAAI,CAAC,KAAK,CAA6B,eAAe,EAAE,MAAM,EAAE;YACrE,UAAU,EAAE;gBACX,EAAE;aACF;YACD,IAAI,EAAE;gBACL,iBAAiB;gBACjB,gBAAgB;gBAChB,QAAQ;aACR;SACD,CAAC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,MAAM,CAAc,EAAU,EAAE,QAAW;QACvD,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,UAAU,QAAc,EAAE,CAAC,CAAC;QAC7D,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,cAAoB,QAAQ,CAAC,CAAC;QAEpE,MAAM,IAAI,CAAC,KAAK,CAA2B,MAAM,EAAE,KAAK,EAAE;YACzD,UAAU,EAAE;gBACX,EAAE;aACF;YACD,IAAI,EAAE;gBACL,QAAQ;aACR;SACD,CAAC,CAAC;IACJ,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseRestClient } from \"@twin.org/api-core\";\nimport type { IBaseRestClientConfig, ICreatedResponse } from \"@twin.org/api-models\";\nimport { Guards, Urn } 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 } from \"@twin.org/web\";\n\n/**\n * Client for performing NFT through to REST endpoints.\n */\nexport class NftRestClient extends BaseRestClient implements INftComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<NftRestClient>();\n\n\t/**\n\t * Create a new instance of NftRestClient.\n\t * @param config The configuration for the client.\n\t */\n\tconstructor(config: IBaseRestClientConfig) {\n\t\tsuper(nameof<NftRestClient>(), config, \"nft\");\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 NftRestClient.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 component configured namespace.\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): Promise<string> {\n\t\tGuards.stringValue(NftRestClient.CLASS_NAME, nameof(tag), tag);\n\n\t\tconst response = await this.fetch<INftMintRequest, ICreatedResponse>(\"/\", \"POST\", {\n\t\t\tbody: {\n\t\t\t\ttag,\n\t\t\t\timmutableMetadata,\n\t\t\t\tmetadata,\n\t\t\t\tnamespace\n\t\t\t}\n\t\t});\n\n\t\treturn response.headers[HeaderTypes.Location];\n\t}\n\n\t/**\n\t * Resolve an NFT.\n\t * @param id The id of the NFT to resolve.\n\t * @returns The data for the NFT.\n\t */\n\tpublic async resolve<T = unknown, U = unknown>(\n\t\tid: string\n\t): Promise<{\n\t\tissuer: string;\n\t\towner: string;\n\t\ttag: string;\n\t\timmutableMetadata?: T;\n\t\tmetadata?: U;\n\t}> {\n\t\tGuards.stringValue(NftRestClient.CLASS_NAME, nameof(id), id);\n\n\t\tconst response = await this.fetch<INftResolveRequest, INftResolveResponse>(\"/:id\", \"GET\", {\n\t\t\tpathParams: {\n\t\t\t\tid\n\t\t\t}\n\t\t});\n\n\t\treturn response.body as {\n\t\t\tissuer: string;\n\t\t\towner: string;\n\t\t\ttag: string;\n\t\t\timmutableMetadata?: T;\n\t\t\tmetadata?: U;\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 * @returns Nothing.\n\t */\n\tpublic async burn(id: string): Promise<void> {\n\t\tUrn.guard(NftRestClient.CLASS_NAME, nameof(id), id);\n\n\t\tawait this.fetch<INftBurnRequest, never>(\"/:id\", \"DELETE\", {\n\t\t\tpathParams: {\n\t\t\t\tid\n\t\t\t}\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 recipientIdentity The recipient identity for the NFT.\n\t * @param recipientAddress The recipient address for the NFT.\n\t * @param metadata Optional mutable data to include during the transfer.\n\t * @returns Nothing.\n\t */\n\tpublic async transfer<T = unknown>(\n\t\tid: string,\n\t\trecipientIdentity: string,\n\t\trecipientAddress: string,\n\t\tmetadata?: T\n\t): Promise<void> {\n\t\tGuards.stringValue(NftRestClient.CLASS_NAME, nameof(id), id);\n\t\tGuards.stringValue(NftRestClient.CLASS_NAME, nameof(recipientIdentity), recipientIdentity);\n\t\tGuards.stringValue(NftRestClient.CLASS_NAME, nameof(recipientAddress), recipientAddress);\n\n\t\tawait this.fetch<INftTransferRequest, never>(\"/:id/transfer\", \"POST\", {\n\t\t\tpathParams: {\n\t\t\t\tid\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\trecipientIdentity,\n\t\t\t\trecipientAddress,\n\t\t\t\tmetadata\n\t\t\t}\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 * @returns Nothing.\n\t */\n\tpublic async update<U = unknown>(id: string, metadata: U): Promise<void> {\n\t\tGuards.stringValue(NftRestClient.CLASS_NAME, nameof(id), id);\n\t\tGuards.object(NftRestClient.CLASS_NAME, nameof(metadata), metadata);\n\n\t\tawait this.fetch<INftUpdateRequest, never>(\"/:id\", \"PUT\", {\n\t\t\tpathParams: {\n\t\t\t\tid\n\t\t\t},\n\t\t\tbody: {\n\t\t\t\tmetadata\n\t\t\t}\n\t\t});\n\t}\n}\n"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./nftRestClient";
|
|
1
|
+
export * from "./nftRestClient.js";
|
|
@@ -10,10 +10,15 @@ export declare class NftRestClient extends BaseRestClient implements INftCompone
|
|
|
10
10
|
*/
|
|
11
11
|
static readonly CLASS_NAME: string;
|
|
12
12
|
/**
|
|
13
|
-
* Create a new instance of
|
|
13
|
+
* Create a new instance of NftRestClient.
|
|
14
14
|
* @param config The configuration for the client.
|
|
15
15
|
*/
|
|
16
16
|
constructor(config: IBaseRestClientConfig);
|
|
17
|
+
/**
|
|
18
|
+
* Returns the class name of the component.
|
|
19
|
+
* @returns The class name of the component.
|
|
20
|
+
*/
|
|
21
|
+
className(): string;
|
|
17
22
|
/**
|
|
18
23
|
* Mint an NFT.
|
|
19
24
|
* @param tag The tag for the NFT.
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @twin.org/nft-rest-client - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.1](https://github.com/twinfoundation/nft/compare/nft-rest-client-v0.0.3-next.0...nft-rest-client-v0.0.3-next.1) (2025-11-12)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add context id features ([#50](https://github.com/twinfoundation/nft/issues/50)) ([56c31c7](https://github.com/twinfoundation/nft/commit/56c31c7ba10e3ef8ad44f6463153f90888e64711))
|
|
9
|
+
* add validate-locales ([0055a56](https://github.com/twinfoundation/nft/commit/0055a56ed166946f1db860aa0725ad53248b3427))
|
|
10
|
+
* eslint migration to flat config ([0e6fc12](https://github.com/twinfoundation/nft/commit/0e6fc128c3c8f6cd34db793787437dd4af2c9994))
|
|
11
|
+
* update dependencies ([8660f76](https://github.com/twinfoundation/nft/commit/8660f76ca324b0f476e45544cac6bee4b3146c3b))
|
|
12
|
+
* update framework core ([f3496b6](https://github.com/twinfoundation/nft/commit/f3496b61bfebbb3479bb92df39ecfa9ac8d90b9b))
|
|
13
|
+
* use shared store mechanism ([#16](https://github.com/twinfoundation/nft/issues/16)) ([897bc78](https://github.com/twinfoundation/nft/commit/897bc7805248ba1388b2dd03df24c33f1633f344))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Dependencies
|
|
17
|
+
|
|
18
|
+
* The following workspace dependencies were updated
|
|
19
|
+
* dependencies
|
|
20
|
+
* @twin.org/nft-models bumped from 0.0.3-next.0 to 0.0.3-next.1
|
|
21
|
+
|
|
3
22
|
## [0.0.2-next.8](https://github.com/twinfoundation/nft/compare/nft-rest-client-v0.0.2-next.7...nft-rest-client-v0.0.2-next.8) (2025-10-09)
|
|
4
23
|
|
|
5
24
|
|
|
@@ -16,7 +16,7 @@ Client for performing NFT through to REST endpoints.
|
|
|
16
16
|
|
|
17
17
|
> **new NftRestClient**(`config`): `NftRestClient`
|
|
18
18
|
|
|
19
|
-
Create a new instance of
|
|
19
|
+
Create a new instance of NftRestClient.
|
|
20
20
|
|
|
21
21
|
#### Parameters
|
|
22
22
|
|
|
@@ -44,6 +44,24 @@ Runtime name for the class.
|
|
|
44
44
|
|
|
45
45
|
## Methods
|
|
46
46
|
|
|
47
|
+
### className()
|
|
48
|
+
|
|
49
|
+
> **className**(): `string`
|
|
50
|
+
|
|
51
|
+
Returns the class name of the component.
|
|
52
|
+
|
|
53
|
+
#### Returns
|
|
54
|
+
|
|
55
|
+
`string`
|
|
56
|
+
|
|
57
|
+
The class name of the component.
|
|
58
|
+
|
|
59
|
+
#### Implementation of
|
|
60
|
+
|
|
61
|
+
`INftComponent.className`
|
|
62
|
+
|
|
63
|
+
***
|
|
64
|
+
|
|
47
65
|
### mint()
|
|
48
66
|
|
|
49
67
|
> **mint**\<`T`, `U`\>(`tag`, `immutableMetadata?`, `metadata?`, `namespace?`): `Promise`\<`string`\>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/nft-rest-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3-next.1",
|
|
4
4
|
"description": "NFT contract implementation which can connect to REST endpoints",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,23 +19,21 @@
|
|
|
19
19
|
"@twin.org/core": "next",
|
|
20
20
|
"@twin.org/entity": "next",
|
|
21
21
|
"@twin.org/nameof": "next",
|
|
22
|
-
"@twin.org/nft-models": "0.0.
|
|
22
|
+
"@twin.org/nft-models": "0.0.3-next.1",
|
|
23
23
|
"@twin.org/web": "next"
|
|
24
24
|
},
|
|
25
|
-
"main": "./dist/
|
|
26
|
-
"module": "./dist/esm/index.mjs",
|
|
25
|
+
"main": "./dist/es/index.js",
|
|
27
26
|
"types": "./dist/types/index.d.ts",
|
|
28
27
|
"exports": {
|
|
29
28
|
".": {
|
|
30
29
|
"types": "./dist/types/index.d.ts",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
30
|
+
"import": "./dist/es/index.js",
|
|
31
|
+
"default": "./dist/es/index.js"
|
|
33
32
|
},
|
|
34
33
|
"./locales/*.json": "./locales/*.json"
|
|
35
34
|
},
|
|
36
35
|
"files": [
|
|
37
|
-
"dist/
|
|
38
|
-
"dist/esm",
|
|
36
|
+
"dist/es",
|
|
39
37
|
"dist/types",
|
|
40
38
|
"locales",
|
|
41
39
|
"docs"
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var apiCore = require('@twin.org/api-core');
|
|
4
|
-
var core = require('@twin.org/core');
|
|
5
|
-
var web = require('@twin.org/web');
|
|
6
|
-
|
|
7
|
-
// Copyright 2024 IOTA Stiftung.
|
|
8
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
9
|
-
/**
|
|
10
|
-
* Client for performing NFT through to REST endpoints.
|
|
11
|
-
*/
|
|
12
|
-
class NftRestClient extends apiCore.BaseRestClient {
|
|
13
|
-
/**
|
|
14
|
-
* Runtime name for the class.
|
|
15
|
-
*/
|
|
16
|
-
static CLASS_NAME = "NftRestClient";
|
|
17
|
-
/**
|
|
18
|
-
* Create a new instance of NftClient.
|
|
19
|
-
* @param config The configuration for the client.
|
|
20
|
-
*/
|
|
21
|
-
constructor(config) {
|
|
22
|
-
super("NftRestClient", config, "nft");
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Mint an NFT.
|
|
26
|
-
* @param tag The tag for the NFT.
|
|
27
|
-
* @param immutableMetadata The immutable metadata for the NFT.
|
|
28
|
-
* @param metadata The metadata for the NFT.
|
|
29
|
-
* @param namespace The namespace of the connector to use for the NFT, defaults to component configured namespace.
|
|
30
|
-
* @returns The id of the created NFT in urn format.
|
|
31
|
-
*/
|
|
32
|
-
async mint(tag, immutableMetadata, metadata, namespace) {
|
|
33
|
-
core.Guards.stringValue(NftRestClient.CLASS_NAME, "tag", tag);
|
|
34
|
-
const response = await this.fetch("/", "POST", {
|
|
35
|
-
body: {
|
|
36
|
-
tag,
|
|
37
|
-
immutableMetadata,
|
|
38
|
-
metadata,
|
|
39
|
-
namespace
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
return response.headers[web.HeaderTypes.Location];
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Resolve an NFT.
|
|
46
|
-
* @param id The id of the NFT to resolve.
|
|
47
|
-
* @returns The data for the NFT.
|
|
48
|
-
*/
|
|
49
|
-
async resolve(id) {
|
|
50
|
-
core.Guards.stringValue(NftRestClient.CLASS_NAME, "id", id);
|
|
51
|
-
const response = await this.fetch("/:id", "GET", {
|
|
52
|
-
pathParams: {
|
|
53
|
-
id
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
return response.body;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Burn an NFT.
|
|
60
|
-
* @param id The id of the NFT to burn in urn format.
|
|
61
|
-
* @returns Nothing.
|
|
62
|
-
*/
|
|
63
|
-
async burn(id) {
|
|
64
|
-
core.Urn.guard(NftRestClient.CLASS_NAME, "id", id);
|
|
65
|
-
await this.fetch("/:id", "DELETE", {
|
|
66
|
-
pathParams: {
|
|
67
|
-
id
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Transfer an NFT.
|
|
73
|
-
* @param id The id of the NFT to transfer in urn format.
|
|
74
|
-
* @param recipientIdentity The recipient identity for the NFT.
|
|
75
|
-
* @param recipientAddress The recipient address for the NFT.
|
|
76
|
-
* @param metadata Optional mutable data to include during the transfer.
|
|
77
|
-
* @returns Nothing.
|
|
78
|
-
*/
|
|
79
|
-
async transfer(id, recipientIdentity, recipientAddress, metadata) {
|
|
80
|
-
core.Guards.stringValue(NftRestClient.CLASS_NAME, "id", id);
|
|
81
|
-
core.Guards.stringValue(NftRestClient.CLASS_NAME, "recipientIdentity", recipientIdentity);
|
|
82
|
-
core.Guards.stringValue(NftRestClient.CLASS_NAME, "recipientAddress", recipientAddress);
|
|
83
|
-
await this.fetch("/:id/transfer", "POST", {
|
|
84
|
-
pathParams: {
|
|
85
|
-
id
|
|
86
|
-
},
|
|
87
|
-
body: {
|
|
88
|
-
recipientIdentity,
|
|
89
|
-
recipientAddress,
|
|
90
|
-
metadata
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Update the data of the NFT.
|
|
96
|
-
* @param id The id of the NFT to update in urn format.
|
|
97
|
-
* @param metadata The mutable data to update.
|
|
98
|
-
* @returns Nothing.
|
|
99
|
-
*/
|
|
100
|
-
async update(id, metadata) {
|
|
101
|
-
core.Guards.stringValue(NftRestClient.CLASS_NAME, "id", id);
|
|
102
|
-
core.Guards.object(NftRestClient.CLASS_NAME, "metadata", metadata);
|
|
103
|
-
await this.fetch("/:id", "PUT", {
|
|
104
|
-
pathParams: {
|
|
105
|
-
id
|
|
106
|
-
},
|
|
107
|
-
body: {
|
|
108
|
-
metadata
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
exports.NftRestClient = NftRestClient;
|