npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@colony/colony-event-metadata-parser

v2.0.2

Published

**Metadata format versions** ColonyDapp should support legacy Metadata formats. Therefore, when parsing (in ColonyDapp) it is necessary to check the Metadata format version and support V1 & later versions. ```ts const metadataVersion = getEventMetadataVer

Downloads

37

Readme

Colony Event Metadata Parser

Metadata format versions ColonyDapp should support legacy Metadata formats. Therefore, when parsing (in ColonyDapp) it is necessary to check the Metadata format version and support V1 & later versions.

const metadataVersion = getEventMetadataVersion(ipfsMetadata);
if (metadataVersion === 1) {
/*
* original metadata format
*/
...
}
else {
/*
* new metadata format
*/
....
}

Parsing To retrieve MetaData from IPFS. (String to Object)

// Colony MetaData
const colonyMetadata = getColonyMetadataFromResponse(ipfsDataJSON);

// Domain MetaData
const domainMetadata = getDomainMetadataFromResponse(ipfsDataJSON);

// Annotation Message
const annotation = getAnnotationMsgFromResponse(ipfsDataJSON);

/////////
// Get Avatar Image
//
// First get Colony Metadata
const colonyMetadata = getColonyMetadataFromResponse(ipfsMetadata);

// Then get IPFS response from avatarHash
avatarHash = colonyMetadata?.colonyAvatarHash;
response = await ipfs.getString(avatarHash);

// Finally, get the avatar image
avatarObject = { image: getColonyAvatarImage(response) };
/////////


// Generic Misc data
// An Agreement is used as example:
const response = await ipfsWithFallback.getString(agreementHash);
const agreement = getNameValueFromMisc('agreement', response);

Deserialising Preparing Metadata to send to IPFS. (Object to String)

// Colony Metadata packed and converted to string
const metadataForIPFS = getStringForMetadataColony({
	colonyDisplayName,
	colonyAvatarHash: colonyAvatarIpfsHash
	colonyTokens,
	verifiedAddresses,
	isWhitelistActivated,
});
colonyMetadataIpfsHash = yield call(ipfsUpload, metadataForIPFS);

// Domain Metadata packed and converted to string
domainMetadataIpfsHash = yield  call(
	ipfsUpload,
	getStringForMetadataDomain({
		domainName,
		domainColor,
		domainPurpose,
}),

// Annotation message packed and converted to string
ipfsHash = yield call(
	ipfsUpload,
	getStringForMetadataAnnotation({
		annotationMsg:  annotationMessage || '',
	}),
);

// ColonyAvatarImage packed and converted to string
colonyAvatarIpfsHash = yield call(
	ipfsUpload,
	getStringForColonyAvatarImage(colonyAvatarImage),
);

// Pack and convert string to be used in a MiscMetadata
// This example uploads a whitelist agreement to IPFS
let  agreementHash = '';
if (payload.agreement) {
	const  miscMetadata = {
		name:  'agreement',
		value:  payload?.agreement,
	};
	agreementHash = yield  call(
		ipfsUpload,
		getStringForMetadataMisc(miscMetadata),
	);
}

License

GPL-3.0