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

cardano transfer: narrow credential relation filter #332

Merged
merged 2 commits into from
Mar 31, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/engine/paima-funnel/src/cde/cardanoTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Routes, query } from '@dcspark/carp-client';
import type { TxAndBlockInfo } from '@dcspark/carp-client';
import { Transaction } from '@dcspark/cardano-multiplatform-lib-nodejs';
import type { BlockTxPair } from '@dcspark/carp-client';
import { RelationFilterType } from '@dcspark/carp-client';

export default async function getCdeData(
url: string,
Expand All @@ -24,10 +25,18 @@ export default async function getCdeData(
): Promise<CdeCardanoTransferDatum[]> {
let result = [] as CdeCardanoTransferDatum[];

const relationFilter =
RelationFilterType.Output |
RelationFilterType.Input |
RelationFilterType.StakeRegistration |
RelationFilterType.StakeDeregistration |
RelationFilterType.StakeDelegation |
RelationFilterType.Withdrawal;
Copy link
Contributor

@SebastienGllmt SebastienGllmt Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this way is possible I guess, but we'd have to be clear in the docs that users have to manually parse the transaction to know if the address appears in

  1. ins: Input, Withdrawal
  2. certs (arguably an ins type): StakeRegistration, StakeDeregistration, StakeDelegation
  3. outs: Output

since right now the CDE only gives you access to the Input and Output cases

Copy link
Contributor

@SebastienGllmt SebastienGllmt Mar 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of a particular nice way to do this other than to include the tx cbor as well (as mentioned originally here: #262), but even tx cbor is not enough for everything (ex: it doesn't give you the datum for the tx)

Copy link
Contributor

@SebastienGllmt SebastienGllmt Mar 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I just realized we can replace all input types with TxCredentialRelationValue.Witness


while (true) {
const event = await timeout(
query(url, Routes.transactionHistory, {
// TODO: maybe it should be Output
relationFilter,
addresses: [extension.credential],
slotLimits: {
from: fromAbsoluteSlot,
Expand Down