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

event-ticketing-system-js-library

v0.2.8

Published

Library for event ticketing system

Downloads

11

Readme

ets-js-library

About

This is a JavaScript library for interacting with event ticketing system. It creates unsigned transactions and fetches data from smart contracts and ipfs.

How to use

Install:

npm i ets-js-library@npm:event-ticketing-system-js-library

Create event:

  1. Create an api token from nft.storage
  2. Import createEvent function from the library.
  3. Create metadata for the new event.
  4. Execute creteEvent function. This will return an unsigned transaction.
  5. Sign and send the transaction anyway you like.
import { createEvent } from "ets-js-library";

const metadata = {
  name: "Event1",
  eventId,
  websiteUrl: "https://event1.com",
  posterImageUrl: imageCidGatewayUrl,
  date: {
    start: Math.floor(Date.now() / 1000),
    end: Math.floor(Date.now() / 1000) + 60 * 60,
  },
  location: {
    country: "Bulgaria",
    city: "Varna",
    address: "Front Beach Alley, 9007 Golden Sands",
    coordinates: {
      latitude: "43.28365485346511",
      longitude: "28.042738484752096",
    },
  },
  ticketTypes: ["super early birds", "early birds", "regular", "onsite"],
  maxTicketsPerAccount: 10,
  contacts: "Contacts string",
  status: "upcoming",
};

let key = "API key for NFT.storage";

let transaction = await createEvent(key, metadata, image, maxTicketsPerClient);
//You need to sign and send the transaction after this.

Update event:

  1. Create an api token from nft.storage
  2. Import updateEvent, getEventIpfsUri and deleteFromIpfs from the library.
  3. Create new metadata for the event.
  4. Execute getEventIpfsUri function. This will return the Uri of the current metadata.
  5. Execute updateEvent function. This will return an unsigned transaction.
  6. Sign and send the transaction anyway you like.
  7. If the transaction succeeds, you can safely delete the old metadata with deleteFromIpfs.
import { updateEvent, getEventIpfsUri, deleteFromIpfs } from "ets-js-library";

const metadata = {
  name: "Event1",
  eventId,
  websiteUrl: "https://event1.com",
  posterImageUrl: imageCidGatewayUrl,
  date: {
    start: Math.floor(Date.now() / 1000),
    end: Math.floor(Date.now() / 1000) + 60 * 60,
  },
  location: {
    country: "Bulgaria",
    city: "Varna",
    address: "Front Beach Alley, 9007 Golden Sands",
    coordinates: {
      latitude: "43.28365485346511",
      longitude: "28.042738484752096",
    },
  },
  ticketTypes: ["super early birds", "early birds", "regular", "onsite"],
  maxTicketsPerAccount: 10,
  contacts: "Contacts string",
  status: "upcoming",
};

let key = "API key for NFT.storage";
let eventId = "Id of event in smart contract";

let metadataUri = await getEventIpfsUri(eventId);

try {
  let transaction = await updateEvent(key, eventId, metadata, image);
  //You need to sign and send the transaction here.
  deleteFromIpfs(key, metadataUri);
} catch (error) {
  console.log(error);
}

Remove event

  1. Create an api token from nft.storage
  2. Import removeEvent and deleteFromIpfs from the library.
  3. Execute removeEvent function. This will return an unsigned transaction.
  4. Sign and send the transaction anyway you like.
  5. If the transaction succeeds, you can safely delete the old metadata with deleteFromIpfs.
import { removeEvent, deleteFromIpfs } from "ets-js-library";

let key = "API key for NFT.storage";
let eventId = "Id of event in smart contract";

let metadataUri = await getEventIpfsUri(eventId);

try {
  let transaction = await removeEvent(eventId);
  //You need to sign and send the transaction here.
  deleteFromIpfs(key, metadataUri);
} catch (error) {
  console.log(error);
}

Fetch events by Ids

  1. Import fetchEvents from the library.
  2. Execute fetchEvents.
import { fetchEvents } from "ets-js-library";

//Ids of events in smart contract.
let eventIds = [1, 2, 3];

let events = fetchEvents(eventIds);

Fetch owned events

  1. Import fetchOwnedEvents function from the library.
  2. Execute fetchOwnedEvents by supplying an address.
import { fetchOwnedEvents } from "ets-js-library";

let address = "Address of events owner.";

let events = fetchOwnedEvents(address);

Fetch cached events from server

  1. You need to have JWT_SECRET first.
  2. Import fetchAllEventsFromServer function from the library.
  3. Create params.
  4. Execute fetchAllEventsFromServer.
import {fetchAllEventsFromServer} from 'ets-js-library';

let params = {
  title: "",
  description: "",
  eventStartDateStartingInterval: "",
  eventStartDateEndingInterval: "",
  eventEndDateStartingInterval: "",
  eventEndDateEndingInterval: "",
  country: "",
  place: "",
  tags: "",
  sort: "",
  pagination: "",
  organizer: "";
};

let events = fetchAllEventsFromServer(serverUrl, JWT_SECRET, params);

Add team member to event

  1. Import addTeamMember function from the library.
  2. Import utils function from ethers.
  3. Generate the hash of the role.
  4. Execute addTeamMember function. This will return an unsigned transaction.
  5. Sign and send the transaction anyway you like.
import { addTeamMember } from "ets-js-library";
import { utils } from "ethers";

let eventId = "Id of event in smart contract";
let address = "Address of new member.";
let role = utils.keccak256(utils.toUtf8Bytes("MODERATOR_ROLE"));

let transaction = await addTeamMember(eventId, role, address);
//You need to sign and send the transaction after this.

Remove team member from event

  1. Import removeTeamMember function from the library.
  2. Import utils function from ethers.
  3. Generate the hash of the role.
  4. Execute removeTeamMember function. This will return an unsigned transaction.
  5. Sign and send the transaction anyway you like.
import { removeTeamMember } from "ets-js-library";
import { utils } from "ethers";

let eventId = "Id of event in smart contract";
let address = "Address of team member.";
let role = utils.keccak256(utils.toUtf8Bytes("MODERATOR_ROLE"));

let transaction = await removeTeamMember(eventId, role, address);
//You need to sign and send the transaction after this.

Tests

Run tests:

npm run test

See test coverage:

npm run coverage

Conventions and standards

Commit message format

feat: Add beta sequence
^--^ ^---------------^
| |
| +-> Summary in present tense.
|
+-------> Type: chore, docs, feat, fix, refactor, style, or test.

Contributing

Please refer to each project's style and contribution guidelines for submitting patches and additions. In general, we follow the "fork-and-pull" Git workflow.

  1. Fork the repo on GitHub
  2. Clone the project to your own machine
  3. Commit changes to your own branch
  4. Push your work back up to your fork
  5. Submit a Pull request so that we can review your changes

NOTE: Be sure to merge the latest from "upstream" before making a pull request!