@collabland/chain
Advanced tools
Comparing version 0.23.0 to 0.24.0
@@ -155,5 +155,6 @@ "use strict"; | ||
async fetchMetadata(token) { | ||
var _a; | ||
var _a, _b, _c; | ||
const metadata = await fetchTokenMetadata(token.uri); | ||
if (metadata != null) { | ||
token.metadata = metadata; | ||
const info = metadata; | ||
@@ -163,3 +164,35 @@ // Set `traits` to `attributes` | ||
delete info.traits; | ||
token.metadata = metadata; | ||
if (info.properties != null && typeof info.properties === 'object') { | ||
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1155.md#erc-1155-metadata-uri-json-schema | ||
info.attributes = (_b = info.attributes) !== null && _b !== void 0 ? _b : []; | ||
for (const p in info.properties) { | ||
const val = info.properties[p]; | ||
if (typeof val === 'object') { | ||
// Complex property | ||
/* "rich_property": { | ||
"name": "Name", | ||
"value": "123", | ||
"display_value": "123 Example Value", | ||
"class": "emphasis", | ||
"css": { | ||
"color": "#ffffff", | ||
"font-weight": "bold", | ||
"text-decoration": "underline" | ||
} | ||
},*/ | ||
info.attributes.push({ | ||
trait_type: (_c = val.name) !== null && _c !== void 0 ? _c : p, | ||
value: String(val.value), | ||
}); | ||
} | ||
else { | ||
// Simple property: "simple_property": "example value", | ||
info.attributes.push({ | ||
trait_type: p, | ||
value: String(val), | ||
}); | ||
} | ||
} | ||
delete info.properties; | ||
} | ||
} | ||
@@ -166,0 +199,0 @@ } |
{ | ||
"name": "@collabland/chain", | ||
"version": "0.23.0", | ||
"version": "0.24.0", | ||
"description": "CollabLand Ethereum Integration", | ||
@@ -34,3 +34,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@collabland/common": "^0.33.1", | ||
"@collabland/common": "^0.33.2", | ||
"is-ipfs": "^6.0.2", | ||
@@ -41,12 +41,12 @@ "parse-data-url": "^4.0.1", | ||
"devDependencies": { | ||
"@loopback/build": "^9.0.1", | ||
"@loopback/eslint-config": "^13.0.1", | ||
"@loopback/testlab": "^5.0.1", | ||
"@types/node": "^16.11.39", | ||
"@loopback/build": "^9.0.2", | ||
"@loopback/eslint-config": "^13.0.2", | ||
"@loopback/testlab": "^5.0.2", | ||
"@types/node": "^16.11.45", | ||
"@types/parse-data-url": "^3.0.0", | ||
"typescript": "~4.7.3" | ||
"typescript": "~4.7.4" | ||
}, | ||
"copyright.owner": "Abridged, Inc.", | ||
"author": "Abridged, Inc.", | ||
"gitHead": "d7373614714b5e06a5aad13eabcbef2071fcd4a9" | ||
"gitHead": "b25a88187a059ab7014ccecf34088087d03f1b5a" | ||
} |
@@ -240,2 +240,3 @@ // Copyright Abridged, Inc. 2021. All Rights Reserved. | ||
if (metadata != null) { | ||
token.metadata = metadata; | ||
const info = metadata as Record<string, AnyType>; | ||
@@ -245,3 +246,35 @@ // Set `traits` to `attributes` | ||
delete info.traits; | ||
token.metadata = metadata; | ||
if (info.properties != null && typeof info.properties === 'object') { | ||
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1155.md#erc-1155-metadata-uri-json-schema | ||
info.attributes = info.attributes ?? []; | ||
for (const p in info.properties) { | ||
const val = info.properties[p]; | ||
if (typeof val === 'object') { | ||
// Complex property | ||
/* "rich_property": { | ||
"name": "Name", | ||
"value": "123", | ||
"display_value": "123 Example Value", | ||
"class": "emphasis", | ||
"css": { | ||
"color": "#ffffff", | ||
"font-weight": "bold", | ||
"text-decoration": "underline" | ||
} | ||
},*/ | ||
info.attributes.push({ | ||
trait_type: val.name ?? p, | ||
value: String(val.value), | ||
}); | ||
} else { | ||
// Simple property: "simple_property": "example value", | ||
info.attributes.push({ | ||
trait_type: p, | ||
value: String(val), | ||
}); | ||
} | ||
} | ||
delete info.properties; | ||
} | ||
} | ||
@@ -248,0 +281,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
146522
3757
Updated@collabland/common@^0.33.2