Skip to content

Commit

Permalink
chore: merge
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirvolek committed Jun 11, 2024
2 parents fb654d9 + 745222f commit 255c393
Show file tree
Hide file tree
Showing 16 changed files with 21,413 additions and 56 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@ Unreleased changes are in the `master` branch.

## [Unreleased]

## [0.1.63] - 2024-03-14

### Changed

- `/epochs/{number}/parameters` and `/epochs/latest/parameters`
- `min_utxo` field deprecated, prefer `coins_per_utxo_size` for Alonzo and later eras

## [0.1.62] - 2024-03-05

### Added

- Parsing version 2 of `CIP68` metadata

### Fixed

- `tx_metadata_label_json` and `script_json` compatibility with fast-json-stringify for non-object/primitive types (eg. string)

## [0.1.61] - 2024-02-06

### Added
Expand Down
21,265 changes: 21,264 additions & 1 deletion json-schema.json

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions openapi.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"openapi": "3.0.0",
"info": {
"version": "0.1.61",
"version": "0.1.63",
"title": "Blockfrost.io ~ API Documentation",
"x-logo": {
"url": "https://staging.blockfrost.io/images/logo.svg",
Expand Down Expand Up @@ -8974,7 +8974,8 @@
"min_utxo": {
"type": "string",
"example": "1000000",
"description": "Minimum UTXO value"
"description": "Minimum UTXO value. Use `coins_per_utxo_size` for Alonzo and later eras",
"deprecated": true
},
"min_pool_cost": {
"type": "string",
Expand Down Expand Up @@ -11008,7 +11009,6 @@
"description": "Transaction hash that contains the specific metadata"
},
"json_metadata": {
"additionalProperties": true,
"anyOf": [
{
"type": "string"
Expand All @@ -11029,9 +11029,11 @@
},
{
"type": "boolean"
},
{
"type": "null"
}
],
"nullable": true,
"description": "Content of the JSON metadata"
}
},
Expand Down Expand Up @@ -12152,7 +12154,8 @@
"enum": [
"CIP25v1",
"CIP25v2",
"CIP68v1"
"CIP68v1",
"CIP68v2"
],
"description": "If on-chain metadata passes validation, we display the standard\nunder which it is valid\n"
},
Expand Down Expand Up @@ -12461,7 +12464,6 @@
"type": "object",
"properties": {
"json": {
"additionalProperties": true,
"anyOf": [
{
"type": "string"
Expand All @@ -12482,9 +12484,11 @@
},
{
"type": "boolean"
},
{
"type": "null"
}
],
"nullable": true,
"description": "JSON contents of the `timelock` script, null for `plutus` scripts"
}
},
Expand Down
12 changes: 6 additions & 6 deletions openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
openapi: 3.0.0
info:
version: 0.1.61
version: 0.1.63
title: Blockfrost.io ~ API Documentation
x-logo:
url: https://staging.blockfrost.io/images/logo.svg
Expand Down Expand Up @@ -6571,7 +6571,8 @@ components:
min_utxo:
type: string
example: '1000000'
description: Minimum UTXO value
description: Minimum UTXO value. Use `coins_per_utxo_size` for Alonzo and later eras
deprecated: true
min_pool_cost:
type: string
example: '340000000'
Expand Down Expand Up @@ -8093,7 +8094,6 @@ components:
type: string
description: Transaction hash that contains the specific metadata
json_metadata:
additionalProperties: true
anyOf:
- type: string
- type: object
Expand All @@ -8103,7 +8103,7 @@ components:
- type: integer
- type: number
- type: boolean
nullable: true
- type: 'null'
description: Content of the JSON metadata
required:
- tx_hash
Expand Down Expand Up @@ -8920,6 +8920,7 @@ components:
- CIP25v1
- CIP25v2
- CIP68v1
- CIP68v2
description: |
If on-chain metadata passes validation, we display the standard
under which it is valid
Expand Down Expand Up @@ -9141,7 +9142,6 @@ components:
type: object
properties:
json:
additionalProperties: true
anyOf:
- type: string
- type: object
Expand All @@ -9151,7 +9151,7 @@ components:
- type: integer
- type: number
- type: boolean
nullable: true
- type: 'null'
description: JSON contents of the `timelock` script, null for `plutus` scripts
required:
- json
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blockfrost/openapi",
"version": "0.1.61",
"version": "0.1.63",
"description": "OpenAPI specifications for blockfrost.io",
"repository": "[email protected]:blockfrost/openapi.git",
"author": "[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion src/definitions.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
openapi: 3.0.0
info:
version: "0.1.61"
version: "0.1.63"
title: Blockfrost.io ~ API Documentation
x-logo:
url: https://staging.blockfrost.io/images/logo.svg
Expand Down
31 changes: 19 additions & 12 deletions src/functions/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
GetOnchainMetadataResult,
Asset,
validateCIP68MetadataOverload,
ValidCIP68Version,
} from '../types/metadata';

