Skip to content

Commit 44d1f60

Browse files
dhlCopilot
andcommitted
fix(codama): Update authority seed to size_prefix to match bincode
This also brings in the enum_discriminator fix from codama 0.9.2 Co-authored-by: Copilot <copilot@github.com>
1 parent 7f4f867 commit 44d1f60

11 files changed

Lines changed: 179 additions & 40 deletions

File tree

Cargo.lock

Lines changed: 91 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import {
1616
getStructEncoder,
1717
getU32Decoder,
1818
getU32Encoder,
19+
getU64Decoder,
20+
getU64Encoder,
1921
getUtf8Decoder,
2022
getUtf8Encoder,
2123
transformEncoder,
@@ -98,7 +100,7 @@ export function getAuthorizeCheckedWithSeedInstructionDataEncoder(): Encoder<Aut
98100
getStructEncoder([
99101
['discriminator', getU32Encoder()],
100102
['stakeAuthorize', getStakeAuthorizeEncoder()],
101-
['authoritySeed', addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
103+
['authoritySeed', addEncoderSizePrefix(getUtf8Encoder(), getU64Encoder())],
102104
['authorityOwner', getAddressEncoder()],
103105
]),
104106
value => ({ ...value, discriminator: AUTHORIZE_CHECKED_WITH_SEED_DISCRIMINATOR }),
@@ -109,7 +111,7 @@ export function getAuthorizeCheckedWithSeedInstructionDataDecoder(): Decoder<Aut
109111
return getStructDecoder([
110112
['discriminator', getU32Decoder()],
111113
['stakeAuthorize', getStakeAuthorizeDecoder()],
112-
['authoritySeed', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
114+
['authoritySeed', addDecoderSizePrefix(getUtf8Decoder(), getU64Decoder())],
113115
['authorityOwner', getAddressDecoder()],
114116
]);
115117
}

clients/js/src/generated/instructions/authorizeWithSeed.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import {
1616
getStructEncoder,
1717
getU32Decoder,
1818
getU32Encoder,
19+
getU64Decoder,
20+
getU64Encoder,
1921
getUtf8Decoder,
2022
getUtf8Encoder,
2123
transformEncoder,
@@ -97,7 +99,7 @@ export function getAuthorizeWithSeedInstructionDataEncoder(): Encoder<AuthorizeW
9799
['discriminator', getU32Encoder()],
98100
['newAuthorizedPubkey', getAddressEncoder()],
99101
['stakeAuthorize', getStakeAuthorizeEncoder()],
100-
['authoritySeed', addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
102+
['authoritySeed', addEncoderSizePrefix(getUtf8Encoder(), getU64Encoder())],
101103
['authorityOwner', getAddressEncoder()],
102104
]),
103105
value => ({ ...value, discriminator: AUTHORIZE_WITH_SEED_DISCRIMINATOR }),
@@ -109,7 +111,7 @@ export function getAuthorizeWithSeedInstructionDataDecoder(): Decoder<AuthorizeW
109111
['discriminator', getU32Decoder()],
110112
['newAuthorizedPubkey', getAddressDecoder()],
111113
['stakeAuthorize', getStakeAuthorizeDecoder()],
112-
['authoritySeed', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
114+
['authoritySeed', addDecoderSizePrefix(getUtf8Decoder(), getU64Decoder())],
113115
['authorityOwner', getAddressDecoder()],
114116
]);
115117
}

clients/js/src/generated/types/stakeAuthorize.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
combineCodec,
1111
getEnumDecoder,
1212
getEnumEncoder,
13+
getU32Decoder,
14+
getU32Encoder,
1315
type FixedSizeCodec,
1416
type FixedSizeDecoder,
1517
type FixedSizeEncoder,
@@ -23,11 +25,11 @@ export enum StakeAuthorize {
2325
export type StakeAuthorizeArgs = StakeAuthorize;
2426

2527
export function getStakeAuthorizeEncoder(): FixedSizeEncoder<StakeAuthorizeArgs> {
26-
return getEnumEncoder(StakeAuthorize);
28+
return getEnumEncoder(StakeAuthorize, { size: getU32Encoder() });
2729
}
2830

2931
export function getStakeAuthorizeDecoder(): FixedSizeDecoder<StakeAuthorize> {
30-
return getEnumDecoder(StakeAuthorize);
32+
return getEnumDecoder(StakeAuthorize, { size: getU32Decoder() });
3133
}
3234

3335
export function getStakeAuthorizeCodec(): FixedSizeCodec<StakeAuthorizeArgs, StakeAuthorize> {

clients/rust/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ readme = "README.md"
88
license-file = "../../LICENSE"
99

1010
[features]
11-
serde = ["dep:serde", "dep:serde_with"]
11+
serde = ["dep:serde", "dep:serde_with", "kaigan/serde"]
1212

1313
[dependencies]
1414
borsh = { version = "1.6", features = ["derive"] }
15+
kaigan = { version = "0.5.0", features = ["borsh-v1"] }
1516
num-derive = "0.4"
1617
num-traits = "0.2"
1718
serde = { version = "1.0", features = ["derive"], optional = true }

clients/rust/src/generated/instructions/authorize_checked_with_seed.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use {
99
crate::generated::types::StakeAuthorize,
1010
borsh::{BorshDeserialize, BorshSerialize},
11+
kaigan::types::U64PrefixString,
1112
solana_pubkey::Pubkey,
1213
};
1314

@@ -102,7 +103,7 @@ impl Default for AuthorizeCheckedWithSeedInstructionData {
102103
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
103104
pub struct AuthorizeCheckedWithSeedInstructionArgs {
104105
pub stake_authorize: StakeAuthorize,
105-
pub authority_seed: String,
106+
pub authority_seed: U64PrefixString,
106107
pub authority_owner: Pubkey,
107108
}
108109

@@ -129,7 +130,7 @@ pub struct AuthorizeCheckedWithSeedBuilder {
129130
new_authority: Option<solana_pubkey::Pubkey>,
130131
lockup_authority: Option<solana_pubkey::Pubkey>,
131132
stake_authorize: Option<StakeAuthorize>,
132-
authority_seed: Option<String>,
133+
authority_seed: Option<U64PrefixString>,
133134
authority_owner: Option<Pubkey>,
134135
__remaining_accounts: Vec<solana_instruction::AccountMeta>,
135136
}
@@ -179,7 +180,7 @@ impl AuthorizeCheckedWithSeedBuilder {
179180
self
180181
}
181182
#[inline(always)]
182-
pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self {
183+
pub fn authority_seed(&mut self, authority_seed: U64PrefixString) -> &mut Self {
183184
self.authority_seed = Some(authority_seed);
184185
self
185186
}
@@ -439,7 +440,7 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> {
439440
self
440441
}
441442
#[inline(always)]
442-
pub fn authority_seed(&mut self, authority_seed: String) -> &mut Self {
443+
pub fn authority_seed(&mut self, authority_seed: U64PrefixString) -> &mut Self {
443444
self.instruction.authority_seed = Some(authority_seed);
444445
self
445446
}
@@ -535,7 +536,7 @@ struct AuthorizeCheckedWithSeedCpiBuilderInstruction<'a, 'b> {
535536
new_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
536537
lockup_authority: Option<&'b solana_account_info::AccountInfo<'a>>,
537538
stake_authorize: Option<StakeAuthorize>,
538-
authority_seed: Option<String>,
539+
authority_seed: Option<U64PrefixString>,
539540
authority_owner: Option<Pubkey>,
540541
/// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
541542
__remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>,

0 commit comments

Comments
 (0)