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

Add support for optional variablePdaSeedNode #199

Open
febo opened this issue Sep 4, 2024 · 0 comments
Open

Add support for optional variablePdaSeedNode #199

febo opened this issue Sep 4, 2024 · 0 comments

Comments

@febo
Copy link
Contributor

febo commented Sep 4, 2024

It might be interesting to support optional values on PDA seeds, e.g.:

k.pdaNode({
  name: "account",
  seeds: [
    k.variablePdaSeedNode(
      "from",
      k.publicKeyTypeNode(),
      "Funding account"
    ),
    k.variablePdaSeedNode(
      "seed",
      k.fixedSizeTypeNode(k.bytesTypeNode(), 32),
      "Optional seed for the account derivation"
    ),
    k.variablePdaSeedNode(
      "group",
      k.numberTypeNode("u64"),
      "Group ID for the address derivation"
    ),
  ],
})

In this example, the seed value is optional – it can either be present or not. This would result in the following AccountSeeds for the findAccountPda helper:

export type AccountSeeds = {
  /** Funding account */
  from: Address;
  /** Optional seed for the account derivation */
  seed?: ReadonlyUint8Array;
  /** Group ID for the address derivation */
  group: number | bigint;
};

You could also combine this with default value support (#107), so you could have optional seed values with a default value if one is not provided.

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

No branches or pull requests

1 participant