export const getCIPstandard = (version: number, isValid: boolean): CIPTypes => {
Expand Down Expand Up @@ -186,11 +187,17 @@ export const getOnchainMetadata = (
};

export const validateCIP68Metadata: validateCIP68MetadataOverload = (
input: any,
schema: any,
input,
schema,
) => {
if (!input) return false;
if (input.version !== 1) return false;
// Validating only v1 and v2.
// Note: Version 2 added support for RFT, but due to botched CIP68 update process
// it was initially included in v1.
// As a result we are allowing both v1 and v2 for any token standard (NFT, FT, RFT).
if (!Number.isInteger(input.version) || input.version > 2) return false;

const versionString = `CIP68v${input.version}` as ValidCIP68Version;

if (schema === 'nft') {
const { isValid: isValidNFT } = validateSchema(
Expand All @@ -199,11 +206,11 @@ export const validateCIP68Metadata: validateCIP68MetadataOverload = (
);

return isValidNFT
? {
version: 'CIP68v1',
? ({
version: versionString,
metadata: input.metadata,
extra: input.extra,
}
} as Extract<validateCIP68MetadataOverload, { type: 'nft' }>)
: false;
} else if (schema === 'ft') {
const { isValid: isValidFT } = validateSchema(
Expand All @@ -212,11 +219,11 @@ export const validateCIP68Metadata: validateCIP68MetadataOverload = (
);

return isValidFT
? {
version: 'CIP68v1',
? ({
version: versionString,
metadata: input.metadata,
extra: input.extra,
}
} as Extract<validateCIP68MetadataOverload, { type: 'ft' }>)
: false;
} else if (schema === 'rft') {
const { isValid: isValidRFT } = validateSchema(
Expand All @@ -225,11 +232,11 @@ export const validateCIP68Metadata: validateCIP68MetadataOverload = (
);

return isValidRFT
? {
version: 'CIP68v1',
? ({
version: versionString,
metadata: input.metadata,
extra: input.extra,
}
} as Extract<validateCIP68MetadataOverload, { type: 'rft' }>)
: false;
} else {
return false;
Expand Down
17 changes: 7 additions & 10 deletions src/generated-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4687,7 +4687,8 @@ export interface components {
*/
protocol_minor_ver: number;
/**
* @description Minimum UTXO value
* @deprecated
* @description Minimum UTXO value. Use `coins_per_utxo_size` for Alonzo and later eras
* @example 1000000
*/
min_utxo: string;
Expand Down Expand Up @@ -6012,11 +6013,9 @@ export interface components {
/** @description Transaction hash that contains the specific metadata */
tx_hash: string;
/** @description Content of the JSON metadata */
json_metadata: ({
[key: string]: unknown;
} & (string | {
json_metadata: string | {
[key: string]: unknown;
} | unknown[] | number | boolean)) | null;
} | unknown[] | number | boolean | null;
})[];
/**
* @example [
Expand Down Expand Up @@ -6751,7 +6750,7 @@ export interface components {
*
* @enum {string|null}
*/
onchain_metadata_standard?: "CIP25v1" | "CIP25v2" | "CIP68v1" | null;
onchain_metadata_standard?: "CIP25v1" | "CIP25v2" | "CIP68v1" | "CIP68v2" | null;
/** @description Arbitrary plutus data (CIP68). */
onchain_metadata_extra?: string | null;
/**
Expand Down Expand Up @@ -6965,11 +6964,9 @@ export interface components {
*/
script_json: {
/** @description JSON contents of the `timelock` script, null for `plutus` scripts */
json: ({
[key: string]: unknown;
} & (string | {
json: string | {
[key: string]: unknown;
} | unknown[] | number | boolean)) | null;
} | unknown[] | number | boolean | null;
};
/**
* @example {
Expand Down
1 change: 1 addition & 0 deletions src/schemas/assets/asset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ properties:
- CIP25v1
- CIP25v2
- CIP68v1
- CIP68v2
description: |
If on-chain metadata passes validation, we display the standard
under which it is valid
Expand Down
3 changes: 2 additions & 1 deletion src/schemas/epochs/epoch_param_content.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ properties:
min_utxo:
type: string
example: "1000000"
description: Minimum UTXO value
description: Minimum UTXO value. Use `coins_per_utxo_size` for Alonzo and later eras
deprecated: true
min_pool_cost:
type: string
example: "340000000"
Expand Down
3 changes: 1 addition & 2 deletions src/schemas/scripts/script_json.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
type: object
properties:
json:
additionalProperties: true
anyOf:
- type: string
- type: object
Expand All @@ -11,7 +10,7 @@ properties:
- type: integer
- type: number
- type: boolean
nullable: true
- type: "null"
description: JSON contents of the `timelock` script, null for `plutus` scripts
required:
- json
Expand Down
3 changes: 1 addition & 2 deletions src/schemas/txs/tx_metadata_label_json.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ items:
type: string
description: Transaction hash that contains the specific metadata
json_metadata:
additionalProperties: true
anyOf:
- type: string
- type: object
Expand All @@ -16,7 +15,7 @@ items:
- type: integer
- type: number
- type: boolean
nullable: true
- type: "null"
description: Content of the JSON metadata
required:
- tx_hash
Expand Down
12 changes: 7 additions & 5 deletions src/types/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,40 @@ export type GetOnchainMetadataResult = {
};

export type CIPTypes = 'CIP25v1' | 'CIP25v2' | null;
export type CIP68Version = 'CIP68v1' | null;
export type ValidCIP68Version = 'CIP68v1' | 'CIP68v2';
export type CIP68Version = ValidCIP68Version | null;

export type validateCIP68MetadataInput = {
metadata: unknown;
version: number;
extra: string | undefined;
} | null;

export type validateCIP68MetadataOverload = {
(input: validateCIP68MetadataInput, type: 'ft'):
| {
version: 'CIP68v1';
version: ValidCIP68Version;
extra: string | undefined;
metadata: Schemas['onchain_metadata_cip68_ft_333'];
}
| false;
(input: validateCIP68MetadataInput, type: 'nft'):
| {
version: 'CIP68v1';
version: ValidCIP68Version;
extra: string | undefined;
metadata: Schemas['onchain_metadata_cip68_nft_222'];
}
| false;
(input: validateCIP68MetadataInput, type: 'rft'):
| {
version: 'CIP68v1';
version: ValidCIP68Version;
extra: string | undefined;
metadata: Schemas['onchain_metadata_cip68_rft_444'];
}
| false;
(input: validateCIP68MetadataInput, type: 'nft' | 'ft' | 'rft'):
| {
version: 'CIP68v1';
version: ValidCIP68Version;
extra: string | undefined;
metadata:
| Schemas['onchain_metadata_cip68_nft_222']
Expand Down
Loading

0 comments on commit 255c393

Please sign in to comment.