Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.DS_Store
target
test-ledger

node_modules/
144 changes: 144 additions & 0 deletions clients/js/src/generated/accounts/automation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/**
* This code was AUTOGENERATED using the Codama library.
* Please DO NOT EDIT THIS FILE, instead use visitors
* to add features, then rerun Codama to update it.
*
* @see https://github.com/codama-idl/codama
*/

import {
assertAccountExists,
assertAccountsExist,
combineCodec,
decodeAccount,
fetchEncodedAccount,
fetchEncodedAccounts,
getAddressDecoder,
getAddressEncoder,
getStructDecoder,
getStructEncoder,
getU64Decoder,
getU64Encoder,
type Account,
type Address,
type EncodedAccount,
type FetchAccountConfig,
type FetchAccountsConfig,
type FixedSizeCodec,
type FixedSizeDecoder,
type FixedSizeEncoder,
type MaybeAccount,
type MaybeEncodedAccount,
} from "@solana/kit";

/** Automation parameters for automated mining deployments. */
export type Automation = {
amount: bigint;
authority: Address;
balance: bigint;
executor: Address;
fee: bigint;
strategy: bigint;
mask: bigint;
};

export type AutomationArgs = {
amount: number | bigint;
authority: Address;
balance: number | bigint;
executor: Address;
fee: number | bigint;
strategy: number | bigint;
mask: number | bigint;
};

/** Gets the encoder for {@link AutomationArgs} account data. */
export function getAutomationEncoder(): FixedSizeEncoder<AutomationArgs> {
return getStructEncoder([
["amount", getU64Encoder()],
["authority", getAddressEncoder()],
["balance", getU64Encoder()],
["executor", getAddressEncoder()],
["fee", getU64Encoder()],
["strategy", getU64Encoder()],
["mask", getU64Encoder()],
]);
}

/** Gets the decoder for {@link Automation} account data. */
export function getAutomationDecoder(): FixedSizeDecoder<Automation> {
return getStructDecoder([
["amount", getU64Decoder()],
["authority", getAddressDecoder()],
["balance", getU64Decoder()],
["executor", getAddressDecoder()],
["fee", getU64Decoder()],
["strategy", getU64Decoder()],
["mask", getU64Decoder()],
]);
}

/** Gets the codec for {@link Automation} account data. */
export function getAutomationCodec(): FixedSizeCodec<
AutomationArgs,
Automation
> {
return combineCodec(getAutomationEncoder(), getAutomationDecoder());
}

export function decodeAutomation<TAddress extends string = string>(
encodedAccount: EncodedAccount<TAddress>,
): Account<Automation, TAddress>;
export function decodeAutomation<TAddress extends string = string>(
encodedAccount: MaybeEncodedAccount<TAddress>,
): MaybeAccount<Automation, TAddress>;
export function decodeAutomation<TAddress extends string = string>(
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>,
): Account<Automation, TAddress> | MaybeAccount<Automation, TAddress> {
return decodeAccount(
encodedAccount as MaybeEncodedAccount<TAddress>,
getAutomationDecoder(),
);
}

export async function fetchAutomation<TAddress extends string = string>(
rpc: Parameters<typeof fetchEncodedAccount>[0],
address: Address<TAddress>,
config?: FetchAccountConfig,
): Promise<Account<Automation, TAddress>> {
const maybeAccount = await fetchMaybeAutomation(rpc, address, config);
assertAccountExists(maybeAccount);
return maybeAccount;
}

export async function fetchMaybeAutomation<TAddress extends string = string>(
rpc: Parameters<typeof fetchEncodedAccount>[0],
address: Address<TAddress>,
config?: FetchAccountConfig,
): Promise<MaybeAccount<Automation, TAddress>> {
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
return decodeAutomation(maybeAccount);
}

export async function fetchAllAutomation(
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
config?: FetchAccountsConfig,
): Promise<Account<Automation>[]> {
const maybeAccounts = await fetchAllMaybeAutomation(rpc, addresses, config);
assertAccountsExist(maybeAccounts);
return maybeAccounts;
}

