Skip to content

Commit dab2dc0

Browse files
version 0.3.13 snapshot
1 parent 9a00137 commit dab2dc0

File tree

10 files changed

+780
-536
lines changed

10 files changed

+780
-536
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ solana = "1.18.18"
88
# Specify Rust toolchains for rustfmt, clippy, and build.
99
# Any unprovided toolchains default to stable.
1010
[workspace.metadata.toolchains]
11-
format = "1.79.0"
12-
lint = "1.79.0"
11+
format = "1.81.0"
12+
lint = "1.81.0"

clients/js/src/generated/accounts/counter.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ import {
3434
import { CounterSeeds, findCounterPda } from '../pdas';
3535
import { Key, getKeyDecoder, getKeyEncoder } from '../types';
3636

37+
export const COUNTER_KEY = Key.Counter;
38+
39+
export function getCounterKeyBytes() {
40+
return getKeyEncoder().encode(COUNTER_KEY);
41+
}
42+
3743
export type Counter = { key: Key; authority: Address; value: number };
3844

3945
export type CounterArgs = { authority: Address; value: number };
@@ -45,7 +51,7 @@ export function getCounterEncoder(): Encoder<CounterArgs> {
4551
['authority', getAddressEncoder()],
4652
['value', getU32Encoder()],
4753
]),
48-
(value) => ({ ...value, key: Key.Counter })
54+
(value) => ({ ...value, key: COUNTER_KEY })
4955
);
5056
}
5157

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

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ import {
4040
type ResolvedAccount,
4141
} from '../shared';
4242

43+
export const CREATE_DISCRIMINATOR = 0;
44+
45+
export function getCreateDiscriminatorBytes() {
46+
return getU8Encoder().encode(CREATE_DISCRIMINATOR);
47+
}
48+
4349
export type CreateInstruction<
4450
TProgram extends string = typeof COUNTER_PROGRAM_ADDRESS,
4551
TAccountCounter extends string | IAccountMeta<string> = string,
@@ -78,7 +84,7 @@ export type CreateInstructionDataArgs = {};
7884
export function getCreateInstructionDataEncoder(): Encoder<CreateInstructionDataArgs> {
7985
return transformEncoder(
8086
getStructEncoder([['discriminator', getU8Encoder()]]),
81-
(value) => ({ ...value, discriminator: 0 })
87+
(value) => ({ ...value, discriminator: CREATE_DISCRIMINATOR })
8288
);
8389
}
8490

@@ -117,16 +123,18 @@ export async function getCreateInstructionAsync<
117123
TAccountAuthority extends string,
118124
TAccountPayer extends string,
119125
TAccountSystemProgram extends string,
126+
TProgramAddress extends Address = typeof COUNTER_PROGRAM_ADDRESS,
120127
>(
121128
input: CreateAsyncInput<
122129
TAccountCounter,
123130
TAccountAuthority,
124131
TAccountPayer,
125132
TAccountSystemProgram
126-
>
133+
>,
134+
config?: { programAddress?: TProgramAddress }
127135
): Promise<
128136
CreateInstruction<
129-
typeof COUNTER_PROGRAM_ADDRESS,
137+
TProgramAddress,
130138
TAccountCounter,
131139
TAccountAuthority,
132140
TAccountPayer,
@@ -135,7 +143,7 @@ export async function getCreateInstructionAsync<
135143
IInstructionWithByteDelta
136144
> {
137145
// Program address.
138-
const programAddress = COUNTER_PROGRAM_ADDRESS;
146+
const programAddress = config?.programAddress ?? COUNTER_PROGRAM_ADDRESS;
139147

140148
// Original accounts.
141149
const originalAccounts = {
@@ -180,7 +188,7 @@ export async function getCreateInstructionAsync<
180188
programAddress,
181189
data: getCreateInstructionDataEncoder().encode({}),
182190
} as CreateInstruction<
183-
typeof COUNTER_PROGRAM_ADDRESS,
191+
TProgramAddress,
184192
TAccountCounter,
185193
TAccountAuthority,
186194
TAccountPayer,
@@ -211,23 +219,25 @@ export function getCreateInstruction<
211219
TAccountAuthority extends string,
212220
TAccountPayer extends string,
213221
TAccountSystemProgram extends string,
222+
TProgramAddress extends Address = typeof COUNTER_PROGRAM_ADDRESS,
214223
>(
215224
input: CreateInput<
216225
TAccountCounter,
217226
TAccountAuthority,
218227
TAccountPayer,
219228
TAccountSystemProgram
220-
>
229+
>,
230+
config?: { programAddress?: TProgramAddress }
221231
): CreateInstruction<
222-
typeof COUNTER_PROGRAM_ADDRESS,
232+
TProgramAddress,
223233
TAccountCounter,
224234
TAccountAuthority,
225235
TAccountPayer,
226236
TAccountSystemProgram
227237
> &
228238
IInstructionWithByteDelta {
229239
// Program address.
230-
const programAddress = COUNTER_PROGRAM_ADDRESS;
240+
const programAddress = config?.programAddress ?? COUNTER_PROGRAM_ADDRESS;
231241

232242
// Original accounts.
233243
const originalAccounts = {
@@ -267,7 +277,7 @@ export function getCreateInstruction<
267277
programAddress,
268278
data: getCreateInstructionDataEncoder().encode({}),
269279
} as CreateInstruction<
270-
typeof COUNTER_PROGRAM_ADDRESS,
280+
TProgramAddress,
271281
TAccountCounter,
272282
TAccountAuthority,
273283
TAccountPayer,

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

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ import {
4141
type ResolvedAccount,
4242
} from '../shared';
4343

44+
export const INCREMENT_DISCRIMINATOR = 1;
45+
46+
export function getIncrementDiscriminatorBytes() {
47+
return getU8Encoder().encode(INCREMENT_DISCRIMINATOR);
48+
}
49+
4450
export type IncrementInstruction<
4551
TProgram extends string = typeof COUNTER_PROGRAM_ADDRESS,
4652
TAccountCounter extends string | IAccountMeta<string> = string,
@@ -76,7 +82,11 @@ export function getIncrementInstructionDataEncoder(): Encoder<IncrementInstructi
7682
['discriminator', getU8Encoder()],
7783
['amount', getOptionEncoder(getU32Encoder())],
7884
]),
79-
(value) => ({ ...value, discriminator: 1, amount: value.amount ?? none() })
85+
(value) => ({
86+
...value,
87+
discriminator: INCREMENT_DISCRIMINATOR,
88+
amount: value.amount ?? none(),
89+
})
8090
);
8191
}
8292

