Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ticket PK-07-2: eventPassPack new model and webhook #220

Open
sebpalluel opened this issue Dec 19, 2023 · 2 comments
Open

Ticket PK-07-2: eventPassPack new model and webhook #220

sebpalluel opened this issue Dec 19, 2023 · 2 comments
Assignees
Milestone

Comments

@sebpalluel
Copy link
Contributor

sebpalluel commented Dec 19, 2023

packNftSupply model:

                "contractAddress",
		error,
		"tokenUri",
		"chainId",
		"packId",
		"organizerId",
		"currentOwnerAddress",
		"lastNftTransferId",
                "eventPassNfts"(array of eventPassNft ids, nullable),
                "redeemableNfts"(array of redeemableNft ids, nullable),
		id,
		created_at,
		updated_at
  1. create the model
  2. create the instances of packNftSupply in pack deploy

Webhook

  1. Rename nftActivity for eventPassNftActivity
  2. move common functions such as extractNftTransfersFromEvent into common.ts and create new common functions for parts of code that are relevant.
  3. create PackNftWrapper similarly to EventPassNftWrapper
@sebpalluel sebpalluel added this to the Pack Feature milestone Dec 19, 2023
@sebpalluel sebpalluel changed the title Ticket PK-07-2: eventPassPack new model Ticket PK-07-2: eventPassPack new model and webhook Jan 4, 2024
@sebpalluel
Copy link
Contributor Author

-- Create packNftSupply table
CREATE TABLE "public"."packNftSupply" (
  "id" uuid NOT NULL DEFAULT gen_random_uuid(),
  "contractAddress" text NOT NULL,
  "error" text,
  "tokenUri" text,
  "chainId" text NOT NULL,
  "packId" text NOT NULL,
  "organizerId" text NOT NULL,
  "currentOwnerAddress" text,
  "lastNftTransferId" uuid REFERENCES "public"."nftTransfer"("id") ON UPDATE NO ACTION ON DELETE NO ACTION,
  "eventPassNfts" uuid[] NULL,
  "redeemableNfts" uuid[] NULL,
  "created_at" timestamptz NOT NULL DEFAULT now(),
  "updated_at" timestamptz NOT NULL DEFAULT now(),
  PRIMARY KEY ("id"),
  UNIQUE ("contractAddress", "chainId", "packId")
);

-- Comments for the packNftSupply table and its columns
COMMENT ON TABLE "public"."packNftSupply" IS E'This table represents the supply details of pack NFTs, tracking the ownership, contents, and metadata associated with each pack.';

COMMENT ON COLUMN "public"."packNftSupply"."contractAddress" IS E'The address of the smart contract representing the pack NFT. Essential for blockchain interactions.';

COMMENT ON COLUMN "public"."packNftSupply"."error" IS E'Any error messages related to this pack NFT, particularly during transactions or metadata retrieval.';

COMMENT ON COLUMN "public"."packNftSupply"."tokenUri" IS E'The URI pointing to the metadata of the pack NFT.';

COMMENT ON COLUMN "public"."packNftSupply"."chainId" IS E'The specific blockchain or network on which the pack NFT exists.';

COMMENT ON COLUMN "public"."packNftSupply"."packId" IS E'A unique identifier for the pack within the platform.';

COMMENT ON COLUMN "public"."packNftSupply"."organizerId" IS E'The identifier of the organizer associated with this pack NFT.';

COMMENT ON COLUMN "public"."packNftSupply"."currentOwnerAddress" IS E'The blockchain address of the current owner of the pack NFT.';

COMMENT ON COLUMN "public"."packNftSupply"."lastNftTransferId" IS E'The reference to the latest transfer record for this pack NFT.';

COMMENT ON COLUMN "public"."packNftSupply"."eventPassNfts" IS E'An array of UUIDs representing the event pass NFTs contained in the pack. Null if the pack is unopened.';

COMMENT ON COLUMN "public"."packNftSupply"."redeemableNfts" IS E'An array of UUIDs representing redeemable NFTs contained in the pack. Null if the pack is unopened.';

-- Create trigger for packNftSupply
CREATE TRIGGER set_packNftSupply_updated_at
  BEFORE UPDATE ON "public"."packNftSupply"
  FOR EACH ROW
  EXECUTE FUNCTION public.set_current_timestamp_updated_at();
 

