@taquito/tzip16 24.2.0-beta.1 → 24.3.0-beta.0

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.
@@ -6,7 +6,7 @@ var core_2 = require("@taquito/core");
6
6
  Object.defineProperty(exports, "InvalidViewParameterError", { enumerable: true, get: function () { return core_2.InvalidViewParameterError; } });
7
7
  /**
8
8
  * @category Error
9
- * @description Error that indicates missing big map metadata (non compliance to the TZIP-16 standard)
9
+ * Error that indicates missing big map metadata (non compliance to the TZIP-16 standard)
10
10
  */
11
11
  class BigMapContractMetadataNotFoundError extends core_1.TaquitoError {
12
12
  constructor(invalidBigMapId) {
@@ -20,7 +20,7 @@ class BigMapContractMetadataNotFoundError extends core_1.TaquitoError {
20
20
  exports.BigMapContractMetadataNotFoundError = BigMapContractMetadataNotFoundError;
21
21
  /**
22
22
  * @category Error
23
- * @description Error that indicates missing metadata in storage
23
+ * Error that indicates missing metadata in storage
24
24
  */
25
25
  class ContractMetadataNotFoundError extends core_1.TaquitoError {
26
26
  constructor(info) {
@@ -33,7 +33,7 @@ class ContractMetadataNotFoundError extends core_1.TaquitoError {
33
33
  exports.ContractMetadataNotFoundError = ContractMetadataNotFoundError;
34
34
  /**
35
35
  * @category Error
36
- * @description Error that indicates missing URI (non compliance to the TZIP-16 standard)
36
+ * Error that indicates missing URI (non compliance to the TZIP-16 standard)
37
37
  */
38
38
  class UriNotFoundError extends core_1.TaquitoError {
39
39
  constructor() {
@@ -46,7 +46,7 @@ class UriNotFoundError extends core_1.TaquitoError {
46
46
  exports.UriNotFoundError = UriNotFoundError;
47
47
  /**
48
48
  * @category Error
49
- * @description Error that indicates an invalid URI (non compliance to the TZIP-16 standard)
49
+ * Error that indicates an invalid URI (non compliance to the TZIP-16 standard)
50
50
  */
51
51
  class InvalidUriError extends core_1.TaquitoError {
52
52
  constructor(uri) {
@@ -59,7 +59,7 @@ class InvalidUriError extends core_1.TaquitoError {
59
59
  exports.InvalidUriError = InvalidUriError;
60
60
  /**
61
61
  * @category Error
62
- * @description Error that indicates invalid metadata (non compliance to the TZIP-16 standard)
62
+ * Error that indicates invalid metadata (non compliance to the TZIP-16 standard)
63
63
  */
64
64
  class InvalidContractMetadataError extends core_1.TaquitoError {
65
65
  constructor(invalidMetadata) {
@@ -72,7 +72,7 @@ class InvalidContractMetadataError extends core_1.TaquitoError {
72
72
  exports.InvalidContractMetadataError = InvalidContractMetadataError;
73
73
  /**
74
74
  * @category Error
75
- * @description Error that indicates the uri protocol being passed or used is not supported
75
+ * Error that indicates the uri protocol being passed or used is not supported
76
76
  */
77
77
  class ProtocolNotSupportedError extends core_1.ParameterValidationError {
78
78
  constructor(protocol) {
@@ -85,7 +85,7 @@ class ProtocolNotSupportedError extends core_1.ParameterValidationError {
85
85
  exports.ProtocolNotSupportedError = ProtocolNotSupportedError;
86
86
  /**
87
87
  * @category Error
88
- * @description Error that indicates the metadata type is invalid (non compliance to the TZIP-16 standard)
88
+ * Error that indicates the metadata type is invalid (non compliance to the TZIP-16 standard)
89
89
  */
90
90
  class InvalidContractMetadataTypeError extends core_1.TaquitoError {
91
91
  constructor() {
@@ -98,7 +98,7 @@ class InvalidContractMetadataTypeError extends core_1.TaquitoError {
98
98
  exports.InvalidContractMetadataTypeError = InvalidContractMetadataTypeError;
99
99
  /**
100
100
  * @category Error
101
- * @description Error that indicates metadata provider being unconfigured in the TezosToolkit instance
101
+ * Error that indicates metadata provider being unconfigured in the TezosToolkit instance
102
102
  */
103
103
  class UnconfiguredContractMetadataProviderError extends core_1.TezosToolkitConfigError {
104
104
  constructor() {
@@ -111,7 +111,7 @@ class UnconfiguredContractMetadataProviderError extends core_1.TezosToolkitConfi
111
111
  exports.UnconfiguredContractMetadataProviderError = UnconfiguredContractMetadataProviderError;
112
112
  /**
113
113
  * @category Error
114
- * @description Error that indicates a forbidden instruction being found inside the View code
114
+ * Error that indicates a forbidden instruction being found inside the View code
115
115
  */
116
116
  class ForbiddenInstructionInViewCodeError extends core_1.TaquitoError {
117
117
  constructor(instruction) {
@@ -124,7 +124,7 @@ class ForbiddenInstructionInViewCodeError extends core_1.TaquitoError {
124
124
  exports.ForbiddenInstructionInViewCodeError = ForbiddenInstructionInViewCodeError;
125
125
  /**
126
126
  * @category Error
127
- * @description Error that indicates parameters are being passed when it is not required
127
+ * Error that indicates parameters are being passed when it is not required
128
128
  */
129
129
  class NoParameterExpectedError extends core_1.ParameterValidationError {
130
130
  constructor(viewName, args) {
@@ -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.HttpHandler = void 0;
13
4
  const http_utils_1 = require("@taquito/http-utils");
@@ -15,16 +6,14 @@ class HttpHandler {
15
6
  constructor() {
16
7
  this.httpBackend = new http_utils_1.HttpBackend();
17
8
  }
18
- getMetadata(_contractAbstraction_1, _a, _context_1) {
19
- return __awaiter(this, arguments, void 0, function* (_contractAbstraction, { protocol, location }, _context) {
20
- return this.httpBackend.createRequest({
21
- url: `${protocol}:${decodeURIComponent(location)}`,
22
- method: 'GET',
23
- headers: {
24
- 'Content-Type': 'text/plain; charset=utf-8'
25
- },
26
- json: false
27
- });
9
+ async getMetadata(_contractAbstraction, { protocol, location }, _context) {
10
+ return this.httpBackend.createRequest({
11
+ url: `${protocol}:${decodeURIComponent(location)}`,
12
+ method: 'GET',
13
+ headers: {
14
+ 'Content-Type': 'text/plain; charset=utf-8'
15
+ },
16
+ json: false
28
17
  });
29
18
  }
30
19
  }
@@ -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.IpfsHttpHandler = void 0;
13
4
  const http_utils_1 = require("@taquito/http-utils");
@@ -16,16 +7,14 @@ class IpfsHttpHandler {
16
7
  this.httpBackend = new http_utils_1.HttpBackend();
17
8
  this._ipfsGateway = ipfsGatheway ? ipfsGatheway : 'ipfs.io';
18
9
  }
19
- getMetadata(_contractAbstraction_1, _a, _context_1) {
20
- return __awaiter(this, arguments, void 0, function* (_contractAbstraction, { location }, _context) {
21
- return this.httpBackend.createRequest({
22
- url: `https://${this._ipfsGateway}/ipfs/${location.substring(2)}/`,
23
- method: 'GET',
24
- headers: {
25
- 'Content-Type': 'text/plain; charset=utf-8'
26
- },
27
- json: false
28
- });
10
+ async getMetadata(_contractAbstraction, { location }, _context) {
11
+ return this.httpBackend.createRequest({
12
+ url: `https://${this._ipfsGateway}/ipfs/${location.substring(2)}/`,
13
+ method: 'GET',
14
+ headers: {
15
+ 'Content-Type': 'text/plain; charset=utf-8'
16
+ },
17
+ json: false
29
18
  });
30
19
  }
31
20
  }
@@ -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.TezosStorageHandler = void 0;
13
4
  const michelson_encoder_1 = require("@taquito/michelson-encoder");
@@ -22,29 +13,27 @@ class TezosStorageHandler {
22
13
  constructor() {
23
14
  this.TEZOS_STORAGE_REGEX = /^(?:\/\/(KT1\w{33})(?:\.(.+))?\/)?([\w|%]+)$/;
24
15
  }
25
- getMetadata(contractAbstraction_1, _a, context_1) {
26
- return __awaiter(this, arguments, void 0, function* (contractAbstraction, { location }, context) {
27
- const parsedTezosStorageUri = this.parseTezosStorageUri(location);
28
- if (!parsedTezosStorageUri) {
29
- throw new errors_1.InvalidUriError(`tezos-storage:${location}`);
30
- }
31
- const script = yield context.readProvider.getScript(parsedTezosStorageUri.contractAddress || contractAbstraction.address, 'head');
32
- const bigMapId = michelson_encoder_1.Schema.fromRPCResponse({ script }).FindFirstInTopLevelPair(script.storage, typeOfValueToFind);
33
- if (!bigMapId || !bigMapId.int) {
34
- throw new errors_1.BigMapContractMetadataNotFoundError(bigMapId);
35
- }
36
- const bytes = yield context.contract.getBigMapKeyByID(bigMapId.int.toString(), parsedTezosStorageUri.path, new michelson_encoder_1.Schema(typeOfValueToFind));
37
- if (!bytes) {
38
- throw new errors_1.ContractMetadataNotFoundError(`No '${parsedTezosStorageUri.path}' key found in the big map %metadata of the contract ${parsedTezosStorageUri.contractAddress || contractAbstraction.address}`);
39
- }
40
- if (!/^[0-9a-fA-F]*$/.test(bytes)) {
41
- throw new errors_1.InvalidContractMetadataTypeError();
42
- }
43
- return (0, utils_1.bytesToString)(bytes);
44
- });
16
+ async getMetadata(contractAbstraction, { location }, context) {
17
+ const parsedTezosStorageUri = this.parseTezosStorageUri(location);
18
+ if (!parsedTezosStorageUri) {
19
+ throw new errors_1.InvalidUriError(`tezos-storage:${location}`);
20
+ }
21
+ const script = await context.readProvider.getScript(parsedTezosStorageUri.contractAddress || contractAbstraction.address, 'head');
22
+ const bigMapId = michelson_encoder_1.Schema.fromRPCResponse({ script }).FindFirstInTopLevelPair(script.storage, typeOfValueToFind);
23
+ if (!bigMapId || !bigMapId.int) {
24
+ throw new errors_1.BigMapContractMetadataNotFoundError(bigMapId);
25
+ }
26
+ const bytes = await context.contract.getBigMapKeyByID(bigMapId.int.toString(), parsedTezosStorageUri.path, new michelson_encoder_1.Schema(typeOfValueToFind));
27
+ if (!bytes) {
28
+ throw new errors_1.ContractMetadataNotFoundError(`No '${parsedTezosStorageUri.path}' key found in the big map %metadata of the contract ${parsedTezosStorageUri.contractAddress || contractAbstraction.address}`);
29
+ }
30
+ if (!/^[0-9a-fA-F]*$/.test(bytes)) {
31
+ throw new errors_1.InvalidContractMetadataTypeError();
32
+ }
33
+ return (0, utils_1.bytesToString)(bytes);
45
34
  }
46
35
  /**
47
- * @description Extract the smart contract address, the network and the path pointing to the metadata from the uri
36
+ * Extract the smart contract address, the network and the path pointing to the metadata from the uri
48
37
  * @returns an object which contains the properties allowing to find where the metadata are located or it returns undefined if the uri is not valid
49
38
  * @param tezosStorageURI URI (without the tezos-storage prefix)
50
39
  */
@@ -1,19 +1,10 @@
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.MetadataProvider = void 0;
13
4
  const errors_1 = require("./errors");
14
5
  const tzip16_utils_1 = require("./tzip16-utils");
15
6
  /**
16
- * @description: Metadata Provider
7
+ \* Metadata Provider
17
8
  */
18
9
  class MetadataProvider {
19
10
  constructor(handlers) {
@@ -21,38 +12,36 @@ class MetadataProvider {
21
12
  this.PROTOCOL_REGEX = /(?:sha256:\/\/0x(.*)\/)?(https?|ipfs|tezos-storage):(.*)/;
22
13
  }
23
14
  /**
24
- * @description Fetch the metadata by using the appropriate handler based on the protcol found in the URI
15
+ * Fetch the metadata by using the appropriate handler based on the protcol found in the URI
25
16
  * @returns an object which contains the uri, the metadata, an optional integrity check result and an optional SHA256 hash
26
- * @param _contractAbstraction the contract abstraction which contains the URI in its storage
27
- * @param _uri the decoded uri found in the storage
17
+ * @param contractAbstraction the contract abstraction which contains the URI in its storage
18
+ * @param uri the decoded uri found in the storage
28
19
  * @param context the TezosToolkit Context
29
20
  */
30
- provideMetadata(contractAbstraction, uri, context) {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- const uriInfo = this.extractProtocolInfo(uri);
33
- if (!uriInfo || !uriInfo.location) {
34
- throw new errors_1.InvalidUriError(uri);
35
- }
36
- const handler = this.handlers.get(uriInfo.protocol);
37
- if (!handler) {
38
- throw new errors_1.ProtocolNotSupportedError(uriInfo.protocol);
39
- }
40
- const metadata = yield handler.getMetadata(contractAbstraction, uriInfo, context);
41
- const sha256Hash = (0, tzip16_utils_1.calculateSHA256Hash)(metadata);
42
- let metadataJSON;
43
- try {
44
- metadataJSON = JSON.parse(metadata);
45
- }
46
- catch (ex) {
47
- throw new errors_1.InvalidContractMetadataError(metadata);
48
- }
49
- return {
50
- uri,
51
- metadata: metadataJSON,
52
- integrityCheckResult: uriInfo.sha256hash ? uriInfo.sha256hash === sha256Hash : undefined,
53
- sha256Hash: uriInfo.sha256hash ? sha256Hash : undefined,
54
- };
55
- });
21
+ async provideMetadata(contractAbstraction, uri, context) {
22
+ const uriInfo = this.extractProtocolInfo(uri);
23
+ if (!uriInfo || !uriInfo.location) {
24
+ throw new errors_1.InvalidUriError(uri);
25
+ }
26
+ const handler = this.handlers.get(uriInfo.protocol);
27
+ if (!handler) {
28
+ throw new errors_1.ProtocolNotSupportedError(uriInfo.protocol);
29
+ }
30
+ const metadata = await handler.getMetadata(contractAbstraction, uriInfo, context);
31
+ const sha256Hash = (0, tzip16_utils_1.calculateSHA256Hash)(metadata);
32
+ let metadataJSON;
33
+ try {
34
+ metadataJSON = JSON.parse(metadata);
35
+ }
36
+ catch (ex) {
37
+ throw new errors_1.InvalidContractMetadataError(metadata);
38
+ }
39
+ return {
40
+ uri,
41
+ metadata: metadataJSON,
42
+ integrityCheckResult: uriInfo.sha256hash ? uriInfo.sha256hash === sha256Hash : undefined,
43
+ sha256Hash: uriInfo.sha256hash ? sha256Hash : undefined,
44
+ };
56
45
  }
57
46
  extractProtocolInfo(_uri) {
58
47
  const extractor = this.PROTOCOL_REGEX.exec(_uri);
@@ -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.Tzip16ContractAbstraction = void 0;
13
4
  const taquito_1 = require("@taquito/taquito");
@@ -29,120 +20,91 @@ class Tzip16ContractAbstraction {
29
20
  this._metadataViewsObject = {};
30
21
  this._metadataProvider = context.metadataProvider;
31
22
  }
32
- findMetadataBigMap() {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- const metadataBigMapId = this.constractAbstraction.schema.FindFirstInTopLevelPair(yield this.context.readProvider.getStorage(this.constractAbstraction.address, 'head'), metadataBigMapType);
35
- if (!metadataBigMapId || !metadataBigMapId.int) {
36
- throw new errors_1.BigMapContractMetadataNotFoundError(metadataBigMapId);
37
- }
38
- return new taquito_1.BigMapAbstraction(new bignumber_js_1.default(metadataBigMapId['int']), new michelson_encoder_1.Schema(metadataBigMapType), this.context.contract);
39
- });
40
- }
41
- getUriOrFail() {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- const metadataBigMap = yield this.findMetadataBigMap();
44
- const uri = yield metadataBigMap.get('');
45
- if (!uri) {
46
- throw new errors_1.UriNotFoundError();
47
- }
48
- return uri;
49
- });
23
+ async findMetadataBigMap() {
24
+ const metadataBigMapId = this.constractAbstraction.schema.FindFirstInTopLevelPair(await this.context.readProvider.getStorage(this.constractAbstraction.address, 'head'), metadataBigMapType);
25
+ if (!metadataBigMapId || !metadataBigMapId.int) {
26
+ throw new errors_1.BigMapContractMetadataNotFoundError(metadataBigMapId);
27
+ }
28
+ return new taquito_1.BigMapAbstraction(new bignumber_js_1.default(metadataBigMapId['int']), new michelson_encoder_1.Schema(metadataBigMapType), this.context.contract);
29
+ }
30
+ async getUriOrFail() {
31
+ const metadataBigMap = await this.findMetadataBigMap();
32
+ const uri = await metadataBigMap.get('');
33
+ if (!uri) {
34
+ throw new errors_1.UriNotFoundError();
35
+ }
36
+ return uri;
50
37
  }
51
38
  /**
52
- * @description Return an object containing the metadata, the uri, an optional integrity check result and an optional sha256 hash
39
+ * Return an object containing the metadata, the uri, an optional integrity check result and an optional sha256 hash
53
40
  */
54
- getMetadata() {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- if (!this._metadataProvider) {
57
- throw new errors_1.UnconfiguredContractMetadataProviderError();
58
- }
59
- if (!this._metadataEnvelope) {
60
- const uri = yield this.getUriOrFail();
61
- this._metadataEnvelope = yield this._metadataProvider.provideMetadata(this.constractAbstraction, (0, utils_1.bytesToString)(uri), this.context);
62
- }
63
- return this._metadataEnvelope;
64
- });
41
+ async getMetadata() {
42
+ if (!this._metadataProvider) {
43
+ throw new errors_1.UnconfiguredContractMetadataProviderError();
44
+ }
45
+ if (!this._metadataEnvelope) {
46
+ const uri = await this.getUriOrFail();
47
+ this._metadataEnvelope = await this._metadataProvider.provideMetadata(this.constractAbstraction, (0, utils_1.bytesToString)(uri), this.context);
48
+ }
49
+ return this._metadataEnvelope;
65
50
  }
66
- metadataName() {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- if (!this._metadataEnvelope) {
69
- yield this.getMetadata();
70
- }
71
- return this._metadataEnvelope.metadata.name;
72
- });
73
- }
74
- metadataDescription() {
75
- return __awaiter(this, void 0, void 0, function* () {
76
- if (!this._metadataEnvelope)
77
- yield this.getMetadata();
78
- return this._metadataEnvelope.metadata.description;
79
- });
80
- }
81
- metadataVersion() {
82
- return __awaiter(this, void 0, void 0, function* () {
83
- if (!this._metadataEnvelope)
84
- yield this.getMetadata();
85
- return this._metadataEnvelope.metadata.version;
86
- });
87
- }
88
- metadataLicense() {
89
- return __awaiter(this, void 0, void 0, function* () {
90
- if (!this._metadataEnvelope)
91
- yield this.getMetadata();
92
- return this._metadataEnvelope.metadata.license;
93
- });
94
- }
95
- metadataAuthors() {
96
- return __awaiter(this, void 0, void 0, function* () {
97
- if (!this._metadataEnvelope)
98
- yield this.getMetadata();
99
- return this._metadataEnvelope.metadata.authors;
100
- });
101
- }
102
- metadataHomepage() {
103
- return __awaiter(this, void 0, void 0, function* () {
104
- if (!this._metadataEnvelope)
105
- yield this.getMetadata();
106
- return this._metadataEnvelope.metadata.homepage;
107
- });
108
- }
109
- metadataSource() {
110
- return __awaiter(this, void 0, void 0, function* () {
111
- if (!this._metadataEnvelope)
112
- yield this.getMetadata();
113
- return this._metadataEnvelope.metadata.source;
114
- });
115
- }
116
- metadataInterfaces() {
117
- return __awaiter(this, void 0, void 0, function* () {
118
- if (!this._metadataEnvelope)
119
- yield this.getMetadata();
120
- return this._metadataEnvelope.metadata.interfaces;
121
- });
122
- }
123
- metadataErrors() {
124
- return __awaiter(this, void 0, void 0, function* () {
125
- if (!this._metadataEnvelope)
126
- yield this.getMetadata();
127
- return this._metadataEnvelope.metadata.errors;
128
- });
129
- }
130
- metadataViews() {
131
- return __awaiter(this, void 0, void 0, function* () {
132
- if (Object.keys(this._metadataViewsObject).length === 0) {
133
- yield this.initializeMetadataViewsList();
134
- }
135
- return this._metadataViewsObject;
136
- });
137
- }
138
- initializeMetadataViewsList() {
139
- return __awaiter(this, void 0, void 0, function* () {
140
- var _a;
141
- const { metadata } = yield this.getMetadata();
142
- const metadataViews = {};
143
- (_a = metadata.views) === null || _a === void 0 ? void 0 : _a.forEach((view) => this.createViewImplementations(view, metadataViews));
144
- this._metadataViewsObject = metadataViews;
145
- });
51
+ async metadataName() {
52
+ if (!this._metadataEnvelope) {
53
+ await this.getMetadata();
54
+ }
55
+ return this._metadataEnvelope.metadata.name;
56
+ }
57
+ async metadataDescription() {
58
+ if (!this._metadataEnvelope)
59
+ await this.getMetadata();
60
+ return this._metadataEnvelope.metadata.description;
61
+ }
62
+ async metadataVersion() {
63
+ if (!this._metadataEnvelope)
64
+ await this.getMetadata();
65
+ return this._metadataEnvelope.metadata.version;
66
+ }
67
+ async metadataLicense() {
68
+ if (!this._metadataEnvelope)
69
+ await this.getMetadata();
70
+ return this._metadataEnvelope.metadata.license;
71
+ }
72
+ async metadataAuthors() {
73
+ if (!this._metadataEnvelope)
74
+ await this.getMetadata();
75
+ return this._metadataEnvelope.metadata.authors;
76
+ }
77
+ async metadataHomepage() {
78
+ if (!this._metadataEnvelope)
79
+ await this.getMetadata();
80
+ return this._metadataEnvelope.metadata.homepage;
81
+ }
82
+ async metadataSource() {
83
+ if (!this._metadataEnvelope)
84
+ await this.getMetadata();
85
+ return this._metadataEnvelope.metadata.source;
86
+ }
87
+ async metadataInterfaces() {
88
+ if (!this._metadataEnvelope)
89
+ await this.getMetadata();
90
+ return this._metadataEnvelope.metadata.interfaces;
91
+ }
92
+ async metadataErrors() {
93
+ if (!this._metadataEnvelope)
94
+ await this.getMetadata();
95
+ return this._metadataEnvelope.metadata.errors;
96
+ }
97
+ async metadataViews() {
98
+ if (Object.keys(this._metadataViewsObject).length === 0) {
99
+ await this.initializeMetadataViewsList();
100
+ }
101
+ return this._metadataViewsObject;
102
+ }
103
+ async initializeMetadataViewsList() {
104
+ const { metadata } = await this.getMetadata();
105
+ const metadataViews = {};
106
+ metadata.views?.forEach((view) => this.createViewImplementations(view, metadataViews));
107
+ this._metadataViewsObject = metadataViews;
146
108
  }
147
109
  generateIndexedViewName(viewName, metadataViews) {
148
110
  let i = 1;
@@ -155,8 +117,7 @@ class Tzip16ContractAbstraction {
155
117
  return viewName;
156
118
  }
157
119
  createViewImplementations(view, metadataViews) {
158
- var _a;
159
- for (const viewImplementation of (_a = view === null || view === void 0 ? void 0 : view.implementations) !== null && _a !== void 0 ? _a : []) {
120
+ for (const viewImplementation of view?.implementations ?? []) {
160
121
  if (view.name) {
161
122
  // when views have the same name, add an index at the end of the name
162
123
  const viewName = this.generateIndexedViewName(view.name, metadataViews);
@@ -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": "3f0dac2d1edb047928bcbe89db422d4de60f007e",
7
- "version": "24.2.0-beta.1"
6
+ "commitHash": "27675679db6515e8b092195ef5c58c2c0ea5f5c8",
7
+ "version": "24.3.0-beta.0"
8
8
  };