diff --git a/sdk/codama.descro.json b/sdk/codama.descro.json
new file mode 100644
index 0000000..9cf422b
--- /dev/null
+++ b/sdk/codama.descro.json
@@ -0,0 +1,11 @@
+{
+ "idl": "./src/idl/descro.json",
+ "scripts": {
+ "js": [
+ {
+ "from": "@codama/renderers-js",
+ "args": ["./src/generated/descro"]
+ }
+ ]
+ }
+}
diff --git a/sdk/codama.registry.json b/sdk/codama.registry.json
new file mode 100644
index 0000000..ba07ed0
--- /dev/null
+++ b/sdk/codama.registry.json
@@ -0,0 +1,11 @@
+{
+ "idl": "./src/idl/descro_ext_resolvers.json",
+ "scripts": {
+ "js": [
+ {
+ "from": "@codama/renderers-js",
+ "args": ["./src/generated/descro_ext_resolvers"]
+ }
+ ]
+ }
+}
diff --git a/sdk/package.json b/sdk/package.json
index 60fd30a..36afcd3 100644
--- a/sdk/package.json
+++ b/sdk/package.json
@@ -4,13 +4,16 @@
"private": true,
"main": "./src/index.ts",
"types": "./src/index.ts",
+ "scripts": {
+ "generate": "codama run js --config codama.descro.json && codama run js --config codama.registry.json"
+ },
"dependencies": {
- "@coral-xyz/anchor": "^0.32.1",
- "@solana/web3.js": "^1.98.4",
- "bn.js": "^5.2.3"
+ "@solana/kit": "^6.0.0"
},
"devDependencies": {
- "@types/bn.js": "^5.2.0",
+ "@codama/nodes-from-anchor": "^1.4.1",
+ "@codama/renderers-js": "^2.2.0",
+ "codama": "^1.6.0",
"typescript": "^6.0.3"
}
}
diff --git a/sdk/src/generated/descro/package.json b/sdk/src/generated/descro/package.json
new file mode 100644
index 0000000..3250d35
--- /dev/null
+++ b/sdk/src/generated/descro/package.json
@@ -0,0 +1,22 @@
+{
+ "name": "js-client",
+ "version": "1.0.0",
+ "description": "",
+ "main": "src/index.ts",
+ "files": [
+ "./dist/src",
+ "./dist/types",
+ "./src/"
+ ],
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "keywords": [],
+ "author": "",
+ "peerDependencies": {
+ "@solana/kit": "^6.4.0"
+ },
+ "dependencies": {
+ "@solana/program-client-core": "^6.4.0"
+ }
+}
diff --git a/sdk/src/generated/descro/src/generated/accounts/escrowAccount.ts b/sdk/src/generated/descro/src/generated/accounts/escrowAccount.ts
new file mode 100644
index 0000000..68df5c5
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/accounts/escrowAccount.ts
@@ -0,0 +1,181 @@
+/**
+ * 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,
+ fixDecoderSize,
+ fixEncoderSize,
+ getAddressDecoder,
+ getAddressEncoder,
+ getBytesDecoder,
+ getBytesEncoder,
+ getOptionDecoder,
+ getOptionEncoder,
+ getStructDecoder,
+ getStructEncoder,
+ getU64Decoder,
+ getU64Encoder,
+ getU8Decoder,
+ getU8Encoder,
+ transformEncoder,
+ type Account,
+ type Address,
+ type Codec,
+ type Decoder,
+ type EncodedAccount,
+ type Encoder,
+ type FetchAccountConfig,
+ type FetchAccountsConfig,
+ type MaybeAccount,
+ type MaybeEncodedAccount,
+ type Option,
+ type OptionOrNullable,
+ type ReadonlyUint8Array,
+} from "@solana/kit";
+import {
+ getEscrowStateDecoder,
+ getEscrowStateEncoder,
+ type EscrowState,
+ type EscrowStateArgs,
+} from "../types";
+
+export const ESCROW_ACCOUNT_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
+ 36, 69, 48, 18, 128, 225, 125, 135,
+]);
+
+export function getEscrowAccountDiscriminatorBytes(): ReadonlyUint8Array {
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
+ ESCROW_ACCOUNT_DISCRIMINATOR,
+ );
+}
+
+export type EscrowAccount = {
+ discriminator: ReadonlyUint8Array;
+ seller: Address;
+ buyer: Address;
+ amount: bigint;
+ disputeResolver: Option
;
+ state: EscrowState;
+ bump: number;
+ vaultBump: number;
+ escrowId: bigint;
+};
+
+export type EscrowAccountArgs = {
+ seller: Address;
+ buyer: Address;
+ amount: number | bigint;
+ disputeResolver: OptionOrNullable;
+ state: EscrowStateArgs;
+ bump: number;
+ vaultBump: number;
+ escrowId: number | bigint;
+};
+
+/** Gets the encoder for {@link EscrowAccountArgs} account data. */
+export function getEscrowAccountEncoder(): Encoder {
+ return transformEncoder(
+ getStructEncoder([
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
+ ["seller", getAddressEncoder()],
+ ["buyer", getAddressEncoder()],
+ ["amount", getU64Encoder()],
+ ["disputeResolver", getOptionEncoder(getAddressEncoder())],
+ ["state", getEscrowStateEncoder()],
+ ["bump", getU8Encoder()],
+ ["vaultBump", getU8Encoder()],
+ ["escrowId", getU64Encoder()],
+ ]),
+ (value) => ({ ...value, discriminator: ESCROW_ACCOUNT_DISCRIMINATOR }),
+ );
+}
+
+/** Gets the decoder for {@link EscrowAccount} account data. */
+export function getEscrowAccountDecoder(): Decoder {
+ return getStructDecoder([
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
+ ["seller", getAddressDecoder()],
+ ["buyer", getAddressDecoder()],
+ ["amount", getU64Decoder()],
+ ["disputeResolver", getOptionDecoder(getAddressDecoder())],
+ ["state", getEscrowStateDecoder()],
+ ["bump", getU8Decoder()],
+ ["vaultBump", getU8Decoder()],
+ ["escrowId", getU64Decoder()],
+ ]);
+}
+
+/** Gets the codec for {@link EscrowAccount} account data. */
+export function getEscrowAccountCodec(): Codec<
+ EscrowAccountArgs,
+ EscrowAccount
+> {
+ return combineCodec(getEscrowAccountEncoder(), getEscrowAccountDecoder());
+}
+
+export function decodeEscrowAccount(
+ encodedAccount: EncodedAccount,
+): Account;
+export function decodeEscrowAccount(
+ encodedAccount: MaybeEncodedAccount,
+): MaybeAccount;
+export function decodeEscrowAccount(
+ encodedAccount: EncodedAccount | MaybeEncodedAccount,
+): Account | MaybeAccount {
+ return decodeAccount(
+ encodedAccount as MaybeEncodedAccount,
+ getEscrowAccountDecoder(),
+ );
+}
+
+export async function fetchEscrowAccount(
+ rpc: Parameters[0],
+ address: Address,
+ config?: FetchAccountConfig,
+): Promise> {
+ const maybeAccount = await fetchMaybeEscrowAccount(rpc, address, config);
+ assertAccountExists(maybeAccount);
+ return maybeAccount;
+}
+
+export async function fetchMaybeEscrowAccount(
+ rpc: Parameters[0],
+ address: Address,
+ config?: FetchAccountConfig,
+): Promise> {
+ const maybeAccount = await fetchEncodedAccount(rpc, address, config);
+ return decodeEscrowAccount(maybeAccount);
+}
+
+export async function fetchAllEscrowAccount(
+ rpc: Parameters[0],
+ addresses: Array,
+ config?: FetchAccountsConfig,
+): Promise[]> {
+ const maybeAccounts = await fetchAllMaybeEscrowAccount(
+ rpc,
+ addresses,
+ config,
+ );
+ assertAccountsExist(maybeAccounts);
+ return maybeAccounts;
+}
+
+export async function fetchAllMaybeEscrowAccount(
+ rpc: Parameters[0],
+ addresses: Array,
+ config?: FetchAccountsConfig,
+): Promise[]> {
+ const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
+ return maybeAccounts.map((maybeAccount) => decodeEscrowAccount(maybeAccount));
+}
diff --git a/sdk/src/generated/descro/src/generated/accounts/index.ts b/sdk/src/generated/descro/src/generated/accounts/index.ts
new file mode 100644
index 0000000..d298919
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/accounts/index.ts
@@ -0,0 +1,9 @@
+/**
+ * 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
+ */
+
+export * from "./escrowAccount";
diff --git a/sdk/src/generated/descro/src/generated/errors/descro.ts b/sdk/src/generated/descro/src/generated/errors/descro.ts
new file mode 100644
index 0000000..d05604d
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/errors/descro.ts
@@ -0,0 +1,68 @@
+/**
+ * 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 {
+ isProgramError,
+ type Address,
+ type SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM,
+ type SolanaError,
+} from "@solana/kit";
+import { DESCRO_PROGRAM_ADDRESS } from "../programs";
+
+/** InvalidState: Invalid state for this instruction */
+export const DESCRO_ERROR__INVALID_STATE = 0x1770; // 6000
+/** Unauthorized: Signer is not authorized */
+export const DESCRO_ERROR__UNAUTHORIZED = 0x1771; // 6001
+/** NoResolverConfigured: No resolver configured for this escrow */
+export const DESCRO_ERROR__NO_RESOLVER_CONFIGURED = 0x1772; // 6002
+/** UnauthorizedResolver: Signer is not the configured resolver */
+export const DESCRO_ERROR__UNAUTHORIZED_RESOLVER = 0x1773; // 6003
+/** Expired: Escrow has expired */
+export const DESCRO_ERROR__EXPIRED = 0x1774; // 6004
+
+export type DescroError =
+ | typeof DESCRO_ERROR__EXPIRED
+ | typeof DESCRO_ERROR__INVALID_STATE
+ | typeof DESCRO_ERROR__NO_RESOLVER_CONFIGURED
+ | typeof DESCRO_ERROR__UNAUTHORIZED
+ | typeof DESCRO_ERROR__UNAUTHORIZED_RESOLVER;
+
+let descroErrorMessages: Record | undefined;
+if (process.env["NODE_ENV"] !== "production") {
+ descroErrorMessages = {
+ [DESCRO_ERROR__EXPIRED]: `Escrow has expired`,
+ [DESCRO_ERROR__INVALID_STATE]: `Invalid state for this instruction`,
+ [DESCRO_ERROR__NO_RESOLVER_CONFIGURED]: `No resolver configured for this escrow`,
+ [DESCRO_ERROR__UNAUTHORIZED]: `Signer is not authorized`,
+ [DESCRO_ERROR__UNAUTHORIZED_RESOLVER]: `Signer is not the configured resolver`,
+ };
+}
+
+export function getDescroErrorMessage(code: DescroError): string {
+ if (process.env["NODE_ENV"] !== "production") {
+ return (descroErrorMessages as Record)[code];
+ }
+
+ return "Error message not available in production bundles.";
+}
+
+export function isDescroError(
+ error: unknown,
+ transactionMessage: {
+ instructions: Record;
+ },
+ code?: TProgramErrorCode,
+): error is SolanaError &
+ Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> {
+ return isProgramError(
+ error,
+ transactionMessage,
+ DESCRO_PROGRAM_ADDRESS,
+ code,
+ );
+}
diff --git a/sdk/src/generated/descro/src/generated/errors/index.ts b/sdk/src/generated/descro/src/generated/errors/index.ts
new file mode 100644
index 0000000..3d77c4e
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/errors/index.ts
@@ -0,0 +1,9 @@
+/**
+ * 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
+ */
+
+export * from "./descro";
diff --git a/sdk/src/generated/descro/src/generated/index.ts b/sdk/src/generated/descro/src/generated/index.ts
new file mode 100644
index 0000000..74d2752
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/index.ts
@@ -0,0 +1,14 @@
+/**
+ * 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
+ */
+
+export * from "./accounts";
+export * from "./errors";
+export * from "./instructions";
+export * from "./pdas";
+export * from "./programs";
+export * from "./types";
diff --git a/sdk/src/generated/descro/src/generated/instructions/cancel.ts b/sdk/src/generated/descro/src/generated/instructions/cancel.ts
new file mode 100644
index 0000000..a3ac96f
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/instructions/cancel.ts
@@ -0,0 +1,211 @@
+/**
+ * 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 {
+ combineCodec,
+ fixDecoderSize,
+ fixEncoderSize,
+ getBytesDecoder,
+ getBytesEncoder,
+ getStructDecoder,
+ getStructEncoder,
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
+ SolanaError,
+ transformEncoder,
+ type AccountMeta,
+ type AccountSignerMeta,
+ type Address,
+ type FixedSizeCodec,
+ type FixedSizeDecoder,
+ type FixedSizeEncoder,
+ type Instruction,
+ type InstructionWithAccounts,
+ type InstructionWithData,
+ type ReadonlyAccount,
+ type ReadonlyUint8Array,
+ type TransactionSigner,
+ type WritableAccount,
+ type WritableSignerAccount,
+} from "@solana/kit";
+import {
+ getAccountMetaFactory,
+ type ResolvedInstructionAccount,
+} from "@solana/program-client-core";
+import { DESCRO_PROGRAM_ADDRESS } from "../programs";
+
+export const CANCEL_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
+ 232, 219, 223, 41, 219, 236, 220, 190,
+]);
+
+export function getCancelDiscriminatorBytes(): ReadonlyUint8Array {
+ return fixEncoderSize(getBytesEncoder(), 8).encode(CANCEL_DISCRIMINATOR);
+}
+
+export type CancelInstruction<
+ TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
+ TAccountSeller extends string | AccountMeta = string,
+ TAccountEscrowAccount extends string | AccountMeta = string,
+ TAccountSystemProgram extends string | AccountMeta =
+ "11111111111111111111111111111111",
+ TRemainingAccounts extends readonly AccountMeta[] = [],
+> = Instruction &
+ InstructionWithData &
+ InstructionWithAccounts<
+ [
+ TAccountSeller extends string
+ ? WritableSignerAccount &
+ AccountSignerMeta
+ : TAccountSeller,
+ TAccountEscrowAccount extends string
+ ? WritableAccount
+ : TAccountEscrowAccount,
+ TAccountSystemProgram extends string
+ ? ReadonlyAccount
+ : TAccountSystemProgram,
+ ...TRemainingAccounts,
+ ]
+ >;
+
+export type CancelInstructionData = { discriminator: ReadonlyUint8Array };
+
+export type CancelInstructionDataArgs = {};
+
+export function getCancelInstructionDataEncoder(): FixedSizeEncoder {
+ return transformEncoder(
+ getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
+ (value) => ({ ...value, discriminator: CANCEL_DISCRIMINATOR }),
+ );
+}
+
+export function getCancelInstructionDataDecoder(): FixedSizeDecoder {
+ return getStructDecoder([
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
+ ]);
+}
+
+export function getCancelInstructionDataCodec(): FixedSizeCodec<
+ CancelInstructionDataArgs,
+ CancelInstructionData
+> {
+ return combineCodec(
+ getCancelInstructionDataEncoder(),
+ getCancelInstructionDataDecoder(),
+ );
+}
+
+export type CancelInput<
+ TAccountSeller extends string = string,
+ TAccountEscrowAccount extends string = string,
+ TAccountSystemProgram extends string = string,
+> = {
+ seller: TransactionSigner;
+ escrowAccount: Address;
+ systemProgram?: Address;
+};
+
+export function getCancelInstruction<
+ TAccountSeller extends string,
+ TAccountEscrowAccount extends string,
+ TAccountSystemProgram extends string,
+ TProgramAddress extends Address = typeof DESCRO_PROGRAM_ADDRESS,
+>(
+ input: CancelInput<
+ TAccountSeller,
+ TAccountEscrowAccount,
+ TAccountSystemProgram
+ >,
+ config?: { programAddress?: TProgramAddress },
+): CancelInstruction<
+ TProgramAddress,
+ TAccountSeller,
+ TAccountEscrowAccount,
+ TAccountSystemProgram
+> {
+ // Program address.
+ const programAddress = config?.programAddress ?? DESCRO_PROGRAM_ADDRESS;
+
+ // Original accounts.
+ const originalAccounts = {
+ seller: { value: input.seller ?? null, isWritable: true },
+ escrowAccount: { value: input.escrowAccount ?? null, isWritable: true },
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
+ };
+ const accounts = originalAccounts as Record<
+ keyof typeof originalAccounts,
+ ResolvedInstructionAccount
+ >;
+
+ // Resolve default values.
+ if (!accounts.systemProgram.value) {
+ accounts.systemProgram.value =
+ "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
+ }
+
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
+ return Object.freeze({
+ accounts: [
+ getAccountMeta("seller", accounts.seller),
+ getAccountMeta("escrowAccount", accounts.escrowAccount),
+ getAccountMeta("systemProgram", accounts.systemProgram),
+ ],
+ data: getCancelInstructionDataEncoder().encode({}),
+ programAddress,
+ } as CancelInstruction<
+ TProgramAddress,
+ TAccountSeller,
+ TAccountEscrowAccount,
+ TAccountSystemProgram
+ >);
+}
+
+export type ParsedCancelInstruction<
+ TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
+ TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
+> = {
+ programAddress: Address;
+ accounts: {
+ seller: TAccountMetas[0];
+ escrowAccount: TAccountMetas[1];
+ systemProgram: TAccountMetas[2];
+ };
+ data: CancelInstructionData;
+};
+
+export function parseCancelInstruction<
+ TProgram extends string,
+ TAccountMetas extends readonly AccountMeta[],
+>(
+ instruction: Instruction &
+ InstructionWithAccounts &
+ InstructionWithData,
+): ParsedCancelInstruction {
+ if (instruction.accounts.length < 3) {
+ throw new SolanaError(
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
+ {
+ actualAccountMetas: instruction.accounts.length,
+ expectedAccountMetas: 3,
+ },
+ );
+ }
+ let accountIndex = 0;
+ const getNextAccount = () => {
+ const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
+ accountIndex += 1;
+ return accountMeta;
+ };
+ return {
+ programAddress: instruction.programAddress,
+ accounts: {
+ seller: getNextAccount(),
+ escrowAccount: getNextAccount(),
+ systemProgram: getNextAccount(),
+ },
+ data: getCancelInstructionDataDecoder().decode(instruction.data),
+ };
+}
diff --git a/sdk/src/generated/descro/src/generated/instructions/complete.ts b/sdk/src/generated/descro/src/generated/instructions/complete.ts
new file mode 100644
index 0000000..5d43f22
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/instructions/complete.ts
@@ -0,0 +1,332 @@
+/**
+ * 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 {
+ combineCodec,
+ fixDecoderSize,
+ fixEncoderSize,
+ getBytesDecoder,
+ getBytesEncoder,
+ getStructDecoder,
+ getStructEncoder,
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
+ SolanaError,
+ transformEncoder,
+ type AccountMeta,
+ type AccountSignerMeta,
+ type Address,
+ type FixedSizeCodec,
+ type FixedSizeDecoder,
+ type FixedSizeEncoder,
+ type Instruction,
+ type InstructionWithAccounts,
+ type InstructionWithData,
+ type ReadonlyAccount,
+ type ReadonlySignerAccount,
+ type ReadonlyUint8Array,
+ type TransactionSigner,
+ type WritableAccount,
+} from "@solana/kit";
+import {
+ getAccountMetaFactory,
+ getAddressFromResolvedInstructionAccount,
+ type ResolvedInstructionAccount,
+} from "@solana/program-client-core";
+import { findVaultPda } from "../pdas";
+import { DESCRO_PROGRAM_ADDRESS } from "../programs";
+
+export const COMPLETE_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
+ 0, 77, 224, 147, 136, 25, 88, 76,
+]);
+
+export function getCompleteDiscriminatorBytes(): ReadonlyUint8Array {
+ return fixEncoderSize(getBytesEncoder(), 8).encode(COMPLETE_DISCRIMINATOR);
+}
+
+export type CompleteInstruction<
+ TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
+ TAccountBuyer extends string | AccountMeta = string,
+ TAccountSeller extends string | AccountMeta = string,
+ TAccountEscrowAccount extends string | AccountMeta = string,
+ TAccountVault extends string | AccountMeta = string,
+ TAccountSystemProgram extends string | AccountMeta =
+ "11111111111111111111111111111111",
+ TRemainingAccounts extends readonly AccountMeta[] = [],
+> = Instruction &
+ InstructionWithData &
+ InstructionWithAccounts<
+ [
+ TAccountBuyer extends string
+ ? ReadonlySignerAccount &
+ AccountSignerMeta
+ : TAccountBuyer,
+ TAccountSeller extends string
+ ? WritableAccount
+ : TAccountSeller,
+ TAccountEscrowAccount extends string
+ ? WritableAccount
+ : TAccountEscrowAccount,
+ TAccountVault extends string
+ ? WritableAccount
+ : TAccountVault,
+ TAccountSystemProgram extends string
+ ? ReadonlyAccount
+ : TAccountSystemProgram,
+ ...TRemainingAccounts,
+ ]
+ >;
+
+export type CompleteInstructionData = { discriminator: ReadonlyUint8Array };
+
+export type CompleteInstructionDataArgs = {};
+
+export function getCompleteInstructionDataEncoder(): FixedSizeEncoder {
+ return transformEncoder(
+ getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
+ (value) => ({ ...value, discriminator: COMPLETE_DISCRIMINATOR }),
+ );
+}
+
+export function getCompleteInstructionDataDecoder(): FixedSizeDecoder {
+ return getStructDecoder([
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
+ ]);
+}
+
+export function getCompleteInstructionDataCodec(): FixedSizeCodec<
+ CompleteInstructionDataArgs,
+ CompleteInstructionData
+> {
+ return combineCodec(
+ getCompleteInstructionDataEncoder(),
+ getCompleteInstructionDataDecoder(),
+ );
+}
+
+export type CompleteAsyncInput<
+ TAccountBuyer extends string = string,
+ TAccountSeller extends string = string,
+ TAccountEscrowAccount extends string = string,
+ TAccountVault extends string = string,
+ TAccountSystemProgram extends string = string,
+> = {
+ buyer: TransactionSigner;
+ seller: Address;
+ escrowAccount: Address;
+ vault?: Address;
+ systemProgram?: Address;
+};
+
+export async function getCompleteInstructionAsync<
+ TAccountBuyer extends string,
+ TAccountSeller extends string,
+ TAccountEscrowAccount extends string,
+ TAccountVault extends string,
+ TAccountSystemProgram extends string,
+ TProgramAddress extends Address = typeof DESCRO_PROGRAM_ADDRESS,
+>(
+ input: CompleteAsyncInput<
+ TAccountBuyer,
+ TAccountSeller,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountSystemProgram
+ >,
+ config?: { programAddress?: TProgramAddress },
+): Promise<
+ CompleteInstruction<
+ TProgramAddress,
+ TAccountBuyer,
+ TAccountSeller,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountSystemProgram
+ >
+> {
+ // Program address.
+ const programAddress = config?.programAddress ?? DESCRO_PROGRAM_ADDRESS;
+
+ // Original accounts.
+ const originalAccounts = {
+ buyer: { value: input.buyer ?? null, isWritable: false },
+ seller: { value: input.seller ?? null, isWritable: true },
+ escrowAccount: { value: input.escrowAccount ?? null, isWritable: true },
+ vault: { value: input.vault ?? null, isWritable: true },
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
+ };
+ const accounts = originalAccounts as Record<
+ keyof typeof originalAccounts,
+ ResolvedInstructionAccount
+ >;
+
+ // Resolve default values.
+ if (!accounts.vault.value) {
+ accounts.vault.value = await findVaultPda({
+ escrowAccount: getAddressFromResolvedInstructionAccount(
+ "escrowAccount",
+ accounts.escrowAccount.value,
+ ),
+ });
+ }
+ if (!accounts.systemProgram.value) {
+ accounts.systemProgram.value =
+ "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
+ }
+
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
+ return Object.freeze({
+ accounts: [
+ getAccountMeta("buyer", accounts.buyer),
+ getAccountMeta("seller", accounts.seller),
+ getAccountMeta("escrowAccount", accounts.escrowAccount),
+ getAccountMeta("vault", accounts.vault),
+ getAccountMeta("systemProgram", accounts.systemProgram),
+ ],
+ data: getCompleteInstructionDataEncoder().encode({}),
+ programAddress,
+ } as CompleteInstruction<
+ TProgramAddress,
+ TAccountBuyer,
+ TAccountSeller,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountSystemProgram
+ >);
+}
+
+export type CompleteInput<
+ TAccountBuyer extends string = string,
+ TAccountSeller extends string = string,
+ TAccountEscrowAccount extends string = string,
+ TAccountVault extends string = string,
+ TAccountSystemProgram extends string = string,
+> = {
+ buyer: TransactionSigner;
+ seller: Address;
+ escrowAccount: Address;
+ vault: Address;
+ systemProgram?: Address;
+};
+
+export function getCompleteInstruction<
+ TAccountBuyer extends string,
+ TAccountSeller extends string,
+ TAccountEscrowAccount extends string,
+ TAccountVault extends string,
+ TAccountSystemProgram extends string,
+ TProgramAddress extends Address = typeof DESCRO_PROGRAM_ADDRESS,
+>(
+ input: CompleteInput<
+ TAccountBuyer,
+ TAccountSeller,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountSystemProgram
+ >,
+ config?: { programAddress?: TProgramAddress },
+): CompleteInstruction<
+ TProgramAddress,
+ TAccountBuyer,
+ TAccountSeller,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountSystemProgram
+> {
+ // Program address.
+ const programAddress = config?.programAddress ?? DESCRO_PROGRAM_ADDRESS;
+
+ // Original accounts.
+ const originalAccounts = {
+ buyer: { value: input.buyer ?? null, isWritable: false },
+ seller: { value: input.seller ?? null, isWritable: true },
+ escrowAccount: { value: input.escrowAccount ?? null, isWritable: true },
+ vault: { value: input.vault ?? null, isWritable: true },
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
+ };
+ const accounts = originalAccounts as Record<
+ keyof typeof originalAccounts,
+ ResolvedInstructionAccount
+ >;
+
+ // Resolve default values.
+ if (!accounts.systemProgram.value) {
+ accounts.systemProgram.value =
+ "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
+ }
+
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
+ return Object.freeze({
+ accounts: [
+ getAccountMeta("buyer", accounts.buyer),
+ getAccountMeta("seller", accounts.seller),
+ getAccountMeta("escrowAccount", accounts.escrowAccount),
+ getAccountMeta("vault", accounts.vault),
+ getAccountMeta("systemProgram", accounts.systemProgram),
+ ],
+ data: getCompleteInstructionDataEncoder().encode({}),
+ programAddress,
+ } as CompleteInstruction<
+ TProgramAddress,
+ TAccountBuyer,
+ TAccountSeller,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountSystemProgram
+ >);
+}
+
+export type ParsedCompleteInstruction<
+ TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
+ TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
+> = {
+ programAddress: Address;
+ accounts: {
+ buyer: TAccountMetas[0];
+ seller: TAccountMetas[1];
+ escrowAccount: TAccountMetas[2];
+ vault: TAccountMetas[3];
+ systemProgram: TAccountMetas[4];
+ };
+ data: CompleteInstructionData;
+};
+
+export function parseCompleteInstruction<
+ TProgram extends string,
+ TAccountMetas extends readonly AccountMeta[],
+>(
+ instruction: Instruction &
+ InstructionWithAccounts &
+ InstructionWithData,
+): ParsedCompleteInstruction {
+ if (instruction.accounts.length < 5) {
+ throw new SolanaError(
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
+ {
+ actualAccountMetas: instruction.accounts.length,
+ expectedAccountMetas: 5,
+ },
+ );
+ }
+ let accountIndex = 0;
+ const getNextAccount = () => {
+ const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
+ accountIndex += 1;
+ return accountMeta;
+ };
+ return {
+ programAddress: instruction.programAddress,
+ accounts: {
+ buyer: getNextAccount(),
+ seller: getNextAccount(),
+ escrowAccount: getNextAccount(),
+ vault: getNextAccount(),
+ systemProgram: getNextAccount(),
+ },
+ data: getCompleteInstructionDataDecoder().decode(instruction.data),
+ };
+}
diff --git a/sdk/src/generated/descro/src/generated/instructions/createEscrow.ts b/sdk/src/generated/descro/src/generated/instructions/createEscrow.ts
new file mode 100644
index 0000000..ac45626
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/instructions/createEscrow.ts
@@ -0,0 +1,385 @@
+/**
+ * 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 {
+ combineCodec,
+ fixDecoderSize,
+ fixEncoderSize,
+ getAddressDecoder,
+ getAddressEncoder,
+ getBytesDecoder,
+ getBytesEncoder,
+ getOptionDecoder,
+ getOptionEncoder,
+ getStructDecoder,
+ getStructEncoder,
+ getU64Decoder,
+ getU64Encoder,
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
+ SolanaError,
+ transformEncoder,
+ type AccountMeta,
+ type AccountSignerMeta,
+ type Address,
+ type Codec,
+ type Decoder,
+ type Encoder,
+ type Instruction,
+ type InstructionWithAccounts,
+ type InstructionWithData,
+ type Option,
+ type OptionOrNullable,
+ type ReadonlyAccount,
+ type ReadonlyUint8Array,
+ type TransactionSigner,
+ type WritableAccount,
+ type WritableSignerAccount,
+} from "@solana/kit";
+import {
+ getAccountMetaFactory,
+ getAddressFromResolvedInstructionAccount,
+ getNonNullResolvedInstructionInput,
+ type ResolvedInstructionAccount,
+} from "@solana/program-client-core";
+import { findEscrowAccountPda, findVaultPda } from "../pdas";
+import { DESCRO_PROGRAM_ADDRESS } from "../programs";
+
+export const CREATE_ESCROW_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
+ 253, 215, 165, 116, 36, 108, 68, 80,
+]);
+
+export function getCreateEscrowDiscriminatorBytes(): ReadonlyUint8Array {
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
+ CREATE_ESCROW_DISCRIMINATOR,
+ );
+}
+
+export type CreateEscrowInstruction<
+ TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
+ TAccountSeller extends string | AccountMeta = string,
+ TAccountBuyer extends string | AccountMeta = string,
+ TAccountEscrowAccount extends string | AccountMeta = string,
+ TAccountVault extends string | AccountMeta = string,
+ TAccountSystemProgram extends string | AccountMeta =
+ "11111111111111111111111111111111",
+ TRemainingAccounts extends readonly AccountMeta[] = [],
+> = Instruction &
+ InstructionWithData &
+ InstructionWithAccounts<
+ [
+ TAccountSeller extends string
+ ? WritableSignerAccount &
+ AccountSignerMeta
+ : TAccountSeller,
+ TAccountBuyer extends string
+ ? ReadonlyAccount
+ : TAccountBuyer,
+ TAccountEscrowAccount extends string
+ ? WritableAccount
+ : TAccountEscrowAccount,
+ TAccountVault extends string
+ ? WritableAccount
+ : TAccountVault,
+ TAccountSystemProgram extends string
+ ? ReadonlyAccount
+ : TAccountSystemProgram,
+ ...TRemainingAccounts,
+ ]
+ >;
+
+export type CreateEscrowInstructionData = {
+ discriminator: ReadonlyUint8Array;
+ amount: bigint;
+ disputeResolver: Option;
+ escrowId: bigint;
+};
+
+export type CreateEscrowInstructionDataArgs = {
+ amount: number | bigint;
+ disputeResolver: OptionOrNullable;
+ escrowId: number | bigint;
+};
+
+export function getCreateEscrowInstructionDataEncoder(): Encoder {
+ return transformEncoder(
+ getStructEncoder([
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
+ ["amount", getU64Encoder()],
+ ["disputeResolver", getOptionEncoder(getAddressEncoder())],
+ ["escrowId", getU64Encoder()],
+ ]),
+ (value) => ({ ...value, discriminator: CREATE_ESCROW_DISCRIMINATOR }),
+ );
+}
+
+export function getCreateEscrowInstructionDataDecoder(): Decoder {
+ return getStructDecoder([
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
+ ["amount", getU64Decoder()],
+ ["disputeResolver", getOptionDecoder(getAddressDecoder())],
+ ["escrowId", getU64Decoder()],
+ ]);
+}
+
+export function getCreateEscrowInstructionDataCodec(): Codec<
+ CreateEscrowInstructionDataArgs,
+ CreateEscrowInstructionData
+> {
+ return combineCodec(
+ getCreateEscrowInstructionDataEncoder(),
+ getCreateEscrowInstructionDataDecoder(),
+ );
+}
+
+export type CreateEscrowAsyncInput<
+ TAccountSeller extends string = string,
+ TAccountBuyer extends string = string,
+ TAccountEscrowAccount extends string = string,
+ TAccountVault extends string = string,
+ TAccountSystemProgram extends string = string,
+> = {
+ seller: TransactionSigner;
+ buyer: Address;
+ escrowAccount?: Address;
+ vault?: Address;
+ systemProgram?: Address;
+ amount: CreateEscrowInstructionDataArgs["amount"];
+ disputeResolver: CreateEscrowInstructionDataArgs["disputeResolver"];
+ escrowId: CreateEscrowInstructionDataArgs["escrowId"];
+};
+
+export async function getCreateEscrowInstructionAsync<
+ TAccountSeller extends string,
+ TAccountBuyer extends string,
+ TAccountEscrowAccount extends string,
+ TAccountVault extends string,
+ TAccountSystemProgram extends string,
+ TProgramAddress extends Address = typeof DESCRO_PROGRAM_ADDRESS,
+>(
+ input: CreateEscrowAsyncInput<
+ TAccountSeller,
+ TAccountBuyer,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountSystemProgram
+ >,
+ config?: { programAddress?: TProgramAddress },
+): Promise<
+ CreateEscrowInstruction<
+ TProgramAddress,
+ TAccountSeller,
+ TAccountBuyer,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountSystemProgram
+ >
+> {
+ // Program address.
+ const programAddress = config?.programAddress ?? DESCRO_PROGRAM_ADDRESS;
+
+ // Original accounts.
+ const originalAccounts = {
+ seller: { value: input.seller ?? null, isWritable: true },
+ buyer: { value: input.buyer ?? null, isWritable: false },
+ escrowAccount: { value: input.escrowAccount ?? null, isWritable: true },
+ vault: { value: input.vault ?? null, isWritable: true },
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
+ };
+ const accounts = originalAccounts as Record<
+ keyof typeof originalAccounts,
+ ResolvedInstructionAccount
+ >;
+
+ // Original args.
+ const args = { ...input };
+
+ // Resolve default values.
+ if (!accounts.escrowAccount.value) {
+ accounts.escrowAccount.value = await findEscrowAccountPda({
+ seller: getAddressFromResolvedInstructionAccount(
+ "seller",
+ accounts.seller.value,
+ ),
+ escrowId: getNonNullResolvedInstructionInput("escrowId", args.escrowId),
+ });
+ }
+ if (!accounts.vault.value) {
+ accounts.vault.value = await findVaultPda({
+ escrowAccount: getAddressFromResolvedInstructionAccount(
+ "escrowAccount",
+ accounts.escrowAccount.value,
+ ),
+ });
+ }
+ if (!accounts.systemProgram.value) {
+ accounts.systemProgram.value =
+ "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
+ }
+
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
+ return Object.freeze({
+ accounts: [
+ getAccountMeta("seller", accounts.seller),
+ getAccountMeta("buyer", accounts.buyer),
+ getAccountMeta("escrowAccount", accounts.escrowAccount),
+ getAccountMeta("vault", accounts.vault),
+ getAccountMeta("systemProgram", accounts.systemProgram),
+ ],
+ data: getCreateEscrowInstructionDataEncoder().encode(
+ args as CreateEscrowInstructionDataArgs,
+ ),
+ programAddress,
+ } as CreateEscrowInstruction<
+ TProgramAddress,
+ TAccountSeller,
+ TAccountBuyer,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountSystemProgram
+ >);
+}
+
+export type CreateEscrowInput<
+ TAccountSeller extends string = string,
+ TAccountBuyer extends string = string,
+ TAccountEscrowAccount extends string = string,
+ TAccountVault extends string = string,
+ TAccountSystemProgram extends string = string,
+> = {
+ seller: TransactionSigner;
+ buyer: Address;
+ escrowAccount: Address;
+ vault: Address;
+ systemProgram?: Address;
+ amount: CreateEscrowInstructionDataArgs["amount"];
+ disputeResolver: CreateEscrowInstructionDataArgs["disputeResolver"];
+ escrowId: CreateEscrowInstructionDataArgs["escrowId"];
+};
+
+export function getCreateEscrowInstruction<
+ TAccountSeller extends string,
+ TAccountBuyer extends string,
+ TAccountEscrowAccount extends string,
+ TAccountVault extends string,
+ TAccountSystemProgram extends string,
+ TProgramAddress extends Address = typeof DESCRO_PROGRAM_ADDRESS,
+>(
+ input: CreateEscrowInput<
+ TAccountSeller,
+ TAccountBuyer,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountSystemProgram
+ >,
+ config?: { programAddress?: TProgramAddress },
+): CreateEscrowInstruction<
+ TProgramAddress,
+ TAccountSeller,
+ TAccountBuyer,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountSystemProgram
+> {
+ // Program address.
+ const programAddress = config?.programAddress ?? DESCRO_PROGRAM_ADDRESS;
+
+ // Original accounts.
+ const originalAccounts = {
+ seller: { value: input.seller ?? null, isWritable: true },
+ buyer: { value: input.buyer ?? null, isWritable: false },
+ escrowAccount: { value: input.escrowAccount ?? null, isWritable: true },
+ vault: { value: input.vault ?? null, isWritable: true },
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
+ };
+ const accounts = originalAccounts as Record<
+ keyof typeof originalAccounts,
+ ResolvedInstructionAccount
+ >;
+
+ // Original args.
+ const args = { ...input };
+
+ // Resolve default values.
+ if (!accounts.systemProgram.value) {
+ accounts.systemProgram.value =
+ "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
+ }
+
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
+ return Object.freeze({
+ accounts: [
+ getAccountMeta("seller", accounts.seller),
+ getAccountMeta("buyer", accounts.buyer),
+ getAccountMeta("escrowAccount", accounts.escrowAccount),
+ getAccountMeta("vault", accounts.vault),
+ getAccountMeta("systemProgram", accounts.systemProgram),
+ ],
+ data: getCreateEscrowInstructionDataEncoder().encode(
+ args as CreateEscrowInstructionDataArgs,
+ ),
+ programAddress,
+ } as CreateEscrowInstruction<
+ TProgramAddress,
+ TAccountSeller,
+ TAccountBuyer,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountSystemProgram
+ >);
+}
+
+export type ParsedCreateEscrowInstruction<
+ TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
+ TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
+> = {
+ programAddress: Address;
+ accounts: {
+ seller: TAccountMetas[0];
+ buyer: TAccountMetas[1];
+ escrowAccount: TAccountMetas[2];
+ vault: TAccountMetas[3];
+ systemProgram: TAccountMetas[4];
+ };
+ data: CreateEscrowInstructionData;
+};
+
+export function parseCreateEscrowInstruction<
+ TProgram extends string,
+ TAccountMetas extends readonly AccountMeta[],
+>(
+ instruction: Instruction &
+ InstructionWithAccounts &
+ InstructionWithData,
+): ParsedCreateEscrowInstruction {
+ if (instruction.accounts.length < 5) {
+ throw new SolanaError(
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
+ {
+ actualAccountMetas: instruction.accounts.length,
+ expectedAccountMetas: 5,
+ },
+ );
+ }
+ let accountIndex = 0;
+ const getNextAccount = () => {
+ const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
+ accountIndex += 1;
+ return accountMeta;
+ };
+ return {
+ programAddress: instruction.programAddress,
+ accounts: {
+ seller: getNextAccount(),
+ buyer: getNextAccount(),
+ escrowAccount: getNextAccount(),
+ vault: getNextAccount(),
+ systemProgram: getNextAccount(),
+ },
+ data: getCreateEscrowInstructionDataDecoder().decode(instruction.data),
+ };
+}
diff --git a/sdk/src/generated/descro/src/generated/instructions/deposit.ts b/sdk/src/generated/descro/src/generated/instructions/deposit.ts
new file mode 100644
index 0000000..1d60b5c
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/instructions/deposit.ts
@@ -0,0 +1,310 @@
+/**
+ * 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 {
+ combineCodec,
+ fixDecoderSize,
+ fixEncoderSize,
+ getBytesDecoder,
+ getBytesEncoder,
+ getStructDecoder,
+ getStructEncoder,
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
+ SolanaError,
+ transformEncoder,
+ type AccountMeta,
+ type AccountSignerMeta,
+ type Address,
+ type FixedSizeCodec,
+ type FixedSizeDecoder,
+ type FixedSizeEncoder,
+ type Instruction,
+ type InstructionWithAccounts,
+ type InstructionWithData,
+ type ReadonlyAccount,
+ type ReadonlyUint8Array,
+ type TransactionSigner,
+ type WritableAccount,
+ type WritableSignerAccount,
+} from "@solana/kit";
+import {
+ getAccountMetaFactory,
+ getAddressFromResolvedInstructionAccount,
+ type ResolvedInstructionAccount,
+} from "@solana/program-client-core";
+import { findVaultPda } from "../pdas";
+import { DESCRO_PROGRAM_ADDRESS } from "../programs";
+
+export const DEPOSIT_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
+ 242, 35, 198, 137, 82, 225, 242, 182,
+]);
+
+export function getDepositDiscriminatorBytes(): ReadonlyUint8Array {
+ return fixEncoderSize(getBytesEncoder(), 8).encode(DEPOSIT_DISCRIMINATOR);
+}
+
+export type DepositInstruction<
+ TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
+ TAccountBuyer extends string | AccountMeta = string,
+ TAccountEscrowAccount extends string | AccountMeta = string,
+ TAccountVault extends string | AccountMeta = string,
+ TAccountSystemProgram extends string | AccountMeta =
+ "11111111111111111111111111111111",
+ TRemainingAccounts extends readonly AccountMeta[] = [],
+> = Instruction &
+ InstructionWithData &
+ InstructionWithAccounts<
+ [
+ TAccountBuyer extends string
+ ? WritableSignerAccount &
+ AccountSignerMeta
+ : TAccountBuyer,
+ TAccountEscrowAccount extends string
+ ? WritableAccount
+ : TAccountEscrowAccount,
+ TAccountVault extends string
+ ? WritableAccount
+ : TAccountVault,
+ TAccountSystemProgram extends string
+ ? ReadonlyAccount
+ : TAccountSystemProgram,
+ ...TRemainingAccounts,
+ ]
+ >;
+
+export type DepositInstructionData = { discriminator: ReadonlyUint8Array };
+
+export type DepositInstructionDataArgs = {};
+
+export function getDepositInstructionDataEncoder(): FixedSizeEncoder {
+ return transformEncoder(
+ getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
+ (value) => ({ ...value, discriminator: DEPOSIT_DISCRIMINATOR }),
+ );
+}
+
+export function getDepositInstructionDataDecoder(): FixedSizeDecoder {
+ return getStructDecoder([
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
+ ]);
+}
+
+export function getDepositInstructionDataCodec(): FixedSizeCodec<
+ DepositInstructionDataArgs,
+ DepositInstructionData
+> {
+ return combineCodec(
+ getDepositInstructionDataEncoder(),
+ getDepositInstructionDataDecoder(),
+ );
+}
+
+export type DepositAsyncInput<
+ TAccountBuyer extends string = string,
+ TAccountEscrowAccount extends string = string,
+ TAccountVault extends string = string,
+ TAccountSystemProgram extends string = string,
+> = {
+ buyer: TransactionSigner;
+ escrowAccount: Address;
+ vault?: Address;
+ systemProgram?: Address;
+};
+
+export async function getDepositInstructionAsync<
+ TAccountBuyer extends string,
+ TAccountEscrowAccount extends string,
+ TAccountVault extends string,
+ TAccountSystemProgram extends string,
+ TProgramAddress extends Address = typeof DESCRO_PROGRAM_ADDRESS,
+>(
+ input: DepositAsyncInput<
+ TAccountBuyer,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountSystemProgram
+ >,
+ config?: { programAddress?: TProgramAddress },
+): Promise<
+ DepositInstruction<
+ TProgramAddress,
+ TAccountBuyer,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountSystemProgram
+ >
+> {
+ // Program address.
+ const programAddress = config?.programAddress ?? DESCRO_PROGRAM_ADDRESS;
+
+ // Original accounts.
+ const originalAccounts = {
+ buyer: { value: input.buyer ?? null, isWritable: true },
+ escrowAccount: { value: input.escrowAccount ?? null, isWritable: true },
+ vault: { value: input.vault ?? null, isWritable: true },
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
+ };
+ const accounts = originalAccounts as Record<
+ keyof typeof originalAccounts,
+ ResolvedInstructionAccount
+ >;
+
+ // Resolve default values.
+ if (!accounts.vault.value) {
+ accounts.vault.value = await findVaultPda({
+ escrowAccount: getAddressFromResolvedInstructionAccount(
+ "escrowAccount",
+ accounts.escrowAccount.value,
+ ),
+ });
+ }
+ if (!accounts.systemProgram.value) {
+ accounts.systemProgram.value =
+ "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
+ }
+
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
+ return Object.freeze({
+ accounts: [
+ getAccountMeta("buyer", accounts.buyer),
+ getAccountMeta("escrowAccount", accounts.escrowAccount),
+ getAccountMeta("vault", accounts.vault),
+ getAccountMeta("systemProgram", accounts.systemProgram),
+ ],
+ data: getDepositInstructionDataEncoder().encode({}),
+ programAddress,
+ } as DepositInstruction<
+ TProgramAddress,
+ TAccountBuyer,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountSystemProgram
+ >);
+}
+
+export type DepositInput<
+ TAccountBuyer extends string = string,
+ TAccountEscrowAccount extends string = string,
+ TAccountVault extends string = string,
+ TAccountSystemProgram extends string = string,
+> = {
+ buyer: TransactionSigner;
+ escrowAccount: Address;
+ vault: Address;
+ systemProgram?: Address;
+};
+
+export function getDepositInstruction<
+ TAccountBuyer extends string,
+ TAccountEscrowAccount extends string,
+ TAccountVault extends string,
+ TAccountSystemProgram extends string,
+ TProgramAddress extends Address = typeof DESCRO_PROGRAM_ADDRESS,
+>(
+ input: DepositInput<
+ TAccountBuyer,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountSystemProgram
+ >,
+ config?: { programAddress?: TProgramAddress },
+): DepositInstruction<
+ TProgramAddress,
+ TAccountBuyer,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountSystemProgram
+> {
+ // Program address.
+ const programAddress = config?.programAddress ?? DESCRO_PROGRAM_ADDRESS;
+
+ // Original accounts.
+ const originalAccounts = {
+ buyer: { value: input.buyer ?? null, isWritable: true },
+ escrowAccount: { value: input.escrowAccount ?? null, isWritable: true },
+ vault: { value: input.vault ?? null, isWritable: true },
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
+ };
+ const accounts = originalAccounts as Record<
+ keyof typeof originalAccounts,
+ ResolvedInstructionAccount
+ >;
+
+ // Resolve default values.
+ if (!accounts.systemProgram.value) {
+ accounts.systemProgram.value =
+ "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
+ }
+
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
+ return Object.freeze({
+ accounts: [
+ getAccountMeta("buyer", accounts.buyer),
+ getAccountMeta("escrowAccount", accounts.escrowAccount),
+ getAccountMeta("vault", accounts.vault),
+ getAccountMeta("systemProgram", accounts.systemProgram),
+ ],
+ data: getDepositInstructionDataEncoder().encode({}),
+ programAddress,
+ } as DepositInstruction<
+ TProgramAddress,
+ TAccountBuyer,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountSystemProgram
+ >);
+}
+
+export type ParsedDepositInstruction<
+ TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
+ TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
+> = {
+ programAddress: Address;
+ accounts: {
+ buyer: TAccountMetas[0];
+ escrowAccount: TAccountMetas[1];
+ vault: TAccountMetas[2];
+ systemProgram: TAccountMetas[3];
+ };
+ data: DepositInstructionData;
+};
+
+export function parseDepositInstruction<
+ TProgram extends string,
+ TAccountMetas extends readonly AccountMeta[],
+>(
+ instruction: Instruction &
+ InstructionWithAccounts &
+ InstructionWithData,
+): ParsedDepositInstruction {
+ if (instruction.accounts.length < 4) {
+ throw new SolanaError(
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
+ {
+ actualAccountMetas: instruction.accounts.length,
+ expectedAccountMetas: 4,
+ },
+ );
+ }
+ let accountIndex = 0;
+ const getNextAccount = () => {
+ const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
+ accountIndex += 1;
+ return accountMeta;
+ };
+ return {
+ programAddress: instruction.programAddress,
+ accounts: {
+ buyer: getNextAccount(),
+ escrowAccount: getNextAccount(),
+ vault: getNextAccount(),
+ systemProgram: getNextAccount(),
+ },
+ data: getDepositInstructionDataDecoder().decode(instruction.data),
+ };
+}
diff --git a/sdk/src/generated/descro/src/generated/instructions/dispute.ts b/sdk/src/generated/descro/src/generated/instructions/dispute.ts
new file mode 100644
index 0000000..1786688
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/instructions/dispute.ts
@@ -0,0 +1,183 @@
+/**
+ * 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 {
+ combineCodec,
+ fixDecoderSize,
+ fixEncoderSize,
+ getBytesDecoder,
+ getBytesEncoder,
+ getStructDecoder,
+ getStructEncoder,
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
+ SolanaError,
+ transformEncoder,
+ type AccountMeta,
+ type AccountSignerMeta,
+ type Address,
+ type FixedSizeCodec,
+ type FixedSizeDecoder,
+ type FixedSizeEncoder,
+ type Instruction,
+ type InstructionWithAccounts,
+ type InstructionWithData,
+ type ReadonlySignerAccount,
+ type ReadonlyUint8Array,
+ type TransactionSigner,
+ type WritableAccount,
+} from "@solana/kit";
+import {
+ getAccountMetaFactory,
+ type ResolvedInstructionAccount,
+} from "@solana/program-client-core";
+import { DESCRO_PROGRAM_ADDRESS } from "../programs";
+
+export const DISPUTE_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
+ 216, 92, 128, 146, 202, 85, 135, 73,
+]);
+
+export function getDisputeDiscriminatorBytes(): ReadonlyUint8Array {
+ return fixEncoderSize(getBytesEncoder(), 8).encode(DISPUTE_DISCRIMINATOR);
+}
+
+export type DisputeInstruction<
+ TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
+ TAccountInitiator extends string | AccountMeta = string,
+ TAccountEscrowAccount extends string | AccountMeta = string,
+ TRemainingAccounts extends readonly AccountMeta[] = [],
+> = Instruction &
+ InstructionWithData &
+ InstructionWithAccounts<
+ [
+ TAccountInitiator extends string
+ ? ReadonlySignerAccount &
+ AccountSignerMeta
+ : TAccountInitiator,
+ TAccountEscrowAccount extends string
+ ? WritableAccount
+ : TAccountEscrowAccount,
+ ...TRemainingAccounts,
+ ]
+ >;
+
+export type DisputeInstructionData = { discriminator: ReadonlyUint8Array };
+
+export type DisputeInstructionDataArgs = {};
+
+export function getDisputeInstructionDataEncoder(): FixedSizeEncoder {
+ return transformEncoder(
+ getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
+ (value) => ({ ...value, discriminator: DISPUTE_DISCRIMINATOR }),
+ );
+}
+
+export function getDisputeInstructionDataDecoder(): FixedSizeDecoder {
+ return getStructDecoder([
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
+ ]);
+}
+
+export function getDisputeInstructionDataCodec(): FixedSizeCodec<
+ DisputeInstructionDataArgs,
+ DisputeInstructionData
+> {
+ return combineCodec(
+ getDisputeInstructionDataEncoder(),
+ getDisputeInstructionDataDecoder(),
+ );
+}
+
+export type DisputeInput<
+ TAccountInitiator extends string = string,
+ TAccountEscrowAccount extends string = string,
+> = {
+ initiator: TransactionSigner;
+ escrowAccount: Address;
+};
+
+export function getDisputeInstruction<
+ TAccountInitiator extends string,
+ TAccountEscrowAccount extends string,
+ TProgramAddress extends Address = typeof DESCRO_PROGRAM_ADDRESS,
+>(
+ input: DisputeInput,
+ config?: { programAddress?: TProgramAddress },
+): DisputeInstruction<
+ TProgramAddress,
+ TAccountInitiator,
+ TAccountEscrowAccount
+> {
+ // Program address.
+ const programAddress = config?.programAddress ?? DESCRO_PROGRAM_ADDRESS;
+
+ // Original accounts.
+ const originalAccounts = {
+ initiator: { value: input.initiator ?? null, isWritable: false },
+ escrowAccount: { value: input.escrowAccount ?? null, isWritable: true },
+ };
+ const accounts = originalAccounts as Record<
+ keyof typeof originalAccounts,
+ ResolvedInstructionAccount
+ >;
+
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
+ return Object.freeze({
+ accounts: [
+ getAccountMeta("initiator", accounts.initiator),
+ getAccountMeta("escrowAccount", accounts.escrowAccount),
+ ],
+ data: getDisputeInstructionDataEncoder().encode({}),
+ programAddress,
+ } as DisputeInstruction<
+ TProgramAddress,
+ TAccountInitiator,
+ TAccountEscrowAccount
+ >);
+}
+
+export type ParsedDisputeInstruction<
+ TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
+ TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
+> = {
+ programAddress: Address;
+ accounts: {
+ initiator: TAccountMetas[0];
+ escrowAccount: TAccountMetas[1];
+ };
+ data: DisputeInstructionData;
+};
+
+export function parseDisputeInstruction<
+ TProgram extends string,
+ TAccountMetas extends readonly AccountMeta[],
+>(
+ instruction: Instruction &
+ InstructionWithAccounts &
+ InstructionWithData,
+): ParsedDisputeInstruction {
+ if (instruction.accounts.length < 2) {
+ throw new SolanaError(
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
+ {
+ actualAccountMetas: instruction.accounts.length,
+ expectedAccountMetas: 2,
+ },
+ );
+ }
+ let accountIndex = 0;
+ const getNextAccount = () => {
+ const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
+ accountIndex += 1;
+ return accountMeta;
+ };
+ return {
+ programAddress: instruction.programAddress,
+ accounts: { initiator: getNextAccount(), escrowAccount: getNextAccount() },
+ data: getDisputeInstructionDataDecoder().decode(instruction.data),
+ };
+}
diff --git a/sdk/src/generated/descro/src/generated/instructions/index.ts b/sdk/src/generated/descro/src/generated/instructions/index.ts
new file mode 100644
index 0000000..d643386
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/instructions/index.ts
@@ -0,0 +1,14 @@
+/**
+ * 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
+ */
+
+export * from "./cancel";
+export * from "./complete";
+export * from "./createEscrow";
+export * from "./deposit";
+export * from "./dispute";
+export * from "./resolve";
diff --git a/sdk/src/generated/descro/src/generated/instructions/resolve.ts b/sdk/src/generated/descro/src/generated/instructions/resolve.ts
new file mode 100644
index 0000000..718ef0f
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/instructions/resolve.ts
@@ -0,0 +1,460 @@
+/**
+ * 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 {
+ combineCodec,
+ fixDecoderSize,
+ fixEncoderSize,
+ getBytesDecoder,
+ getBytesEncoder,
+ getStructDecoder,
+ getStructEncoder,
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
+ SolanaError,
+ transformEncoder,
+ type AccountMeta,
+ type AccountSignerMeta,
+ type Address,
+ type FixedSizeCodec,
+ type FixedSizeDecoder,
+ type FixedSizeEncoder,
+ type Instruction,
+ type InstructionWithAccounts,
+ type InstructionWithData,
+ type ReadonlyAccount,
+ type ReadonlySignerAccount,
+ type ReadonlyUint8Array,
+ type TransactionSigner,
+ type WritableAccount,
+} from "@solana/kit";
+import {
+ getAccountMetaFactory,
+ getAddressFromResolvedInstructionAccount,
+ type ResolvedInstructionAccount,
+} from "@solana/program-client-core";
+import { findEscrowAuthorityPda, findVaultPda } from "../pdas";
+import { DESCRO_PROGRAM_ADDRESS } from "../programs";
+import {
+ getWinnerDecoder,
+ getWinnerEncoder,
+ type Winner,
+ type WinnerArgs,
+} from "../types";
+
+export const RESOLVE_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
+ 246, 150, 236, 206, 108, 63, 58, 10,
+]);
+
+export function getResolveDiscriminatorBytes(): ReadonlyUint8Array {
+ return fixEncoderSize(getBytesEncoder(), 8).encode(RESOLVE_DISCRIMINATOR);
+}
+
+export type ResolveInstruction<
+ TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
+ TAccountResolver extends string | AccountMeta = string,
+ TAccountWinner extends string | AccountMeta = string,
+ TAccountSeller extends string | AccountMeta = string,
+ TAccountEscrowAccount extends string | AccountMeta = string,
+ TAccountVault extends string | AccountMeta = string,
+ TAccountResolverEntry extends string | AccountMeta = string,
+ TAccountEscrowAuthority extends string | AccountMeta = string,
+ TAccountRegistryProgram extends string | AccountMeta = string,
+ TAccountSystemProgram extends string | AccountMeta =
+ "11111111111111111111111111111111",
+ TRemainingAccounts extends readonly AccountMeta[] = [],
+> = Instruction &
+ InstructionWithData &
+ InstructionWithAccounts<
+ [
+ TAccountResolver extends string
+ ? ReadonlySignerAccount &
+ AccountSignerMeta
+ : TAccountResolver,
+ TAccountWinner extends string
+ ? WritableAccount
+ : TAccountWinner,
+ TAccountSeller extends string
+ ? WritableAccount
+ : TAccountSeller,
+ TAccountEscrowAccount extends string
+ ? WritableAccount
+ : TAccountEscrowAccount,
+ TAccountVault extends string
+ ? WritableAccount
+ : TAccountVault,
+ TAccountResolverEntry extends string
+ ? WritableAccount
+ : TAccountResolverEntry,
+ TAccountEscrowAuthority extends string
+ ? ReadonlyAccount
+ : TAccountEscrowAuthority,
+ TAccountRegistryProgram extends string
+ ? ReadonlyAccount
+ : TAccountRegistryProgram,
+ TAccountSystemProgram extends string
+ ? ReadonlyAccount
+ : TAccountSystemProgram,
+ ...TRemainingAccounts,
+ ]
+ >;
+
+export type ResolveInstructionData = {
+ discriminator: ReadonlyUint8Array;
+ winner: Winner;
+};
+
+export type ResolveInstructionDataArgs = { winner: WinnerArgs };
+
+export function getResolveInstructionDataEncoder(): FixedSizeEncoder {
+ return transformEncoder(
+ getStructEncoder([
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
+ ["winner", getWinnerEncoder()],
+ ]),
+ (value) => ({ ...value, discriminator: RESOLVE_DISCRIMINATOR }),
+ );
+}
+
+export function getResolveInstructionDataDecoder(): FixedSizeDecoder {
+ return getStructDecoder([
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
+ ["winner", getWinnerDecoder()],
+ ]);
+}
+
+export function getResolveInstructionDataCodec(): FixedSizeCodec<
+ ResolveInstructionDataArgs,
+ ResolveInstructionData
+> {
+ return combineCodec(
+ getResolveInstructionDataEncoder(),
+ getResolveInstructionDataDecoder(),
+ );
+}
+
+export type ResolveAsyncInput<
+ TAccountResolver extends string = string,
+ TAccountWinner extends string = string,
+ TAccountSeller extends string = string,
+ TAccountEscrowAccount extends string = string,
+ TAccountVault extends string = string,
+ TAccountResolverEntry extends string = string,
+ TAccountEscrowAuthority extends string = string,
+ TAccountRegistryProgram extends string = string,
+ TAccountSystemProgram extends string = string,
+> = {
+ resolver: TransactionSigner;
+ winner: Address;
+ seller: Address;
+ escrowAccount: Address;
+ vault?: Address;
+ resolverEntry: Address;
+ escrowAuthority?: Address;
+ registryProgram: Address;
+ systemProgram?: Address;
+ winnerArg: ResolveInstructionDataArgs["winner"];
+};
+
+export async function getResolveInstructionAsync<
+ TAccountResolver extends string,
+ TAccountWinner extends string,
+ TAccountSeller extends string,
+ TAccountEscrowAccount extends string,
+ TAccountVault extends string,
+ TAccountResolverEntry extends string,
+ TAccountEscrowAuthority extends string,
+ TAccountRegistryProgram extends string,
+ TAccountSystemProgram extends string,
+ TProgramAddress extends Address = typeof DESCRO_PROGRAM_ADDRESS,
+>(
+ input: ResolveAsyncInput<
+ TAccountResolver,
+ TAccountWinner,
+ TAccountSeller,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountResolverEntry,
+ TAccountEscrowAuthority,
+ TAccountRegistryProgram,
+ TAccountSystemProgram
+ >,
+ config?: { programAddress?: TProgramAddress },
+): Promise<
+ ResolveInstruction<
+ TProgramAddress,
+ TAccountResolver,
+ TAccountWinner,
+ TAccountSeller,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountResolverEntry,
+ TAccountEscrowAuthority,
+ TAccountRegistryProgram,
+ TAccountSystemProgram
+ >
+> {
+ // Program address.
+ const programAddress = config?.programAddress ?? DESCRO_PROGRAM_ADDRESS;
+
+ // Original accounts.
+ const originalAccounts = {
+ resolver: { value: input.resolver ?? null, isWritable: false },
+ winner: { value: input.winner ?? null, isWritable: true },
+ seller: { value: input.seller ?? null, isWritable: true },
+ escrowAccount: { value: input.escrowAccount ?? null, isWritable: true },
+ vault: { value: input.vault ?? null, isWritable: true },
+ resolverEntry: { value: input.resolverEntry ?? null, isWritable: true },
+ escrowAuthority: {
+ value: input.escrowAuthority ?? null,
+ isWritable: false,
+ },
+ registryProgram: {
+ value: input.registryProgram ?? null,
+ isWritable: false,
+ },
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
+ };
+ const accounts = originalAccounts as Record<
+ keyof typeof originalAccounts,
+ ResolvedInstructionAccount
+ >;
+
+ // Original args.
+ const args = { ...input, winner: input.winnerArg };
+
+ // Resolve default values.
+ if (!accounts.vault.value) {
+ accounts.vault.value = await findVaultPda({
+ escrowAccount: getAddressFromResolvedInstructionAccount(
+ "escrowAccount",
+ accounts.escrowAccount.value,
+ ),
+ });
+ }
+ if (!accounts.escrowAuthority.value) {
+ accounts.escrowAuthority.value = await findEscrowAuthorityPda();
+ }
+ if (!accounts.systemProgram.value) {
+ accounts.systemProgram.value =
+ "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
+ }
+
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
+ return Object.freeze({
+ accounts: [
+ getAccountMeta("resolver", accounts.resolver),
+ getAccountMeta("winner", accounts.winner),
+ getAccountMeta("seller", accounts.seller),
+ getAccountMeta("escrowAccount", accounts.escrowAccount),
+ getAccountMeta("vault", accounts.vault),
+ getAccountMeta("resolverEntry", accounts.resolverEntry),
+ getAccountMeta("escrowAuthority", accounts.escrowAuthority),
+ getAccountMeta("registryProgram", accounts.registryProgram),
+ getAccountMeta("systemProgram", accounts.systemProgram),
+ ],
+ data: getResolveInstructionDataEncoder().encode(
+ args as ResolveInstructionDataArgs,
+ ),
+ programAddress,
+ } as ResolveInstruction<
+ TProgramAddress,
+ TAccountResolver,
+ TAccountWinner,
+ TAccountSeller,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountResolverEntry,
+ TAccountEscrowAuthority,
+ TAccountRegistryProgram,
+ TAccountSystemProgram
+ >);
+}
+
+export type ResolveInput<
+ TAccountResolver extends string = string,
+ TAccountWinner extends string = string,
+ TAccountSeller extends string = string,
+ TAccountEscrowAccount extends string = string,
+ TAccountVault extends string = string,
+ TAccountResolverEntry extends string = string,
+ TAccountEscrowAuthority extends string = string,
+ TAccountRegistryProgram extends string = string,
+ TAccountSystemProgram extends string = string,
+> = {
+ resolver: TransactionSigner;
+ winner: Address;
+ seller: Address;
+ escrowAccount: Address;
+ vault: Address;
+ resolverEntry: Address;
+ escrowAuthority: Address;
+ registryProgram: Address;
+ systemProgram?: Address;
+ winnerArg: ResolveInstructionDataArgs["winner"];
+};
+
+export function getResolveInstruction<
+ TAccountResolver extends string,
+ TAccountWinner extends string,
+ TAccountSeller extends string,
+ TAccountEscrowAccount extends string,
+ TAccountVault extends string,
+ TAccountResolverEntry extends string,
+ TAccountEscrowAuthority extends string,
+ TAccountRegistryProgram extends string,
+ TAccountSystemProgram extends string,
+ TProgramAddress extends Address = typeof DESCRO_PROGRAM_ADDRESS,
+>(
+ input: ResolveInput<
+ TAccountResolver,
+ TAccountWinner,
+ TAccountSeller,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountResolverEntry,
+ TAccountEscrowAuthority,
+ TAccountRegistryProgram,
+ TAccountSystemProgram
+ >,
+ config?: { programAddress?: TProgramAddress },
+): ResolveInstruction<
+ TProgramAddress,
+ TAccountResolver,
+ TAccountWinner,
+ TAccountSeller,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountResolverEntry,
+ TAccountEscrowAuthority,
+ TAccountRegistryProgram,
+ TAccountSystemProgram
+> {
+ // Program address.
+ const programAddress = config?.programAddress ?? DESCRO_PROGRAM_ADDRESS;
+
+ // Original accounts.
+ const originalAccounts = {
+ resolver: { value: input.resolver ?? null, isWritable: false },
+ winner: { value: input.winner ?? null, isWritable: true },
+ seller: { value: input.seller ?? null, isWritable: true },
+ escrowAccount: { value: input.escrowAccount ?? null, isWritable: true },
+ vault: { value: input.vault ?? null, isWritable: true },
+ resolverEntry: { value: input.resolverEntry ?? null, isWritable: true },
+ escrowAuthority: {
+ value: input.escrowAuthority ?? null,
+ isWritable: false,
+ },
+ registryProgram: {
+ value: input.registryProgram ?? null,
+ isWritable: false,
+ },
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
+ };
+ const accounts = originalAccounts as Record<
+ keyof typeof originalAccounts,
+ ResolvedInstructionAccount
+ >;
+
+ // Original args.
+ const args = { ...input, winner: input.winnerArg };
+
+ // Resolve default values.
+ if (!accounts.systemProgram.value) {
+ accounts.systemProgram.value =
+ "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
+ }
+
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
+ return Object.freeze({
+ accounts: [
+ getAccountMeta("resolver", accounts.resolver),
+ getAccountMeta("winner", accounts.winner),
+ getAccountMeta("seller", accounts.seller),
+ getAccountMeta("escrowAccount", accounts.escrowAccount),
+ getAccountMeta("vault", accounts.vault),
+ getAccountMeta("resolverEntry", accounts.resolverEntry),
+ getAccountMeta("escrowAuthority", accounts.escrowAuthority),
+ getAccountMeta("registryProgram", accounts.registryProgram),
+ getAccountMeta("systemProgram", accounts.systemProgram),
+ ],
+ data: getResolveInstructionDataEncoder().encode(
+ args as ResolveInstructionDataArgs,
+ ),
+ programAddress,
+ } as ResolveInstruction<
+ TProgramAddress,
+ TAccountResolver,
+ TAccountWinner,
+ TAccountSeller,
+ TAccountEscrowAccount,
+ TAccountVault,
+ TAccountResolverEntry,
+ TAccountEscrowAuthority,
+ TAccountRegistryProgram,
+ TAccountSystemProgram
+ >);
+}
+
+export type ParsedResolveInstruction<
+ TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
+ TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
+> = {
+ programAddress: Address;
+ accounts: {
+ resolver: TAccountMetas[0];
+ winner: TAccountMetas[1];
+ seller: TAccountMetas[2];
+ escrowAccount: TAccountMetas[3];
+ vault: TAccountMetas[4];
+ resolverEntry: TAccountMetas[5];
+ escrowAuthority: TAccountMetas[6];
+ registryProgram: TAccountMetas[7];
+ systemProgram: TAccountMetas[8];
+ };
+ data: ResolveInstructionData;
+};
+
+export function parseResolveInstruction<
+ TProgram extends string,
+ TAccountMetas extends readonly AccountMeta[],
+>(
+ instruction: Instruction &
+ InstructionWithAccounts &
+ InstructionWithData,
+): ParsedResolveInstruction {
+ if (instruction.accounts.length < 9) {
+ throw new SolanaError(
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
+ {
+ actualAccountMetas: instruction.accounts.length,
+ expectedAccountMetas: 9,
+ },
+ );
+ }
+ let accountIndex = 0;
+ const getNextAccount = () => {
+ const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
+ accountIndex += 1;
+ return accountMeta;
+ };
+ return {
+ programAddress: instruction.programAddress,
+ accounts: {
+ resolver: getNextAccount(),
+ winner: getNextAccount(),
+ seller: getNextAccount(),
+ escrowAccount: getNextAccount(),
+ vault: getNextAccount(),
+ resolverEntry: getNextAccount(),
+ escrowAuthority: getNextAccount(),
+ registryProgram: getNextAccount(),
+ systemProgram: getNextAccount(),
+ },
+ data: getResolveInstructionDataDecoder().decode(instruction.data),
+ };
+}
diff --git a/sdk/src/generated/descro/src/generated/pdas/escrowAccount.ts b/sdk/src/generated/descro/src/generated/pdas/escrowAccount.ts
new file mode 100644
index 0000000..894c9c1
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/pdas/escrowAccount.ts
@@ -0,0 +1,38 @@
+/**
+ * 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 {
+ getAddressEncoder,
+ getBytesEncoder,
+ getProgramDerivedAddress,
+ getU64Encoder,
+ type Address,
+ type ProgramDerivedAddress,
+} from "@solana/kit";
+
+export type EscrowAccountSeeds = {
+ seller: Address;
+ escrowId: number | bigint;
+};
+
+export async function findEscrowAccountPda(
+ seeds: EscrowAccountSeeds,
+ config: { programAddress?: Address | undefined } = {},
+): Promise {
+ const {
+ programAddress = "DjVR4EuYV6USMJFfsGZwhZ3y8rtWsmG8EvDY96GTqqi3" as Address<"DjVR4EuYV6USMJFfsGZwhZ3y8rtWsmG8EvDY96GTqqi3">,
+ } = config;
+ return await getProgramDerivedAddress({
+ programAddress,
+ seeds: [
+ getBytesEncoder().encode(new Uint8Array([101, 115, 99, 114, 111, 119])),
+ getAddressEncoder().encode(seeds.seller),
+ getU64Encoder().encode(seeds.escrowId),
+ ],
+ });
+}
diff --git a/sdk/src/generated/descro/src/generated/pdas/escrowAuthority.ts b/sdk/src/generated/descro/src/generated/pdas/escrowAuthority.ts
new file mode 100644
index 0000000..3e0d93a
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/pdas/escrowAuthority.ts
@@ -0,0 +1,33 @@
+/**
+ * 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 {
+ getBytesEncoder,
+ getProgramDerivedAddress,
+ type Address,
+ type ProgramDerivedAddress,
+} from "@solana/kit";
+
+export async function findEscrowAuthorityPda(
+ config: { programAddress?: Address | undefined } = {},
+): Promise {
+ const {
+ programAddress = "DjVR4EuYV6USMJFfsGZwhZ3y8rtWsmG8EvDY96GTqqi3" as Address<"DjVR4EuYV6USMJFfsGZwhZ3y8rtWsmG8EvDY96GTqqi3">,
+ } = config;
+ return await getProgramDerivedAddress({
+ programAddress,
+ seeds: [
+ getBytesEncoder().encode(
+ new Uint8Array([
+ 101, 115, 99, 114, 111, 119, 95, 97, 117, 116, 104, 111, 114, 105,
+ 116, 121,
+ ]),
+ ),
+ ],
+ });
+}
diff --git a/sdk/src/generated/descro/src/generated/pdas/index.ts b/sdk/src/generated/descro/src/generated/pdas/index.ts
new file mode 100644
index 0000000..78009cd
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/pdas/index.ts
@@ -0,0 +1,11 @@
+/**
+ * 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
+ */
+
+export * from "./escrowAccount";
+export * from "./escrowAuthority";
+export * from "./vault";
diff --git a/sdk/src/generated/descro/src/generated/pdas/vault.ts b/sdk/src/generated/descro/src/generated/pdas/vault.ts
new file mode 100644
index 0000000..2586c5e
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/pdas/vault.ts
@@ -0,0 +1,35 @@
+/**
+ * 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 {
+ getAddressEncoder,
+ getBytesEncoder,
+ getProgramDerivedAddress,
+ type Address,
+ type ProgramDerivedAddress,
+} from "@solana/kit";
+
+export type VaultSeeds = {
+ escrowAccount: Address;
+};
+
+export async function findVaultPda(
+ seeds: VaultSeeds,
+ config: { programAddress?: Address | undefined } = {},
+): Promise {
+ const {
+ programAddress = "DjVR4EuYV6USMJFfsGZwhZ3y8rtWsmG8EvDY96GTqqi3" as Address<"DjVR4EuYV6USMJFfsGZwhZ3y8rtWsmG8EvDY96GTqqi3">,
+ } = config;
+ return await getProgramDerivedAddress({
+ programAddress,
+ seeds: [
+ getBytesEncoder().encode(new Uint8Array([118, 97, 117, 108, 116])),
+ getAddressEncoder().encode(seeds.escrowAccount),
+ ],
+ });
+}
diff --git a/sdk/src/generated/descro/src/generated/programs/descro.ts b/sdk/src/generated/descro/src/generated/programs/descro.ts
new file mode 100644
index 0000000..0b08d2f
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/programs/descro.ts
@@ -0,0 +1,351 @@
+/**
+ * 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 {
+ assertIsInstructionWithAccounts,
+ containsBytes,
+ extendClient,
+ fixEncoderSize,
+ getBytesEncoder,
+ SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT,
+ SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,
+ SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,
+ SolanaError,
+ type Address,
+ type ClientWithRpc,
+ type ClientWithTransactionPlanning,
+ type ClientWithTransactionSending,
+ type GetAccountInfoApi,
+ type GetMultipleAccountsApi,
+ type Instruction,
+ type InstructionWithData,
+ type ReadonlyUint8Array,
+} from "@solana/kit";
+import {
+ addSelfFetchFunctions,
+ addSelfPlanAndSendFunctions,
+ type SelfFetchFunctions,
+ type SelfPlanAndSendFunctions,
+} from "@solana/program-client-core";
+import {
+ getEscrowAccountCodec,
+ type EscrowAccount,
+ type EscrowAccountArgs,
+} from "../accounts";
+import {
+ getCancelInstruction,
+ getCompleteInstructionAsync,
+ getCreateEscrowInstructionAsync,
+ getDepositInstructionAsync,
+ getDisputeInstruction,
+ getResolveInstructionAsync,
+ parseCancelInstruction,
+ parseCompleteInstruction,
+ parseCreateEscrowInstruction,
+ parseDepositInstruction,
+ parseDisputeInstruction,
+ parseResolveInstruction,
+ type CancelInput,
+ type CompleteAsyncInput,
+ type CreateEscrowAsyncInput,
+ type DepositAsyncInput,
+ type DisputeInput,
+ type ParsedCancelInstruction,
+ type ParsedCompleteInstruction,
+ type ParsedCreateEscrowInstruction,
+ type ParsedDepositInstruction,
+ type ParsedDisputeInstruction,
+ type ParsedResolveInstruction,
+ type ResolveAsyncInput,
+} from "../instructions";
+import {
+ findEscrowAccountPda,
+ findEscrowAuthorityPda,
+ findVaultPda,
+} from "../pdas";
+
+export const DESCRO_PROGRAM_ADDRESS =
+ "DjVR4EuYV6USMJFfsGZwhZ3y8rtWsmG8EvDY96GTqqi3" as Address<"DjVR4EuYV6USMJFfsGZwhZ3y8rtWsmG8EvDY96GTqqi3">;
+
+export enum DescroAccount {
+ EscrowAccount,
+}
+
+export function identifyDescroAccount(
+ account: { data: ReadonlyUint8Array } | ReadonlyUint8Array,
+): DescroAccount {
+ const data = "data" in account ? account.data : account;
+ if (
+ containsBytes(
+ data,
+ fixEncoderSize(getBytesEncoder(), 8).encode(
+ new Uint8Array([36, 69, 48, 18, 128, 225, 125, 135]),
+ ),
+ 0,
+ )
+ ) {
+ return DescroAccount.EscrowAccount;
+ }
+ throw new SolanaError(
+ SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT,
+ { accountData: data, programName: "descro" },
+ );
+}
+
+export enum DescroInstruction {
+ Cancel,
+ Complete,
+ CreateEscrow,
+ Deposit,
+ Dispute,
+ Resolve,
+}
+
+export function identifyDescroInstruction(
+ instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array,
+): DescroInstruction {
+ const data = "data" in instruction ? instruction.data : instruction;
+ if (
+ containsBytes(
+ data,
+ fixEncoderSize(getBytesEncoder(), 8).encode(
+ new Uint8Array([232, 219, 223, 41, 219, 236, 220, 190]),
+ ),
+ 0,
+ )
+ ) {
+ return DescroInstruction.Cancel;
+ }
+ if (
+ containsBytes(
+ data,
+ fixEncoderSize(getBytesEncoder(), 8).encode(
+ new Uint8Array([0, 77, 224, 147, 136, 25, 88, 76]),
+ ),
+ 0,
+ )
+ ) {
+ return DescroInstruction.Complete;
+ }
+ if (
+ containsBytes(
+ data,
+ fixEncoderSize(getBytesEncoder(), 8).encode(
+ new Uint8Array([253, 215, 165, 116, 36, 108, 68, 80]),
+ ),
+ 0,
+ )
+ ) {
+ return DescroInstruction.CreateEscrow;
+ }
+ if (
+ containsBytes(
+ data,
+ fixEncoderSize(getBytesEncoder(), 8).encode(
+ new Uint8Array([242, 35, 198, 137, 82, 225, 242, 182]),
+ ),
+ 0,
+ )
+ ) {
+ return DescroInstruction.Deposit;
+ }
+ if (
+ containsBytes(
+ data,
+ fixEncoderSize(getBytesEncoder(), 8).encode(
+ new Uint8Array([216, 92, 128, 146, 202, 85, 135, 73]),
+ ),
+ 0,
+ )
+ ) {
+ return DescroInstruction.Dispute;
+ }
+ if (
+ containsBytes(
+ data,
+ fixEncoderSize(getBytesEncoder(), 8).encode(
+ new Uint8Array([246, 150, 236, 206, 108, 63, 58, 10]),
+ ),
+ 0,
+ )
+ ) {
+ return DescroInstruction.Resolve;
+ }
+ throw new SolanaError(
+ SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,
+ { instructionData: data, programName: "descro" },
+ );
+}
+
+export type ParsedDescroInstruction<
+ TProgram extends string = "DjVR4EuYV6USMJFfsGZwhZ3y8rtWsmG8EvDY96GTqqi3",
+> =
+ | ({
+ instructionType: DescroInstruction.Cancel;
+ } & ParsedCancelInstruction)
+ | ({
+ instructionType: DescroInstruction.Complete;
+ } & ParsedCompleteInstruction)
+ | ({
+ instructionType: DescroInstruction.CreateEscrow;
+ } & ParsedCreateEscrowInstruction)
+ | ({
+ instructionType: DescroInstruction.Deposit;
+ } & ParsedDepositInstruction)
+ | ({
+ instructionType: DescroInstruction.Dispute;
+ } & ParsedDisputeInstruction)
+ | ({
+ instructionType: DescroInstruction.Resolve;
+ } & ParsedResolveInstruction);
+
+export function parseDescroInstruction(
+ instruction: Instruction & InstructionWithData,
+): ParsedDescroInstruction {
+ const instructionType = identifyDescroInstruction(instruction);
+ switch (instructionType) {
+ case DescroInstruction.Cancel: {
+ assertIsInstructionWithAccounts(instruction);
+ return {
+ instructionType: DescroInstruction.Cancel,
+ ...parseCancelInstruction(instruction),
+ };
+ }
+ case DescroInstruction.Complete: {
+ assertIsInstructionWithAccounts(instruction);
+ return {
+ instructionType: DescroInstruction.Complete,
+ ...parseCompleteInstruction(instruction),
+ };
+ }
+ case DescroInstruction.CreateEscrow: {
+ assertIsInstructionWithAccounts(instruction);
+ return {
+ instructionType: DescroInstruction.CreateEscrow,
+ ...parseCreateEscrowInstruction(instruction),
+ };
+ }
+ case DescroInstruction.Deposit: {
+ assertIsInstructionWithAccounts(instruction);
+ return {
+ instructionType: DescroInstruction.Deposit,
+ ...parseDepositInstruction(instruction),
+ };
+ }
+ case DescroInstruction.Dispute: {
+ assertIsInstructionWithAccounts(instruction);
+ return {
+ instructionType: DescroInstruction.Dispute,
+ ...parseDisputeInstruction(instruction),
+ };
+ }
+ case DescroInstruction.Resolve: {
+ assertIsInstructionWithAccounts(instruction);
+ return {
+ instructionType: DescroInstruction.Resolve,
+ ...parseResolveInstruction(instruction),
+ };
+ }
+ default:
+ throw new SolanaError(
+ SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,
+ { instructionType: instructionType as string, programName: "descro" },
+ );
+ }
+}
+
+export type DescroPlugin = {
+ accounts: DescroPluginAccounts;
+ instructions: DescroPluginInstructions;
+ pdas: DescroPluginPdas;
+};
+
+export type DescroPluginAccounts = {
+ escrowAccount: ReturnType &
+ SelfFetchFunctions;
+};
+
+export type DescroPluginInstructions = {
+ cancel: (
+ input: CancelInput,
+ ) => ReturnType & SelfPlanAndSendFunctions;
+ complete: (
+ input: CompleteAsyncInput,
+ ) => ReturnType &
+ SelfPlanAndSendFunctions;
+ createEscrow: (
+ input: CreateEscrowAsyncInput,
+ ) => ReturnType &
+ SelfPlanAndSendFunctions;
+ deposit: (
+ input: DepositAsyncInput,
+ ) => ReturnType & SelfPlanAndSendFunctions;
+ dispute: (
+ input: DisputeInput,
+ ) => ReturnType & SelfPlanAndSendFunctions;
+ resolve: (
+ input: ResolveAsyncInput,
+ ) => ReturnType & SelfPlanAndSendFunctions;
+};
+
+export type DescroPluginPdas = {
+ vault: typeof findVaultPda;
+ escrowAccount: typeof findEscrowAccountPda;
+ escrowAuthority: typeof findEscrowAuthorityPda;
+};
+
+export type DescroPluginRequirements = ClientWithRpc<
+ GetAccountInfoApi & GetMultipleAccountsApi
+> &
+ ClientWithTransactionPlanning &
+ ClientWithTransactionSending;
+
+export function descroProgram() {
+ return (
+ client: T,
+ ): Omit & { descro: DescroPlugin } => {
+ return extendClient(client, {
+ descro: {
+ accounts: {
+ escrowAccount: addSelfFetchFunctions(client, getEscrowAccountCodec()),
+ },
+ instructions: {
+ cancel: (input) =>
+ addSelfPlanAndSendFunctions(client, getCancelInstruction(input)),
+ complete: (input) =>
+ addSelfPlanAndSendFunctions(
+ client,
+ getCompleteInstructionAsync(input),
+ ),
+ createEscrow: (input) =>
+ addSelfPlanAndSendFunctions(
+ client,
+ getCreateEscrowInstructionAsync(input),
+ ),
+ deposit: (input) =>
+ addSelfPlanAndSendFunctions(
+ client,
+ getDepositInstructionAsync(input),
+ ),
+ dispute: (input) =>
+ addSelfPlanAndSendFunctions(client, getDisputeInstruction(input)),
+ resolve: (input) =>
+ addSelfPlanAndSendFunctions(
+ client,
+ getResolveInstructionAsync(input),
+ ),
+ },
+ pdas: {
+ vault: findVaultPda,
+ escrowAccount: findEscrowAccountPda,
+ escrowAuthority: findEscrowAuthorityPda,
+ },
+ },
+ });
+ };
+}
diff --git a/sdk/src/generated/descro/src/generated/programs/index.ts b/sdk/src/generated/descro/src/generated/programs/index.ts
new file mode 100644
index 0000000..3d77c4e
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/programs/index.ts
@@ -0,0 +1,9 @@
+/**
+ * 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
+ */
+
+export * from "./descro";
diff --git a/sdk/src/generated/descro/src/generated/types/escrowState.ts b/sdk/src/generated/descro/src/generated/types/escrowState.ts
new file mode 100644
index 0000000..7453e67
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/types/escrowState.ts
@@ -0,0 +1,41 @@
+/**
+ * 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 {
+ combineCodec,
+ getEnumDecoder,
+ getEnumEncoder,
+ type FixedSizeCodec,
+ type FixedSizeDecoder,
+ type FixedSizeEncoder,
+} from "@solana/kit";
+
+export enum EscrowState {
+ AwaitingDeposit,
+ Active,
+ Disputed,
+ Complete,
+ Cancelled,
+}
+
+export type EscrowStateArgs = EscrowState;
+
+export function getEscrowStateEncoder(): FixedSizeEncoder {
+ return getEnumEncoder(EscrowState);
+}
+
+export function getEscrowStateDecoder(): FixedSizeDecoder {
+ return getEnumDecoder(EscrowState);
+}
+
+export function getEscrowStateCodec(): FixedSizeCodec<
+ EscrowStateArgs,
+ EscrowState
+> {
+ return combineCodec(getEscrowStateEncoder(), getEscrowStateDecoder());
+}
diff --git a/sdk/src/generated/descro/src/generated/types/index.ts b/sdk/src/generated/descro/src/generated/types/index.ts
new file mode 100644
index 0000000..269e5f8
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/types/index.ts
@@ -0,0 +1,10 @@
+/**
+ * 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
+ */
+
+export * from "./escrowState";
+export * from "./winner";
diff --git a/sdk/src/generated/descro/src/generated/types/winner.ts b/sdk/src/generated/descro/src/generated/types/winner.ts
new file mode 100644
index 0000000..870fc04
--- /dev/null
+++ b/sdk/src/generated/descro/src/generated/types/winner.ts
@@ -0,0 +1,35 @@
+/**
+ * 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 {
+ combineCodec,
+ getEnumDecoder,
+ getEnumEncoder,
+ type FixedSizeCodec,
+ type FixedSizeDecoder,
+ type FixedSizeEncoder,
+} from "@solana/kit";
+
+export enum Winner {
+ Buyer,
+ Seller,
+}
+
+export type WinnerArgs = Winner;
+
+export function getWinnerEncoder(): FixedSizeEncoder {
+ return getEnumEncoder(Winner);
+}
+
+export function getWinnerDecoder(): FixedSizeDecoder {
+ return getEnumDecoder(Winner);
+}
+
+export function getWinnerCodec(): FixedSizeCodec {
+ return combineCodec(getWinnerEncoder(), getWinnerDecoder());
+}
diff --git a/sdk/src/generated/descro_ext_resolvers/package.json b/sdk/src/generated/descro_ext_resolvers/package.json
new file mode 100644
index 0000000..3250d35
--- /dev/null
+++ b/sdk/src/generated/descro_ext_resolvers/package.json
@@ -0,0 +1,22 @@
+{
+ "name": "js-client",
+ "version": "1.0.0",
+ "description": "",
+ "main": "src/index.ts",
+ "files": [
+ "./dist/src",
+ "./dist/types",
+ "./src/"
+ ],
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "keywords": [],
+ "author": "",
+ "peerDependencies": {
+ "@solana/kit": "^6.4.0"
+ },
+ "dependencies": {
+ "@solana/program-client-core": "^6.4.0"
+ }
+}
diff --git a/sdk/src/generated/descro_ext_resolvers/src/generated/accounts/index.ts b/sdk/src/generated/descro_ext_resolvers/src/generated/accounts/index.ts
new file mode 100644
index 0000000..4ac749e
--- /dev/null
+++ b/sdk/src/generated/descro_ext_resolvers/src/generated/accounts/index.ts
@@ -0,0 +1,9 @@
+/**
+ * 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
+ */
+
+export * from "./resolverEntry";
diff --git a/sdk/src/generated/descro_ext_resolvers/src/generated/accounts/resolverEntry.ts b/sdk/src/generated/descro_ext_resolvers/src/generated/accounts/resolverEntry.ts
new file mode 100644
index 0000000..8334673
--- /dev/null
+++ b/sdk/src/generated/descro_ext_resolvers/src/generated/accounts/resolverEntry.ts
@@ -0,0 +1,197 @@
+/**
+ * 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 {
+ addDecoderSizePrefix,
+ addEncoderSizePrefix,
+ assertAccountExists,
+ assertAccountsExist,
+ combineCodec,
+ decodeAccount,
+ fetchEncodedAccount,
+ fetchEncodedAccounts,
+ fixDecoderSize,
+ fixEncoderSize,
+ getAddressDecoder,
+ getAddressEncoder,
+ getBytesDecoder,
+ getBytesEncoder,
+ getI64Decoder,
+ getI64Encoder,
+ getStructDecoder,
+ getStructEncoder,
+ getU16Decoder,
+ getU16Encoder,
+ getU32Decoder,
+ getU32Encoder,
+ getU64Decoder,
+ getU64Encoder,
+ getUtf8Decoder,
+ getUtf8Encoder,
+ transformEncoder,
+ type Account,
+ type Address,
+ type Codec,
+ type Decoder,
+ type EncodedAccount,
+ type Encoder,
+ type FetchAccountConfig,
+ type FetchAccountsConfig,
+ type MaybeAccount,
+ type MaybeEncodedAccount,
+ type ReadonlyUint8Array,
+} from "@solana/kit";
+import {
+ getResolverTypeDecoder,
+ getResolverTypeEncoder,
+ type ResolverType,
+ type ResolverTypeArgs,
+} from "../types";
+
+export const RESOLVER_ENTRY_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
+ 0, 60, 55, 58, 157, 135, 51, 191,
+]);
+
+export function getResolverEntryDiscriminatorBytes(): ReadonlyUint8Array {
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
+ RESOLVER_ENTRY_DISCRIMINATOR,
+ );
+}
+
+export type ResolverEntry = {
+ discriminator: ReadonlyUint8Array;
+ authority: Address;
+ resolverType: ResolverType;
+ name: string;
+ description: string;
+ feeBps: number;
+ feeRecipient: Address;
+ metadataUri: string;
+ totalResolved: bigint;
+ ruledForBuyer: bigint;
+ ruledForSeller: bigint;
+ registeredAt: bigint;
+};
+
+export type ResolverEntryArgs = {
+ authority: Address;
+ resolverType: ResolverTypeArgs;
+ name: string;
+ description: string;
+ feeBps: number;
+ feeRecipient: Address;
+ metadataUri: string;
+ totalResolved: number | bigint;
+ ruledForBuyer: number | bigint;
+ ruledForSeller: number | bigint;
+ registeredAt: number | bigint;
+};
+
+/** Gets the encoder for {@link ResolverEntryArgs} account data. */
+export function getResolverEntryEncoder(): Encoder {
+ return transformEncoder(
+ getStructEncoder([
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
+ ["authority", getAddressEncoder()],
+ ["resolverType", getResolverTypeEncoder()],
+ ["name", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
+ ["description", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
+ ["feeBps", getU16Encoder()],
+ ["feeRecipient", getAddressEncoder()],
+ ["metadataUri", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
+ ["totalResolved", getU64Encoder()],
+ ["ruledForBuyer", getU64Encoder()],
+ ["ruledForSeller", getU64Encoder()],
+ ["registeredAt", getI64Encoder()],
+ ]),
+ (value) => ({ ...value, discriminator: RESOLVER_ENTRY_DISCRIMINATOR }),
+ );
+}
+
+/** Gets the decoder for {@link ResolverEntry} account data. */
+export function getResolverEntryDecoder(): Decoder {
+ return getStructDecoder([
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
+ ["authority", getAddressDecoder()],
+ ["resolverType", getResolverTypeDecoder()],
+ ["name", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
+ ["description", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
+ ["feeBps", getU16Decoder()],
+ ["feeRecipient", getAddressDecoder()],
+ ["metadataUri", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
+ ["totalResolved", getU64Decoder()],
+ ["ruledForBuyer", getU64Decoder()],
+ ["ruledForSeller", getU64Decoder()],
+ ["registeredAt", getI64Decoder()],
+ ]);
+}
+
+/** Gets the codec for {@link ResolverEntry} account data. */
+export function getResolverEntryCodec(): Codec<
+ ResolverEntryArgs,
+ ResolverEntry
+> {
+ return combineCodec(getResolverEntryEncoder(), getResolverEntryDecoder());
+}
+
+export function decodeResolverEntry(
+ encodedAccount: EncodedAccount,
+): Account;
+export function decodeResolverEntry(
+ encodedAccount: MaybeEncodedAccount,
+): MaybeAccount;
+export function decodeResolverEntry(
+ encodedAccount: EncodedAccount | MaybeEncodedAccount,
+): Account | MaybeAccount