@twin.org/nft-rest-client 0.0.1-next.3 → 0.0.1-next.30

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.
@@ -2,6 +2,7 @@
2
2
 
3
3
  var apiCore = require('@twin.org/api-core');
4
4
  var core = require('@twin.org/core');
5
+ var web = require('@twin.org/web');
5
6
 
6
7
  // Copyright 2024 IOTA Stiftung.
7
8
  // SPDX-License-Identifier: Apache-2.0.
@@ -22,26 +23,23 @@ class NftClient extends apiCore.BaseRestClient {
22
23
  }
23
24
  /**
24
25
  * Mint an NFT.
25
- * @param issuer The issuer for the NFT, will also be the initial owner.
26
26
  * @param tag The tag for the NFT.
27
27
  * @param immutableMetadata The immutable metadata for the NFT.
28
28
  * @param metadata The metadata for the NFT.
29
29
  * @param namespace The namespace of the connector to use for the NFT, defaults to component configured namespace.
30
30
  * @returns The id of the created NFT in urn format.
31
31
  */
32
- async mint(issuer, tag, immutableMetadata, metadata, namespace) {
33
- core.Guards.stringValue(this.CLASS_NAME, "issuer", issuer);
32
+ async mint(tag, immutableMetadata, metadata, namespace) {
34
33
  core.Guards.stringValue(this.CLASS_NAME, "tag", tag);
35
34
  const response = await this.fetch("/", "POST", {
36
35
  body: {
37
- issuer,
38
36
  tag,
39
37
  immutableMetadata,
40
38
  metadata,
41
39
  namespace
42
40
  }
43
41
  });
44
- return response.headers.Location;
42
+ return response.headers[web.HeaderTypes.Location];
45
43
  }
46
44
  /**
47
45
  * Resolve an NFT.
@@ -73,19 +71,22 @@ class NftClient extends apiCore.BaseRestClient {
73
71
  /**
74
72
  * Transfer an NFT.
75
73
  * @param id The id of the NFT to transfer in urn format.
76
- * @param recipient The recipient of the NFT.
74
+ * @param recipientIdentity The recipient identity for the NFT.
75
+ * @param recipientAddress The recipient address for the NFT.
77
76
  * @param metadata Optional mutable data to include during the transfer.
78
77
  * @returns Nothing.
79
78
  */
80
- async transfer(id, recipient, metadata) {
79
+ async transfer(id, recipientIdentity, recipientAddress, metadata) {
81
80
  core.Guards.stringValue(this.CLASS_NAME, "id", id);
82
- core.Guards.stringValue(this.CLASS_NAME, "recipient", recipient);
81
+ core.Guards.stringValue(this.CLASS_NAME, "recipientIdentity", recipientIdentity);
82
+ core.Guards.stringValue(this.CLASS_NAME, "recipientAddress", recipientAddress);
83
83
  await this.fetch("/:id/transfer", "POST", {
84
84
  pathParams: {
85
85
  id
86
86
  },
87
87
  body: {
88
- recipient,
88
+ recipientIdentity,
89
+ recipientAddress,
89
90
  metadata
90
91
  }
91
92
  });
@@ -1,5 +1,6 @@
1
1
  import { BaseRestClient } from '@twin.org/api-core';
2
2
  import { Guards, Urn } from '@twin.org/core';
3
+ import { HeaderTypes } from '@twin.org/web';
3
4
 
4
5
  // Copyright 2024 IOTA Stiftung.
5
6
  // SPDX-License-Identifier: Apache-2.0.
@@ -20,26 +21,23 @@ class NftClient extends BaseRestClient {
20
21
  }
21
22
  /**
22
23
  * Mint an NFT.
23
- * @param issuer The issuer for the NFT, will also be the initial owner.
24
24
  * @param tag The tag for the NFT.
25
25
  * @param immutableMetadata The immutable metadata for the NFT.
26
26
  * @param metadata The metadata for the NFT.
27
27
  * @param namespace The namespace of the connector to use for the NFT, defaults to component configured namespace.
28
28
  * @returns The id of the created NFT in urn format.
29
29
  */
30
- async mint(issuer, tag, immutableMetadata, metadata, namespace) {
31
- Guards.stringValue(this.CLASS_NAME, "issuer", issuer);
30
+ async mint(tag, immutableMetadata, metadata, namespace) {
32
31
  Guards.stringValue(this.CLASS_NAME, "tag", tag);
33
32
  const response = await this.fetch("/", "POST", {
34
33
  body: {
35
- issuer,
36
34
  tag,
37
35
  immutableMetadata,
38
36
  metadata,
39
37
  namespace
40
38
  }
41
39
  });
42
- return response.headers.Location;
40
+ return response.headers[HeaderTypes.Location];
43
41
  }
44
42
  /**
45
43
  * Resolve an NFT.
@@ -71,19 +69,22 @@ class NftClient extends BaseRestClient {
71
69
  /**
72
70
  * Transfer an NFT.
73
71
  * @param id The id of the NFT to transfer in urn format.
74
- * @param recipient The recipient of the NFT.
72
+ * @param recipientIdentity The recipient identity for the NFT.
73
+ * @param recipientAddress The recipient address for the NFT.
75
74
  * @param metadata Optional mutable data to include during the transfer.
76
75
  * @returns Nothing.
77
76
  */
78
- async transfer(id, recipient, metadata) {
77
+ async transfer(id, recipientIdentity, recipientAddress, metadata) {
79
78
  Guards.stringValue(this.CLASS_NAME, "id", id);
80
- Guards.stringValue(this.CLASS_NAME, "recipient", recipient);
79
+ Guards.stringValue(this.CLASS_NAME, "recipientIdentity", recipientIdentity);
80
+ Guards.stringValue(this.CLASS_NAME, "recipientAddress", recipientAddress);
81
81
  await this.fetch("/:id/transfer", "POST", {
82
82
  pathParams: {
83
83
  id
84
84
  },
85
85
  body: {
86
- recipient,
86
+ recipientIdentity,
87
+ recipientAddress,
87
88
  metadata
88
89
  }
89
90
  });
@@ -16,14 +16,13 @@ export declare class NftClient extends BaseRestClient implements INftComponent {
16
16
  constructor(config: IBaseRestClientConfig);
17
17
  /**
18
18
  * Mint an NFT.
19
- * @param issuer The issuer for the NFT, will also be the initial owner.
20
19
  * @param tag The tag for the NFT.
21
20
  * @param immutableMetadata The immutable metadata for the NFT.
22
21
  * @param metadata The metadata for the NFT.
23
22
  * @param namespace The namespace of the connector to use for the NFT, defaults to component configured namespace.
24
23
  * @returns The id of the created NFT in urn format.
25
24
  */
26
- mint<T = unknown, U = unknown>(issuer: string, tag: string, immutableMetadata?: T, metadata?: U, namespace?: string): Promise<string>;
25
+ mint<T = unknown, U = unknown>(tag: string, immutableMetadata?: T, metadata?: U, namespace?: string): Promise<string>;
27
26
  /**
28
27
  * Resolve an NFT.
29
28
  * @param id The id of the NFT to resolve.
@@ -45,16 +44,17 @@ export declare class NftClient extends BaseRestClient implements INftComponent {
45
44
  /**
46
45
  * Transfer an NFT.
47
46
  * @param id The id of the NFT to transfer in urn format.
48
- * @param recipient The recipient of the NFT.
47
+ * @param recipientIdentity The recipient identity for the NFT.
48
+ * @param recipientAddress The recipient address for the NFT.
49
49
  * @param metadata Optional mutable data to include during the transfer.
50
50
  * @returns Nothing.
51
51
  */
52
- transfer<T = unknown>(id: string, recipient: string, metadata?: T): Promise<void>;
52
+ transfer<T = unknown>(id: string, recipientIdentity: string, recipientAddress: string, metadata?: T): Promise<void>;
53
53
  /**
54
54
  * Update the data of the NFT.
55
55
  * @param id The id of the NFT to update in urn format.
56
56
  * @param metadata The mutable data to update.
57
57
  * @returns Nothing.
58
58
  */
59
- update<T = unknown>(id: string, metadata: T): Promise<void>;
59
+ update<U = unknown>(id: string, metadata: U): Promise<void>;
60
60
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,103 @@
1
1
  # @twin.org/nft-rest-client - Changelog
2
2
 
3
- ## v0.0.1-next.3
3
+ ## [0.0.1-next.30](https://github.com/twinfoundation/nft/compare/nft-rest-client-v0.0.1-next.29...nft-rest-client-v0.0.1-next.30) (2025-05-22)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **nft-rest-client:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/nft-models bumped from 0.0.1-next.29 to 0.0.1-next.30
16
+
17
+ ## [0.0.1-next.29](https://github.com/twinfoundation/nft/compare/nft-rest-client-v0.0.1-next.28...nft-rest-client-v0.0.1-next.29) (2025-05-21)
18
+
19
+
20
+ ### Miscellaneous Chores
21
+
22
+ * **nft-rest-client:** Synchronize repo versions
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/nft-models bumped from 0.0.1-next.28 to 0.0.1-next.29
30
+
31
+ ## [0.0.1-next.28](https://github.com/twinfoundation/nft/compare/nft-rest-client-v0.0.1-next.27...nft-rest-client-v0.0.1-next.28) (2025-05-06)
32
+
33
+
34
+ ### Miscellaneous Chores
35
+
36
+ * **nft-rest-client:** Synchronize repo versions
37
+
38
+
39
+ ### Dependencies
40
+
41
+ * The following workspace dependencies were updated
42
+ * dependencies
43
+ * @twin.org/nft-models bumped from 0.0.1-next.27 to 0.0.1-next.28
44
+
45
+ ## [0.0.1-next.27](https://github.com/twinfoundation/nft/compare/nft-rest-client-v0.0.1-next.26...nft-rest-client-v0.0.1-next.27) (2025-04-24)
46
+
47
+
48
+ ### Miscellaneous Chores
49
+
50
+ * **nft-rest-client:** Synchronize repo versions
51
+
52
+
53
+ ### Dependencies
54
+
55
+ * The following workspace dependencies were updated
56
+ * dependencies
57
+ * @twin.org/nft-models bumped from 0.0.1-next.26 to 0.0.1-next.27
58
+
59
+ ## [0.0.1-next.26](https://github.com/twinfoundation/nft/compare/nft-rest-client-v0.0.1-next.25...nft-rest-client-v0.0.1-next.26) (2025-04-17)
60
+
61
+
62
+ ### Features
63
+
64
+ * use shared store mechanism ([#16](https://github.com/twinfoundation/nft/issues/16)) ([897bc78](https://github.com/twinfoundation/nft/commit/897bc7805248ba1388b2dd03df24c33f1633f344))
65
+
66
+
67
+ ### Dependencies
68
+
69
+ * The following workspace dependencies were updated
70
+ * dependencies
71
+ * @twin.org/nft-models bumped from 0.0.1-next.25 to 0.0.1-next.26
72
+
73
+ ## [0.0.1-next.25](https://github.com/twinfoundation/nft/compare/nft-rest-client-v0.0.1-next.24...nft-rest-client-v0.0.1-next.25) (2025-04-17)
74
+
75
+
76
+ ### Miscellaneous Chores
77
+
78
+ * **nft-rest-client:** Synchronize repo versions
79
+
80
+
81
+ ### Dependencies
82
+
83
+ * The following workspace dependencies were updated
84
+ * dependencies
85
+ * @twin.org/nft-models bumped from 0.0.1-next.24 to 0.0.1-next.25
86
+
87
+ ## [0.0.1-next.24](https://github.com/twinfoundation/nft/compare/nft-rest-client-v0.0.1-next.23...nft-rest-client-v0.0.1-next.24) (2025-03-28)
88
+
89
+
90
+ ### Miscellaneous Chores
91
+
92
+ * **nft-rest-client:** Synchronize repo versions
93
+
94
+
95
+ ### Dependencies
96
+
97
+ * The following workspace dependencies were updated
98
+ * dependencies
99
+ * @twin.org/nft-models bumped from 0.0.1-next.23 to 0.0.1-next.24
100
+
101
+ ## v0.0.1-next.23
4
102
 
5
103
  - Initial Release
@@ -12,21 +12,23 @@ Client for performing NFT through to REST endpoints.
12
12
 
13
13
  ## Constructors
14
14
 
15
- ### new NftClient()
15
+ ### Constructor
16
16
 
17
- > **new NftClient**(`config`): [`NftClient`](NftClient.md)
17
+ > **new NftClient**(`config`): `NftClient`
18
18
 
19
19
  Create a new instance of NftClient.
20
20
 
21
21
  #### Parameters
22
22
 
23
- **config**: `IBaseRestClientConfig`
23
+ ##### config
24
+
25
+ `IBaseRestClientConfig`
24
26
 
25
27
  The configuration for the client.
26
28
 
27
29
  #### Returns
28
30
 
29
- [`NftClient`](NftClient.md)
31
+ `NftClient`
30
32
 
31
33
  #### Overrides
32
34
 
@@ -48,35 +50,43 @@ Runtime name for the class.
48
50
 
49
51
  ### mint()
50
52
 
51
- > **mint**\<`T`, `U`\>(`issuer`, `tag`, `immutableMetadata`?, `metadata`?, `namespace`?): `Promise`\<`string`\>
53
+ > **mint**\<`T`, `U`\>(`tag`, `immutableMetadata?`, `metadata?`, `namespace?`): `Promise`\<`string`\>
52
54
 
53
55
  Mint an NFT.
54
56
 
55
57
  #### Type Parameters
56
58
 
57
- **T** = `unknown`
59
+ ##### T
58
60
 
59
- **U** = `unknown`
61
+ `T` = `unknown`
60
62
 
61
- #### Parameters
63
+ ##### U
62
64
 
63
- **issuer**: `string`
65
+ `U` = `unknown`
64
66
 
65
- The issuer for the NFT, will also be the initial owner.
67
+ #### Parameters
68
+
69
+ ##### tag
66
70
 
67
- • **tag**: `string`
71
+ `string`
68
72
 
69
73
  The tag for the NFT.
70
74
 
71
- **immutableMetadata?**: `T`
75
+ ##### immutableMetadata?
76
+
77
+ `T`
72
78
 
73
79
  The immutable metadata for the NFT.
74
80
 
75
- **metadata?**: `U`
81
+ ##### metadata?
82
+
83
+ `U`
76
84
 
77
85
  The metadata for the NFT.
78
86
 
79
- **namespace?**: `string`
87
+ ##### namespace?
88
+
89
+ `string`
80
90
 
81
91
  The namespace of the connector to use for the NFT, defaults to component configured namespace.
82
92
 
@@ -94,48 +104,34 @@ The id of the created NFT in urn format.
94
104
 
95
105
  ### resolve()
96
106
 
97
- > **resolve**\<`T`, `U`\>(`id`): `Promise`\<`object`\>
107
+ > **resolve**\<`T`, `U`\>(`id`): `Promise`\<\{ `issuer`: `string`; `owner`: `string`; `tag`: `string`; `immutableMetadata`: `T`; `metadata`: `U`; \}\>
98
108
 
99
109
  Resolve an NFT.
100
110
 
101
111
  #### Type Parameters
102
112
 
103
- **T** = `unknown`
113
+ ##### T
104
114
 
105
- **U** = `unknown`
115
+ `T` = `unknown`
116
+
117
+ ##### U
118
+
119
+ `U` = `unknown`
106
120
 
107
121
  #### Parameters
108
122
 
109
- **id**: `string`
123
+ ##### id
124
+
125
+ `string`
110
126
 
111
127
  The id of the NFT to resolve.
112
128
 
113
129
  #### Returns
114
130
 
115
- `Promise`\<`object`\>
131
+ `Promise`\<\{ `issuer`: `string`; `owner`: `string`; `tag`: `string`; `immutableMetadata`: `T`; `metadata`: `U`; \}\>
116
132
 
117
133
  The data for the NFT.
118
134
 
119
- ##### issuer
120
-
121
- > **issuer**: `string`
122
-
123
- ##### owner
124
-
125
- > **owner**: `string`
126
-
127
- ##### tag
128
-
129
- > **tag**: `string`
130
-
131
- ##### immutableMetadata?
132
-
133
- > `optional` **immutableMetadata**: `T`
134
-
135
- ##### metadata?
136
-
137
- > `optional` **metadata**: `U`
138
-
139
135
  #### Implementation of
140
136
 
141
137
  `INftComponent.resolve`
@@ -150,7 +146,9 @@ Burn an NFT.
150
146
 
151
147
  #### Parameters
152
148
 
153
- **id**: `string`
149
+ ##### id
150
+
151
+ `string`
154
152
 
155
153
  The id of the NFT to burn in urn format.
156
154
 
@@ -168,25 +166,39 @@ Nothing.
168
166
 
169
167
  ### transfer()
170
168
 
171
- > **transfer**\<`T`\>(`id`, `recipient`, `metadata`?): `Promise`\<`void`\>
169
+ > **transfer**\<`T`\>(`id`, `recipientIdentity`, `recipientAddress`, `metadata?`): `Promise`\<`void`\>
172
170
 
173
171
  Transfer an NFT.
174
172
 
175
173
  #### Type Parameters
176
174
 
177
- **T** = `unknown`
175
+ ##### T
176
+
177
+ `T` = `unknown`
178
178
 
179
179
  #### Parameters
180
180
 
181
- **id**: `string`
181
+ ##### id
182
+
183
+ `string`
182
184
 
183
185
  The id of the NFT to transfer in urn format.
184
186
 
185
- **recipient**: `string`
187
+ ##### recipientIdentity
186
188
 
187
- The recipient of the NFT.
189
+ `string`
188
190
 
189
- **metadata?**: `T`
191
+ The recipient identity for the NFT.
192
+
193
+ ##### recipientAddress
194
+
195
+ `string`
196
+
197
+ The recipient address for the NFT.
198
+
199
+ ##### metadata?
200
+
201
+ `T`
190
202
 
191
203
  Optional mutable data to include during the transfer.
192
204
 
@@ -204,21 +216,27 @@ Nothing.
204
216
 
205
217
  ### update()
206
218
 
207
- > **update**\<`T`\>(`id`, `metadata`): `Promise`\<`void`\>
219
+ > **update**\<`U`\>(`id`, `metadata`): `Promise`\<`void`\>
208
220
 
209
221
  Update the data of the NFT.
210
222
 
211
223
  #### Type Parameters
212
224
 
213
- **T** = `unknown`
225
+ ##### U
226
+
227
+ `U` = `unknown`
214
228
 
215
229
  #### Parameters
216
230
 
217
- **id**: `string`
231
+ ##### id
232
+
233
+ `string`
218
234
 
219
235
  The id of the NFT to update in urn format.
220
236
 
221
- **metadata**: `T`
237
+ ##### metadata
238
+
239
+ `U`
222
240
 
223
241
  The mutable data to update.
224
242
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/nft-rest-client",
3
- "version": "0.0.1-next.3",
3
+ "version": "0.0.1-next.30",
4
4
  "description": "NFT contract implementation which can connect to REST endpoints",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,50 +13,25 @@
13
13
  "engines": {
14
14
  "node": ">=20.0.0"
15
15
  },
16
- "scripts": {
17
- "clean": "rimraf dist coverage docs/reference",
18
- "build": "tspc",
19
- "test": "vitest --run --config ./vitest.config.ts --no-cache",
20
- "coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
21
- "bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
22
- "bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
23
- "bundle": "npm run bundle:esm && npm run bundle:cjs",
24
- "docs:clean": "rimraf docs/reference",
25
- "docs:generate": "typedoc",
26
- "docs": "npm run docs:clean && npm run docs:generate",
27
- "dist": "npm run clean && npm run build && npm run test && npm run bundle && npm run docs"
28
- },
29
16
  "dependencies": {
30
- "@twin.org/api-models": "next",
31
17
  "@twin.org/api-core": "next",
18
+ "@twin.org/api-models": "next",
32
19
  "@twin.org/core": "next",
33
20
  "@twin.org/entity": "next",
34
21
  "@twin.org/nameof": "next",
35
- "@twin.org/nft-models": "0.0.1-next.3"
36
- },
37
- "devDependencies": {
38
- "@twin.org/nameof-transformer": "next",
39
- "@vitest/coverage-v8": "2.1.1",
40
- "copyfiles": "2.4.1",
41
- "rimraf": "6.0.1",
42
- "rollup": "4.22.0",
43
- "rollup-plugin-typescript2": "0.36.0",
44
- "ts-patch": "3.2.1",
45
- "typedoc": "0.26.7",
46
- "typedoc-plugin-markdown": "4.2.7",
47
- "typescript": "5.6.2",
48
- "vitest": "2.1.1"
22
+ "@twin.org/nft-models": "0.0.1-next.30",
23
+ "@twin.org/web": "next"
49
24
  },
50
25
  "main": "./dist/cjs/index.cjs",
51
26
  "module": "./dist/esm/index.mjs",
52
27
  "types": "./dist/types/index.d.ts",
53
28
  "exports": {
54
29
  ".": {
30
+ "types": "./dist/types/index.d.ts",
55
31
  "require": "./dist/cjs/index.cjs",
56
- "import": "./dist/esm/index.mjs",
57
- "types": "./dist/types/index.d.ts"
32
+ "import": "./dist/esm/index.mjs"
58
33
  },
59
- "./locales": "./locales"
34
+ "./locales/*.json": "./locales/*.json"
60
35
  },
61
36
  "files": [
62
37
  "dist/cjs",