Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 6 additions & 23 deletions packages/abl/idl/abl_srfc37.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
"seeds": [
{
"kind": "account",
"path": "list_config.seed",
"account": "ListConfig"
"path": "list_config"
},
{
"kind": "arg",
Expand Down Expand Up @@ -179,27 +178,7 @@
"name": "list_config"
},
{
"name": "ebalts_mint_config",
"pda": {
"seeds": [
{
"kind": "const",
"value": [77, 73, 78, 84, 95, 67, 79, 78, 70, 73, 71]
},
{
"kind": "account",
"path": "mint"
}
],
"program": {
"kind": "const",
"value": [
202, 3, 2, 25, 133, 31, 219, 239, 24, 84, 179, 198, 92, 76, 228,
172, 204, 14, 138, 90, 35, 151, 49, 178, 41, 166, 250, 0, 0, 0,
0, 0
]
}
}
"name": "ebalts_mint_config"
},
{
"name": "mint"
Expand Down Expand Up @@ -297,6 +276,10 @@
{
"name": "wallet",
"type": "pubkey"
},
{
"name": "list_config",
"type": "pubkey"
}
]
}
Expand Down
12 changes: 9 additions & 3 deletions packages/abl/src/generated/accounts/aBWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,20 @@ export function getABWalletDiscriminatorBytes() {
return fixEncoderSize(getBytesEncoder(), 8).encode(A_B_WALLET_DISCRIMINATOR);
}

export type ABWallet = { discriminator: ReadonlyUint8Array; wallet: Address };
export type ABWallet = {
discriminator: ReadonlyUint8Array;
wallet: Address;
listConfig: Address;
};

export type ABWalletArgs = { wallet: Address };
export type ABWalletArgs = { wallet: Address; listConfig: Address };

