@taquito/tzip12 24.2.0 → 24.3.0-beta.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.
@@ -4,7 +4,7 @@ exports.InvalidTokenMetadata = exports.TokenIdNotFound = exports.TokenMetadataNo
4
4
  const core_1 = require("@taquito/core");
5
5
  /**
6
6
  * @category Error
7
- * @description Error that indicates the metadata not being found on the contract
7
+ * Error that indicates the metadata not being found on the contract
8
8
  */
9
9
  class TokenMetadataNotFound extends core_1.TaquitoError {
10
10
  constructor(address) {
@@ -17,7 +17,7 @@ class TokenMetadataNotFound extends core_1.TaquitoError {
17
17
  exports.TokenMetadataNotFound = TokenMetadataNotFound;
18
18
  /**
19
19
  * @category Error
20
- * @description Error that indicates the token ID not being found
20
+ * Error that indicates the token ID not being found
21
21
  */
22
22
  class TokenIdNotFound extends core_1.TaquitoError {
23
23
  constructor(tokenId) {
@@ -29,7 +29,7 @@ class TokenIdNotFound extends core_1.TaquitoError {
29
29
  exports.TokenIdNotFound = TokenIdNotFound;
30
30
  /**
31
31
  * @category Error
32
- * @description Error that indicates that the token metadata is invalid (not compliant with the TZIP-12 standard)
32
+ * Error that indicates that the token metadata is invalid (not compliant with the TZIP-12 standard)
33
33
  */
34
34
  class InvalidTokenMetadata extends core_1.TaquitoError {
35
35
  constructor(invalidMetadata) {
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.Tzip12ContractAbstraction = void 0;
13
4
  const michelson_encoder_1 = require("@taquito/michelson-encoder");
@@ -35,62 +26,53 @@ class Tzip12ContractAbstraction {
35
26
  this._tzip16ContractAbstraction = new tzip16_1.Tzip16ContractAbstraction(this.contractAbstraction, this.context);
36
27
  }
37
28
  /**
38
- * @description Fetches the contract metadata (according to the Tzip-016 standard)
29
+ * Fetches the contract metadata (according to the Tzip-016 standard)
39
30
  * @returns An object containing the metadata, the uri, an optional integrity check result and an optional sha256 hash
40
31
  * or `Undefined` if the contract has no metadata (non-compliant with Tzip-016)
41
32
  */
42
- getContractMetadata() {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- try {
45
- const contractMetadata = yield this._tzip16ContractAbstraction.getMetadata();
46
- return contractMetadata.metadata;
47
- }
48
- catch (err) {
49
- // The contract is not compliant with Tzip-016. There is no contract metadata.
50
- }
51
- });
33
+ async getContractMetadata() {
34
+ try {
35
+ const contractMetadata = await this._tzip16ContractAbstraction.getMetadata();
36
+ return contractMetadata.metadata;
37
+ }
38
+ catch (err) {
39
+ // The contract is not compliant with Tzip-016. There is no contract metadata.
40
+ }
52
41
  }
53
42
  /**
54
- * @description The Tzip-016 "interfaces" field MUST be present in the contract metadata. It should contain "TZIP-012[version-info]"
43
+ * The Tzip-016 "interfaces" field MUST be present in the contract metadata. It should contain "TZIP-012[version-info]"
55
44
  * @returns True if "interfaces" field is present and contains "TZIP-012", false otherwise
56
45
  */
57
- isTzip12Compliant() {
58
- return __awaiter(this, void 0, void 0, function* () {
59
- var _a;
60
- let isCompliant = false;
61
- const metadata = yield this.getContractMetadata();
62
- if (metadata) {
63
- const tzip12Interface = (_a = metadata.interfaces) === null || _a === void 0 ? void 0 : _a.filter((x) => {
64
- return x.substring(0, 8) === 'TZIP-012';
65
- });
66
- isCompliant = tzip12Interface && tzip12Interface.length !== 0 ? true : false;
67
- }
68
- return isCompliant;
69
- });
46
+ async isTzip12Compliant() {
47
+ let isCompliant = false;
48
+ const metadata = await this.getContractMetadata();
49
+ if (metadata) {
50
+ const tzip12Interface = metadata.interfaces?.filter((x) => {
51
+ return x.substring(0, 8) === 'TZIP-012';
52
+ });
53
+ isCompliant = tzip12Interface && tzip12Interface.length !== 0 ? true : false;
54
+ }
55
+ return isCompliant;
70
56
  }
71
57
  /**
72
- * @description Fetches the token metadata for a specified token ID.
58
+ * Fetches the token metadata for a specified token ID.
73
59
  * The function first tries to find a `token_metadata` view in the contract metadata and to execute it with the token ID.
74
60
  * If there is no view, the function tries to find a `token_metadata` bigmap in the top-level pairs of the storage.
75
61
  * @param tokenId The ID of the token for which we want to retrieve token metadata
76
62
  * @returns An object of type `TokenMetadata`
77
63
  * @throws {@link TokenIdNotFound, TokenMetadataNotFound, InvalidTokenMetadata}
78
64
  */
79
- getTokenMetadata(tokenId) {
80
- return __awaiter(this, void 0, void 0, function* () {
81
- const tokenMetadata = yield this.retrieveTokenMetadataFromView(tokenId);
82
- return !tokenMetadata ? this.retrieveTokenMetadataFromBigMap(tokenId) : tokenMetadata;
83
- });
65
+ async getTokenMetadata(tokenId) {
66
+ const tokenMetadata = await this.retrieveTokenMetadataFromView(tokenId);
67
+ return !tokenMetadata ? this.retrieveTokenMetadataFromBigMap(tokenId) : tokenMetadata;
84
68
  }
85
- retrieveTokenMetadataFromView(tokenId) {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- if (yield this.getContractMetadata()) {
88
- const views = yield this._tzip16ContractAbstraction.metadataViews();
89
- if (views && this.hasTokenMetadataView(views)) {
90
- return this.executeTokenMetadataView(views['token_metadata'](), tokenId);
91
- }
69
+ async retrieveTokenMetadataFromView(tokenId) {
70
+ if (await this.getContractMetadata()) {
71
+ const views = await this._tzip16ContractAbstraction.metadataViews();
72
+ if (views && this.hasTokenMetadataView(views)) {
73
+ return this.executeTokenMetadataView(views['token_metadata'](), tokenId);
92
74
  }
93
- });
75
+ }
94
76
  }
95
77
  hasTokenMetadataView(views) {
96
78
  for (const view of Object.keys(views)) {
@@ -100,35 +82,31 @@ class Tzip12ContractAbstraction {
100
82
  }
101
83
  return false;
102
84
  }
103
- executeTokenMetadataView(tokenMetadataView, tokenId) {
104
- return __awaiter(this, void 0, void 0, function* () {
105
- const tokenMetadata = yield tokenMetadataView.executeView(tokenId);
106
- const tokenMap = Object.values(tokenMetadata)[1];
107
- if (!michelson_encoder_1.MichelsonMap.isMichelsonMap(tokenMap)) {
108
- throw new errors_1.TokenMetadataNotFound(this.contractAbstraction.address);
109
- }
110
- const metadataFromUri = yield this.fetchTokenMetadataFromUri(tokenMap);
111
- return this.formatMetadataToken(tokenId, tokenMap, metadataFromUri);
112
- });
85
+ async executeTokenMetadataView(tokenMetadataView, tokenId) {
86
+ const tokenMetadata = await tokenMetadataView.executeView(tokenId);
87
+ const tokenMap = Object.values(tokenMetadata)[1];
88
+ if (!michelson_encoder_1.MichelsonMap.isMichelsonMap(tokenMap)) {
89
+ throw new errors_1.TokenMetadataNotFound(this.contractAbstraction.address);
90
+ }
91
+ const metadataFromUri = await this.fetchTokenMetadataFromUri(tokenMap);
92
+ return this.formatMetadataToken(tokenId, tokenMap, metadataFromUri);
113
93
  }
114
- fetchTokenMetadataFromUri(tokenMetadata) {
115
- return __awaiter(this, void 0, void 0, function* () {
116
- const uri = tokenMetadata.get('');
117
- if (uri) {
118
- try {
119
- const metadataFromUri = yield this.context.metadataProvider.provideMetadata(this.contractAbstraction, (0, utils_1.bytesToString)(uri), this.context);
120
- return metadataFromUri.metadata;
94
+ async fetchTokenMetadataFromUri(tokenMetadata) {
95
+ const uri = tokenMetadata.get('');
96
+ if (uri) {
97
+ try {
98
+ const metadataFromUri = await this.context.metadataProvider.provideMetadata(this.contractAbstraction, (0, utils_1.bytesToString)(uri), this.context);
99
+ return metadataFromUri.metadata;
100
+ }
101
+ catch (e) {
102
+ if (e.name === 'InvalidUriError') {
103
+ console.warn(`The URI ${(0, utils_1.bytesToString)(uri)} is present in the token metadata, but is invalid.`);
121
104
  }
122
- catch (e) {
123
- if (e.name === 'InvalidUriError') {
124
- console.warn(`The URI ${(0, utils_1.bytesToString)(uri)} is present in the token metadata, but is invalid.`);
125
- }
126
- else {
127
- throw e;
128
- }
105
+ else {
106
+ throw e;
129
107
  }
130
108
  }
131
- });
109
+ }
132
110
  }
133
111
  formatMetadataToken(tokenId, metadataTokenMap, metadataFromUri) {
134
112
  const tokenMetadataDecoded = {
@@ -160,32 +138,28 @@ class Tzip12ContractAbstraction {
160
138
  }
161
139
  return tokenMetadataDecoded;
162
140
  }
163
- retrieveTokenMetadataFromBigMap(tokenId) {
164
- return __awaiter(this, void 0, void 0, function* () {
165
- const bigmapTokenMetadataId = yield this.findTokenMetadataBigMap();
166
- let pairNatMap;
167
- try {
168
- pairNatMap = yield this.context.contract.getBigMapKeyByID(bigmapTokenMetadataId['int'].toString(), tokenId.toString(), new michelson_encoder_1.Schema(tokenMetadataBigMapType));
169
- }
170
- catch (err) {
171
- throw new errors_1.TokenIdNotFound(tokenId);
172
- }
173
- const michelsonMap = pairNatMap['token_info'];
174
- if (!michelson_encoder_1.MichelsonMap.isMichelsonMap(michelsonMap)) {
175
- throw new errors_1.TokenIdNotFound(tokenId);
176
- }
177
- const metadataFromUri = yield this.fetchTokenMetadataFromUri(michelsonMap);
178
- return this.formatMetadataToken(tokenId, michelsonMap, metadataFromUri);
179
- });
141
+ async retrieveTokenMetadataFromBigMap(tokenId) {
142
+ const bigmapTokenMetadataId = await this.findTokenMetadataBigMap();
143
+ let pairNatMap;
144
+ try {
145
+ pairNatMap = await this.context.contract.getBigMapKeyByID(bigmapTokenMetadataId['int'].toString(), tokenId.toString(), new michelson_encoder_1.Schema(tokenMetadataBigMapType));
146
+ }
147
+ catch (err) {
148
+ throw new errors_1.TokenIdNotFound(tokenId);
149
+ }
150
+ const michelsonMap = pairNatMap['token_info'];
151
+ if (!michelson_encoder_1.MichelsonMap.isMichelsonMap(michelsonMap)) {
152
+ throw new errors_1.TokenIdNotFound(tokenId);
153
+ }
154
+ const metadataFromUri = await this.fetchTokenMetadataFromUri(michelsonMap);
155
+ return this.formatMetadataToken(tokenId, michelsonMap, metadataFromUri);
180
156
  }
181
- findTokenMetadataBigMap() {
182
- return __awaiter(this, void 0, void 0, function* () {
183
- const tokenMetadataBigMapId = this.contractAbstraction.schema.FindFirstInTopLevelPair(yield this.context.readProvider.getStorage(this.contractAbstraction.address, 'head'), tokenMetadataBigMapType);
184
- if (!tokenMetadataBigMapId || !tokenMetadataBigMapId.int) {
185
- throw new errors_1.TokenMetadataNotFound(this.contractAbstraction.address);
186
- }
187
- return { int: tokenMetadataBigMapId.int };
188
- });
157
+ async findTokenMetadataBigMap() {
158
+ const tokenMetadataBigMapId = this.contractAbstraction.schema.FindFirstInTopLevelPair(await this.context.readProvider.getStorage(this.contractAbstraction.address, 'head'), tokenMetadataBigMapType);
159
+ if (!tokenMetadataBigMapId || !tokenMetadataBigMapId.int) {
160
+ throw new errors_1.TokenMetadataNotFound(this.contractAbstraction.address);
161
+ }
162
+ return { int: tokenMetadataBigMapId.int };
189
163
  }
190
164
  }
191
165
  exports.Tzip12ContractAbstraction = Tzip12ContractAbstraction;
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT!
5
5
  exports.VERSION = {
6
- "commitHash": "105a7b15cfb862a0732c204e0e9741098d697775",
7
- "version": "24.2.0"
6
+ "commitHash": "05df48fee92f846cba793920d6fa829afd6a1847",
7
+ "version": "24.3.0-beta.1"
8
8
  };
@@ -3,41 +3,9 @@ import { Tzip16ContractAbstraction, MetadataProvider, DEFAULT_HANDLERS } from '@
3
3
  import { bytesToString } from '@taquito/utils';
4
4
  import { TaquitoError } from '@taquito/core';
5
5
 
6
- /******************************************************************************
7
- Copyright (c) Microsoft Corporation.
8
-
9
- Permission to use, copy, modify, and/or distribute this software for any
10
- purpose with or without fee is hereby granted.
11
-
12
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
13
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
14
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
15
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
17
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18
- PERFORMANCE OF THIS SOFTWARE.
19
- ***************************************************************************** */
20
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
21
-
22
-
23
- function __awaiter(thisArg, _arguments, P, generator) {
24
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
25
- return new (P || (P = Promise))(function (resolve, reject) {
26
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
27
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
28
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
29
- step((generator = generator.apply(thisArg, _arguments || [])).next());
30
- });
31
- }
32
-
33
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
34
- var e = new Error(message);
35
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
36
- };
37
-
38
6
  /**
39
7
  * @category Error
40
- * @description Error that indicates the metadata not being found on the contract
8
+ * Error that indicates the metadata not being found on the contract
41
9
  */
42
10
  class TokenMetadataNotFound extends TaquitoError {
43
11
  constructor(address) {
@@ -49,7 +17,7 @@ class TokenMetadataNotFound extends TaquitoError {
49
17
  }
50
18
  /**
51
19
  * @category Error
52
- * @description Error that indicates the token ID not being found
20
+ * Error that indicates the token ID not being found
53
21
  */
54
22
  class TokenIdNotFound extends TaquitoError {
55
23
  constructor(tokenId) {
@@ -60,7 +28,7 @@ class TokenIdNotFound extends TaquitoError {
60
28
  }
61
29
  /**
62
30
  * @category Error
63
- * @description Error that indicates that the token metadata is invalid (not compliant with the TZIP-12 standard)
31
+ * Error that indicates that the token metadata is invalid (not compliant with the TZIP-12 standard)
64
32
  */
65
33
  class InvalidTokenMetadata extends TaquitoError {
66
34
  constructor(invalidMetadata) {
@@ -93,62 +61,53 @@ class Tzip12ContractAbstraction {
93
61
  this._tzip16ContractAbstraction = new Tzip16ContractAbstraction(this.contractAbstraction, this.context);
94
62
  }
95
63
  /**
96
- * @description Fetches the contract metadata (according to the Tzip-016 standard)
64
+ * Fetches the contract metadata (according to the Tzip-016 standard)
97
65
  * @returns An object containing the metadata, the uri, an optional integrity check result and an optional sha256 hash
98
66
  * or `Undefined` if the contract has no metadata (non-compliant with Tzip-016)
99
67
  */
100
- getContractMetadata() {
101
- return __awaiter(this, void 0, void 0, function* () {
102
- try {
103
- const contractMetadata = yield this._tzip16ContractAbstraction.getMetadata();
104
- return contractMetadata.metadata;
105
- }
106
- catch (err) {
107
- // The contract is not compliant with Tzip-016. There is no contract metadata.
108
- }
109
- });
68
+ async getContractMetadata() {
69
+ try {
70
+ const contractMetadata = await this._tzip16ContractAbstraction.getMetadata();
71
+ return contractMetadata.metadata;
72
+ }
73
+ catch (err) {
74
+ // The contract is not compliant with Tzip-016. There is no contract metadata.
75
+ }
110
76
  }
111
77
  /**
112
- * @description The Tzip-016 "interfaces" field MUST be present in the contract metadata. It should contain "TZIP-012[version-info]"
78
+ * The Tzip-016 "interfaces" field MUST be present in the contract metadata. It should contain "TZIP-012[version-info]"
113
79
  * @returns True if "interfaces" field is present and contains "TZIP-012", false otherwise
114
80
  */
115
- isTzip12Compliant() {
116
- return __awaiter(this, void 0, void 0, function* () {
117
- var _a;
118
- let isCompliant = false;
119
- const metadata = yield this.getContractMetadata();
120
- if (metadata) {
121
- const tzip12Interface = (_a = metadata.interfaces) === null || _a === void 0 ? void 0 : _a.filter((x) => {
122
- return x.substring(0, 8) === 'TZIP-012';
123
- });
124
- isCompliant = tzip12Interface && tzip12Interface.length !== 0 ? true : false;
125
- }
126
- return isCompliant;
127
- });
81
+ async isTzip12Compliant() {
82
+ let isCompliant = false;
83
+ const metadata = await this.getContractMetadata();
84
+ if (metadata) {
85
+ const tzip12Interface = metadata.interfaces?.filter((x) => {
86
+ return x.substring(0, 8) === 'TZIP-012';
87
+ });
88
+ isCompliant = tzip12Interface && tzip12Interface.length !== 0 ? true : false;
89
+ }
90
+ return isCompliant;
128
91
  }
129
92
  /**
130
- * @description Fetches the token metadata for a specified token ID.
93
+ * Fetches the token metadata for a specified token ID.
131
94
  * The function first tries to find a `token_metadata` view in the contract metadata and to execute it with the token ID.
132
95
  * If there is no view, the function tries to find a `token_metadata` bigmap in the top-level pairs of the storage.
133
96
  * @param tokenId The ID of the token for which we want to retrieve token metadata
134
97
  * @returns An object of type `TokenMetadata`
135
98
  * @throws {@link TokenIdNotFound, TokenMetadataNotFound, InvalidTokenMetadata}
136
99
  */
137
- getTokenMetadata(tokenId) {
138
- return __awaiter(this, void 0, void 0, function* () {
139
- const tokenMetadata = yield this.retrieveTokenMetadataFromView(tokenId);
140
- return !tokenMetadata ? this.retrieveTokenMetadataFromBigMap(tokenId) : tokenMetadata;
141
- });
142
- }
143
- retrieveTokenMetadataFromView(tokenId) {
144
- return __awaiter(this, void 0, void 0, function* () {
145
- if (yield this.getContractMetadata()) {
146
- const views = yield this._tzip16ContractAbstraction.metadataViews();
147
- if (views && this.hasTokenMetadataView(views)) {
148
- return this.executeTokenMetadataView(views['token_metadata'](), tokenId);
149
- }
100
+ async getTokenMetadata(tokenId) {
101
+ const tokenMetadata = await this.retrieveTokenMetadataFromView(tokenId);
102
+ return !tokenMetadata ? this.retrieveTokenMetadataFromBigMap(tokenId) : tokenMetadata;
103
+ }
104
+ async retrieveTokenMetadataFromView(tokenId) {
105
+ if (await this.getContractMetadata()) {
106
+ const views = await this._tzip16ContractAbstraction.metadataViews();
107
+ if (views && this.hasTokenMetadataView(views)) {
108
+ return this.executeTokenMetadataView(views['token_metadata'](), tokenId);
150
109
  }
151
- });
110
+ }
152
111
  }
153
112
  hasTokenMetadataView(views) {
154
113
  for (const view of Object.keys(views)) {
@@ -158,35 +117,31 @@ class Tzip12ContractAbstraction {
158
117
  }
159
118
  return false;
160
119
  }
161
- executeTokenMetadataView(tokenMetadataView, tokenId) {
162
- return __awaiter(this, void 0, void 0, function* () {
163
- const tokenMetadata = yield tokenMetadataView.executeView(tokenId);
164
- const tokenMap = Object.values(tokenMetadata)[1];
165
- if (!MichelsonMap.isMichelsonMap(tokenMap)) {
166
- throw new TokenMetadataNotFound(this.contractAbstraction.address);
167
- }
168
- const metadataFromUri = yield this.fetchTokenMetadataFromUri(tokenMap);
169
- return this.formatMetadataToken(tokenId, tokenMap, metadataFromUri);
170
- });
120
+ async executeTokenMetadataView(tokenMetadataView, tokenId) {
121
+ const tokenMetadata = await tokenMetadataView.executeView(tokenId);
122
+ const tokenMap = Object.values(tokenMetadata)[1];
123
+ if (!MichelsonMap.isMichelsonMap(tokenMap)) {
124
+ throw new TokenMetadataNotFound(this.contractAbstraction.address);
125
+ }
126
+ const metadataFromUri = await this.fetchTokenMetadataFromUri(tokenMap);
127
+ return this.formatMetadataToken(tokenId, tokenMap, metadataFromUri);
171
128
  }
172
- fetchTokenMetadataFromUri(tokenMetadata) {
173
- return __awaiter(this, void 0, void 0, function* () {
174
- const uri = tokenMetadata.get('');
175
- if (uri) {
176
- try {
177
- const metadataFromUri = yield this.context.metadataProvider.provideMetadata(this.contractAbstraction, bytesToString(uri), this.context);
178
- return metadataFromUri.metadata;
129
+ async fetchTokenMetadataFromUri(tokenMetadata) {
130
+ const uri = tokenMetadata.get('');
131
+ if (uri) {
132
+ try {
133
+ const metadataFromUri = await this.context.metadataProvider.provideMetadata(this.contractAbstraction, bytesToString(uri), this.context);
134
+ return metadataFromUri.metadata;
135
+ }
136
+ catch (e) {
137
+ if (e.name === 'InvalidUriError') {
138
+ console.warn(`The URI ${bytesToString(uri)} is present in the token metadata, but is invalid.`);
179
139
  }
180
- catch (e) {
181
- if (e.name === 'InvalidUriError') {
182
- console.warn(`The URI ${bytesToString(uri)} is present in the token metadata, but is invalid.`);
183
- }
184
- else {
185
- throw e;
186
- }
140
+ else {
141
+ throw e;
187
142
  }
188
143
  }
189
- });
144
+ }
190
145
  }
191
146
  formatMetadataToken(tokenId, metadataTokenMap, metadataFromUri) {
192
147
  const tokenMetadataDecoded = {
@@ -218,32 +173,28 @@ class Tzip12ContractAbstraction {
218
173
  }
219
174
  return tokenMetadataDecoded;
220
175
  }
221
- retrieveTokenMetadataFromBigMap(tokenId) {
222
- return __awaiter(this, void 0, void 0, function* () {
223
- const bigmapTokenMetadataId = yield this.findTokenMetadataBigMap();
224
- let pairNatMap;
225
- try {
226
- pairNatMap = yield this.context.contract.getBigMapKeyByID(bigmapTokenMetadataId['int'].toString(), tokenId.toString(), new Schema(tokenMetadataBigMapType));
227
- }
228
- catch (err) {
229
- throw new TokenIdNotFound(tokenId);
230
- }
231
- const michelsonMap = pairNatMap['token_info'];
232
- if (!MichelsonMap.isMichelsonMap(michelsonMap)) {
233
- throw new TokenIdNotFound(tokenId);
234
- }
235
- const metadataFromUri = yield this.fetchTokenMetadataFromUri(michelsonMap);
236
- return this.formatMetadataToken(tokenId, michelsonMap, metadataFromUri);
237
- });
176
+ async retrieveTokenMetadataFromBigMap(tokenId) {
177
+ const bigmapTokenMetadataId = await this.findTokenMetadataBigMap();
178
+ let pairNatMap;
179
+ try {
180
+ pairNatMap = await this.context.contract.getBigMapKeyByID(bigmapTokenMetadataId['int'].toString(), tokenId.toString(), new Schema(tokenMetadataBigMapType));
181
+ }
182
+ catch (err) {
183
+ throw new TokenIdNotFound(tokenId);
184
+ }
185
+ const michelsonMap = pairNatMap['token_info'];
186
+ if (!MichelsonMap.isMichelsonMap(michelsonMap)) {
187
+ throw new TokenIdNotFound(tokenId);
188
+ }
189
+ const metadataFromUri = await this.fetchTokenMetadataFromUri(michelsonMap);
190
+ return this.formatMetadataToken(tokenId, michelsonMap, metadataFromUri);
238
191
  }
239
- findTokenMetadataBigMap() {
240
- return __awaiter(this, void 0, void 0, function* () {
241
- const tokenMetadataBigMapId = this.contractAbstraction.schema.FindFirstInTopLevelPair(yield this.context.readProvider.getStorage(this.contractAbstraction.address, 'head'), tokenMetadataBigMapType);
242
- if (!tokenMetadataBigMapId || !tokenMetadataBigMapId.int) {
243
- throw new TokenMetadataNotFound(this.contractAbstraction.address);
244
- }
245
- return { int: tokenMetadataBigMapId.int };
246
- });
192
+ async findTokenMetadataBigMap() {
193
+ const tokenMetadataBigMapId = this.contractAbstraction.schema.FindFirstInTopLevelPair(await this.context.readProvider.getStorage(this.contractAbstraction.address, 'head'), tokenMetadataBigMapType);
194
+ if (!tokenMetadataBigMapId || !tokenMetadataBigMapId.int) {
195
+ throw new TokenMetadataNotFound(this.contractAbstraction.address);
196
+ }
197
+ return { int: tokenMetadataBigMapId.int };
247
198
  }
248
199
  }
249
200
 
@@ -273,8 +224,8 @@ class Tzip12Module {
273
224
 
274
225
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT!
275
226
  const VERSION = {
276
- "commitHash": "105a7b15cfb862a0732c204e0e9741098d697775",
277
- "version": "24.2.0"
227
+ "commitHash": "05df48fee92f846cba793920d6fa829afd6a1847",
228
+ "version": "24.3.0-beta.1"
278
229
  };
279
230
 
280
231
  export { InvalidTokenMetadata, TokenIdNotFound, TokenMetadataNotFound, Tzip12ContractAbstraction, Tzip12Module, VERSION, tzip12 };
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-tzip12.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"taquito-tzip12.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}