export async function fetchAllMaybeAutomation(
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
config?: FetchAccountsConfig,
): Promise<MaybeAccount<Automation>[]> {
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
return maybeAccounts.map((maybeAccount) => decodeAutomation(maybeAccount));
}

export function getAutomationSize(): number {
return 104;
}
127 changes: 127 additions & 0 deletions clients/js/src/generated/accounts/board.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/**
* This code was AUTOGENERATED using the Codama library.
* Please DO NOT EDIT THIS FILE, instead use visitors
* to add features, then rerun Codama to update it.
*
* @see https://github.com/codama-idl/codama
*/

import {
assertAccountExists,
assertAccountsExist,
combineCodec,
decodeAccount,
fetchEncodedAccount,
fetchEncodedAccounts,
getStructDecoder,
getStructEncoder,
getU64Decoder,
getU64Encoder,
type Account,
type Address,
type EncodedAccount,
type FetchAccountConfig,
type FetchAccountsConfig,
type FixedSizeCodec,
type FixedSizeDecoder,
type FixedSizeEncoder,
type MaybeAccount,
type MaybeEncodedAccount,
} from "@solana/kit";

/** Global round tracking for the mining game. */
export type Board = {
roundId: bigint;
startSlot: bigint;
endSlot: bigint;
epochId: bigint;
};

export type BoardArgs = {
roundId: number | bigint;
startSlot: number | bigint;
endSlot: number | bigint;
epochId: number | bigint;
};

/** Gets the encoder for {@link BoardArgs} account data. */
export function getBoardEncoder(): FixedSizeEncoder<BoardArgs> {
return getStructEncoder([
["roundId", getU64Encoder()],
["startSlot", getU64Encoder()],
["endSlot", getU64Encoder()],
["epochId", getU64Encoder()],
]);
}

/** Gets the decoder for {@link Board} account data. */
export function getBoardDecoder(): FixedSizeDecoder<Board> {
return getStructDecoder([
["roundId", getU64Decoder()],
["startSlot", getU64Decoder()],
["endSlot", getU64Decoder()],
["epochId", getU64Decoder()],
]);
}

/** Gets the codec for {@link Board} account data. */
export function getBoardCodec(): FixedSizeCodec<BoardArgs, Board> {
return combineCodec(getBoardEncoder(), getBoardDecoder());
}

export function decodeBoard<TAddress extends string = string>(
encodedAccount: EncodedAccount<TAddress>,
): Account<Board, TAddress>;
export function decodeBoard<TAddress extends string = string>(
encodedAccount: MaybeEncodedAccount<TAddress>,
): MaybeAccount<Board, TAddress>;
export function decodeBoard<TAddress extends string = string>(
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>,
): Account<Board, TAddress> | MaybeAccount<Board, TAddress> {
return decodeAccount(
encodedAccount as MaybeEncodedAccount<TAddress>,
getBoardDecoder(),
);
}

export async function fetchBoard<TAddress extends string = string>(
rpc: Parameters<typeof fetchEncodedAccount>[0],
address: Address<TAddress>,
config?: FetchAccountConfig,
): Promise<Account<Board, TAddress>> {
const maybeAccount = await fetchMaybeBoard(rpc, address, config);
assertAccountExists(maybeAccount);
return maybeAccount;
}

export async function fetchMaybeBoard<TAddress extends string = string>(
rpc: Parameters<typeof fetchEncodedAccount>[0],
address: Address<TAddress>,
config?: FetchAccountConfig,
): Promise<MaybeAccount<Board, TAddress>> {
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
return decodeBoard(maybeAccount);
}

export async function fetchAllBoard(
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
config?: FetchAccountsConfig,
): Promise<Account<Board>[]> {
const maybeAccounts = await fetchAllMaybeBoard(rpc, addresses, config);
assertAccountsExist(maybeAccounts);
return maybeAccounts;
}

export async function fetchAllMaybeBoard(
rpc: Parameters<typeof fetchEncodedAccounts>[0],
addresses: Array<Address>,
config?: FetchAccountsConfig,
): Promise<MaybeAccount<Board>[]> {
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
return maybeAccounts.map((maybeAccount) => decodeBoard(maybeAccount));
}

export function getBoardSize(): number {
return 32;
}
Loading