Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@blockfrost/blockfrost-utils

Package Overview
Dependencies
Maintainers
3
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blockfrost/blockfrost-utils - npm Package Compare versions

Comparing version 2.3.1-beta.1 to 2.3.1-beta.2

40

lib/cip68.js

@@ -38,3 +38,3 @@ "use strict";

};
const CIP68_METADATA_FORMAT = {
const METADATA_SCHEME_MAP = {
ft: {

@@ -258,3 +258,3 @@ name: {

exports.getReferenceNFT = getReferenceNFT;
const convertDatumValue = (value, schema) => {
const convertDatumValue = (decodedValue, schema) => {
var _a;

@@ -264,24 +264,24 @@ if (!schema) {

}
if (schema.type === 'number' && typeof value === 'number') {
return value;
if (schema.type === 'number' && typeof decodedValue === 'number') {
return decodedValue;
}
else if (schema.type === 'bytestring' && Buffer.isBuffer(value)) {
return (0, exports.toUTF8OrHex)(value);
else if (schema.type === 'bytestring' && Buffer.isBuffer(decodedValue)) {
return (0, exports.toUTF8OrHex)(decodedValue);
}
else if (Array.isArray(value)) {
else if (Array.isArray(decodedValue)) {
const convertedArray = [];
for (const [index, arrayItem] of value.entries()) {
const arrayItemSchema = 'items' in schema ? (_a = schema.items) !== null && _a !== void 0 ? _a : null : null;
for (const arrayItem of decodedValue) {
const arrayItemSchema = (_a = schema.items) !== null && _a !== void 0 ? _a : null;
const v = convertDatumValue(arrayItem, arrayItemSchema);
if (v === null) {
// Invalid data
// One of the item has unsupported format which means we keep CBOR value instead
return null;
}
convertedArray[index] = v;
convertedArray.push(v);
}
return convertedArray;
}
else if (value instanceof Map) {
else if (decodedValue instanceof Map) {
const metadataMap = {};
for (const [key, mapValue] of value.entries()) {
for (const [key, mapValue] of decodedValue.entries()) {
// key and value are converted to utf-8 if their bytes are valid utf-8 sequence, hex otherwise

@@ -294,2 +294,3 @@ const convertedKey = Buffer.isBuffer(key) ? (0, exports.toUTF8OrHex)(key) : key;

if (convertedValue === null) {
// Unsupported format
return null;

@@ -302,4 +303,4 @@ }

else {
// no conversion
return value;
// Unsupported format
return null;
}

@@ -309,3 +310,3 @@ };

var _a;
const metadataFormat = CIP68_METADATA_FORMAT[options.standard];
const metadataFormat = METADATA_SCHEME_MAP[options.standard];
const datum = CardanoWasm.PlutusData.from_hex(datumHex);

@@ -347,3 +348,3 @@ const constrPlutusData = datum.as_constr_plutus_data();

if (!(metadataFormat && convertedKey in metadataFormat)) {
// Custom field not covered by CIP58 standard
// Custom field not covered by CIP68 standard
// Return unparsed CBOR data

@@ -358,2 +359,4 @@ metadataMap[convertedKey] = value === null || value === void 0 ? void 0 : value.to_hex();

const filesValue = convertDatumValue(decodedValue, metadataFormat[convertedKey]);
// If convertDatumValue returns null then the decodedValue has unsupported format,
// return CBOR hex instead
metadataMap[convertedKey] = filesValue !== null && filesValue !== void 0 ? filesValue : value.to_hex();

@@ -370,4 +373,3 @@ }

// convert to utf-8 or return bytes as hex
const convertedValue = (0, exports.toUTF8OrHex)(decodedValue);
metadataMap[convertedKey] = convertedValue;
metadataMap[convertedKey] = (0, exports.toUTF8OrHex)(decodedValue);
}

@@ -374,0 +376,0 @@ else {

{
"name": "@blockfrost/blockfrost-utils",
"version": "2.3.1-beta.1",
"version": "2.3.1-beta.2",
"repository": "git@github.com:blockfrost/blockfrost-utils.git",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc