Skip to content

Commit 1d4223c

Browse files
authored
Fix constant PDA seed rendering in renderers-js-umi (#88)
1 parent a671c3c commit 1d4223c

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@kinobi-so/renderers-js-umi": patch
3+
---
4+
5+
Fix constant PDA seed rendering in renderers-js-umi

packages/renderers-js-umi/public/templates/accountsPage.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export function find{{ account.name | pascalCase }}Pda(
103103
{% if seed.kind === 'constantPdaSeedNode' and seed.value.kind === 'programIdValueNode' %}
104104
publicKeySerializer().serialize(programId),
105105
{% elif seed.kind === 'constantPdaSeedNode' %}
106-
{{ seed.typeManifest.serializer }}.serialize({{ seed.valueManifest.render }}),
106+
{{ seed.typeManifest.serializer }}.serialize({{ seed.valueManifest.value }}),
107107
{% else %}
108108
{{ seed.typeManifest.serializer }}.serialize(seeds.{{ seed.name | camelCase }}),
109109
{% endif %}
Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
1-
import { accountNode, constantPdaSeedNodeFromProgramId, pdaLinkNode, pdaNode, programNode } from '@kinobi-so/nodes';
1+
import {
2+
accountNode,
3+
constantPdaSeedNodeFromProgramId,
4+
constantPdaSeedNodeFromString,
5+
pdaLinkNode,
6+
pdaNode,
7+
programNode,
8+
publicKeyTypeNode,
9+
variablePdaSeedNode,
10+
} from '@kinobi-so/nodes';
211
import { visit } from '@kinobi-so/visitors-core';
312
import { test } from 'vitest';
413

514
import { getRenderMapVisitor } from '../src';
615
import { renderMapContains } from './_setup';
716

8-
test('it renders PDA helpers for PDA with no seeds', async () => {
9-
// Given the following program with 1 account and 1 pda with empty seeds.
17+
test('it renders PDA helpers for PDA', async () => {
18+
// Given the following program with 1 account and 1 pda with seeds.
1019
const node = programNode({
1120
accounts: [accountNode({ name: 'foo', pda: pdaLinkNode('bar') })],
1221
name: 'myProgram',
13-
pdas: [pdaNode({ name: 'bar', seeds: [constantPdaSeedNodeFromProgramId()] })],
22+
pdas: [
23+
pdaNode({
24+
name: 'bar',
25+
seeds: [
26+
constantPdaSeedNodeFromProgramId(),
27+
constantPdaSeedNodeFromString('utf8', 'bar'),
28+
variablePdaSeedNode('authority', publicKeyTypeNode()),
29+
],
30+
}),
31+
],
1432
publicKey: '1111',
1533
});
1634

@@ -22,5 +40,8 @@ test('it renders PDA helpers for PDA with no seeds', async () => {
2240
'export function findFooPda',
2341
'export async function fetchFooFromSeeds',
2442
'export async function safeFetchFooFromSeeds',
43+
'publicKeySerializer().serialize(programId)',
44+
"string({ size: 'variable' }).serialize('bar')",
45+
'publicKeySerializer().serialize(seeds.authority)',
2546
]);
2647
});

0 commit comments

Comments
 (0)