-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add docs for cardano's transfer and mint and burn
- Loading branch information
1 parent
183c0c0
commit 7608e5c
Showing
4 changed files
with
118 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...ome/300-react-to-events/2-primitive-catalogue/20-cardano/30-cardano-transfer.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
|
||
# Cardano Transfer {#transfer} | ||
|
||
### 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<CardanoTransfer> = { | ||
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. | ||
|
53 changes: 53 additions & 0 deletions
53
...me/300-react-to-events/2-primitive-catalogue/20-cardano/40-cardano-mint-burn.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<CardanoMint> = { | ||
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. |