@sebpalluel
Copy link
Contributor Author

sebpalluel commented Jan 9, 2024

-- Create packNftSupply table
CREATE TABLE "public"."packNftSupply" (
  "id" uuid NOT NULL DEFAULT gen_random_uuid(),
  "contractAddress" text NOT NULL,
  "error" text,
  "tokenUri" text,
  "chainId" text NOT NULL,
  "packId" text NOT NULL,
  "organizerId" text NOT NULL,
  "currentOwnerAddress" text,
  "lastNftTransferId" uuid REFERENCES "public"."nftTransfer"("id") ON UPDATE NO ACTION ON DELETE NO ACTION,
  "created_at" timestamptz NOT NULL DEFAULT now(),
  "updated_at" timestamptz NOT NULL DEFAULT now(),
  PRIMARY KEY ("id"),
  UNIQUE ("contractAddress", "chainId", "packId")
);

-- Comments for the packNftSupply table and its columns
COMMENT ON TABLE "public"."packNftSupply" IS E'This table represents the supply details of pack NFTs, tracking the ownership, contents, and metadata associated with each pack.';

COMMENT ON COLUMN "public"."packNftSupply"."contractAddress" IS E'The address of the smart contract representing the pack NFT. Essential for blockchain interactions.';

COMMENT ON COLUMN "public"."packNftSupply"."error" IS E'Any error messages related to this pack NFT, particularly during transactions or metadata retrieval.';

COMMENT ON COLUMN "public"."packNftSupply"."tokenUri" IS E'The URI pointing to the metadata of the pack NFT.';

COMMENT ON COLUMN "public"."packNftSupply"."chainId" IS E'The specific blockchain or network on which the pack NFT exists.';

COMMENT ON COLUMN "public"."packNftSupply"."packId" IS E'A unique identifier for the pack within the platform.';

COMMENT ON COLUMN "public"."packNftSupply"."organizerId" IS E'The identifier of the organizer associated with this pack NFT.';

COMMENT ON COLUMN "public"."packNftSupply"."currentOwnerAddress" IS E'The blockchain address of the current owner of the pack NFT.';

COMMENT ON COLUMN "public"."packNftSupply"."lastNftTransferId" IS E'The reference to the latest transfer record for this pack NFT.';

-- Create trigger for packNftSupply
CREATE TRIGGER set_packNftSupply_updated_at
  BEFORE UPDATE ON "public"."packNftSupply"
  FOR EACH ROW
  EXECUTE FUNCTION public.set_current_timestamp_updated_at();
  
-- Create a junction table for linking packNftSupply to eventPassNft
CREATE TABLE "public"."pack_event_pass_nft" (
    pack_nft_supply_id uuid NOT NULL REFERENCES "public"."packNftSupply"("id"),
    event_pass_nft_id uuid NOT NULL REFERENCES "public"."eventPassNft"("id"),
    PRIMARY KEY (pack_nft_supply_id, event_pass_nft_id),
    UNIQUE (event_pass_nft_id)
);

COMMENT ON TABLE "public"."pack_event_pass_nft" IS E'Junction table linking pack NFTs to event pass NFTs. Ensures that each event pass NFT is uniquely associated with a pack.';

COMMENT ON COLUMN "public"."pack_event_pass_nft"."pack_nft_supply_id" IS E'Identifier for the pack NFT supply.';

COMMENT ON COLUMN "public"."pack_event_pass_nft"."event_pass_nft_id" IS E'Identifier for the event pass NFT.';

-- View for listing eventPassNfts associated with each packNftSupply
CREATE VIEW "public"."view_pack_nft_supply_eventPassNfts" AS
SELECT 
    pns.id AS pack_nft_supply_id,
    array_agg(pepn.event_pass_nft_id) FILTER (WHERE pepn.event_pass_nft_id IS NOT NULL) AS eventPassNfts
FROM 
    "public"."packNftSupply" pns
LEFT JOIN 
    "public"."pack_event_pass_nft" pepn ON pns.id = pepn.pack_nft_supply_id
GROUP BY 
    pns.id;

COMMENT ON VIEW "public"."view_pack_nft_supply_eventPassNfts" IS 'A view listing all event pass NFTs associated with each pack NFT supply.';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants