@taquito/tzip12 17.2.0 → 17.3.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/LICENSE CHANGED
@@ -1,7 +1,202 @@
1
- Copyright 2019 ECAD Labs Inc
2
1
 
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
4
5
 
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
7
 
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
5
5
  exports.VERSION = {
6
- "commitHash": "b85fc404e34545a518215e449b3f1253f4520eec",
7
- "version": "17.2.0"
6
+ "commitHash": "a5b3c864e1537d0fe0a7f8f0b55989ef89311fa2",
7
+ "version": "17.3.0"
8
8
  };
9
9
  //# sourceMappingURL=version.js.map
@@ -270,8 +270,8 @@ class Tzip12Module {
270
270
 
271
271
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
272
272
  const VERSION = {
273
- "commitHash": "b85fc404e34545a518215e449b3f1253f4520eec",
274
- "version": "17.2.0"
273
+ "commitHash": "a5b3c864e1537d0fe0a7f8f0b55989ef89311fa2",
274
+ "version": "17.3.0"
275
275
  };
276
276
 
277
277
  export { InvalidTokenMetadata, TokenIdNotFound, TokenMetadataNotFound, Tzip12ContractAbstraction, Tzip12Module, VERSION, tzip12 };
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-tzip12.es6.js","sources":["../src/errors.ts","../src/tzip12-contract-abstraction.ts","../src/composer.ts","../src/tzip12-extension.ts","../src/version.ts"],"sourcesContent":["import { TaquitoError } from '@taquito/core';\n\n/**\n * @category Error\n * @description Error that indicates the metadata not being found on the contract\n */\nexport class TokenMetadataNotFound extends TaquitoError {\n constructor(public readonly address: string) {\n super();\n this.name = 'TokenMetadataNotFound';\n this.message = `No token metadata was found for the contract: ${address}`;\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates the token ID not being found\n */\nexport class TokenIdNotFound extends TaquitoError {\n constructor(public readonly tokenId: number) {\n super(`Could not find token metadata for the token ID: ${tokenId}`);\n this.name = 'TokenIdNotFound';\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates that the token metadata is invalid (not compliant with the TZIP-12 standard)\n */\nexport class InvalidTokenMetadata extends TaquitoError {\n constructor(public readonly invalidMetadata: any) {\n super();\n this.name = 'InvalidTokenMetadata';\n this.message =\n 'Non-compliance with the TZIP-012 standard. The required property `decimals` is missing.';\n }\n}\n","import { MichelsonMap, Schema } from '@taquito/michelson-encoder';\nimport { ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';\nimport {\n Tzip16ContractAbstraction,\n MetadataContext,\n View,\n bytes2Char,\n BigMapId,\n} from '@taquito/tzip16';\nimport { InvalidTokenMetadata, TokenIdNotFound, TokenMetadataNotFound } from './errors';\n\nconst tokenMetadataBigMapType = {\n prim: 'big_map',\n args: [\n { prim: 'nat' },\n {\n prim: 'pair',\n args: [\n { prim: 'nat', annots: ['%token_id'] },\n { prim: 'map', args: [{ prim: 'string' }, { prim: 'bytes' }], annots: ['%token_info'] },\n ],\n },\n ],\n annots: ['%token_metadata'],\n};\n\nexport interface TokenMetadata {\n token_id: number;\n decimals: number;\n name?: string;\n symbol?: string;\n}\n\nexport class Tzip12ContractAbstraction {\n private _tzip16ContractAbstraction: Tzip16ContractAbstraction;\n\n constructor(\n private contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n private context: MetadataContext\n ) {\n this._tzip16ContractAbstraction = new Tzip16ContractAbstraction(\n this.contractAbstraction,\n this.context\n );\n }\n\n /**\n * @description Fetches the contract metadata (according to the Tzip-016 standard)\n * @returns An object containing the metadata, the uri, an optional integrity check result and an optional sha256 hash\n * or `Undefined` if the contract has no metadata (non-compliant with Tzip-016)\n */\n private async getContractMetadata() {\n try {\n const contractMetadata = await this._tzip16ContractAbstraction.getMetadata();\n return contractMetadata.metadata;\n } catch (err) {\n // The contract is not compliant with Tzip-016. There is no contract metadata.\n }\n }\n\n /**\n * @description The Tzip-016 \"interfaces\" field MUST be present in the contract metadata. It should contain \"TZIP-012[version-info]\"\n * @returns True if \"interfaces\" field is present and contains \"TZIP-012\", false otherwise\n */\n async isTzip12Compliant() {\n let isCompliant = false;\n const metadata = await this.getContractMetadata();\n if (metadata) {\n const tzip12Interface = metadata.interfaces?.filter((x) => {\n return x.substring(0, 8) === 'TZIP-012';\n });\n isCompliant = tzip12Interface && tzip12Interface.length !== 0 ? true : false;\n }\n return isCompliant;\n }\n\n /**\n * @description Fetches the token metadata for a specified token ID.\n * The function first tries to find a `token_metadata` view in the contract metadata and to execute it with the token ID.\n * If there is no view, the function tries to find a `token_metadata` bigmap in the top-level pairs of the storage.\n * @param tokenId The ID of the token for which we want to retrieve token metadata\n * @returns An object of type `TokenMetadata`\n * @throws {@link TokenIdNotFound, TokenMetadataNotFound, InvalidTokenMetadata}\n */\n async getTokenMetadata(tokenId: number) {\n const tokenMetadata = await this.retrieveTokenMetadataFromView(tokenId);\n return !tokenMetadata ? this.retrieveTokenMetadataFromBigMap(tokenId) : tokenMetadata;\n }\n\n private async retrieveTokenMetadataFromView(tokenId: number) {\n if (await this.getContractMetadata()) {\n const views = await this._tzip16ContractAbstraction.metadataViews();\n if (views && this.hasTokenMetadataView(views)) {\n return this.executeTokenMetadataView(views['token_metadata'](), tokenId);\n }\n }\n }\n\n private hasTokenMetadataView(views: object) {\n for (const view of Object.keys(views)) {\n if (view === 'token_metadata') {\n return true;\n }\n }\n return false;\n }\n\n private async executeTokenMetadataView(\n tokenMetadataView: View,\n tokenId: number\n ): Promise<TokenMetadata> {\n const tokenMetadata = await tokenMetadataView.executeView(tokenId);\n const tokenMap = Object.values(tokenMetadata)[1];\n if (!MichelsonMap.isMichelsonMap(tokenMap)) {\n throw new TokenMetadataNotFound(this.contractAbstraction.address);\n }\n const metadataFromUri = await this.fetchTokenMetadataFromUri(\n tokenMap as MichelsonMap<string, string>\n );\n return this.formatMetadataToken(\n tokenId,\n tokenMap as MichelsonMap<string, string>,\n metadataFromUri\n );\n }\n\n private async fetchTokenMetadataFromUri(tokenMetadata: MichelsonMap<string, string>) {\n const uri = tokenMetadata.get('');\n if (uri) {\n try {\n const metadataFromUri = await this.context.metadataProvider.provideMetadata(\n this.contractAbstraction,\n bytes2Char(uri),\n this.context\n );\n return metadataFromUri.metadata;\n } catch (e: any) {\n if (e.name === 'InvalidUriError') {\n console.warn(\n `The URI ${bytes2Char(uri)} is present in the token metadata, but is invalid.`\n );\n } else {\n throw e;\n }\n }\n }\n }\n\n private formatMetadataToken(\n tokenId: number,\n metadataTokenMap: MichelsonMap<string, string>,\n metadataFromUri?: any\n ): TokenMetadata {\n const tokenMetadataDecoded = {\n token_id: tokenId,\n };\n for (const keyTokenMetadata of metadataTokenMap.keys()) {\n if (keyTokenMetadata === 'decimals') {\n Object.assign(tokenMetadataDecoded, {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n [keyTokenMetadata]: Number(bytes2Char(metadataTokenMap.get(keyTokenMetadata)!)),\n });\n } else if (!(keyTokenMetadata === '')) {\n Object.assign(tokenMetadataDecoded, {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n [keyTokenMetadata]: bytes2Char(metadataTokenMap.get(keyTokenMetadata)!),\n });\n }\n }\n // if an URI is present, add the fetched properties to the object\n // if a property is in the URI and the map, prevalence is accorded to value from the URI\n if (metadataFromUri) {\n for (const property in metadataFromUri) {\n Object.assign(tokenMetadataDecoded, { [property]: metadataFromUri[property] });\n }\n }\n if (!('decimals' in tokenMetadataDecoded)) {\n throw new InvalidTokenMetadata(tokenMetadataDecoded);\n }\n return tokenMetadataDecoded as TokenMetadata;\n }\n\n private async retrieveTokenMetadataFromBigMap(tokenId: number) {\n const bigmapTokenMetadataId = await this.findTokenMetadataBigMap();\n let pairNatMap;\n try {\n pairNatMap = await this.context.contract.getBigMapKeyByID<{\n token_info: MichelsonMap<string, string>;\n }>(\n bigmapTokenMetadataId['int'].toString(),\n tokenId.toString(),\n new Schema(tokenMetadataBigMapType)\n );\n } catch (err) {\n throw new TokenIdNotFound(tokenId);\n }\n\n const michelsonMap = pairNatMap['token_info'];\n if (!MichelsonMap.isMichelsonMap(michelsonMap)) {\n throw new TokenIdNotFound(tokenId);\n }\n const metadataFromUri = await this.fetchTokenMetadataFromUri(\n michelsonMap as MichelsonMap<string, string>\n );\n return this.formatMetadataToken(\n tokenId,\n michelsonMap as MichelsonMap<string, string>,\n metadataFromUri\n );\n }\n\n private async findTokenMetadataBigMap(): Promise<BigMapId> {\n const tokenMetadataBigMapId = this.contractAbstraction.schema.FindFirstInTopLevelPair<BigMapId>(\n await this.context.readProvider.getStorage(this.contractAbstraction.address, 'head'),\n tokenMetadataBigMapType\n );\n if (!tokenMetadataBigMapId || !tokenMetadataBigMapId.int) {\n throw new TokenMetadataNotFound(this.contractAbstraction.address);\n }\n return { int: tokenMetadataBigMapId.int };\n }\n}\n","import { Context, ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';\nimport { Tzip12ContractAbstraction } from './tzip12-contract-abstraction';\nimport { MetadataContext } from '@taquito/tzip16';\n\nconst ABSTRACTION_KEY = Symbol('Tzip12ContractAbstractionObjectKey');\n\nexport function tzip12<T extends ContractAbstraction<ContractProvider | Wallet>>(\n abs: T,\n context: Context\n) {\n return Object.assign(abs, {\n // namespace tzip12\n tzip12(\n this: ContractAbstraction<ContractProvider | Wallet> & {\n [ABSTRACTION_KEY]?: Tzip12ContractAbstraction;\n }\n ) {\n if (!this[ABSTRACTION_KEY]) {\n this[ABSTRACTION_KEY] = new Tzip12ContractAbstraction(this, context as MetadataContext);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this[ABSTRACTION_KEY]!;\n },\n });\n}\n","import { Context, Extension } from \"@taquito/taquito\";\nimport { DEFAULT_HANDLERS, MetadataProviderInterface, MetadataProvider } from '@taquito/tzip16'\n\n// The same default metadataProvider is used for tzip16 and tzip12\nexport class Tzip12Module implements Extension {\n private _metadataProvider: MetadataProviderInterface;\n\n constructor(metadataProvider?: MetadataProviderInterface) {\n this._metadataProvider = metadataProvider ? metadataProvider : new MetadataProvider(DEFAULT_HANDLERS);\n }\n\n configureContext(context: Context) {\n Object.assign(context, { metadataProvider: this._metadataProvider });\n }\n}","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"b85fc404e34545a518215e449b3f1253f4520eec\",\n \"version\": \"17.2.0\"\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;;AAGG;AACG,MAAO,qBAAsB,SAAQ,YAAY,CAAA;AACrD,IAAA,WAAA,CAA4B,OAAe,EAAA;AACzC,QAAA,KAAK,EAAE,CAAC;QADkB,IAAO,CAAA,OAAA,GAAP,OAAO,CAAQ;AAEzC,QAAA,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;AACpC,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,GAAG,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;KACzG;AAED,IAAA,gBAAgB,CAAC,OAAgB,EAAA;AAC7B,QAAA,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;KACxE;AACJ;;ACbD;AACa,MAAA,OAAO,GAAG;AACnB,IAAA,YAAY,EAAE,0CAA0C;AACxD,IAAA,SAAS,EAAE,QAAQ;;;;;"}
1
+ {"version":3,"file":"taquito-tzip12.es6.js","sources":["../src/errors.ts","../src/tzip12-contract-abstraction.ts","../src/composer.ts","../src/tzip12-extension.ts","../src/version.ts"],"sourcesContent":["import { TaquitoError } from '@taquito/core';\n\n/**\n * @category Error\n * @description Error that indicates the metadata not being found on the contract\n */\nexport class TokenMetadataNotFound extends TaquitoError {\n constructor(public readonly address: string) {\n super();\n this.name = 'TokenMetadataNotFound';\n this.message = `No token metadata was found for the contract: ${address}`;\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates the token ID not being found\n */\nexport class TokenIdNotFound extends TaquitoError {\n constructor(public readonly tokenId: number) {\n super(`Could not find token metadata for the token ID: ${tokenId}`);\n this.name = 'TokenIdNotFound';\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates that the token metadata is invalid (not compliant with the TZIP-12 standard)\n */\nexport class InvalidTokenMetadata extends TaquitoError {\n constructor(public readonly invalidMetadata: any) {\n super();\n this.name = 'InvalidTokenMetadata';\n this.message =\n 'Non-compliance with the TZIP-012 standard. The required property `decimals` is missing.';\n }\n}\n","import { MichelsonMap, Schema } from '@taquito/michelson-encoder';\nimport { ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';\nimport {\n Tzip16ContractAbstraction,\n MetadataContext,\n View,\n bytes2Char,\n BigMapId,\n} from '@taquito/tzip16';\nimport { InvalidTokenMetadata, TokenIdNotFound, TokenMetadataNotFound } from './errors';\n\nconst tokenMetadataBigMapType = {\n prim: 'big_map',\n args: [\n { prim: 'nat' },\n {\n prim: 'pair',\n args: [\n { prim: 'nat', annots: ['%token_id'] },\n { prim: 'map', args: [{ prim: 'string' }, { prim: 'bytes' }], annots: ['%token_info'] },\n ],\n },\n ],\n annots: ['%token_metadata'],\n};\n\nexport interface TokenMetadata {\n token_id: number;\n decimals: number;\n name?: string;\n symbol?: string;\n}\n\nexport class Tzip12ContractAbstraction {\n private _tzip16ContractAbstraction: Tzip16ContractAbstraction;\n\n constructor(\n private contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n private context: MetadataContext\n ) {\n this._tzip16ContractAbstraction = new Tzip16ContractAbstraction(\n this.contractAbstraction,\n this.context\n );\n }\n\n /**\n * @description Fetches the contract metadata (according to the Tzip-016 standard)\n * @returns An object containing the metadata, the uri, an optional integrity check result and an optional sha256 hash\n * or `Undefined` if the contract has no metadata (non-compliant with Tzip-016)\n */\n private async getContractMetadata() {\n try {\n const contractMetadata = await this._tzip16ContractAbstraction.getMetadata();\n return contractMetadata.metadata;\n } catch (err) {\n // The contract is not compliant with Tzip-016. There is no contract metadata.\n }\n }\n\n /**\n * @description The Tzip-016 \"interfaces\" field MUST be present in the contract metadata. It should contain \"TZIP-012[version-info]\"\n * @returns True if \"interfaces\" field is present and contains \"TZIP-012\", false otherwise\n */\n async isTzip12Compliant() {\n let isCompliant = false;\n const metadata = await this.getContractMetadata();\n if (metadata) {\n const tzip12Interface = metadata.interfaces?.filter((x) => {\n return x.substring(0, 8) === 'TZIP-012';\n });\n isCompliant = tzip12Interface && tzip12Interface.length !== 0 ? true : false;\n }\n return isCompliant;\n }\n\n /**\n * @description Fetches the token metadata for a specified token ID.\n * The function first tries to find a `token_metadata` view in the contract metadata and to execute it with the token ID.\n * If there is no view, the function tries to find a `token_metadata` bigmap in the top-level pairs of the storage.\n * @param tokenId The ID of the token for which we want to retrieve token metadata\n * @returns An object of type `TokenMetadata`\n * @throws {@link TokenIdNotFound, TokenMetadataNotFound, InvalidTokenMetadata}\n */\n async getTokenMetadata(tokenId: number) {\n const tokenMetadata = await this.retrieveTokenMetadataFromView(tokenId);\n return !tokenMetadata ? this.retrieveTokenMetadataFromBigMap(tokenId) : tokenMetadata;\n }\n\n private async retrieveTokenMetadataFromView(tokenId: number) {\n if (await this.getContractMetadata()) {\n const views = await this._tzip16ContractAbstraction.metadataViews();\n if (views && this.hasTokenMetadataView(views)) {\n return this.executeTokenMetadataView(views['token_metadata'](), tokenId);\n }\n }\n }\n\n private hasTokenMetadataView(views: object) {\n for (const view of Object.keys(views)) {\n if (view === 'token_metadata') {\n return true;\n }\n }\n return false;\n }\n\n private async executeTokenMetadataView(\n tokenMetadataView: View,\n tokenId: number\n ): Promise<TokenMetadata> {\n const tokenMetadata = await tokenMetadataView.executeView(tokenId);\n const tokenMap = Object.values(tokenMetadata)[1];\n if (!MichelsonMap.isMichelsonMap(tokenMap)) {\n throw new TokenMetadataNotFound(this.contractAbstraction.address);\n }\n const metadataFromUri = await this.fetchTokenMetadataFromUri(\n tokenMap as MichelsonMap<string, string>\n );\n return this.formatMetadataToken(\n tokenId,\n tokenMap as MichelsonMap<string, string>,\n metadataFromUri\n );\n }\n\n private async fetchTokenMetadataFromUri(tokenMetadata: MichelsonMap<string, string>) {\n const uri = tokenMetadata.get('');\n if (uri) {\n try {\n const metadataFromUri = await this.context.metadataProvider.provideMetadata(\n this.contractAbstraction,\n bytes2Char(uri),\n this.context\n );\n return metadataFromUri.metadata;\n } catch (e: any) {\n if (e.name === 'InvalidUriError') {\n console.warn(\n `The URI ${bytes2Char(uri)} is present in the token metadata, but is invalid.`\n );\n } else {\n throw e;\n }\n }\n }\n }\n\n private formatMetadataToken(\n tokenId: number,\n metadataTokenMap: MichelsonMap<string, string>,\n metadataFromUri?: any\n ): TokenMetadata {\n const tokenMetadataDecoded = {\n token_id: tokenId,\n };\n for (const keyTokenMetadata of metadataTokenMap.keys()) {\n if (keyTokenMetadata === 'decimals') {\n Object.assign(tokenMetadataDecoded, {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n [keyTokenMetadata]: Number(bytes2Char(metadataTokenMap.get(keyTokenMetadata)!)),\n });\n } else if (!(keyTokenMetadata === '')) {\n Object.assign(tokenMetadataDecoded, {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n [keyTokenMetadata]: bytes2Char(metadataTokenMap.get(keyTokenMetadata)!),\n });\n }\n }\n // if an URI is present, add the fetched properties to the object\n // if a property is in the URI and the map, prevalence is accorded to value from the URI\n if (metadataFromUri) {\n for (const property in metadataFromUri) {\n Object.assign(tokenMetadataDecoded, { [property]: metadataFromUri[property] });\n }\n }\n if (!('decimals' in tokenMetadataDecoded)) {\n throw new InvalidTokenMetadata(tokenMetadataDecoded);\n }\n return tokenMetadataDecoded as TokenMetadata;\n }\n\n private async retrieveTokenMetadataFromBigMap(tokenId: number) {\n const bigmapTokenMetadataId = await this.findTokenMetadataBigMap();\n let pairNatMap;\n try {\n pairNatMap = await this.context.contract.getBigMapKeyByID<{\n token_info: MichelsonMap<string, string>;\n }>(\n bigmapTokenMetadataId['int'].toString(),\n tokenId.toString(),\n new Schema(tokenMetadataBigMapType)\n );\n } catch (err) {\n throw new TokenIdNotFound(tokenId);\n }\n\n const michelsonMap = pairNatMap['token_info'];\n if (!MichelsonMap.isMichelsonMap(michelsonMap)) {\n throw new TokenIdNotFound(tokenId);\n }\n const metadataFromUri = await this.fetchTokenMetadataFromUri(\n michelsonMap as MichelsonMap<string, string>\n );\n return this.formatMetadataToken(\n tokenId,\n michelsonMap as MichelsonMap<string, string>,\n metadataFromUri\n );\n }\n\n private async findTokenMetadataBigMap(): Promise<BigMapId> {\n const tokenMetadataBigMapId = this.contractAbstraction.schema.FindFirstInTopLevelPair<BigMapId>(\n await this.context.readProvider.getStorage(this.contractAbstraction.address, 'head'),\n tokenMetadataBigMapType\n );\n if (!tokenMetadataBigMapId || !tokenMetadataBigMapId.int) {\n throw new TokenMetadataNotFound(this.contractAbstraction.address);\n }\n return { int: tokenMetadataBigMapId.int };\n }\n}\n","import { Context, ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';\nimport { Tzip12ContractAbstraction } from './tzip12-contract-abstraction';\nimport { MetadataContext } from '@taquito/tzip16';\n\nconst ABSTRACTION_KEY = Symbol('Tzip12ContractAbstractionObjectKey');\n\nexport function tzip12<T extends ContractAbstraction<ContractProvider | Wallet>>(\n abs: T,\n context: Context\n) {\n return Object.assign(abs, {\n // namespace tzip12\n tzip12(\n this: ContractAbstraction<ContractProvider | Wallet> & {\n [ABSTRACTION_KEY]?: Tzip12ContractAbstraction;\n }\n ) {\n if (!this[ABSTRACTION_KEY]) {\n this[ABSTRACTION_KEY] = new Tzip12ContractAbstraction(this, context as MetadataContext);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this[ABSTRACTION_KEY]!;\n },\n });\n}\n","import { Context, Extension } from \"@taquito/taquito\";\nimport { DEFAULT_HANDLERS, MetadataProviderInterface, MetadataProvider } from '@taquito/tzip16'\n\n// The same default metadataProvider is used for tzip16 and tzip12\nexport class Tzip12Module implements Extension {\n private _metadataProvider: MetadataProviderInterface;\n\n constructor(metadataProvider?: MetadataProviderInterface) {\n this._metadataProvider = metadataProvider ? metadataProvider : new MetadataProvider(DEFAULT_HANDLERS);\n }\n\n configureContext(context: Context) {\n Object.assign(context, { metadataProvider: this._metadataProvider });\n }\n}","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"a5b3c864e1537d0fe0a7f8f0b55989ef89311fa2\",\n \"version\": \"17.3.0\"\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;;AAGG;AACG,MAAO,qBAAsB,SAAQ,YAAY,CAAA;AACrD,IAAA,WAAA,CAA4B,OAAe,EAAA;AACzC,QAAA,KAAK,EAAE,CAAC;QADkB,IAAO,CAAA,OAAA,GAAP,OAAO,CAAQ;AAE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C,EAAA;AACpD,QAAA,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;KACzG;AAED,IAAA,gBAAgB,CAAC,OAAgB,EAAA;AAC7B,QAAA,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;KACxE;AACJ;;ACbD;AACa,MAAA,OAAO,GAAG;AACnB,IAAA,YAAY,EAAE,0CAA0C;AACxD,IAAA,SAAS,EAAE,QAAQ;;;;;"}
@@ -272,8 +272,8 @@
272
272
 
273
273
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
274
274
  const VERSION = {
275
- "commitHash": "b85fc404e34545a518215e449b3f1253f4520eec",
276
- "version": "17.2.0"
275
+ "commitHash": "a5b3c864e1537d0fe0a7f8f0b55989ef89311fa2",
276
+ "version": "17.3.0"
277
277
  };
278
278
 
279
279
  exports.InvalidTokenMetadata = InvalidTokenMetadata;
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-tzip12.umd.js","sources":["../src/errors.ts","../src/tzip12-contract-abstraction.ts","../src/composer.ts","../src/tzip12-extension.ts","../src/version.ts"],"sourcesContent":["import { TaquitoError } from '@taquito/core';\n\n/**\n * @category Error\n * @description Error that indicates the metadata not being found on the contract\n */\nexport class TokenMetadataNotFound extends TaquitoError {\n constructor(public readonly address: string) {\n super();\n this.name = 'TokenMetadataNotFound';\n this.message = `No token metadata was found for the contract: ${address}`;\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates the token ID not being found\n */\nexport class TokenIdNotFound extends TaquitoError {\n constructor(public readonly tokenId: number) {\n super(`Could not find token metadata for the token ID: ${tokenId}`);\n this.name = 'TokenIdNotFound';\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates that the token metadata is invalid (not compliant with the TZIP-12 standard)\n */\nexport class InvalidTokenMetadata extends TaquitoError {\n constructor(public readonly invalidMetadata: any) {\n super();\n this.name = 'InvalidTokenMetadata';\n this.message =\n 'Non-compliance with the TZIP-012 standard. The required property `decimals` is missing.';\n }\n}\n","import { MichelsonMap, Schema } from '@taquito/michelson-encoder';\nimport { ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';\nimport {\n Tzip16ContractAbstraction,\n MetadataContext,\n View,\n bytes2Char,\n BigMapId,\n} from '@taquito/tzip16';\nimport { InvalidTokenMetadata, TokenIdNotFound, TokenMetadataNotFound } from './errors';\n\nconst tokenMetadataBigMapType = {\n prim: 'big_map',\n args: [\n { prim: 'nat' },\n {\n prim: 'pair',\n args: [\n { prim: 'nat', annots: ['%token_id'] },\n { prim: 'map', args: [{ prim: 'string' }, { prim: 'bytes' }], annots: ['%token_info'] },\n ],\n },\n ],\n annots: ['%token_metadata'],\n};\n\nexport interface TokenMetadata {\n token_id: number;\n decimals: number;\n name?: string;\n symbol?: string;\n}\n\nexport class Tzip12ContractAbstraction {\n private _tzip16ContractAbstraction: Tzip16ContractAbstraction;\n\n constructor(\n private contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n private context: MetadataContext\n ) {\n this._tzip16ContractAbstraction = new Tzip16ContractAbstraction(\n this.contractAbstraction,\n this.context\n );\n }\n\n /**\n * @description Fetches the contract metadata (according to the Tzip-016 standard)\n * @returns An object containing the metadata, the uri, an optional integrity check result and an optional sha256 hash\n * or `Undefined` if the contract has no metadata (non-compliant with Tzip-016)\n */\n private async getContractMetadata() {\n try {\n const contractMetadata = await this._tzip16ContractAbstraction.getMetadata();\n return contractMetadata.metadata;\n } catch (err) {\n // The contract is not compliant with Tzip-016. There is no contract metadata.\n }\n }\n\n /**\n * @description The Tzip-016 \"interfaces\" field MUST be present in the contract metadata. It should contain \"TZIP-012[version-info]\"\n * @returns True if \"interfaces\" field is present and contains \"TZIP-012\", false otherwise\n */\n async isTzip12Compliant() {\n let isCompliant = false;\n const metadata = await this.getContractMetadata();\n if (metadata) {\n const tzip12Interface = metadata.interfaces?.filter((x) => {\n return x.substring(0, 8) === 'TZIP-012';\n });\n isCompliant = tzip12Interface && tzip12Interface.length !== 0 ? true : false;\n }\n return isCompliant;\n }\n\n /**\n * @description Fetches the token metadata for a specified token ID.\n * The function first tries to find a `token_metadata` view in the contract metadata and to execute it with the token ID.\n * If there is no view, the function tries to find a `token_metadata` bigmap in the top-level pairs of the storage.\n * @param tokenId The ID of the token for which we want to retrieve token metadata\n * @returns An object of type `TokenMetadata`\n * @throws {@link TokenIdNotFound, TokenMetadataNotFound, InvalidTokenMetadata}\n */\n async getTokenMetadata(tokenId: number) {\n const tokenMetadata = await this.retrieveTokenMetadataFromView(tokenId);\n return !tokenMetadata ? this.retrieveTokenMetadataFromBigMap(tokenId) : tokenMetadata;\n }\n\n private async retrieveTokenMetadataFromView(tokenId: number) {\n if (await this.getContractMetadata()) {\n const views = await this._tzip16ContractAbstraction.metadataViews();\n if (views && this.hasTokenMetadataView(views)) {\n return this.executeTokenMetadataView(views['token_metadata'](), tokenId);\n }\n }\n }\n\n private hasTokenMetadataView(views: object) {\n for (const view of Object.keys(views)) {\n if (view === 'token_metadata') {\n return true;\n }\n }\n return false;\n }\n\n private async executeTokenMetadataView(\n tokenMetadataView: View,\n tokenId: number\n ): Promise<TokenMetadata> {\n const tokenMetadata = await tokenMetadataView.executeView(tokenId);\n const tokenMap = Object.values(tokenMetadata)[1];\n if (!MichelsonMap.isMichelsonMap(tokenMap)) {\n throw new TokenMetadataNotFound(this.contractAbstraction.address);\n }\n const metadataFromUri = await this.fetchTokenMetadataFromUri(\n tokenMap as MichelsonMap<string, string>\n );\n return this.formatMetadataToken(\n tokenId,\n tokenMap as MichelsonMap<string, string>,\n metadataFromUri\n );\n }\n\n private async fetchTokenMetadataFromUri(tokenMetadata: MichelsonMap<string, string>) {\n const uri = tokenMetadata.get('');\n if (uri) {\n try {\n const metadataFromUri = await this.context.metadataProvider.provideMetadata(\n this.contractAbstraction,\n bytes2Char(uri),\n this.context\n );\n return metadataFromUri.metadata;\n } catch (e: any) {\n if (e.name === 'InvalidUriError') {\n console.warn(\n `The URI ${bytes2Char(uri)} is present in the token metadata, but is invalid.`\n );\n } else {\n throw e;\n }\n }\n }\n }\n\n private formatMetadataToken(\n tokenId: number,\n metadataTokenMap: MichelsonMap<string, string>,\n metadataFromUri?: any\n ): TokenMetadata {\n const tokenMetadataDecoded = {\n token_id: tokenId,\n };\n for (const keyTokenMetadata of metadataTokenMap.keys()) {\n if (keyTokenMetadata === 'decimals') {\n Object.assign(tokenMetadataDecoded, {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n [keyTokenMetadata]: Number(bytes2Char(metadataTokenMap.get(keyTokenMetadata)!)),\n });\n } else if (!(keyTokenMetadata === '')) {\n Object.assign(tokenMetadataDecoded, {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n [keyTokenMetadata]: bytes2Char(metadataTokenMap.get(keyTokenMetadata)!),\n });\n }\n }\n // if an URI is present, add the fetched properties to the object\n // if a property is in the URI and the map, prevalence is accorded to value from the URI\n if (metadataFromUri) {\n for (const property in metadataFromUri) {\n Object.assign(tokenMetadataDecoded, { [property]: metadataFromUri[property] });\n }\n }\n if (!('decimals' in tokenMetadataDecoded)) {\n throw new InvalidTokenMetadata(tokenMetadataDecoded);\n }\n return tokenMetadataDecoded as TokenMetadata;\n }\n\n private async retrieveTokenMetadataFromBigMap(tokenId: number) {\n const bigmapTokenMetadataId = await this.findTokenMetadataBigMap();\n let pairNatMap;\n try {\n pairNatMap = await this.context.contract.getBigMapKeyByID<{\n token_info: MichelsonMap<string, string>;\n }>(\n bigmapTokenMetadataId['int'].toString(),\n tokenId.toString(),\n new Schema(tokenMetadataBigMapType)\n );\n } catch (err) {\n throw new TokenIdNotFound(tokenId);\n }\n\n const michelsonMap = pairNatMap['token_info'];\n if (!MichelsonMap.isMichelsonMap(michelsonMap)) {\n throw new TokenIdNotFound(tokenId);\n }\n const metadataFromUri = await this.fetchTokenMetadataFromUri(\n michelsonMap as MichelsonMap<string, string>\n );\n return this.formatMetadataToken(\n tokenId,\n michelsonMap as MichelsonMap<string, string>,\n metadataFromUri\n );\n }\n\n private async findTokenMetadataBigMap(): Promise<BigMapId> {\n const tokenMetadataBigMapId = this.contractAbstraction.schema.FindFirstInTopLevelPair<BigMapId>(\n await this.context.readProvider.getStorage(this.contractAbstraction.address, 'head'),\n tokenMetadataBigMapType\n );\n if (!tokenMetadataBigMapId || !tokenMetadataBigMapId.int) {\n throw new TokenMetadataNotFound(this.contractAbstraction.address);\n }\n return { int: tokenMetadataBigMapId.int };\n }\n}\n","import { Context, ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';\nimport { Tzip12ContractAbstraction } from './tzip12-contract-abstraction';\nimport { MetadataContext } from '@taquito/tzip16';\n\nconst ABSTRACTION_KEY = Symbol('Tzip12ContractAbstractionObjectKey');\n\nexport function tzip12<T extends ContractAbstraction<ContractProvider | Wallet>>(\n abs: T,\n context: Context\n) {\n return Object.assign(abs, {\n // namespace tzip12\n tzip12(\n this: ContractAbstraction<ContractProvider | Wallet> & {\n [ABSTRACTION_KEY]?: Tzip12ContractAbstraction;\n }\n ) {\n if (!this[ABSTRACTION_KEY]) {\n this[ABSTRACTION_KEY] = new Tzip12ContractAbstraction(this, context as MetadataContext);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this[ABSTRACTION_KEY]!;\n },\n });\n}\n","import { Context, Extension } from \"@taquito/taquito\";\nimport { DEFAULT_HANDLERS, MetadataProviderInterface, MetadataProvider } from '@taquito/tzip16'\n\n// The same default metadataProvider is used for tzip16 and tzip12\nexport class Tzip12Module implements Extension {\n private _metadataProvider: MetadataProviderInterface;\n\n constructor(metadataProvider?: MetadataProviderInterface) {\n this._metadataProvider = metadataProvider ? metadataProvider : new MetadataProvider(DEFAULT_HANDLERS);\n }\n\n configureContext(context: Context) {\n Object.assign(context, { metadataProvider: this._metadataProvider });\n }\n}","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"b85fc404e34545a518215e449b3f1253f4520eec\",\n \"version\": \"17.2.0\"\n};\n"],"names":["TaquitoError","Tzip16ContractAbstraction","MichelsonMap","bytes2Char","Schema","MetadataProvider","DEFAULT_HANDLERS"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEA;;;IAGG;IACG,MAAO,qBAAsB,SAAQA,iBAAY,CAAA;IACrD,IAAA,WAAA,CAA4B,OAAe,EAAA;IACzC,QAAA,KAAK,EAAE,CAAC;YADkB,IAAO,CAAA,OAAA,GAAP,OAAO,CAAQ;IAEzC,QAAA,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACpC,QAAA,IAAI,CAAC,OAAO,GAAG,CAAiD,8CAAA,EAAA,OAAO,EAAE,CAAC;SAC3E;IACF,CAAA;IAED;;;IAGG;IACG,MAAO,eAAgB,SAAQA,iBAAY,CAAA;IAC/C,IAAA,WAAA,CAA4B,OAAe,EAAA;IACzC,QAAA,KAAK,CAAC,CAAA,gDAAA,EAAmD,OAAO,CAAA,CAAE,CAAC,CAAC;YAD1C,IAAO,CAAA,OAAA,GAAP,OAAO,CAAQ;IAEzC,QAAA,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;SAC/B;IACF,CAAA;IAED;;;IAGG;IACG,MAAO,oBAAqB,SAAQA,iBAAY,CAAA;IACpD,IAAA,WAAA,CAA4B,eAAoB,EAAA;IAC9C,QAAA,KAAK,EAAE,CAAC;YADkB,IAAe,CAAA,eAAA,GAAf,eAAe,CAAK;IAE9C,QAAA,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACnC,QAAA,IAAI,CAAC,OAAO;IACV,YAAA,yFAAyF,CAAC;SAC7F;IACF;;ICzBD,MAAM,uBAAuB,GAAG;IAC9B,IAAA,IAAI,EAAE,SAAS;IACf,IAAA,IAAI,EAAE;YACJ,EAAE,I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AAe,GAAG,MAAM,CAAC,oCAAoC,CAAC,CAAC;IAErD,SAAA,MAAM,CACpB,GAAM,EACN,OAAgB,EAAA;IAEhB,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE;;YAExB,MAAM,GAAA;IAKJ,YAAA,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE;oBAC1B,IAAI,CAAC,eAAe,CAAC,GAAG,IAAI,yBAAyB,CAAC,IAAI,EAAE,OAA0B,CAAC,CAAC;IACzF,aAAA;;IAGD,YAAA,OAAO,IAAI,CAAC,eAAe,CAAE,CAAC;aAC/B;IACF,KAAA,CAAC,CAAC;IACL;;ICtBA;UACa,YAAY,CAAA;IAGrB,IAAA,WAAA,CAAY,gBAA4C,EAAA;IACpD,QAAA,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,IAAIG,uBAAgB,CAACC,uBAAgB,CAAC,CAAC;SACzG;IAED,IAAA,gBAAgB,CAAC,OAAgB,EAAA;IAC7B,QAAA,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;SACxE;IACJ;;ICbD;AACa,UAAA,OAAO,GAAG;IACnB,IAAA,YAAY,EAAE,0CAA0C;IACxD,IAAA,SAAS,EAAE,QAAQ;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"taquito-tzip12.umd.js","sources":["../src/errors.ts","../src/tzip12-contract-abstraction.ts","../src/composer.ts","../src/tzip12-extension.ts","../src/version.ts"],"sourcesContent":["import { TaquitoError } from '@taquito/core';\n\n/**\n * @category Error\n * @description Error that indicates the metadata not being found on the contract\n */\nexport class TokenMetadataNotFound extends TaquitoError {\n constructor(public readonly address: string) {\n super();\n this.name = 'TokenMetadataNotFound';\n this.message = `No token metadata was found for the contract: ${address}`;\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates the token ID not being found\n */\nexport class TokenIdNotFound extends TaquitoError {\n constructor(public readonly tokenId: number) {\n super(`Could not find token metadata for the token ID: ${tokenId}`);\n this.name = 'TokenIdNotFound';\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates that the token metadata is invalid (not compliant with the TZIP-12 standard)\n */\nexport class InvalidTokenMetadata extends TaquitoError {\n constructor(public readonly invalidMetadata: any) {\n super();\n this.name = 'InvalidTokenMetadata';\n this.message =\n 'Non-compliance with the TZIP-012 standard. The required property `decimals` is missing.';\n }\n}\n","import { MichelsonMap, Schema } from '@taquito/michelson-encoder';\nimport { ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';\nimport {\n Tzip16ContractAbstraction,\n MetadataContext,\n View,\n bytes2Char,\n BigMapId,\n} from '@taquito/tzip16';\nimport { InvalidTokenMetadata, TokenIdNotFound, TokenMetadataNotFound } from './errors';\n\nconst tokenMetadataBigMapType = {\n prim: 'big_map',\n args: [\n { prim: 'nat' },\n {\n prim: 'pair',\n args: [\n { prim: 'nat', annots: ['%token_id'] },\n { prim: 'map', args: [{ prim: 'string' }, { prim: 'bytes' }], annots: ['%token_info'] },\n ],\n },\n ],\n annots: ['%token_metadata'],\n};\n\nexport interface TokenMetadata {\n token_id: number;\n decimals: number;\n name?: string;\n symbol?: string;\n}\n\nexport class Tzip12ContractAbstraction {\n private _tzip16ContractAbstraction: Tzip16ContractAbstraction;\n\n constructor(\n private contractAbstraction: ContractAbstraction<ContractProvider | Wallet>,\n private context: MetadataContext\n ) {\n this._tzip16ContractAbstraction = new Tzip16ContractAbstraction(\n this.contractAbstraction,\n this.context\n );\n }\n\n /**\n * @description Fetches the contract metadata (according to the Tzip-016 standard)\n * @returns An object containing the metadata, the uri, an optional integrity check result and an optional sha256 hash\n * or `Undefined` if the contract has no metadata (non-compliant with Tzip-016)\n */\n private async getContractMetadata() {\n try {\n const contractMetadata = await this._tzip16ContractAbstraction.getMetadata();\n return contractMetadata.metadata;\n } catch (err) {\n // The contract is not compliant with Tzip-016. There is no contract metadata.\n }\n }\n\n /**\n * @description The Tzip-016 \"interfaces\" field MUST be present in the contract metadata. It should contain \"TZIP-012[version-info]\"\n * @returns True if \"interfaces\" field is present and contains \"TZIP-012\", false otherwise\n */\n async isTzip12Compliant() {\n let isCompliant = false;\n const metadata = await this.getContractMetadata();\n if (metadata) {\n const tzip12Interface = metadata.interfaces?.filter((x) => {\n return x.substring(0, 8) === 'TZIP-012';\n });\n isCompliant = tzip12Interface && tzip12Interface.length !== 0 ? true : false;\n }\n return isCompliant;\n }\n\n /**\n * @description Fetches the token metadata for a specified token ID.\n * The function first tries to find a `token_metadata` view in the contract metadata and to execute it with the token ID.\n * If there is no view, the function tries to find a `token_metadata` bigmap in the top-level pairs of the storage.\n * @param tokenId The ID of the token for which we want to retrieve token metadata\n * @returns An object of type `TokenMetadata`\n * @throws {@link TokenIdNotFound, TokenMetadataNotFound, InvalidTokenMetadata}\n */\n async getTokenMetadata(tokenId: number) {\n const tokenMetadata = await this.retrieveTokenMetadataFromView(tokenId);\n return !tokenMetadata ? this.retrieveTokenMetadataFromBigMap(tokenId) : tokenMetadata;\n }\n\n private async retrieveTokenMetadataFromView(tokenId: number) {\n if (await this.getContractMetadata()) {\n const views = await this._tzip16ContractAbstraction.metadataViews();\n if (views && this.hasTokenMetadataView(views)) {\n return this.executeTokenMetadataView(views['token_metadata'](), tokenId);\n }\n }\n }\n\n private hasTokenMetadataView(views: object) {\n for (const view of Object.keys(views)) {\n if (view === 'token_metadata') {\n return true;\n }\n }\n return false;\n }\n\n private async executeTokenMetadataView(\n tokenMetadataView: View,\n tokenId: number\n ): Promise<TokenMetadata> {\n const tokenMetadata = await tokenMetadataView.executeView(tokenId);\n const tokenMap = Object.values(tokenMetadata)[1];\n if (!MichelsonMap.isMichelsonMap(tokenMap)) {\n throw new TokenMetadataNotFound(this.contractAbstraction.address);\n }\n const metadataFromUri = await this.fetchTokenMetadataFromUri(\n tokenMap as MichelsonMap<string, string>\n );\n return this.formatMetadataToken(\n tokenId,\n tokenMap as MichelsonMap<string, string>,\n metadataFromUri\n );\n }\n\n private async fetchTokenMetadataFromUri(tokenMetadata: MichelsonMap<string, string>) {\n const uri = tokenMetadata.get('');\n if (uri) {\n try {\n const metadataFromUri = await this.context.metadataProvider.provideMetadata(\n this.contractAbstraction,\n bytes2Char(uri),\n this.context\n );\n return metadataFromUri.metadata;\n } catch (e: any) {\n if (e.name === 'InvalidUriError') {\n console.warn(\n `The URI ${bytes2Char(uri)} is present in the token metadata, but is invalid.`\n );\n } else {\n throw e;\n }\n }\n }\n }\n\n private formatMetadataToken(\n tokenId: number,\n metadataTokenMap: MichelsonMap<string, string>,\n metadataFromUri?: any\n ): TokenMetadata {\n const tokenMetadataDecoded = {\n token_id: tokenId,\n };\n for (const keyTokenMetadata of metadataTokenMap.keys()) {\n if (keyTokenMetadata === 'decimals') {\n Object.assign(tokenMetadataDecoded, {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n [keyTokenMetadata]: Number(bytes2Char(metadataTokenMap.get(keyTokenMetadata)!)),\n });\n } else if (!(keyTokenMetadata === '')) {\n Object.assign(tokenMetadataDecoded, {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n [keyTokenMetadata]: bytes2Char(metadataTokenMap.get(keyTokenMetadata)!),\n });\n }\n }\n // if an URI is present, add the fetched properties to the object\n // if a property is in the URI and the map, prevalence is accorded to value from the URI\n if (metadataFromUri) {\n for (const property in metadataFromUri) {\n Object.assign(tokenMetadataDecoded, { [property]: metadataFromUri[property] });\n }\n }\n if (!('decimals' in tokenMetadataDecoded)) {\n throw new InvalidTokenMetadata(tokenMetadataDecoded);\n }\n return tokenMetadataDecoded as TokenMetadata;\n }\n\n private async retrieveTokenMetadataFromBigMap(tokenId: number) {\n const bigmapTokenMetadataId = await this.findTokenMetadataBigMap();\n let pairNatMap;\n try {\n pairNatMap = await this.context.contract.getBigMapKeyByID<{\n token_info: MichelsonMap<string, string>;\n }>(\n bigmapTokenMetadataId['int'].toString(),\n tokenId.toString(),\n new Schema(tokenMetadataBigMapType)\n );\n } catch (err) {\n throw new TokenIdNotFound(tokenId);\n }\n\n const michelsonMap = pairNatMap['token_info'];\n if (!MichelsonMap.isMichelsonMap(michelsonMap)) {\n throw new TokenIdNotFound(tokenId);\n }\n const metadataFromUri = await this.fetchTokenMetadataFromUri(\n michelsonMap as MichelsonMap<string, string>\n );\n return this.formatMetadataToken(\n tokenId,\n michelsonMap as MichelsonMap<string, string>,\n metadataFromUri\n );\n }\n\n private async findTokenMetadataBigMap(): Promise<BigMapId> {\n const tokenMetadataBigMapId = this.contractAbstraction.schema.FindFirstInTopLevelPair<BigMapId>(\n await this.context.readProvider.getStorage(this.contractAbstraction.address, 'head'),\n tokenMetadataBigMapType\n );\n if (!tokenMetadataBigMapId || !tokenMetadataBigMapId.int) {\n throw new TokenMetadataNotFound(this.contractAbstraction.address);\n }\n return { int: tokenMetadataBigMapId.int };\n }\n}\n","import { Context, ContractAbstraction, ContractProvider, Wallet } from '@taquito/taquito';\nimport { Tzip12ContractAbstraction } from './tzip12-contract-abstraction';\nimport { MetadataContext } from '@taquito/tzip16';\n\nconst ABSTRACTION_KEY = Symbol('Tzip12ContractAbstractionObjectKey');\n\nexport function tzip12<T extends ContractAbstraction<ContractProvider | Wallet>>(\n abs: T,\n context: Context\n) {\n return Object.assign(abs, {\n // namespace tzip12\n tzip12(\n this: ContractAbstraction<ContractProvider | Wallet> & {\n [ABSTRACTION_KEY]?: Tzip12ContractAbstraction;\n }\n ) {\n if (!this[ABSTRACTION_KEY]) {\n this[ABSTRACTION_KEY] = new Tzip12ContractAbstraction(this, context as MetadataContext);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this[ABSTRACTION_KEY]!;\n },\n });\n}\n","import { Context, Extension } from \"@taquito/taquito\";\nimport { DEFAULT_HANDLERS, MetadataProviderInterface, MetadataProvider } from '@taquito/tzip16'\n\n// The same default metadataProvider is used for tzip16 and tzip12\nexport class Tzip12Module implements Extension {\n private _metadataProvider: MetadataProviderInterface;\n\n constructor(metadataProvider?: MetadataProviderInterface) {\n this._metadataProvider = metadataProvider ? metadataProvider : new MetadataProvider(DEFAULT_HANDLERS);\n }\n\n configureContext(context: Context) {\n Object.assign(context, { metadataProvider: this._metadataProvider });\n }\n}","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"a5b3c864e1537d0fe0a7f8f0b55989ef89311fa2\",\n \"version\": \"17.3.0\"\n};\n"],"names":["TaquitoError","Tzip16ContractAbstraction","MichelsonMap","bytes2Char","Schema","MetadataProvider","DEFAULT_HANDLERS"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEA;;;IAGG;IACG,MAAO,qBAAsB,SAAQA,iBAAY,CAAA;IACrD,IAAA,WAAA,CAA4B,OAAe,EAAA;IACzC,QAAA,KAAK,EAAE,CAAC;YADkB,IAAO,CAAA,OAAA,GAAP,OAAO,CAAQ;IAEzC,QAAA,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACpC,QAAA,IAAI,CAAC,OAAO,GAAG,CAAiD,8CAAA,EAAA,OAAO,EAAE,CAAC;SAC3E;IACF,CAAA;IAED;;;IAGG;IACG,MAAO,eAAgB,SAAQA,iBAAY,CAAA;IAC/C,IAAA,WAAA,CAA4B,OAAe,EAAA;IACzC,QAAA,KAAK,CAAC,CAAA,gDAAA,EAAmD,OAAO,CAAA,CAAE,CAAC,CAAC;YAD1C,IAAO,CAAA,OAAA,GAAP,OAAO,CAAQ;IAEzC,QAAA,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;SAC/B;IACF,CAAA;IAED;;;IAGG;IACG,MAAO,oBAAqB,SAAQA,iBAAY,CAAA;IACpD,IAAA,WAAA,CAA4B,eAAoB,EAAA;IAC9C,QAAA,KAAK,EAAE,CAAC;YADkB,IAAe,CAAA,eAAA,GAAf,eAAe,CAAK;IAE9C,QAAA,IAAI,CAAC,IAAI,GAA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CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACnE,aAAA;IACD,YAAA,OAAO,EAAE,GAAG,EAAE,qBAAqB,CAAC,GAAG,EAAE,CAAC;aAC3C,CAAA,CAAA;IAAA,KAAA;IACF;;ICzND,MAAM,eAAe,GAAG,MAAM,CAAC,oCAAoC,CAAC,CAAC;IAErD,SAAA,MAAM,CACpB,GAAM,EACN,OAAgB,EAAA;IAEhB,IAAA,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE;;YAExB,MAAM,GAAA;IAKJ,YAAA,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE;oBAC1B,IAAI,CAAC,eAAe,CAAC,GAAG,IAAI,yBAAyB,CAAC,IAAI,EAAE,OAA0B,CAAC,CAAC;IACzF,aAAA;;IAGD,YAAA,OAAO,IAAI,CAAC,eAAe,CAAE,CAAC;aAC/B;IACF,KAAA,CAAC,CAAC;IACL;;ICtBA;UACa,YAAY,CAAA;IAGrB,IAAA,WAAA,CAAY,gBAA4C,EAAA;IACpD,QAAA,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,IAAIG,uBAAgB,CAACC,uBAAgB,CAAC,CAAC;SACzG;IAED,IAAA,gBAAgB,CAAC,OAAgB,EAAA;IAC7B,QAAA,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;SACxE;IACJ;;ICbD;AACa,UAAA,OAAO,GAAG;IACnB,IAAA,YAAY,EAAE,0CAA0C;IACxD,IAAA,SAAS,EAAE,QAAQ;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taquito/tzip12",
3
- "version": "17.2.0",
3
+ "version": "17.3.0",
4
4
  "description": "Tzip12",
5
5
  "keywords": [
6
6
  "tezos",
@@ -63,9 +63,9 @@
63
63
  ]
64
64
  },
65
65
  "dependencies": {
66
- "@taquito/michelson-encoder": "^17.2.0",
67
- "@taquito/taquito": "^17.2.0",
68
- "@taquito/tzip16": "^17.2.0"
66
+ "@taquito/michelson-encoder": "^17.3.0",
67
+ "@taquito/taquito": "^17.3.0",
68
+ "@taquito/tzip16": "^17.3.0"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/bluebird": "^3.5.36",
@@ -96,5 +96,5 @@
96
96
  "ts-toolbelt": "^9.6.0",
97
97
  "typescript": "~4.1.5"
98
98
  },
99
- "gitHead": "8fe3376401f12f5a97556479620c0414a6e5c7c3"
99
+ "gitHead": "b7520a1c1de248e8cc1d01b4e0422bb546723563"
100
100
  }