@taquito/tzip16 24.2.0 → 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.
- package/dist/lib/errors.js +10 -10
- package/dist/lib/handlers/http-handler.js +8 -19
- package/dist/lib/handlers/ipfs-handler.js +8 -19
- package/dist/lib/handlers/tezos-storage-handler.js +19 -30
- package/dist/lib/metadata-provider.js +28 -39
- package/dist/lib/tzip16-contract-abstraction.js +82 -121
- package/dist/lib/version.js +2 -2
- package/dist/lib/viewKind/michelson-storage-view.js +53 -64
- package/dist/taquito-tzip16.es6.js +208 -280
- package/dist/taquito-tzip16.es6.js.map +1 -1
- package/dist/taquito-tzip16.umd.js +208 -280
- package/dist/taquito-tzip16.umd.js.map +1 -1
- package/dist/types/errors.d.ts +10 -10
- package/dist/types/handlers/tezos-storage-handler.d.ts +1 -1
- package/dist/types/metadata-provider.d.ts +4 -4
- package/dist/types/tzip16-contract-abstraction.d.ts +1 -1
- package/dist/types/viewKind/michelson-storage-view.d.ts +3 -3
- package/package.json +24 -14
- package/LICENSE +0 -202
package/dist/lib/errors.js
CHANGED
|
@@ -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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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(
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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(
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
|
27
|
-
* @param
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
*
|
|
39
|
+
* Return an object containing the metadata, the uri, an optional integrity check result and an optional sha256 hash
|
|
53
40
|
*/
|
|
54
|
-
getMetadata() {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
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);
|
package/dist/lib/version.js
CHANGED
|
@@ -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": "
|
|
7
|
-
"version": "24.
|
|
6
|
+
"commitHash": "27675679db6515e8b092195ef5c58c2c0ea5f5c8",
|
|
7
|
+
"version": "24.3.0-beta.0"
|
|
8
8
|
};
|