export function getABWalletEncoder(): FixedSizeEncoder<ABWalletArgs> {
return transformEncoder(
getStructEncoder([
['discriminator', fixEncoderSize(getBytesEncoder(), 8)],
['wallet', getAddressEncoder()],
['listConfig', getAddressEncoder()],
]),
value => ({ ...value, discriminator: A_B_WALLET_DISCRIMINATOR })
);
Expand All @@ -61,6 +66,7 @@ export function getABWalletDecoder(): FixedSizeDecoder<ABWallet> {
return getStructDecoder([
['discriminator', fixDecoderSize(getBytesDecoder(), 8)],
['wallet', getAddressDecoder()],
['listConfig', getAddressDecoder()],
]);
}

Expand Down Expand Up @@ -122,5 +128,5 @@ export async function fetchAllMaybeABWallet(
}

export function getABWalletSize(): number {
return 40;
return 72;
}
100 changes: 99 additions & 1 deletion packages/abl/src/generated/instructions/addWalletToList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
getAddressEncoder,
getBytesDecoder,
getBytesEncoder,
getProgramDerivedAddress,
getStructDecoder,
getStructEncoder,
transformEncoder,
Expand All @@ -33,7 +34,12 @@ import {
type WritableSignerAccount,
} from '@solana/kit';
import { ABL_SRFC37_PROGRAM_ADDRESS } from '../programs';
import { getAccountMetaFactory, type ResolvedAccount } from '../shared';
import {
expectAddress,
expectSome,
getAccountMetaFactory,
type ResolvedAccount,
} from '../shared';

export const ADD_WALLET_TO_LIST_DISCRIMINATOR = new Uint8Array([
249, 25, 0, 35, 88, 124, 60, 201,
Expand Down Expand Up @@ -109,6 +115,98 @@ export function getAddWalletToListInstructionDataCodec(): FixedSizeCodec<
);
}

export type AddWalletToListAsyncInput<
TAccountAuthority extends string = string,
TAccountListConfig extends string = string,
TAccountAbWallet extends string = string,
TAccountSystemProgram extends string = string,
> = {
authority: TransactionSigner<TAccountAuthority>;
listConfig: Address<TAccountListConfig>;
abWallet?: Address<TAccountAbWallet>;
systemProgram?: Address<TAccountSystemProgram>;
wallet: AddWalletToListInstructionDataArgs['wallet'];
};

export async function getAddWalletToListInstructionAsync<
TAccountAuthority extends string,
TAccountListConfig extends string,
TAccountAbWallet extends string,
TAccountSystemProgram extends string,
TProgramAddress extends Address = typeof ABL_SRFC37_PROGRAM_ADDRESS,
>(
input: AddWalletToListAsyncInput<
TAccountAuthority,
TAccountListConfig,
TAccountAbWallet,
TAccountSystemProgram
>,
config?: { programAddress?: TProgramAddress }
): Promise<
AddWalletToListInstruction<
TProgramAddress,
TAccountAuthority,
TAccountListConfig,
TAccountAbWallet,
TAccountSystemProgram
>
> {
// Program address.
const programAddress = config?.programAddress ?? ABL_SRFC37_PROGRAM_ADDRESS;

// Original accounts.
const originalAccounts = {
authority: { value: input.authority ?? null, isWritable: true },
listConfig: { value: input.listConfig ?? null, isWritable: false },
abWallet: { value: input.abWallet ?? null, isWritable: true },
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
};
const accounts = originalAccounts as Record<
keyof typeof originalAccounts,
ResolvedAccount
>;

// Original args.
const args = { ...input };

// Resolve default values.
if (!accounts.abWallet.value) {
accounts.abWallet.value = await getProgramDerivedAddress({
programAddress,
seeds: [
getAddressEncoder().encode(expectAddress(accounts.listConfig.value)),
getAddressEncoder().encode(expectSome(args.wallet)),
],
});
}
if (!accounts.systemProgram.value) {
accounts.systemProgram.value =
'11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
}

const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
const instruction = {
accounts: [
getAccountMeta(accounts.authority),
getAccountMeta(accounts.listConfig),
getAccountMeta(accounts.abWallet),
getAccountMeta(accounts.systemProgram),
],
programAddress,
data: getAddWalletToListInstructionDataEncoder().encode(
args as AddWalletToListInstructionDataArgs
),
} as AddWalletToListInstruction<
TProgramAddress,
TAccountAuthority,
TAccountListConfig,
TAccountAbWallet,
TAccountSystemProgram
>;

return instruction;
}

export type AddWalletToListInput<
TAccountAuthority extends string = string,
TAccountListConfig extends string = string,
Expand Down
14 changes: 1 addition & 13 deletions packages/abl/src/generated/instructions/setExtraMetasThaw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export type SetExtraMetasThawAsyncInput<
> = {
authority: TransactionSigner<TAccountAuthority>;
listConfig: Address<TAccountListConfig>;
ebaltsMintConfig?: Address<TAccountEbaltsMintConfig>;
ebaltsMintConfig: Address<TAccountEbaltsMintConfig>;
mint: Address<TAccountMint>;
extraMetasThaw?: Address<TAccountExtraMetasThaw>;
systemProgram?: Address<TAccountSystemProgram>;
Expand Down Expand Up @@ -182,18 +182,6 @@ export async function getSetExtraMetasThawInstructionAsync<
>;

// Resolve default values.
if (!accounts.ebaltsMintConfig.value) {
accounts.ebaltsMintConfig.value = await getProgramDerivedAddress({
programAddress:
'Eba1ts11111111111111111111111111111111111111' as Address<'Eba1ts11111111111111111111111111111111111111'>,
seeds: [
getBytesEncoder().encode(
new Uint8Array([77, 73, 78, 84, 95, 67, 79, 78, 70, 73, 71])
),
getAddressEncoder().encode(expectAddress(accounts.mint.value)),
],
});
}
if (!accounts.extraMetasThaw.value) {
accounts.extraMetasThaw.value = await getProgramDerivedAddress({
programAddress,
Expand Down
97 changes: 0 additions & 97 deletions packages/sdk/src/abl/createList.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/sdk/src/abl/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './createList';
export * from './list';
export * from './utils';
export * from './setExtraMetas';
Loading