@taquito/tzip16 25.2.0-beta1 → 25.2.0-beta3
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/taquito-tzip16.es6.js +52 -15
- package/dist/taquito-tzip16.es6.js.map +1 -1
- package/dist/taquito-tzip16.umd.js +52 -15
- package/dist/taquito-tzip16.umd.js.map +1 -1
- package/dist/types/handlers/ipfs-handler.d.ts +1 -0
- package/dist/types/metadata-provider.d.ts +2 -1
- package/dist/types/tzip16-contract-abstraction.d.ts +13 -1
- package/package.json +8 -10
|
@@ -18059,6 +18059,7 @@
|
|
|
18059
18059
|
*/
|
|
18060
18060
|
constructor(ipfsGateway, timeout = 10000) {
|
|
18061
18061
|
this.timeout = timeout;
|
|
18062
|
+
this.integrityVerified = true;
|
|
18062
18063
|
this.httpBackend = new httpUtils.HttpBackend();
|
|
18063
18064
|
if (!Number.isFinite(timeout) || timeout <= 0)
|
|
18064
18065
|
throw new RangeError('IPFS gateway timeout must be positive');
|
|
@@ -18173,6 +18174,10 @@
|
|
|
18173
18174
|
];
|
|
18174
18175
|
for (const forbiddenInstruction of illegalInstructions) {
|
|
18175
18176
|
for (const instruction of code) {
|
|
18177
|
+
if (Array.isArray(instruction)) {
|
|
18178
|
+
this.findForbiddenInstructionInViewCodeError(instruction);
|
|
18179
|
+
continue;
|
|
18180
|
+
}
|
|
18176
18181
|
if (instruction.prim === forbiddenInstruction) {
|
|
18177
18182
|
throw new ForbiddenInstructionInViewCodeError(forbiddenInstruction);
|
|
18178
18183
|
}
|
|
@@ -18187,10 +18192,15 @@
|
|
|
18187
18192
|
* The method throws an error is the instruction SELF is present, but not followed by ADDRESS
|
|
18188
18193
|
*/
|
|
18189
18194
|
illegalUseOfSelfInstruction(code) {
|
|
18190
|
-
for (
|
|
18195
|
+
for (let i = 0; i < code.length; i++) {
|
|
18196
|
+
const instruction = code[i];
|
|
18197
|
+
if (Array.isArray(instruction)) {
|
|
18198
|
+
this.illegalUseOfSelfInstruction(instruction);
|
|
18199
|
+
continue;
|
|
18200
|
+
}
|
|
18191
18201
|
if (instruction.prim === 'SELF') {
|
|
18192
|
-
const
|
|
18193
|
-
const nextInstruction =
|
|
18202
|
+
const next = code[i + 1];
|
|
18203
|
+
const nextInstruction = next && !Array.isArray(next) ? next.prim : undefined;
|
|
18194
18204
|
if (nextInstruction !== 'ADDRESS') {
|
|
18195
18205
|
throw new ForbiddenInstructionInViewCodeError('the instruction SELF should only be used before ADDRESS');
|
|
18196
18206
|
}
|
|
@@ -18215,13 +18225,17 @@
|
|
|
18215
18225
|
CHAIN_ID: [{ prim: 'PUSH', args: [{ prim: 'string' }, { string: chainId }] }],
|
|
18216
18226
|
};
|
|
18217
18227
|
code.forEach((x, i) => {
|
|
18228
|
+
if (Array.isArray(x)) {
|
|
18229
|
+
this.adaptViewCodeToContext(x, contractBalance, blockTimeStamp, chainId);
|
|
18230
|
+
return;
|
|
18231
|
+
}
|
|
18218
18232
|
for (const instruction in instructionsToReplace) {
|
|
18219
18233
|
if (x.prim === instruction) {
|
|
18220
18234
|
code[i] = Object(instructionsToReplace)[instruction];
|
|
18221
18235
|
}
|
|
18222
|
-
|
|
18223
|
-
|
|
18224
|
-
|
|
18236
|
+
}
|
|
18237
|
+
if (x.args && x.args.length !== 0) {
|
|
18238
|
+
this.adaptViewCodeToContext(x.args, contractBalance, blockTimeStamp, chainId);
|
|
18225
18239
|
}
|
|
18226
18240
|
});
|
|
18227
18241
|
return code;
|
|
@@ -18259,7 +18273,7 @@
|
|
|
18259
18273
|
const chainId = await this.readProvider.getChainId();
|
|
18260
18274
|
const contractBalance = (await this.readProvider.getBalance(this.contract.address, this.contract.readBlock)).toString();
|
|
18261
18275
|
const blockTimestamp = await this.readProvider.getBlockTimestamp(this.contract.readBlock);
|
|
18262
|
-
const code = this.adaptViewCodeToContext(this.code, contractBalance, blockTimestamp, chainId);
|
|
18276
|
+
const code = this.adaptViewCodeToContext(structuredClone(this.code), contractBalance, blockTimestamp, chainId);
|
|
18263
18277
|
if (!this.viewParameterType) {
|
|
18264
18278
|
code.unshift({ prim: 'CDR' });
|
|
18265
18279
|
}
|
|
@@ -18354,15 +18368,33 @@
|
|
|
18354
18368
|
return uri;
|
|
18355
18369
|
}
|
|
18356
18370
|
/**
|
|
18357
|
-
*
|
|
18371
|
+
* Fetch and cache the contract metadata envelope on this `Tzip16ContractAbstraction` instance.
|
|
18372
|
+
* Subsequent calls to `getMetadata()`, `metadataViews()`, and the `metadata*()` accessors
|
|
18373
|
+
* reuse the cached envelope without re-fetching.
|
|
18374
|
+
*
|
|
18375
|
+
* @returns an object containing the parsed `metadata`, the `uri`, the `sha256Hash` of the raw
|
|
18376
|
+
* metadata string, and an optional `integrityCheckResult` (`true` when verified via a
|
|
18377
|
+
* `sha256://` commitment or a content-verifying handler such as `IpfsHttpHandler`).
|
|
18358
18378
|
*/
|
|
18359
18379
|
async getMetadata() {
|
|
18360
18380
|
if (!this._metadataProvider) {
|
|
18361
18381
|
throw new UnconfiguredContractMetadataProviderError();
|
|
18362
18382
|
}
|
|
18363
18383
|
if (!this._metadataEnvelope) {
|
|
18364
|
-
|
|
18365
|
-
|
|
18384
|
+
if (!this._metadataEnvelopePromise) {
|
|
18385
|
+
this._metadataEnvelopePromise = (async () => {
|
|
18386
|
+
try {
|
|
18387
|
+
const uri = await this.getUriOrFail();
|
|
18388
|
+
const envelope = await this._metadataProvider.provideMetadata(this.constractAbstraction, utils.bytesToString(uri), this.context);
|
|
18389
|
+
this._metadataEnvelope = envelope;
|
|
18390
|
+
return envelope;
|
|
18391
|
+
}
|
|
18392
|
+
finally {
|
|
18393
|
+
this._metadataEnvelopePromise = undefined;
|
|
18394
|
+
}
|
|
18395
|
+
})();
|
|
18396
|
+
}
|
|
18397
|
+
return this._metadataEnvelopePromise;
|
|
18366
18398
|
}
|
|
18367
18399
|
return this._metadataEnvelope;
|
|
18368
18400
|
}
|
|
@@ -18412,6 +18444,11 @@
|
|
|
18412
18444
|
await this.getMetadata();
|
|
18413
18445
|
return this._metadataEnvelope.metadata.errors;
|
|
18414
18446
|
}
|
|
18447
|
+
/**
|
|
18448
|
+
* Build and cache off-chain view implementations from the cached metadata envelope returned by
|
|
18449
|
+
* `getMetadata()`. If `getMetadata()` has already resolved on this instance, `metadataViews()`
|
|
18450
|
+
* uses that same cached envelope without re-fetching.
|
|
18451
|
+
*/
|
|
18415
18452
|
async metadataViews() {
|
|
18416
18453
|
if (Object.keys(this._metadataViewsObject).length === 0) {
|
|
18417
18454
|
await this.initializeMetadataViewsList();
|
|
@@ -18499,7 +18536,7 @@
|
|
|
18499
18536
|
try {
|
|
18500
18537
|
metadataJSON = JSON.parse(metadata.replace(/^\uFEFF/, ''));
|
|
18501
18538
|
}
|
|
18502
|
-
catch
|
|
18539
|
+
catch {
|
|
18503
18540
|
const error = new InvalidContractMetadataError(metadata);
|
|
18504
18541
|
error.message = `Unable to parse metadata from ${uri} as JSON.`;
|
|
18505
18542
|
if (uriInfo.protocol === 'ipfs') {
|
|
@@ -18512,8 +18549,8 @@
|
|
|
18512
18549
|
return {
|
|
18513
18550
|
uri,
|
|
18514
18551
|
metadata: metadataJSON,
|
|
18515
|
-
integrityCheckResult: uriInfo.sha256hash
|
|
18516
|
-
sha256Hash
|
|
18552
|
+
integrityCheckResult: uriInfo.sha256hash !== undefined || handler.integrityVerified === true ? true : undefined,
|
|
18553
|
+
sha256Hash,
|
|
18517
18554
|
};
|
|
18518
18555
|
}
|
|
18519
18556
|
extractProtocolInfo(_uri) {
|
|
@@ -18564,8 +18601,8 @@
|
|
|
18564
18601
|
|
|
18565
18602
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT!
|
|
18566
18603
|
const VERSION = {
|
|
18567
|
-
"commitHash": "
|
|
18568
|
-
"version": "25.2.0-
|
|
18604
|
+
"commitHash": "ef213b695ad2612be52315f787f1d719c968eddc",
|
|
18605
|
+
"version": "25.2.0-beta3"
|
|
18569
18606
|
};
|
|
18570
18607
|
|
|
18571
18608
|
Object.defineProperty(exports, "InvalidViewParameterError", {
|