Skip to content

Commit ed06d26

Browse files
committed
feat: new Poseidon Str naming type plus made fixes in tests
1 parent 7e5854b commit ed06d26

File tree

6 files changed

+20
-12
lines changed

6 files changed

+20
-12
lines changed

basics/realloc/poseidon/realloc-program/programs/realloc-program/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ pub struct UpdateContext<'info> {
2828
// Due to current limitations in Poseidon, dynamic allocation (reallocation) is not supported on Poseidon right now.
2929
// As a result, this example uses fixed-sized fields to work around the limitation.
3030
// In typical Solana programs using Anchor, dynamic reallocation allows accounts to resize based on the input data.
31-
#[account(mut, seeds = [b"message"], bump)]
31+
// so I am adding it manually right now
32+
#[account(
33+
mut,
34+
realloc = 48,
35+
realloc::payer = payer,
36+
realloc::zero = true,
37+
)]
3238
pub account: Account<'info, MessageAccountState>,
3339
pub system_program: Program<'info, System>,
3440
}

basics/realloc/poseidon/realloc-program/tests/bankrun.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ describe('realloc_program', async () => {
5656
.update(updatedMessage)
5757
.accounts({
5858
payer: payer.publicKey,
59+
account: messagePDA,
5960
})
6061
.rpc();
6162

basics/realloc/poseidon/realloc-program/tests/realloc-program.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ describe('realloc_program', () => {
4747
.update(updatedMessage)
4848
.accounts({
4949
payer: provider.wallet.publicKey,
50+
account: messagePDA,
5051
})
5152
.signers([])
5253
.rpc();

basics/realloc/poseidon/realloc-program/ts-programs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
"license": "ISC",
1111
"description": "",
1212
"dependencies": {
13-
"@solanaturbine/poseidon": "^0.0.5"
13+
"@solanaturbine/poseidon": "^0.0.11"
1414
}
1515
}

basics/realloc/poseidon/realloc-program/ts-programs/pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Account, String as PoseidonString, Pubkey, Result, Signer, SystemAccount, u8 } from '@solanaturbine/poseidon';
1+
import { Account, Pubkey, Result, Signer, Str, SystemAccount, u8 } from '@solanaturbine/poseidon';
22

33
// Note:
44
// Realloc Program:
@@ -10,23 +10,23 @@ import { Account, String as PoseidonString, Pubkey, Result, Signer, SystemAccoun
1010
export default class ReallocProgram {
1111
static PROGRAM_ID = new Pubkey('7T1DgawXjJD6kGaC43ujSw2xXLhn7w28MGzyD7oV8Q1B');
1212

13-
initialize(payer: Signer, account: MessageAccountState, input: PoseidonString): Result {
14-
account.derive(['message']).init();
13+
initialize(payer: Signer, account: MessageAccountState, input: Str<25>): Result {
14+
account.derive(['message']).init(payer);
1515

1616
account.message = input;
1717

1818
account.bump = account.getBump();
1919
}
2020

21-
update(payer: Signer, account: MessageAccountState, input: PoseidonString): Result {
21+
update(payer: Signer, account: MessageAccountState, input: Str<25>): Result {
2222
account.derive(['message']);
2323

2424
account.message = input;
2525
}
2626
}
2727

2828
export interface MessageAccountState extends Account {
29-
message: PoseidonString;
29+
message: Str<25>;
3030

3131
bump: u8;
3232
}

0 commit comments

Comments
 (0)