@@ -111,17 +121,15 @@ export type IncrementAsyncInput<
111121
export async function getIncrementInstructionAsync<
112122
TAccountCounter extends string,
113123
TAccountAuthority extends string,
124+
TProgramAddress extends Address = typeof COUNTER_PROGRAM_ADDRESS,
114125
>(
115-
input: IncrementAsyncInput<TAccountCounter, TAccountAuthority>
126+
input: IncrementAsyncInput<TAccountCounter, TAccountAuthority>,
127+
config?: { programAddress?: TProgramAddress }
116128
): Promise<
117-
IncrementInstruction<
118-
typeof COUNTER_PROGRAM_ADDRESS,
119-
TAccountCounter,
120-
TAccountAuthority
121-
>
129+
IncrementInstruction<TProgramAddress, TAccountCounter, TAccountAuthority>
122130
> {
123131
// Program address.
124-
const programAddress = COUNTER_PROGRAM_ADDRESS;
132+
const programAddress = config?.programAddress ?? COUNTER_PROGRAM_ADDRESS;
125133

126134
// Original accounts.
127135
const originalAccounts = {
@@ -154,7 +162,7 @@ export async function getIncrementInstructionAsync<
154162
args as IncrementInstructionDataArgs
155163
),
156164
} as IncrementInstruction<
157-
typeof COUNTER_PROGRAM_ADDRESS,
165+
TProgramAddress,
158166
TAccountCounter,
159167
TAccountAuthority
160168
>;
@@ -176,15 +184,13 @@ export type IncrementInput<
176184
export function getIncrementInstruction<
177185
TAccountCounter extends string,
178186
TAccountAuthority extends string,
187+
TProgramAddress extends Address = typeof COUNTER_PROGRAM_ADDRESS,
179188
>(
180-
input: IncrementInput<TAccountCounter, TAccountAuthority>
181-
): IncrementInstruction<
182-
typeof COUNTER_PROGRAM_ADDRESS,
183-
TAccountCounter,
184-
TAccountAuthority
185-
> {
189+
input: IncrementInput<TAccountCounter, TAccountAuthority>,
190+
config?: { programAddress?: TProgramAddress }
191+
): IncrementInstruction<TProgramAddress, TAccountCounter, TAccountAuthority> {
186192
// Program address.
187-
const programAddress = COUNTER_PROGRAM_ADDRESS;
193+
const programAddress = config?.programAddress ?? COUNTER_PROGRAM_ADDRESS;
188194

189195
// Original accounts.
190196
const originalAccounts = {
@@ -210,7 +216,7 @@ export function getIncrementInstruction<
210216
args as IncrementInstructionDataArgs
211217
),
212218
} as IncrementInstruction<
213-
typeof COUNTER_PROGRAM_ADDRESS,
219+
TProgramAddress,
214220
TAccountCounter,
215221
TAccountAuthority
216222
>;

clients/rust/Cargo.toml

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

1010
[features]
11+
anchor = ["dep:anchor-lang"]
1112
test-sbf = []
1213
serde = ["dep:serde", "dep:serde_with"]
1314

1415
[dependencies]
16+
anchor-lang = { version = "0.30.0", optional = true }
1517
borsh = "^0.10"
1618
num-derive = "^0.3"
1719
num-traits = "^0.2"

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
},
2626
"devDependencies": {
2727
"@iarna/toml": "^2.2.5",
28-
"@kinobi-so/nodes-from-anchor": "^0.20.9",
29-
"@kinobi-so/renderers-js": "^0.21.2",
30-
"@kinobi-so/renderers-rust": "^0.21.0",
28+
"@kinobi-so/nodes-from-anchor": "^0.21.3",
29+
"@kinobi-so/renderers-js": "^0.21.9",
30+
"@kinobi-so/renderers-rust": "^0.21.7",
3131
"@metaplex-foundation/shank-js": "^0.1.7",
32-
"kinobi": "^0.21.0",
32+
"kinobi": "^0.21.5",
3333
"typescript": "^5.5.2",
3434
"zx": "^7.2.3"
3535
},

0 commit comments

Comments
 (0)