From d6b00d7279e7db73b272129f425e1b935e19093e Mon Sep 17 00:00:00 2001 From: Enzo Cioppettini Date: Tue, 5 Mar 2024 01:38:57 -0300 Subject: [PATCH 1/2] add docs for cardano's transfer and mint and burn --- .../20-cardano/10-stakepools.md | 1 + .../20-cardano/20-delayed-state.md | 1 + .../20-cardano/30-cardano-transfer.md | 65 +++++++++++++++++++ .../20-cardano/40-cardano-mint-burn.md | 53 +++++++++++++++ 4 files changed, 120 insertions(+) create mode 100644 docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/30-cardano-transfer.md create mode 100644 docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/40-cardano-mint-burn.md diff --git a/docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/10-stakepools.md b/docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/10-stakepools.md index 0dc47b3d..0d820460 100644 --- a/docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/10-stakepools.md +++ b/docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/10-stakepools.md @@ -12,6 +12,7 @@ extensions: startSlot: 32815320 stopSlot: 32815924 scheduledPrefix: cd + network: CardanoNetworkConfigEntryName ``` ### Meaning diff --git a/docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/20-delayed-state.md b/docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/20-delayed-state.md index f197ad1f..3fbb1f81 100644 --- a/docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/20-delayed-state.md +++ b/docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/20-delayed-state.md @@ -23,6 +23,7 @@ extensions: - "919d4c2c9455016289341b1bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" startSlot: 22505578 stopSlot: 32815924 + network: CardanoNetworkConfigEntryName ``` ### Meaning diff --git a/docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/30-cardano-transfer.md b/docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/30-cardano-transfer.md new file mode 100644 index 00000000..ab3f4cfc --- /dev/null +++ b/docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/30-cardano-transfer.md @@ -0,0 +1,65 @@ + +# Cardano Transfer {#transfer} + +Keeps track of the entire (between the indexed slots) transaction history of a +particular address. + +### Example + +```yaml +extensions: + - name: "CardanoTransfer" + type: cardano-transfer + credential: addr_test1qp27ms6du9e2fga6njk9ruzprp7gg3uddrnc3htv7mct8kwrwdlnpt07ycmdqyuw7lft338dt33tmr6xdwnn8ezsudpquved20 + startSlot: 12472120 + stopSlot: 12500000 + scheduledPrefix: ct + network: CardanoNetworkConfigEntryName +``` + +### Meaning + +- `startSlot` is required and means that only transactions that happen after that slot (exclusive) will be considered. +- `stopSlot` is optional, and it stops the indexing at that point. +- `credential` is the address to track. This can be a bech32 address, or a hex encoded credential. + +### Paima Concise format + +The scheduled input for each event is of the following form. + +``` +cardanoTransfer = ct|txId|metadata|inputCredentials|outputs +``` + +It can be parsed with a rule of the form: + +```ts +const cardanoTransfer: ParserRecord = { + txId: PaimaParser.NCharsParser(0, 64), + metadata: PaimaParser.OptionalParser(null, PaimaParser.RegexParser(/[a-f0-9]*/)), + inputCredentials: PaimaParser.ArrayParser({ + item: PaimaParser.RegexParser(/[a-f0-9]*/), + }), + outputs: (keyName: string, input: string) => { + return JSON.parse(input); + }, +}; + +interface CardanoTransfer { + txId: string; + metadata: string | null; + inputCredentials: string[]; + outputs: { + asset: { policyId: string; assetName: string } | null; + amount: string; + address: string; + }[]; +} +``` + +- The metadata field is in its binary form, but hex encoded. +- The entries in `inputCredentials` are also hex encoded. Each one is the binary +representation of the payment key (64 characters or 32 bytes). +- `outputs` preserves the same order as in the binary transaction. The `asset` +will be `null` when the amount is in lovelace. + diff --git a/docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/40-cardano-mint-burn.md b/docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/40-cardano-mint-burn.md new file mode 100644 index 00000000..b568c697 --- /dev/null +++ b/docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/40-cardano-mint-burn.md @@ -0,0 +1,53 @@ +# Cardano Mint and Burn {#mint-burn} + +### Example + +```yaml +extensions: + - name: "CARDANO-MINT-BURN" + type: cardano-mint-burn + policyIds: + - "0fc891fb7368d3b7c7b88815c203fda0d6862b0f1d797222672e91fe" + - "0fc891fb7368d3b7c7b88815c203fda0d6862b0f1d797222672e91ff" + startSlot: 722300 + stopSlot: 733216 + scheduledPrefix: cmb + network: CardanoNetworkConfigEntryName +``` + +### Meaning + +- `startSlot` is required and means that only mints events after that slot (exclusive) will be considered. +- `stopSlot` is optional, and it stops the indexing at that point. +- `policyIds` is an array with the collections to index. + +### Paima Concise format + +The scheduled input for each event is of the following form. + +``` +cardanoMint = cmb|txId|metadata|assets +``` + +It can be parsed with a rule of the form: + +```ts +const cardanoMint: ParserRecord = { + txId: PaimaParser.NCharsParser(0, 64), + metadata: PaimaParser.OptionalParser(null, PaimaParser.RegexParser(/[a-f0-9]*/)), + assets: (keyName: string, input: string) => { + return JSON.parse(input); + }, +}; + +export interface CardanoMint { + txId: string; + metadata: string | null; + assets: { asset: { policyId: string; assetName: string }; amount: string }; +} +``` + +- The `metadata` field is hex encoded (if any), and it's the metadata in binary +form. +- The `assets` field has the minted or burned assets. The difference between a +mint and a burn is in the sign of `amount` when interpreted as a number. \ No newline at end of file From 24965603cb6e8c07a8a56d22ec9fb825dc845cd4 Mon Sep 17 00:00:00 2001 From: Enzo Cioppettini Date: Wed, 20 Mar 2024 12:15:14 -0300 Subject: [PATCH 2/2] replace bech32 in example with payment credential --- .../20-cardano/30-cardano-transfer.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/30-cardano-transfer.md b/docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/30-cardano-transfer.md index ab3f4cfc..0de4c67f 100644 --- a/docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/30-cardano-transfer.md +++ b/docs/home/300-react-to-events/2-primitive-catalogue/20-cardano/30-cardano-transfer.md @@ -2,7 +2,7 @@ # Cardano Transfer {#transfer} Keeps track of the entire (between the indexed slots) transaction history of a -particular address. +payment credential or particular address. ### Example @@ -10,7 +10,7 @@ particular address. extensions: - name: "CardanoTransfer" type: cardano-transfer - credential: addr_test1qp27ms6du9e2fga6njk9ruzprp7gg3uddrnc3htv7mct8kwrwdlnpt07ycmdqyuw7lft338dt33tmr6xdwnn8ezsudpquved20 + credential: 8200581c55edc34de172a4a3ba9cac51f041187c84478d68e788dd6cf6f0b3d9 startSlot: 12472120 stopSlot: 12500000 scheduledPrefix: ct @@ -21,7 +21,10 @@ extensions: - `startSlot` is required and means that only transactions that happen after that slot (exclusive) will be considered. - `stopSlot` is optional, and it stops the indexing at that point. -- `credential` is the address to track. This can be a bech32 address, or a hex encoded credential. +- `credential` can be a hex encoded payment credential, in which case all +associated addresses are indexed, regardless of the staking part. Or it can be +bech32 address instead, in this case the indexed transactions are those with the +same exact address (same payment part and staking part). ### Paima Concise format