update sdk
This commit is contained in:
@@ -19,6 +19,8 @@ import {
|
||||
getAddressEncoder,
|
||||
getBytesDecoder,
|
||||
getBytesEncoder,
|
||||
getI64Decoder,
|
||||
getI64Encoder,
|
||||
getOptionDecoder,
|
||||
getOptionEncoder,
|
||||
getStructDecoder,
|
||||
@@ -69,6 +71,7 @@ export type EscrowAccount = {
|
||||
bump: number;
|
||||
vaultBump: number;
|
||||
escrowId: bigint;
|
||||
disputeRaisedAt: Option<bigint>;
|
||||
};
|
||||
|
||||
export type EscrowAccountArgs = {
|
||||
@@ -80,6 +83,7 @@ export type EscrowAccountArgs = {
|
||||
bump: number;
|
||||
vaultBump: number;
|
||||
escrowId: number | bigint;
|
||||
disputeRaisedAt: OptionOrNullable<number | bigint>;
|
||||
};
|
||||
|
||||
/** Gets the encoder for {@link EscrowAccountArgs} account data. */
|
||||
@@ -95,6 +99,7 @@ export function getEscrowAccountEncoder(): Encoder<EscrowAccountArgs> {
|
||||
["bump", getU8Encoder()],
|
||||
["vaultBump", getU8Encoder()],
|
||||
["escrowId", getU64Encoder()],
|
||||
["disputeRaisedAt", getOptionEncoder(getI64Encoder())],
|
||||
]),
|
||||
(value) => ({ ...value, discriminator: ESCROW_ACCOUNT_DISCRIMINATOR }),
|
||||
);
|
||||
@@ -112,6 +117,7 @@ export function getEscrowAccountDecoder(): Decoder<EscrowAccount> {
|
||||
["bump", getU8Decoder()],
|
||||
["vaultBump", getU8Decoder()],
|
||||
["escrowId", getU64Decoder()],
|
||||
["disputeRaisedAt", getOptionDecoder(getI64Decoder())],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,20 +24,36 @@ export const DESCRO_ERROR__NO_RESOLVER_CONFIGURED = 0x1772; // 6002
|
||||
export const DESCRO_ERROR__UNAUTHORIZED_RESOLVER = 0x1773; // 6003
|
||||
/** Expired: Escrow has expired */
|
||||
export const DESCRO_ERROR__EXPIRED = 0x1774; // 6004
|
||||
/** DisputeTimeoutNotReached: Dispute timeout period has not elapsed yet */
|
||||
export const DESCRO_ERROR__DISPUTE_TIMEOUT_NOT_REACHED = 0x1775; // 6005
|
||||
/** InsufficientVaultBalance: Vault balance is insufficient for the requested escrow amount */
|
||||
export const DESCRO_ERROR__INSUFFICIENT_VAULT_BALANCE = 0x1776; // 6006
|
||||
/** AmountBelowRentMinimum: Amount must be at least rent-exempt minimum for the vault (~890880 lamports) */
|
||||
export const DESCRO_ERROR__AMOUNT_BELOW_RENT_MINIMUM = 0x1777; // 6007
|
||||
/** ResolverSignatureRequired: Resolver must co-sign this transaction (SignatureGated acceptance policy) */
|
||||
export const DESCRO_ERROR__RESOLVER_SIGNATURE_REQUIRED = 0x1778; // 6008
|
||||
|
||||
export type DescroError =
|
||||
| typeof DESCRO_ERROR__AMOUNT_BELOW_RENT_MINIMUM
|
||||
| typeof DESCRO_ERROR__DISPUTE_TIMEOUT_NOT_REACHED
|
||||
| typeof DESCRO_ERROR__EXPIRED
|
||||
| typeof DESCRO_ERROR__INSUFFICIENT_VAULT_BALANCE
|
||||
| typeof DESCRO_ERROR__INVALID_STATE
|
||||
| typeof DESCRO_ERROR__NO_RESOLVER_CONFIGURED
|
||||
| typeof DESCRO_ERROR__RESOLVER_SIGNATURE_REQUIRED
|
||||
| typeof DESCRO_ERROR__UNAUTHORIZED
|
||||
| typeof DESCRO_ERROR__UNAUTHORIZED_RESOLVER;
|
||||
|
||||
let descroErrorMessages: Record<DescroError, string> | undefined;
|
||||
if (process.env["NODE_ENV"] !== "production") {
|
||||
descroErrorMessages = {
|
||||
[DESCRO_ERROR__AMOUNT_BELOW_RENT_MINIMUM]: `Amount must be at least rent-exempt minimum for the vault (~890880 lamports)`,
|
||||
[DESCRO_ERROR__DISPUTE_TIMEOUT_NOT_REACHED]: `Dispute timeout period has not elapsed yet`,
|
||||
[DESCRO_ERROR__EXPIRED]: `Escrow has expired`,
|
||||
[DESCRO_ERROR__INSUFFICIENT_VAULT_BALANCE]: `Vault balance is insufficient for the requested escrow amount`,
|
||||
[DESCRO_ERROR__INVALID_STATE]: `Invalid state for this instruction`,
|
||||
[DESCRO_ERROR__NO_RESOLVER_CONFIGURED]: `No resolver configured for this escrow`,
|
||||
[DESCRO_ERROR__RESOLVER_SIGNATURE_REQUIRED]: `Resolver must co-sign this transaction (SignatureGated acceptance policy)`,
|
||||
[DESCRO_ERROR__UNAUTHORIZED]: `Signer is not authorized`,
|
||||
[DESCRO_ERROR__UNAUTHORIZED_RESOLVER]: `Signer is not the configured resolver`,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,384 @@
|
||||
/**
|
||||
* 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 BUYER_CREATE_ESCROW_DISCRIMINATOR: ReadonlyUint8Array =
|
||||
new Uint8Array([79, 199, 251, 30, 163, 86, 13, 73]);
|
||||
|
||||
export function getBuyerCreateEscrowDiscriminatorBytes(): ReadonlyUint8Array {
|
||||
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
||||
BUYER_CREATE_ESCROW_DISCRIMINATOR,
|
||||
);
|
||||
}
|
||||
|
||||
export type BuyerCreateEscrowInstruction<
|
||||
TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
|
||||
TAccountBuyer extends string | AccountMeta<string> = string,
|
||||
TAccountSeller extends string | AccountMeta<string> = string,
|
||||
TAccountEscrowAccount extends string | AccountMeta<string> = string,
|
||||
TAccountVault extends string | AccountMeta<string> = string,
|
||||
TAccountSystemProgram extends string | AccountMeta<string> =
|
||||
"11111111111111111111111111111111",
|
||||
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
||||
> = Instruction<TProgram> &
|
||||
InstructionWithData<ReadonlyUint8Array> &
|
||||
InstructionWithAccounts<
|
||||
[
|
||||
TAccountBuyer extends string
|
||||
? WritableSignerAccount<TAccountBuyer> &
|
||||
AccountSignerMeta<TAccountBuyer>
|
||||
: TAccountBuyer,
|
||||
TAccountSeller extends string
|
||||
? ReadonlyAccount<TAccountSeller>
|
||||
: TAccountSeller,
|
||||
TAccountEscrowAccount extends string
|
||||
? WritableAccount<TAccountEscrowAccount>
|
||||
: TAccountEscrowAccount,
|
||||
TAccountVault extends string
|
||||
? WritableAccount<TAccountVault>
|
||||
: TAccountVault,
|
||||
TAccountSystemProgram extends string
|
||||
? ReadonlyAccount<TAccountSystemProgram>
|
||||
: TAccountSystemProgram,
|
||||
...TRemainingAccounts,
|
||||
]
|
||||
>;
|
||||
|
||||
export type BuyerCreateEscrowInstructionData = {
|
||||
discriminator: ReadonlyUint8Array;
|
||||
amount: bigint;
|
||||
disputeResolver: Option<Address>;
|
||||
escrowId: bigint;
|
||||
};
|
||||
|
||||
export type BuyerCreateEscrowInstructionDataArgs = {
|
||||
amount: number | bigint;
|
||||
disputeResolver: OptionOrNullable<Address>;
|
||||
escrowId: number | bigint;
|
||||
};
|
||||
|
||||
export function getBuyerCreateEscrowInstructionDataEncoder(): Encoder<BuyerCreateEscrowInstructionDataArgs> {
|
||||
return transformEncoder(
|
||||
getStructEncoder([
|
||||
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
||||
["amount", getU64Encoder()],
|
||||
["disputeResolver", getOptionEncoder(getAddressEncoder())],
|
||||
["escrowId", getU64Encoder()],
|
||||
]),
|
||||
(value) => ({ ...value, discriminator: BUYER_CREATE_ESCROW_DISCRIMINATOR }),
|
||||
);
|
||||
}
|
||||
|
||||
export function getBuyerCreateEscrowInstructionDataDecoder(): Decoder<BuyerCreateEscrowInstructionData> {
|
||||
return getStructDecoder([
|
||||
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
||||
["amount", getU64Decoder()],
|
||||
["disputeResolver", getOptionDecoder(getAddressDecoder())],
|
||||
["escrowId", getU64Decoder()],
|
||||
]);
|
||||
}
|
||||
|
||||
export function getBuyerCreateEscrowInstructionDataCodec(): Codec<
|
||||
BuyerCreateEscrowInstructionDataArgs,
|
||||
BuyerCreateEscrowInstructionData
|
||||
> {
|
||||
return combineCodec(
|
||||
getBuyerCreateEscrowInstructionDataEncoder(),
|
||||
getBuyerCreateEscrowInstructionDataDecoder(),
|
||||
);
|
||||
}
|
||||
|
||||
export type BuyerCreateEscrowAsyncInput<
|
||||
TAccountBuyer extends string = string,
|
||||
TAccountSeller extends string = string,
|
||||
TAccountEscrowAccount extends string = string,
|
||||
TAccountVault extends string = string,
|
||||
TAccountSystemProgram extends string = string,
|
||||
> = {
|
||||
buyer: TransactionSigner<TAccountBuyer>;
|
||||
seller: Address<TAccountSeller>;
|
||||
escrowAccount?: Address<TAccountEscrowAccount>;
|
||||
vault?: Address<TAccountVault>;
|
||||
systemProgram?: Address<TAccountSystemProgram>;
|
||||
amount: BuyerCreateEscrowInstructionDataArgs["amount"];
|
||||
disputeResolver: BuyerCreateEscrowInstructionDataArgs["disputeResolver"];
|
||||
escrowId: BuyerCreateEscrowInstructionDataArgs["escrowId"];
|
||||
};
|
||||
|
||||
export async function getBuyerCreateEscrowInstructionAsync<
|
||||
TAccountBuyer extends string,
|
||||
TAccountSeller extends string,
|
||||
TAccountEscrowAccount extends string,
|
||||
TAccountVault extends string,
|
||||
TAccountSystemProgram extends string,
|
||||
TProgramAddress extends Address = typeof DESCRO_PROGRAM_ADDRESS,
|
||||
>(
|
||||
input: BuyerCreateEscrowAsyncInput<
|
||||
TAccountBuyer,
|
||||
TAccountSeller,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountSystemProgram
|
||||
>,
|
||||
config?: { programAddress?: TProgramAddress },
|
||||
): Promise<
|
||||
BuyerCreateEscrowInstruction<
|
||||
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: true },
|
||||
seller: { value: input.seller ?? 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("buyer", accounts.buyer),
|
||||
getAccountMeta("seller", accounts.seller),
|
||||
getAccountMeta("escrowAccount", accounts.escrowAccount),
|
||||
getAccountMeta("vault", accounts.vault),
|
||||
getAccountMeta("systemProgram", accounts.systemProgram),
|
||||
],
|
||||
data: getBuyerCreateEscrowInstructionDataEncoder().encode(
|
||||
args as BuyerCreateEscrowInstructionDataArgs,
|
||||
),
|
||||
programAddress,
|
||||
} as BuyerCreateEscrowInstruction<
|
||||
TProgramAddress,
|
||||
TAccountBuyer,
|
||||
TAccountSeller,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountSystemProgram
|
||||
>);
|
||||
}
|
||||
|
||||
export type BuyerCreateEscrowInput<
|
||||
TAccountBuyer extends string = string,
|
||||
TAccountSeller extends string = string,
|
||||
TAccountEscrowAccount extends string = string,
|
||||
TAccountVault extends string = string,
|
||||
TAccountSystemProgram extends string = string,
|
||||
> = {
|
||||
buyer: TransactionSigner<TAccountBuyer>;
|
||||
seller: Address<TAccountSeller>;
|
||||
escrowAccount: Address<TAccountEscrowAccount>;
|
||||
vault: Address<TAccountVault>;
|
||||
systemProgram?: Address<TAccountSystemProgram>;
|
||||
amount: BuyerCreateEscrowInstructionDataArgs["amount"];
|
||||
disputeResolver: BuyerCreateEscrowInstructionDataArgs["disputeResolver"];
|
||||
escrowId: BuyerCreateEscrowInstructionDataArgs["escrowId"];
|
||||
};
|
||||
|
||||
export function getBuyerCreateEscrowInstruction<
|
||||
TAccountBuyer extends string,
|
||||
TAccountSeller extends string,
|
||||
TAccountEscrowAccount extends string,
|
||||
TAccountVault extends string,
|
||||
TAccountSystemProgram extends string,
|
||||
TProgramAddress extends Address = typeof DESCRO_PROGRAM_ADDRESS,
|
||||
>(
|
||||
input: BuyerCreateEscrowInput<
|
||||
TAccountBuyer,
|
||||
TAccountSeller,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountSystemProgram
|
||||
>,
|
||||
config?: { programAddress?: TProgramAddress },
|
||||
): BuyerCreateEscrowInstruction<
|
||||
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: true },
|
||||
seller: { value: input.seller ?? 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("buyer", accounts.buyer),
|
||||
getAccountMeta("seller", accounts.seller),
|
||||
getAccountMeta("escrowAccount", accounts.escrowAccount),
|
||||
getAccountMeta("vault", accounts.vault),
|
||||
getAccountMeta("systemProgram", accounts.systemProgram),
|
||||
],
|
||||
data: getBuyerCreateEscrowInstructionDataEncoder().encode(
|
||||
args as BuyerCreateEscrowInstructionDataArgs,
|
||||
),
|
||||
programAddress,
|
||||
} as BuyerCreateEscrowInstruction<
|
||||
TProgramAddress,
|
||||
TAccountBuyer,
|
||||
TAccountSeller,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountSystemProgram
|
||||
>);
|
||||
}
|
||||
|
||||
export type ParsedBuyerCreateEscrowInstruction<
|
||||
TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
|
||||
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
||||
> = {
|
||||
programAddress: Address<TProgram>;
|
||||
accounts: {
|
||||
buyer: TAccountMetas[0];
|
||||
seller: TAccountMetas[1];
|
||||
escrowAccount: TAccountMetas[2];
|
||||
vault: TAccountMetas[3];
|
||||
systemProgram: TAccountMetas[4];
|
||||
};
|
||||
data: BuyerCreateEscrowInstructionData;
|
||||
};
|
||||
|
||||
export function parseBuyerCreateEscrowInstruction<
|
||||
TProgram extends string,
|
||||
TAccountMetas extends readonly AccountMeta[],
|
||||
>(
|
||||
instruction: Instruction<TProgram> &
|
||||
InstructionWithAccounts<TAccountMetas> &
|
||||
InstructionWithData<ReadonlyUint8Array>,
|
||||
): ParsedBuyerCreateEscrowInstruction<TProgram, TAccountMetas> {
|
||||
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: getBuyerCreateEscrowInstructionDataDecoder().decode(instruction.data),
|
||||
};
|
||||
}
|
||||
@@ -34,8 +34,10 @@ import {
|
||||
} 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 CANCEL_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
|
||||
@@ -48,8 +50,10 @@ export function getCancelDiscriminatorBytes(): ReadonlyUint8Array {
|
||||
|
||||
export type CancelInstruction<
|
||||
TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
|
||||
TAccountSeller extends string | AccountMeta<string> = string,
|
||||
TAccountCanceller extends string | AccountMeta<string> = string,
|
||||
TAccountBuyer extends string | AccountMeta<string> = string,
|
||||
TAccountEscrowAccount extends string | AccountMeta<string> = string,
|
||||
TAccountVault extends string | AccountMeta<string> = string,
|
||||
TAccountSystemProgram extends string | AccountMeta<string> =
|
||||
"11111111111111111111111111111111",
|
||||
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
||||
@@ -57,13 +61,19 @@ export type CancelInstruction<
|
||||
InstructionWithData<ReadonlyUint8Array> &
|
||||
InstructionWithAccounts<
|
||||
[
|
||||
TAccountSeller extends string
|
||||
? WritableSignerAccount<TAccountSeller> &
|
||||
AccountSignerMeta<TAccountSeller>
|
||||
: TAccountSeller,
|
||||
TAccountCanceller extends string
|
||||
? WritableSignerAccount<TAccountCanceller> &
|
||||
AccountSignerMeta<TAccountCanceller>
|
||||
: TAccountCanceller,
|
||||
TAccountBuyer extends string
|
||||
? WritableAccount<TAccountBuyer>
|
||||
: TAccountBuyer,
|
||||
TAccountEscrowAccount extends string
|
||||
? WritableAccount<TAccountEscrowAccount>
|
||||
: TAccountEscrowAccount,
|
||||
TAccountVault extends string
|
||||
? WritableAccount<TAccountVault>
|
||||
: TAccountVault,
|
||||
TAccountSystemProgram extends string
|
||||
? ReadonlyAccount<TAccountSystemProgram>
|
||||
: TAccountSystemProgram,
|
||||
@@ -98,32 +108,133 @@ export function getCancelInstructionDataCodec(): FixedSizeCodec<
|
||||
);
|
||||
}
|
||||
|
||||
export type CancelInput<
|
||||
TAccountSeller extends string = string,
|
||||
export type CancelAsyncInput<
|
||||
TAccountCanceller extends string = string,
|
||||
TAccountBuyer extends string = string,
|
||||
TAccountEscrowAccount extends string = string,
|
||||
TAccountVault extends string = string,
|
||||
TAccountSystemProgram extends string = string,
|
||||
> = {
|
||||
seller: TransactionSigner<TAccountSeller>;
|
||||
canceller: TransactionSigner<TAccountCanceller>;
|
||||
buyer: Address<TAccountBuyer>;
|
||||
escrowAccount: Address<TAccountEscrowAccount>;
|
||||
vault?: Address<TAccountVault>;
|
||||
systemProgram?: Address<TAccountSystemProgram>;
|
||||
};
|
||||
|
||||
export async function getCancelInstructionAsync<
|
||||
TAccountCanceller extends string,
|
||||
TAccountBuyer extends string,
|
||||
TAccountEscrowAccount extends string,
|
||||
TAccountVault extends string,
|
||||
TAccountSystemProgram extends string,
|
||||
TProgramAddress extends Address = typeof DESCRO_PROGRAM_ADDRESS,
|
||||
>(
|
||||
input: CancelAsyncInput<
|
||||
TAccountCanceller,
|
||||
TAccountBuyer,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountSystemProgram
|
||||
>,
|
||||
config?: { programAddress?: TProgramAddress },
|
||||
): Promise<
|
||||
CancelInstruction<
|
||||
TProgramAddress,
|
||||
TAccountCanceller,
|
||||
TAccountBuyer,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountSystemProgram
|
||||
>
|
||||
> {
|
||||
// Program address.
|
||||
const programAddress = config?.programAddress ?? DESCRO_PROGRAM_ADDRESS;
|
||||
|
||||
// Original accounts.
|
||||
const originalAccounts = {
|
||||
canceller: { value: input.canceller ?? null, isWritable: true },
|
||||
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("canceller", accounts.canceller),
|
||||
getAccountMeta("buyer", accounts.buyer),
|
||||
getAccountMeta("escrowAccount", accounts.escrowAccount),
|
||||
getAccountMeta("vault", accounts.vault),
|
||||
getAccountMeta("systemProgram", accounts.systemProgram),
|
||||
],
|
||||
data: getCancelInstructionDataEncoder().encode({}),
|
||||
programAddress,
|
||||
} as CancelInstruction<
|
||||
TProgramAddress,
|
||||
TAccountCanceller,
|
||||
TAccountBuyer,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountSystemProgram
|
||||
>);
|
||||
}
|
||||
|
||||
export type CancelInput<
|
||||
TAccountCanceller extends string = string,
|
||||
TAccountBuyer extends string = string,
|
||||
TAccountEscrowAccount extends string = string,
|
||||
TAccountVault extends string = string,
|
||||
TAccountSystemProgram extends string = string,
|
||||
> = {
|
||||
canceller: TransactionSigner<TAccountCanceller>;
|
||||
buyer: Address<TAccountBuyer>;
|
||||
escrowAccount: Address<TAccountEscrowAccount>;
|
||||
vault: Address<TAccountVault>;
|
||||
systemProgram?: Address<TAccountSystemProgram>;
|
||||
};
|
||||
|
||||
export function getCancelInstruction<
|
||||
TAccountSeller extends string,
|
||||
TAccountCanceller extends string,
|
||||
TAccountBuyer extends string,
|
||||
TAccountEscrowAccount extends string,
|
||||
TAccountVault extends string,
|
||||
TAccountSystemProgram extends string,
|
||||
TProgramAddress extends Address = typeof DESCRO_PROGRAM_ADDRESS,
|
||||
>(
|
||||
input: CancelInput<
|
||||
TAccountSeller,
|
||||
TAccountCanceller,
|
||||
TAccountBuyer,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountSystemProgram
|
||||
>,
|
||||
config?: { programAddress?: TProgramAddress },
|
||||
): CancelInstruction<
|
||||
TProgramAddress,
|
||||
TAccountSeller,
|
||||
TAccountCanceller,
|
||||
TAccountBuyer,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountSystemProgram
|
||||
> {
|
||||
// Program address.
|
||||
@@ -131,8 +242,10 @@ export function getCancelInstruction<
|
||||
|
||||
// Original accounts.
|
||||
const originalAccounts = {
|
||||
seller: { value: input.seller ?? null, isWritable: true },
|
||||
canceller: { value: input.canceller ?? null, isWritable: true },
|
||||
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<
|
||||
@@ -149,16 +262,20 @@ export function getCancelInstruction<
|
||||
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
||||
return Object.freeze({
|
||||
accounts: [
|
||||
getAccountMeta("seller", accounts.seller),
|
||||
getAccountMeta("canceller", accounts.canceller),
|
||||
getAccountMeta("buyer", accounts.buyer),
|
||||
getAccountMeta("escrowAccount", accounts.escrowAccount),
|
||||
getAccountMeta("vault", accounts.vault),
|
||||
getAccountMeta("systemProgram", accounts.systemProgram),
|
||||
],
|
||||
data: getCancelInstructionDataEncoder().encode({}),
|
||||
programAddress,
|
||||
} as CancelInstruction<
|
||||
TProgramAddress,
|
||||
TAccountSeller,
|
||||
TAccountCanceller,
|
||||
TAccountBuyer,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountSystemProgram
|
||||
>);
|
||||
}
|
||||
@@ -169,9 +286,11 @@ export type ParsedCancelInstruction<
|
||||
> = {
|
||||
programAddress: Address<TProgram>;
|
||||
accounts: {
|
||||
seller: TAccountMetas[0];
|
||||
escrowAccount: TAccountMetas[1];
|
||||
systemProgram: TAccountMetas[2];
|
||||
canceller: TAccountMetas[0];
|
||||
buyer: TAccountMetas[1];
|
||||
escrowAccount: TAccountMetas[2];
|
||||
vault: TAccountMetas[3];
|
||||
systemProgram: TAccountMetas[4];
|
||||
};
|
||||
data: CancelInstructionData;
|
||||
};
|
||||
@@ -184,12 +303,12 @@ export function parseCancelInstruction<
|
||||
InstructionWithAccounts<TAccountMetas> &
|
||||
InstructionWithData<ReadonlyUint8Array>,
|
||||
): ParsedCancelInstruction<TProgram, TAccountMetas> {
|
||||
if (instruction.accounts.length < 3) {
|
||||
if (instruction.accounts.length < 5) {
|
||||
throw new SolanaError(
|
||||
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
||||
{
|
||||
actualAccountMetas: instruction.accounts.length,
|
||||
expectedAccountMetas: 3,
|
||||
expectedAccountMetas: 5,
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -202,8 +321,10 @@ export function parseCancelInstruction<
|
||||
return {
|
||||
programAddress: instruction.programAddress,
|
||||
accounts: {
|
||||
seller: getNextAccount(),
|
||||
canceller: getNextAccount(),
|
||||
buyer: getNextAccount(),
|
||||
escrowAccount: getNextAccount(),
|
||||
vault: getNextAccount(),
|
||||
systemProgram: getNextAccount(),
|
||||
},
|
||||
data: getCancelInstructionDataDecoder().decode(instruction.data),
|
||||
|
||||
@@ -63,8 +63,10 @@ export type CreateEscrowInstruction<
|
||||
TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
|
||||
TAccountSeller extends string | AccountMeta<string> = string,
|
||||
TAccountBuyer extends string | AccountMeta<string> = string,
|
||||
TAccountResolver extends string | AccountMeta<string> = string,
|
||||
TAccountEscrowAccount extends string | AccountMeta<string> = string,
|
||||
TAccountVault extends string | AccountMeta<string> = string,
|
||||
TAccountResolverEntry extends string | AccountMeta<string> = string,
|
||||
TAccountSystemProgram extends string | AccountMeta<string> =
|
||||
"11111111111111111111111111111111",
|
||||
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
||||
@@ -79,12 +81,18 @@ export type CreateEscrowInstruction<
|
||||
TAccountBuyer extends string
|
||||
? ReadonlyAccount<TAccountBuyer>
|
||||
: TAccountBuyer,
|
||||
TAccountResolver extends string
|
||||
? ReadonlyAccount<TAccountResolver>
|
||||
: TAccountResolver,
|
||||
TAccountEscrowAccount extends string
|
||||
? WritableAccount<TAccountEscrowAccount>
|
||||
: TAccountEscrowAccount,
|
||||
TAccountVault extends string
|
||||
? WritableAccount<TAccountVault>
|
||||
: TAccountVault,
|
||||
TAccountResolverEntry extends string
|
||||
? ReadonlyAccount<TAccountResolverEntry>
|
||||
: TAccountResolverEntry,
|
||||
TAccountSystemProgram extends string
|
||||
? ReadonlyAccount<TAccountSystemProgram>
|
||||
: TAccountSystemProgram,
|
||||
@@ -139,14 +147,18 @@ export function getCreateEscrowInstructionDataCodec(): Codec<
|
||||
export type CreateEscrowAsyncInput<
|
||||
TAccountSeller extends string = string,
|
||||
TAccountBuyer extends string = string,
|
||||
TAccountResolver extends string = string,
|
||||
TAccountEscrowAccount extends string = string,
|
||||
TAccountVault extends string = string,
|
||||
TAccountResolverEntry extends string = string,
|
||||
TAccountSystemProgram extends string = string,
|
||||
> = {
|
||||
seller: TransactionSigner<TAccountSeller>;
|
||||
buyer: Address<TAccountBuyer>;
|
||||
resolver: Address<TAccountResolver>;
|
||||
escrowAccount?: Address<TAccountEscrowAccount>;
|
||||
vault?: Address<TAccountVault>;
|
||||
resolverEntry: Address<TAccountResolverEntry>;
|
||||
systemProgram?: Address<TAccountSystemProgram>;
|
||||
amount: CreateEscrowInstructionDataArgs["amount"];
|
||||
disputeResolver: CreateEscrowInstructionDataArgs["disputeResolver"];
|
||||
@@ -156,16 +168,20 @@ export type CreateEscrowAsyncInput<
|
||||
export async function getCreateEscrowInstructionAsync<
|
||||
TAccountSeller extends string,
|
||||
TAccountBuyer extends string,
|
||||
TAccountResolver extends string,
|
||||
TAccountEscrowAccount extends string,
|
||||
TAccountVault extends string,
|
||||
TAccountResolverEntry extends string,
|
||||
TAccountSystemProgram extends string,
|
||||
TProgramAddress extends Address = typeof DESCRO_PROGRAM_ADDRESS,
|
||||
>(
|
||||
input: CreateEscrowAsyncInput<
|
||||
TAccountSeller,
|
||||
TAccountBuyer,
|
||||
TAccountResolver,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountResolverEntry,
|
||||
TAccountSystemProgram
|
||||
>,
|
||||
config?: { programAddress?: TProgramAddress },
|
||||
@@ -174,8 +190,10 @@ export async function getCreateEscrowInstructionAsync<
|
||||
TProgramAddress,
|
||||
TAccountSeller,
|
||||
TAccountBuyer,
|
||||
TAccountResolver,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountResolverEntry,
|
||||
TAccountSystemProgram
|
||||
>
|
||||
> {
|
||||
@@ -186,8 +204,10 @@ export async function getCreateEscrowInstructionAsync<
|
||||
const originalAccounts = {
|
||||
seller: { value: input.seller ?? null, isWritable: true },
|
||||
buyer: { value: input.buyer ?? null, isWritable: false },
|
||||
resolver: { value: input.resolver ?? null, isWritable: false },
|
||||
escrowAccount: { value: input.escrowAccount ?? null, isWritable: true },
|
||||
vault: { value: input.vault ?? null, isWritable: true },
|
||||
resolverEntry: { value: input.resolverEntry ?? null, isWritable: false },
|
||||
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
||||
};
|
||||
const accounts = originalAccounts as Record<
|
||||
@@ -226,8 +246,10 @@ export async function getCreateEscrowInstructionAsync<
|
||||
accounts: [
|
||||
getAccountMeta("seller", accounts.seller),
|
||||
getAccountMeta("buyer", accounts.buyer),
|
||||
getAccountMeta("resolver", accounts.resolver),
|
||||
getAccountMeta("escrowAccount", accounts.escrowAccount),
|
||||
getAccountMeta("vault", accounts.vault),
|
||||
getAccountMeta("resolverEntry", accounts.resolverEntry),
|
||||
getAccountMeta("systemProgram", accounts.systemProgram),
|
||||
],
|
||||
data: getCreateEscrowInstructionDataEncoder().encode(
|
||||
@@ -238,8 +260,10 @@ export async function getCreateEscrowInstructionAsync<
|
||||
TProgramAddress,
|
||||
TAccountSeller,
|
||||
TAccountBuyer,
|
||||
TAccountResolver,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountResolverEntry,
|
||||
TAccountSystemProgram
|
||||
>);
|
||||
}
|
||||
@@ -247,14 +271,18 @@ export async function getCreateEscrowInstructionAsync<
|
||||
export type CreateEscrowInput<
|
||||
TAccountSeller extends string = string,
|
||||
TAccountBuyer extends string = string,
|
||||
TAccountResolver extends string = string,
|
||||
TAccountEscrowAccount extends string = string,
|
||||
TAccountVault extends string = string,
|
||||
TAccountResolverEntry extends string = string,
|
||||
TAccountSystemProgram extends string = string,
|
||||
> = {
|
||||
seller: TransactionSigner<TAccountSeller>;
|
||||
buyer: Address<TAccountBuyer>;
|
||||
resolver: Address<TAccountResolver>;
|
||||
escrowAccount: Address<TAccountEscrowAccount>;
|
||||
vault: Address<TAccountVault>;
|
||||
resolverEntry: Address<TAccountResolverEntry>;
|
||||
systemProgram?: Address<TAccountSystemProgram>;
|
||||
amount: CreateEscrowInstructionDataArgs["amount"];
|
||||
disputeResolver: CreateEscrowInstructionDataArgs["disputeResolver"];
|
||||
@@ -264,16 +292,20 @@ export type CreateEscrowInput<
|
||||
export function getCreateEscrowInstruction<
|
||||
TAccountSeller extends string,
|
||||
TAccountBuyer extends string,
|
||||
TAccountResolver extends string,
|
||||
TAccountEscrowAccount extends string,
|
||||
TAccountVault extends string,
|
||||
TAccountResolverEntry extends string,
|
||||
TAccountSystemProgram extends string,
|
||||
TProgramAddress extends Address = typeof DESCRO_PROGRAM_ADDRESS,
|
||||
>(
|
||||
input: CreateEscrowInput<
|
||||
TAccountSeller,
|
||||
TAccountBuyer,
|
||||
TAccountResolver,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountResolverEntry,
|
||||
TAccountSystemProgram
|
||||
>,
|
||||
config?: { programAddress?: TProgramAddress },
|
||||
@@ -281,8 +313,10 @@ export function getCreateEscrowInstruction<
|
||||
TProgramAddress,
|
||||
TAccountSeller,
|
||||
TAccountBuyer,
|
||||
TAccountResolver,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountResolverEntry,
|
||||
TAccountSystemProgram
|
||||
> {
|
||||
// Program address.
|
||||
@@ -292,8 +326,10 @@ export function getCreateEscrowInstruction<
|
||||
const originalAccounts = {
|
||||
seller: { value: input.seller ?? null, isWritable: true },
|
||||
buyer: { value: input.buyer ?? null, isWritable: false },
|
||||
resolver: { value: input.resolver ?? null, isWritable: false },
|
||||
escrowAccount: { value: input.escrowAccount ?? null, isWritable: true },
|
||||
vault: { value: input.vault ?? null, isWritable: true },
|
||||
resolverEntry: { value: input.resolverEntry ?? null, isWritable: false },
|
||||
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
||||
};
|
||||
const accounts = originalAccounts as Record<
|
||||
@@ -315,8 +351,10 @@ export function getCreateEscrowInstruction<
|
||||
accounts: [
|
||||
getAccountMeta("seller", accounts.seller),
|
||||
getAccountMeta("buyer", accounts.buyer),
|
||||
getAccountMeta("resolver", accounts.resolver),
|
||||
getAccountMeta("escrowAccount", accounts.escrowAccount),
|
||||
getAccountMeta("vault", accounts.vault),
|
||||
getAccountMeta("resolverEntry", accounts.resolverEntry),
|
||||
getAccountMeta("systemProgram", accounts.systemProgram),
|
||||
],
|
||||
data: getCreateEscrowInstructionDataEncoder().encode(
|
||||
@@ -327,8 +365,10 @@ export function getCreateEscrowInstruction<
|
||||
TProgramAddress,
|
||||
TAccountSeller,
|
||||
TAccountBuyer,
|
||||
TAccountResolver,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountResolverEntry,
|
||||
TAccountSystemProgram
|
||||
>);
|
||||
}
|
||||
@@ -341,9 +381,11 @@ export type ParsedCreateEscrowInstruction<
|
||||
accounts: {
|
||||
seller: TAccountMetas[0];
|
||||
buyer: TAccountMetas[1];
|
||||
escrowAccount: TAccountMetas[2];
|
||||
vault: TAccountMetas[3];
|
||||
systemProgram: TAccountMetas[4];
|
||||
resolver: TAccountMetas[2];
|
||||
escrowAccount: TAccountMetas[3];
|
||||
vault: TAccountMetas[4];
|
||||
resolverEntry: TAccountMetas[5];
|
||||
systemProgram: TAccountMetas[6];
|
||||
};
|
||||
data: CreateEscrowInstructionData;
|
||||
};
|
||||
@@ -356,12 +398,12 @@ export function parseCreateEscrowInstruction<
|
||||
InstructionWithAccounts<TAccountMetas> &
|
||||
InstructionWithData<ReadonlyUint8Array>,
|
||||
): ParsedCreateEscrowInstruction<TProgram, TAccountMetas> {
|
||||
if (instruction.accounts.length < 5) {
|
||||
if (instruction.accounts.length < 7) {
|
||||
throw new SolanaError(
|
||||
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
||||
{
|
||||
actualAccountMetas: instruction.accounts.length,
|
||||
expectedAccountMetas: 5,
|
||||
expectedAccountMetas: 7,
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -376,8 +418,10 @@ export function parseCreateEscrowInstruction<
|
||||
accounts: {
|
||||
seller: getNextAccount(),
|
||||
buyer: getNextAccount(),
|
||||
resolver: getNextAccount(),
|
||||
escrowAccount: getNextAccount(),
|
||||
vault: getNextAccount(),
|
||||
resolverEntry: getNextAccount(),
|
||||
systemProgram: getNextAccount(),
|
||||
},
|
||||
data: getCreateEscrowInstructionDataDecoder().decode(instruction.data),
|
||||
|
||||
@@ -0,0 +1,382 @@
|
||||
/**
|
||||
* 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,
|
||||
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";
|
||||
import {
|
||||
getWinnerDecoder,
|
||||
getWinnerEncoder,
|
||||
type Winner,
|
||||
type WinnerArgs,
|
||||
} from "../types";
|
||||
|
||||
export const EMERGENCY_RESOLVE_DISCRIMINATOR: ReadonlyUint8Array =
|
||||
new Uint8Array([63, 112, 185, 42, 47, 61, 232, 79]);
|
||||
|
||||
export function getEmergencyResolveDiscriminatorBytes(): ReadonlyUint8Array {
|
||||
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
||||
EMERGENCY_RESOLVE_DISCRIMINATOR,
|
||||
);
|
||||
}
|
||||
|
||||
export type EmergencyResolveInstruction<
|
||||
TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
|
||||
TAccountBuyer extends string | AccountMeta<string> = string,
|
||||
TAccountSeller extends string | AccountMeta<string> = string,
|
||||
TAccountWinner extends string | AccountMeta<string> = string,
|
||||
TAccountEscrowAccount extends string | AccountMeta<string> = string,
|
||||
TAccountVault extends string | AccountMeta<string> = string,
|
||||
TAccountSystemProgram extends string | AccountMeta<string> =
|
||||
"11111111111111111111111111111111",
|
||||
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
||||
> = Instruction<TProgram> &
|
||||
InstructionWithData<ReadonlyUint8Array> &
|
||||
InstructionWithAccounts<
|
||||
[
|
||||
TAccountBuyer extends string
|
||||
? ReadonlySignerAccount<TAccountBuyer> &
|
||||
AccountSignerMeta<TAccountBuyer>
|
||||
: TAccountBuyer,
|
||||
TAccountSeller extends string
|
||||
? WritableSignerAccount<TAccountSeller> &
|
||||
AccountSignerMeta<TAccountSeller>
|
||||
: TAccountSeller,
|
||||
TAccountWinner extends string
|
||||
? WritableAccount<TAccountWinner>
|
||||
: TAccountWinner,
|
||||
TAccountEscrowAccount extends string
|
||||
? WritableAccount<TAccountEscrowAccount>
|
||||
: TAccountEscrowAccount,
|
||||
TAccountVault extends string
|
||||
? WritableAccount<TAccountVault>
|
||||
: TAccountVault,
|
||||
TAccountSystemProgram extends string
|
||||
? ReadonlyAccount<TAccountSystemProgram>
|
||||
: TAccountSystemProgram,
|
||||
...TRemainingAccounts,
|
||||
]
|
||||
>;
|
||||
|
||||
export type EmergencyResolveInstructionData = {
|
||||
discriminator: ReadonlyUint8Array;
|
||||
winner: Winner;
|
||||
};
|
||||
|
||||
export type EmergencyResolveInstructionDataArgs = { winner: WinnerArgs };
|
||||
|
||||
export function getEmergencyResolveInstructionDataEncoder(): FixedSizeEncoder<EmergencyResolveInstructionDataArgs> {
|
||||
return transformEncoder(
|
||||
getStructEncoder([
|
||||
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
||||
["winner", getWinnerEncoder()],
|
||||
]),
|
||||
(value) => ({ ...value, discriminator: EMERGENCY_RESOLVE_DISCRIMINATOR }),
|
||||
);
|
||||
}
|
||||
|
||||
export function getEmergencyResolveInstructionDataDecoder(): FixedSizeDecoder<EmergencyResolveInstructionData> {
|
||||
return getStructDecoder([
|
||||
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
||||
["winner", getWinnerDecoder()],
|
||||
]);
|
||||
}
|
||||
|
||||
export function getEmergencyResolveInstructionDataCodec(): FixedSizeCodec<
|
||||
EmergencyResolveInstructionDataArgs,
|
||||
EmergencyResolveInstructionData
|
||||
> {
|
||||
return combineCodec(
|
||||
getEmergencyResolveInstructionDataEncoder(),
|
||||
getEmergencyResolveInstructionDataDecoder(),
|
||||
);
|
||||
}
|
||||
|
||||
export type EmergencyResolveAsyncInput<
|
||||
TAccountBuyer extends string = string,
|
||||
TAccountSeller extends string = string,
|
||||
TAccountWinner extends string = string,
|
||||
TAccountEscrowAccount extends string = string,
|
||||
TAccountVault extends string = string,
|
||||
TAccountSystemProgram extends string = string,
|
||||
> = {
|
||||
buyer: TransactionSigner<TAccountBuyer>;
|
||||
seller: TransactionSigner<TAccountSeller>;
|
||||
winner: Address<TAccountWinner>;
|
||||
escrowAccount: Address<TAccountEscrowAccount>;
|
||||
vault?: Address<TAccountVault>;
|
||||
systemProgram?: Address<TAccountSystemProgram>;
|
||||
winnerArg: EmergencyResolveInstructionDataArgs["winner"];
|
||||
};
|
||||
|
||||
export async function getEmergencyResolveInstructionAsync<
|
||||
TAccountBuyer extends string,
|
||||
TAccountSeller extends string,
|
||||
TAccountWinner extends string,
|
||||
TAccountEscrowAccount extends string,
|
||||
TAccountVault extends string,
|
||||
TAccountSystemProgram extends string,
|
||||
TProgramAddress extends Address = typeof DESCRO_PROGRAM_ADDRESS,
|
||||
>(
|
||||
input: EmergencyResolveAsyncInput<
|
||||
TAccountBuyer,
|
||||
TAccountSeller,
|
||||
TAccountWinner,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountSystemProgram
|
||||
>,
|
||||
config?: { programAddress?: TProgramAddress },
|
||||
): Promise<
|
||||
EmergencyResolveInstruction<
|
||||
TProgramAddress,
|
||||
TAccountBuyer,
|
||||
TAccountSeller,
|
||||
TAccountWinner,
|
||||
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 },
|
||||
winner: { value: input.winner ?? 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
|
||||
>;
|
||||
|
||||
// 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.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("winner", accounts.winner),
|
||||
getAccountMeta("escrowAccount", accounts.escrowAccount),
|
||||
getAccountMeta("vault", accounts.vault),
|
||||
getAccountMeta("systemProgram", accounts.systemProgram),
|
||||
],
|
||||
data: getEmergencyResolveInstructionDataEncoder().encode(
|
||||
args as EmergencyResolveInstructionDataArgs,
|
||||
),
|
||||
programAddress,
|
||||
} as EmergencyResolveInstruction<
|
||||
TProgramAddress,
|
||||
TAccountBuyer,
|
||||
TAccountSeller,
|
||||
TAccountWinner,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountSystemProgram
|
||||
>);
|
||||
}
|
||||
|
||||
export type EmergencyResolveInput<
|
||||
TAccountBuyer extends string = string,
|
||||
TAccountSeller extends string = string,
|
||||
TAccountWinner extends string = string,
|
||||
TAccountEscrowAccount extends string = string,
|
||||
TAccountVault extends string = string,
|
||||
TAccountSystemProgram extends string = string,
|
||||
> = {
|
||||
buyer: TransactionSigner<TAccountBuyer>;
|
||||
seller: TransactionSigner<TAccountSeller>;
|
||||
winner: Address<TAccountWinner>;
|
||||
escrowAccount: Address<TAccountEscrowAccount>;
|
||||
vault: Address<TAccountVault>;
|
||||
systemProgram?: Address<TAccountSystemProgram>;
|
||||
winnerArg: EmergencyResolveInstructionDataArgs["winner"];
|
||||
};
|
||||
|
||||
export function getEmergencyResolveInstruction<
|
||||
TAccountBuyer extends string,
|
||||
TAccountSeller extends string,
|
||||
TAccountWinner extends string,
|
||||
TAccountEscrowAccount extends string,
|
||||
TAccountVault extends string,
|
||||
TAccountSystemProgram extends string,
|
||||
TProgramAddress extends Address = typeof DESCRO_PROGRAM_ADDRESS,
|
||||
>(
|
||||
input: EmergencyResolveInput<
|
||||
TAccountBuyer,
|
||||
TAccountSeller,
|
||||
TAccountWinner,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountSystemProgram
|
||||
>,
|
||||
config?: { programAddress?: TProgramAddress },
|
||||
): EmergencyResolveInstruction<
|
||||
TProgramAddress,
|
||||
TAccountBuyer,
|
||||
TAccountSeller,
|
||||
TAccountWinner,
|
||||
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 },
|
||||
winner: { value: input.winner ?? 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
|
||||
>;
|
||||
|
||||
// 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("buyer", accounts.buyer),
|
||||
getAccountMeta("seller", accounts.seller),
|
||||
getAccountMeta("winner", accounts.winner),
|
||||
getAccountMeta("escrowAccount", accounts.escrowAccount),
|
||||
getAccountMeta("vault", accounts.vault),
|
||||
getAccountMeta("systemProgram", accounts.systemProgram),
|
||||
],
|
||||
data: getEmergencyResolveInstructionDataEncoder().encode(
|
||||
args as EmergencyResolveInstructionDataArgs,
|
||||
),
|
||||
programAddress,
|
||||
} as EmergencyResolveInstruction<
|
||||
TProgramAddress,
|
||||
TAccountBuyer,
|
||||
TAccountSeller,
|
||||
TAccountWinner,
|
||||
TAccountEscrowAccount,
|
||||
TAccountVault,
|
||||
TAccountSystemProgram
|
||||
>);
|
||||
}
|
||||
|
||||
export type ParsedEmergencyResolveInstruction<
|
||||
TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
|
||||
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
||||
> = {
|
||||
programAddress: Address<TProgram>;
|
||||
accounts: {
|
||||
buyer: TAccountMetas[0];
|
||||
seller: TAccountMetas[1];
|
||||
winner: TAccountMetas[2];
|
||||
escrowAccount: TAccountMetas[3];
|
||||
vault: TAccountMetas[4];
|
||||
systemProgram: TAccountMetas[5];
|
||||
};
|
||||
data: EmergencyResolveInstructionData;
|
||||
};
|
||||
|
||||
export function parseEmergencyResolveInstruction<
|
||||
TProgram extends string,
|
||||
TAccountMetas extends readonly AccountMeta[],
|
||||
>(
|
||||
instruction: Instruction<TProgram> &
|
||||
InstructionWithAccounts<TAccountMetas> &
|
||||
InstructionWithData<ReadonlyUint8Array>,
|
||||
): ParsedEmergencyResolveInstruction<TProgram, TAccountMetas> {
|
||||
if (instruction.accounts.length < 6) {
|
||||
throw new SolanaError(
|
||||
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
||||
{
|
||||
actualAccountMetas: instruction.accounts.length,
|
||||
expectedAccountMetas: 6,
|
||||
},
|
||||
);
|
||||
}
|
||||
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(),
|
||||
winner: getNextAccount(),
|
||||
escrowAccount: getNextAccount(),
|
||||
vault: getNextAccount(),
|
||||
systemProgram: getNextAccount(),
|
||||
},
|
||||
data: getEmergencyResolveInstructionDataDecoder().decode(instruction.data),
|
||||
};
|
||||
}
|
||||
@@ -6,9 +6,12 @@
|
||||
* @see https://github.com/codama-idl/codama
|
||||
*/
|
||||
|
||||
export * from "./buyerCreateEscrow";
|
||||
export * from "./cancel";
|
||||
export * from "./complete";
|
||||
export * from "./createEscrow";
|
||||
export * from "./deposit";
|
||||
export * from "./dispute";
|
||||
export * from "./emergencyResolve";
|
||||
export * from "./resolve";
|
||||
export * from "./sellerConfirm";
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
/**
|
||||
* 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,
|
||||
type ResolvedInstructionAccount,
|
||||
} from "@solana/program-client-core";
|
||||
import { DESCRO_PROGRAM_ADDRESS } from "../programs";
|
||||
|
||||
export const SELLER_CONFIRM_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
|
||||
21, 244, 3, 109, 138, 95, 198, 242,
|
||||
]);
|
||||
|
||||
export function getSellerConfirmDiscriminatorBytes(): ReadonlyUint8Array {
|
||||
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
||||
SELLER_CONFIRM_DISCRIMINATOR,
|
||||
);
|
||||
}
|
||||
|
||||
export type SellerConfirmInstruction<
|
||||
TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
|
||||
TAccountSeller extends string | AccountMeta<string> = string,
|
||||
TAccountResolver extends string | AccountMeta<string> = string,
|
||||
TAccountEscrowAccount extends string | AccountMeta<string> = string,
|
||||
TAccountResolverEntry extends string | AccountMeta<string> = string,
|
||||
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
||||
> = Instruction<TProgram> &
|
||||
InstructionWithData<ReadonlyUint8Array> &
|
||||
InstructionWithAccounts<
|
||||
[
|
||||
TAccountSeller extends string
|
||||
? ReadonlySignerAccount<TAccountSeller> &
|
||||
AccountSignerMeta<TAccountSeller>
|
||||
: TAccountSeller,
|
||||
TAccountResolver extends string
|
||||
? ReadonlyAccount<TAccountResolver>
|
||||
: TAccountResolver,
|
||||
TAccountEscrowAccount extends string
|
||||
? WritableAccount<TAccountEscrowAccount>
|
||||
: TAccountEscrowAccount,
|
||||
TAccountResolverEntry extends string
|
||||
? ReadonlyAccount<TAccountResolverEntry>
|
||||
: TAccountResolverEntry,
|
||||
...TRemainingAccounts,
|
||||
]
|
||||
>;
|
||||
|
||||
export type SellerConfirmInstructionData = {
|
||||
discriminator: ReadonlyUint8Array;
|
||||
};
|
||||
|
||||
export type SellerConfirmInstructionDataArgs = {};
|
||||
|
||||
export function getSellerConfirmInstructionDataEncoder(): FixedSizeEncoder<SellerConfirmInstructionDataArgs> {
|
||||
return transformEncoder(
|
||||
getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
|
||||
(value) => ({ ...value, discriminator: SELLER_CONFIRM_DISCRIMINATOR }),
|
||||
);
|
||||
}
|
||||
|
||||
export function getSellerConfirmInstructionDataDecoder(): FixedSizeDecoder<SellerConfirmInstructionData> {
|
||||
return getStructDecoder([
|
||||
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
||||
]);
|
||||
}
|
||||
|
||||
export function getSellerConfirmInstructionDataCodec(): FixedSizeCodec<
|
||||
SellerConfirmInstructionDataArgs,
|
||||
SellerConfirmInstructionData
|
||||
> {
|
||||
return combineCodec(
|
||||
getSellerConfirmInstructionDataEncoder(),
|
||||
getSellerConfirmInstructionDataDecoder(),
|
||||
);
|
||||
}
|
||||
|
||||
export type SellerConfirmInput<
|
||||
TAccountSeller extends string = string,
|
||||
TAccountResolver extends string = string,
|
||||
TAccountEscrowAccount extends string = string,
|
||||
TAccountResolverEntry extends string = string,
|
||||
> = {
|
||||
seller: TransactionSigner<TAccountSeller>;
|
||||
resolver: Address<TAccountResolver>;
|
||||
escrowAccount: Address<TAccountEscrowAccount>;
|
||||
resolverEntry: Address<TAccountResolverEntry>;
|
||||
};
|
||||
|
||||
export function getSellerConfirmInstruction<
|
||||
TAccountSeller extends string,
|
||||
TAccountResolver extends string,
|
||||
TAccountEscrowAccount extends string,
|
||||
TAccountResolverEntry extends string,
|
||||
TProgramAddress extends Address = typeof DESCRO_PROGRAM_ADDRESS,
|
||||
>(
|
||||
input: SellerConfirmInput<
|
||||
TAccountSeller,
|
||||
TAccountResolver,
|
||||
TAccountEscrowAccount,
|
||||
TAccountResolverEntry
|
||||
>,
|
||||
config?: { programAddress?: TProgramAddress },
|
||||
): SellerConfirmInstruction<
|
||||
TProgramAddress,
|
||||
TAccountSeller,
|
||||
TAccountResolver,
|
||||
TAccountEscrowAccount,
|
||||
TAccountResolverEntry
|
||||
> {
|
||||
// Program address.
|
||||
const programAddress = config?.programAddress ?? DESCRO_PROGRAM_ADDRESS;
|
||||
|
||||
// Original accounts.
|
||||
const originalAccounts = {
|
||||
seller: { value: input.seller ?? null, isWritable: false },
|
||||
resolver: { value: input.resolver ?? null, isWritable: false },
|
||||
escrowAccount: { value: input.escrowAccount ?? null, isWritable: true },
|
||||
resolverEntry: { value: input.resolverEntry ?? null, isWritable: false },
|
||||
};
|
||||
const accounts = originalAccounts as Record<
|
||||
keyof typeof originalAccounts,
|
||||
ResolvedInstructionAccount
|
||||
>;
|
||||
|
||||
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
||||
return Object.freeze({
|
||||
accounts: [
|
||||
getAccountMeta("seller", accounts.seller),
|
||||
getAccountMeta("resolver", accounts.resolver),
|
||||
getAccountMeta("escrowAccount", accounts.escrowAccount),
|
||||
getAccountMeta("resolverEntry", accounts.resolverEntry),
|
||||
],
|
||||
data: getSellerConfirmInstructionDataEncoder().encode({}),
|
||||
programAddress,
|
||||
} as SellerConfirmInstruction<
|
||||
TProgramAddress,
|
||||
TAccountSeller,
|
||||
TAccountResolver,
|
||||
TAccountEscrowAccount,
|
||||
TAccountResolverEntry
|
||||
>);
|
||||
}
|
||||
|
||||
export type ParsedSellerConfirmInstruction<
|
||||
TProgram extends string = typeof DESCRO_PROGRAM_ADDRESS,
|
||||
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
||||
> = {
|
||||
programAddress: Address<TProgram>;
|
||||
accounts: {
|
||||
seller: TAccountMetas[0];
|
||||
resolver: TAccountMetas[1];
|
||||
escrowAccount: TAccountMetas[2];
|
||||
resolverEntry: TAccountMetas[3];
|
||||
};
|
||||
data: SellerConfirmInstructionData;
|
||||
};
|
||||
|
||||
export function parseSellerConfirmInstruction<
|
||||
TProgram extends string,
|
||||
TAccountMetas extends readonly AccountMeta[],
|
||||
>(
|
||||
instruction: Instruction<TProgram> &
|
||||
InstructionWithAccounts<TAccountMetas> &
|
||||
InstructionWithData<ReadonlyUint8Array>,
|
||||
): ParsedSellerConfirmInstruction<TProgram, TAccountMetas> {
|
||||
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: {
|
||||
seller: getNextAccount(),
|
||||
resolver: getNextAccount(),
|
||||
escrowAccount: getNextAccount(),
|
||||
resolverEntry: getNextAccount(),
|
||||
},
|
||||
data: getSellerConfirmInstructionDataDecoder().decode(instruction.data),
|
||||
};
|
||||
}
|
||||
@@ -38,30 +38,42 @@ import {
|
||||
type EscrowAccountArgs,
|
||||
} from "../accounts";
|
||||
import {
|
||||
getCancelInstruction,
|
||||
getBuyerCreateEscrowInstructionAsync,
|
||||
getCancelInstructionAsync,
|
||||
getCompleteInstructionAsync,
|
||||
getCreateEscrowInstructionAsync,
|
||||
getDepositInstructionAsync,
|
||||
getDisputeInstruction,
|
||||
getEmergencyResolveInstructionAsync,
|
||||
getResolveInstructionAsync,
|
||||
getSellerConfirmInstruction,
|
||||
parseBuyerCreateEscrowInstruction,
|
||||
parseCancelInstruction,
|
||||
parseCompleteInstruction,
|
||||
parseCreateEscrowInstruction,
|
||||
parseDepositInstruction,
|
||||
parseDisputeInstruction,
|
||||
parseEmergencyResolveInstruction,
|
||||
parseResolveInstruction,
|
||||
type CancelInput,
|
||||
parseSellerConfirmInstruction,
|
||||
type BuyerCreateEscrowAsyncInput,
|
||||
type CancelAsyncInput,
|
||||
type CompleteAsyncInput,
|
||||
type CreateEscrowAsyncInput,
|
||||
type DepositAsyncInput,
|
||||
type DisputeInput,
|
||||
type EmergencyResolveAsyncInput,
|
||||
type ParsedBuyerCreateEscrowInstruction,
|
||||
type ParsedCancelInstruction,
|
||||
type ParsedCompleteInstruction,
|
||||
type ParsedCreateEscrowInstruction,
|
||||
type ParsedDepositInstruction,
|
||||
type ParsedDisputeInstruction,
|
||||
type ParsedEmergencyResolveInstruction,
|
||||
type ParsedResolveInstruction,
|
||||
type ParsedSellerConfirmInstruction,
|
||||
type ResolveAsyncInput,
|
||||
type SellerConfirmInput,
|
||||
} from "../instructions";
|
||||
import {
|
||||
findEscrowAccountPda,
|
||||
@@ -98,18 +110,32 @@ export function identifyDescroAccount(
|
||||
}
|
||||
|
||||
export enum DescroInstruction {
|
||||
BuyerCreateEscrow,
|
||||
Cancel,
|
||||
Complete,
|
||||
CreateEscrow,
|
||||
Deposit,
|
||||
Dispute,
|
||||
EmergencyResolve,
|
||||
Resolve,
|
||||
SellerConfirm,
|
||||
}
|
||||
|
||||
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([79, 199, 251, 30, 163, 86, 13, 73]),
|
||||
),
|
||||
0,
|
||||
)
|
||||
) {
|
||||
return DescroInstruction.BuyerCreateEscrow;
|
||||
}
|
||||
if (
|
||||
containsBytes(
|
||||
data,
|
||||
@@ -165,6 +191,17 @@ export function identifyDescroInstruction(
|
||||
) {
|
||||
return DescroInstruction.Dispute;
|
||||
}
|
||||
if (
|
||||
containsBytes(
|
||||
data,
|
||||
fixEncoderSize(getBytesEncoder(), 8).encode(
|
||||
new Uint8Array([63, 112, 185, 42, 47, 61, 232, 79]),
|
||||
),
|
||||
0,
|
||||
)
|
||||
) {
|
||||
return DescroInstruction.EmergencyResolve;
|
||||
}
|
||||
if (
|
||||
containsBytes(
|
||||
data,
|
||||
@@ -176,6 +213,17 @@ export function identifyDescroInstruction(
|
||||
) {
|
||||
return DescroInstruction.Resolve;
|
||||
}
|
||||
if (
|
||||
containsBytes(
|
||||
data,
|
||||
fixEncoderSize(getBytesEncoder(), 8).encode(
|
||||
new Uint8Array([21, 244, 3, 109, 138, 95, 198, 242]),
|
||||
),
|
||||
0,
|
||||
)
|
||||
) {
|
||||
return DescroInstruction.SellerConfirm;
|
||||
}
|
||||
throw new SolanaError(
|
||||
SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,
|
||||
{ instructionData: data, programName: "descro" },
|
||||
@@ -185,6 +233,9 @@ export function identifyDescroInstruction(
|
||||
export type ParsedDescroInstruction<
|
||||
TProgram extends string = "DjVR4EuYV6USMJFfsGZwhZ3y8rtWsmG8EvDY96GTqqi3",
|
||||
> =
|
||||
| ({
|
||||
instructionType: DescroInstruction.BuyerCreateEscrow;
|
||||
} & ParsedBuyerCreateEscrowInstruction<TProgram>)
|
||||
| ({
|
||||
instructionType: DescroInstruction.Cancel;
|
||||
} & ParsedCancelInstruction<TProgram>)
|
||||
@@ -200,15 +251,28 @@ export type ParsedDescroInstruction<
|
||||
| ({
|
||||
instructionType: DescroInstruction.Dispute;
|
||||
} & ParsedDisputeInstruction<TProgram>)
|
||||
| ({
|
||||
instructionType: DescroInstruction.EmergencyResolve;
|
||||
} & ParsedEmergencyResolveInstruction<TProgram>)
|
||||
| ({
|
||||
instructionType: DescroInstruction.Resolve;
|
||||
} & ParsedResolveInstruction<TProgram>);
|
||||
} & ParsedResolveInstruction<TProgram>)
|
||||
| ({
|
||||
instructionType: DescroInstruction.SellerConfirm;
|
||||
} & ParsedSellerConfirmInstruction<TProgram>);
|
||||
|
||||
export function parseDescroInstruction<TProgram extends string>(
|
||||
instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,
|
||||
): ParsedDescroInstruction<TProgram> {
|
||||
const instructionType = identifyDescroInstruction(instruction);
|
||||
switch (instructionType) {
|
||||
case DescroInstruction.BuyerCreateEscrow: {
|
||||
assertIsInstructionWithAccounts(instruction);
|
||||
return {
|
||||
instructionType: DescroInstruction.BuyerCreateEscrow,
|
||||
...parseBuyerCreateEscrowInstruction(instruction),
|
||||
};
|
||||
}
|
||||
case DescroInstruction.Cancel: {
|
||||
assertIsInstructionWithAccounts(instruction);
|
||||
return {
|
||||
@@ -244,6 +308,13 @@ export function parseDescroInstruction<TProgram extends string>(
|
||||
...parseDisputeInstruction(instruction),
|
||||
};
|
||||
}
|
||||
case DescroInstruction.EmergencyResolve: {
|
||||
assertIsInstructionWithAccounts(instruction);
|
||||
return {
|
||||
instructionType: DescroInstruction.EmergencyResolve,
|
||||
...parseEmergencyResolveInstruction(instruction),
|
||||
};
|
||||
}
|
||||
case DescroInstruction.Resolve: {
|
||||
assertIsInstructionWithAccounts(instruction);
|
||||
return {
|
||||
@@ -251,6 +322,13 @@ export function parseDescroInstruction<TProgram extends string>(
|
||||
...parseResolveInstruction(instruction),
|
||||
};
|
||||
}
|
||||
case DescroInstruction.SellerConfirm: {
|
||||
assertIsInstructionWithAccounts(instruction);
|
||||
return {
|
||||
instructionType: DescroInstruction.SellerConfirm,
|
||||
...parseSellerConfirmInstruction(instruction),
|
||||
};
|
||||
}
|
||||
default:
|
||||
throw new SolanaError(
|
||||
SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,
|
||||
@@ -271,9 +349,13 @@ export type DescroPluginAccounts = {
|
||||
};
|
||||
|
||||
export type DescroPluginInstructions = {
|
||||
buyerCreateEscrow: (
|
||||
input: BuyerCreateEscrowAsyncInput,
|
||||
) => ReturnType<typeof getBuyerCreateEscrowInstructionAsync> &
|
||||
SelfPlanAndSendFunctions;
|
||||
cancel: (
|
||||
input: CancelInput,
|
||||
) => ReturnType<typeof getCancelInstruction> & SelfPlanAndSendFunctions;
|
||||
input: CancelAsyncInput,
|
||||
) => ReturnType<typeof getCancelInstructionAsync> & SelfPlanAndSendFunctions;
|
||||
complete: (
|
||||
input: CompleteAsyncInput,
|
||||
) => ReturnType<typeof getCompleteInstructionAsync> &
|
||||
@@ -288,14 +370,22 @@ export type DescroPluginInstructions = {
|
||||
dispute: (
|
||||
input: DisputeInput,
|
||||
) => ReturnType<typeof getDisputeInstruction> & SelfPlanAndSendFunctions;
|
||||
emergencyResolve: (
|
||||
input: EmergencyResolveAsyncInput,
|
||||
) => ReturnType<typeof getEmergencyResolveInstructionAsync> &
|
||||
SelfPlanAndSendFunctions;
|
||||
resolve: (
|
||||
input: ResolveAsyncInput,
|
||||
) => ReturnType<typeof getResolveInstructionAsync> & SelfPlanAndSendFunctions;
|
||||
sellerConfirm: (
|
||||
input: SellerConfirmInput,
|
||||
) => ReturnType<typeof getSellerConfirmInstruction> &
|
||||
SelfPlanAndSendFunctions;
|
||||
};
|
||||
|
||||
export type DescroPluginPdas = {
|
||||
vault: typeof findVaultPda;
|
||||
escrowAccount: typeof findEscrowAccountPda;
|
||||
vault: typeof findVaultPda;
|
||||
escrowAuthority: typeof findEscrowAuthorityPda;
|
||||
};
|
||||
|
||||
@@ -315,8 +405,16 @@ export function descroProgram() {
|
||||
escrowAccount: addSelfFetchFunctions(client, getEscrowAccountCodec()),
|
||||
},
|
||||
instructions: {
|
||||
buyerCreateEscrow: (input) =>
|
||||
addSelfPlanAndSendFunctions(
|
||||
client,
|
||||
getBuyerCreateEscrowInstructionAsync(input),
|
||||
),
|
||||
cancel: (input) =>
|
||||
addSelfPlanAndSendFunctions(client, getCancelInstruction(input)),
|
||||
addSelfPlanAndSendFunctions(
|
||||
client,
|
||||
getCancelInstructionAsync(input),
|
||||
),
|
||||
complete: (input) =>
|
||||
addSelfPlanAndSendFunctions(
|
||||
client,
|
||||
@@ -334,15 +432,25 @@ export function descroProgram() {
|
||||
),
|
||||
dispute: (input) =>
|
||||
addSelfPlanAndSendFunctions(client, getDisputeInstruction(input)),
|
||||
emergencyResolve: (input) =>
|
||||
addSelfPlanAndSendFunctions(
|
||||
client,
|
||||
getEmergencyResolveInstructionAsync(input),
|
||||
),
|
||||
resolve: (input) =>
|
||||
addSelfPlanAndSendFunctions(
|
||||
client,
|
||||
getResolveInstructionAsync(input),
|
||||
),
|
||||
sellerConfirm: (input) =>
|
||||
addSelfPlanAndSendFunctions(
|
||||
client,
|
||||
getSellerConfirmInstruction(input),
|
||||
),
|
||||
},
|
||||
pdas: {
|
||||
vault: findVaultPda,
|
||||
escrowAccount: findEscrowAccountPda,
|
||||
vault: findVaultPda,
|
||||
escrowAuthority: findEscrowAuthorityPda,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
|
||||
export enum EscrowState {
|
||||
AwaitingDeposit,
|
||||
AwaitingSellerConfirm,
|
||||
Active,
|
||||
Disputed,
|
||||
Complete,
|
||||
|
||||
@@ -47,8 +47,12 @@ import {
|
||||
type ReadonlyUint8Array,
|
||||
} from "@solana/kit";
|
||||
import {
|
||||
getAcceptancePolicyDecoder,
|
||||
getAcceptancePolicyEncoder,
|
||||
getResolverTypeDecoder,
|
||||
getResolverTypeEncoder,
|
||||
type AcceptancePolicy,
|
||||
type AcceptancePolicyArgs,
|
||||
type ResolverType,
|
||||
type ResolverTypeArgs,
|
||||
} from "../types";
|
||||
@@ -67,6 +71,7 @@ export type ResolverEntry = {
|
||||
discriminator: ReadonlyUint8Array;
|
||||
authority: Address;
|
||||
resolverType: ResolverType;
|
||||
acceptancePolicy: AcceptancePolicy;
|
||||
name: string;
|
||||
description: string;
|
||||
feeBps: number;
|
||||
@@ -81,6 +86,7 @@ export type ResolverEntry = {
|
||||
export type ResolverEntryArgs = {
|
||||
authority: Address;
|
||||
resolverType: ResolverTypeArgs;
|
||||
acceptancePolicy: AcceptancePolicyArgs;
|
||||
name: string;
|
||||
description: string;
|
||||
feeBps: number;
|
||||
@@ -99,6 +105,7 @@ export function getResolverEntryEncoder(): Encoder<ResolverEntryArgs> {
|
||||
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
||||
["authority", getAddressEncoder()],
|
||||
["resolverType", getResolverTypeEncoder()],
|
||||
["acceptancePolicy", getAcceptancePolicyEncoder()],
|
||||
["name", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
|
||||
["description", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
|
||||
["feeBps", getU16Encoder()],
|
||||
@@ -119,6 +126,7 @@ export function getResolverEntryDecoder(): Decoder<ResolverEntry> {
|
||||
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
||||
["authority", getAddressDecoder()],
|
||||
["resolverType", getResolverTypeDecoder()],
|
||||
["acceptancePolicy", getAcceptancePolicyDecoder()],
|
||||
["name", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
||||
["description", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
||||
["feeBps", getU16Decoder()],
|
||||
|
||||
@@ -50,8 +50,12 @@ import {
|
||||
import { findResolverEntryPda } from "../pdas";
|
||||
import { DESCRO_EXT_RESOLVERS_PROGRAM_ADDRESS } from "../programs";
|
||||
import {
|
||||
getAcceptancePolicyDecoder,
|
||||
getAcceptancePolicyEncoder,
|
||||
getResolverTypeDecoder,
|
||||
getResolverTypeEncoder,
|
||||
type AcceptancePolicy,
|
||||
type AcceptancePolicyArgs,
|
||||
type ResolverType,
|
||||
type ResolverTypeArgs,
|
||||
} from "../types";
|
||||
@@ -93,6 +97,7 @@ export type RegisterResolverInstruction<
|
||||
export type RegisterResolverInstructionData = {
|
||||
discriminator: ReadonlyUint8Array;
|
||||
resolverType: ResolverType;
|
||||
acceptancePolicy: AcceptancePolicy;
|
||||
name: string;
|
||||
description: string;
|
||||
feeBps: number;
|
||||
@@ -102,6 +107,7 @@ export type RegisterResolverInstructionData = {
|
||||
|
||||
export type RegisterResolverInstructionDataArgs = {
|
||||
resolverType: ResolverTypeArgs;
|
||||
acceptancePolicy: AcceptancePolicyArgs;
|
||||
name: string;
|
||||
description: string;
|
||||
feeBps: number;
|
||||
@@ -114,6 +120,7 @@ export function getRegisterResolverInstructionDataEncoder(): Encoder<RegisterRes
|
||||
getStructEncoder([
|
||||
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
||||
["resolverType", getResolverTypeEncoder()],
|
||||
["acceptancePolicy", getAcceptancePolicyEncoder()],
|
||||
["name", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
|
||||
["description", addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
|
||||
["feeBps", getU16Encoder()],
|
||||
@@ -128,6 +135,7 @@ export function getRegisterResolverInstructionDataDecoder(): Decoder<RegisterRes
|
||||
return getStructDecoder([
|
||||
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
||||
["resolverType", getResolverTypeDecoder()],
|
||||
["acceptancePolicy", getAcceptancePolicyDecoder()],
|
||||
["name", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
||||
["description", addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
||||
["feeBps", getU16Decoder()],
|
||||
@@ -155,6 +163,7 @@ export type RegisterResolverAsyncInput<
|
||||
resolverEntry?: Address<TAccountResolverEntry>;
|
||||
systemProgram?: Address<TAccountSystemProgram>;
|
||||
resolverType: RegisterResolverInstructionDataArgs["resolverType"];
|
||||
acceptancePolicy: RegisterResolverInstructionDataArgs["acceptancePolicy"];
|
||||
name: RegisterResolverInstructionDataArgs["name"];
|
||||
description: RegisterResolverInstructionDataArgs["description"];
|
||||
feeBps: RegisterResolverInstructionDataArgs["feeBps"];
|
||||
@@ -242,6 +251,7 @@ export type RegisterResolverInput<
|
||||
resolverEntry: Address<TAccountResolverEntry>;
|
||||
systemProgram?: Address<TAccountSystemProgram>;
|
||||
resolverType: RegisterResolverInstructionDataArgs["resolverType"];
|
||||
acceptancePolicy: RegisterResolverInstructionDataArgs["acceptancePolicy"];
|
||||
name: RegisterResolverInstructionDataArgs["name"];
|
||||
description: RegisterResolverInstructionDataArgs["description"];
|
||||
feeBps: RegisterResolverInstructionDataArgs["feeBps"];
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* 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 AcceptancePolicy {
|
||||
Open,
|
||||
SignatureGated,
|
||||
ProgramGated,
|
||||
}
|
||||
|
||||
export type AcceptancePolicyArgs = AcceptancePolicy;
|
||||
|
||||
export function getAcceptancePolicyEncoder(): FixedSizeEncoder<AcceptancePolicyArgs> {
|
||||
return getEnumEncoder(AcceptancePolicy);
|
||||
}
|
||||
|
||||
export function getAcceptancePolicyDecoder(): FixedSizeDecoder<AcceptancePolicy> {
|
||||
return getEnumDecoder(AcceptancePolicy);
|
||||
}
|
||||
|
||||
export function getAcceptancePolicyCodec(): FixedSizeCodec<
|
||||
AcceptancePolicyArgs,
|
||||
AcceptancePolicy
|
||||
> {
|
||||
return combineCodec(
|
||||
getAcceptancePolicyEncoder(),
|
||||
getAcceptancePolicyDecoder(),
|
||||
);
|
||||
}
|
||||
@@ -6,5 +6,6 @@
|
||||
* @see https://github.com/codama-idl/codama
|
||||
*/
|
||||
|
||||
export * from "./acceptancePolicy";
|
||||
export * from "./resolverType";
|
||||
export * from "./ruling";
|
||||
|
||||
@@ -7,6 +7,98 @@
|
||||
"description": "Created with Anchor"
|
||||
},
|
||||
"instructions": [
|
||||
{
|
||||
"name": "buyer_create_escrow",
|
||||
"discriminator": [
|
||||
79,
|
||||
199,
|
||||
251,
|
||||
30,
|
||||
163,
|
||||
86,
|
||||
13,
|
||||
73
|
||||
],
|
||||
"accounts": [
|
||||
{
|
||||
"name": "buyer",
|
||||
"writable": true,
|
||||
"signer": true
|
||||
},
|
||||
{
|
||||
"name": "seller"
|
||||
},
|
||||
{
|
||||
"name": "escrow_account",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
101,
|
||||
115,
|
||||
99,
|
||||
114,
|
||||
111,
|
||||
119
|
||||
]
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "seller"
|
||||
},
|
||||
{
|
||||
"kind": "arg",
|
||||
"path": "escrow_id"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "vault",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
118,
|
||||
97,
|
||||
117,
|
||||
108,
|
||||
116
|
||||
]
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "escrow_account"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "system_program",
|
||||
"address": "11111111111111111111111111111111"
|
||||
}
|
||||
],
|
||||
"args": [
|
||||
{
|
||||
"name": "amount",
|
||||
"type": "u64"
|
||||
},
|
||||
{
|
||||
"name": "dispute_resolver",
|
||||
"type": {
|
||||
"option": "pubkey"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "escrow_id",
|
||||
"type": "u64"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "cancel",
|
||||
"discriminator": [
|
||||
@@ -21,10 +113,14 @@
|
||||
],
|
||||
"accounts": [
|
||||
{
|
||||
"name": "seller",
|
||||
"name": "canceller",
|
||||
"writable": true,
|
||||
"signer": true
|
||||
},
|
||||
{
|
||||
"name": "buyer",
|
||||
"writable": true
|
||||
},
|
||||
{
|
||||
"name": "escrow_account",
|
||||
"writable": true,
|
||||
@@ -54,6 +150,28 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "vault",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
118,
|
||||
97,
|
||||
117,
|
||||
108,
|
||||
116
|
||||
]
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "escrow_account"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "system_program",
|
||||
"address": "11111111111111111111111111111111"
|
||||
@@ -161,6 +279,9 @@
|
||||
{
|
||||
"name": "buyer"
|
||||
},
|
||||
{
|
||||
"name": "resolver"
|
||||
},
|
||||
{
|
||||
"name": "escrow_account",
|
||||
"writable": true,
|
||||
@@ -210,6 +331,9 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "resolver_entry"
|
||||
},
|
||||
{
|
||||
"name": "system_program",
|
||||
"address": "11111111111111111111111111111111"
|
||||
@@ -357,6 +481,99 @@
|
||||
],
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"name": "emergency_resolve",
|
||||
"discriminator": [
|
||||
63,
|
||||
112,
|
||||
185,
|
||||
42,
|
||||
47,
|
||||
61,
|
||||
232,
|
||||
79
|
||||
],
|
||||
"accounts": [
|
||||
{
|
||||
"name": "buyer",
|
||||
"signer": true
|
||||
},
|
||||
{
|
||||
"name": "seller",
|
||||
"writable": true,
|
||||
"signer": true
|
||||
},
|
||||
{
|
||||
"name": "winner",
|
||||
"writable": true
|
||||
},
|
||||
{
|
||||
"name": "escrow_account",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
101,
|
||||
115,
|
||||
99,
|
||||
114,
|
||||
111,
|
||||
119
|
||||
]
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "escrow_account.seller",
|
||||
"account": "EscrowAccount"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "escrow_account.escrow_id",
|
||||
"account": "EscrowAccount"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "vault",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
118,
|
||||
97,
|
||||
117,
|
||||
108,
|
||||
116
|
||||
]
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "escrow_account"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "system_program",
|
||||
"address": "11111111111111111111111111111111"
|
||||
}
|
||||
],
|
||||
"args": [
|
||||
{
|
||||
"name": "winner",
|
||||
"type": {
|
||||
"defined": {
|
||||
"name": "Winner"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "resolve",
|
||||
"discriminator": [
|
||||
@@ -542,6 +759,60 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "seller_confirm",
|
||||
"discriminator": [
|
||||
21,
|
||||
244,
|
||||
3,
|
||||
109,
|
||||
138,
|
||||
95,
|
||||
198,
|
||||
242
|
||||
],
|
||||
"accounts": [
|
||||
{
|
||||
"name": "seller",
|
||||
"signer": true
|
||||
},
|
||||
{
|
||||
"name": "resolver"
|
||||
},
|
||||
{
|
||||
"name": "escrow_account",
|
||||
"writable": true,
|
||||
"pda": {
|
||||
"seeds": [
|
||||
{
|
||||
"kind": "const",
|
||||
"value": [
|
||||
101,
|
||||
115,
|
||||
99,
|
||||
114,
|
||||
111,
|
||||
119
|
||||
]
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "seller"
|
||||
},
|
||||
{
|
||||
"kind": "account",
|
||||
"path": "escrow_account.escrow_id",
|
||||
"account": "EscrowAccount"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "resolver_entry"
|
||||
}
|
||||
],
|
||||
"args": []
|
||||
}
|
||||
],
|
||||
"accounts": [
|
||||
@@ -584,6 +855,26 @@
|
||||
"code": 6004,
|
||||
"name": "Expired",
|
||||
"msg": "Escrow has expired"
|
||||
},
|
||||
{
|
||||
"code": 6005,
|
||||
"name": "DisputeTimeoutNotReached",
|
||||
"msg": "Dispute timeout period has not elapsed yet"
|
||||
},
|
||||
{
|
||||
"code": 6006,
|
||||
"name": "InsufficientVaultBalance",
|
||||
"msg": "Vault balance is insufficient for the requested escrow amount"
|
||||
},
|
||||
{
|
||||
"code": 6007,
|
||||
"name": "AmountBelowRentMinimum",
|
||||
"msg": "Amount must be at least rent-exempt minimum for the vault (~890880 lamports)"
|
||||
},
|
||||
{
|
||||
"code": 6008,
|
||||
"name": "ResolverSignatureRequired",
|
||||
"msg": "Resolver must co-sign this transaction (SignatureGated acceptance policy)"
|
||||
}
|
||||
],
|
||||
"types": [
|
||||
@@ -629,6 +920,12 @@
|
||||
{
|
||||
"name": "escrow_id",
|
||||
"type": "u64"
|
||||
},
|
||||
{
|
||||
"name": "dispute_raised_at",
|
||||
"type": {
|
||||
"option": "i64"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -641,6 +938,9 @@
|
||||
{
|
||||
"name": "AwaitingDeposit"
|
||||
},
|
||||
{
|
||||
"name": "AwaitingSellerConfirm"
|
||||
},
|
||||
{
|
||||
"name": "Active"
|
||||
},
|
||||
|
||||
@@ -64,6 +64,14 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "acceptance_policy",
|
||||
"type": {
|
||||
"defined": {
|
||||
"name": "AcceptancePolicy"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"type": "string"
|
||||
@@ -285,6 +293,23 @@
|
||||
}
|
||||
],
|
||||
"types": [
|
||||
{
|
||||
"name": "AcceptancePolicy",
|
||||
"type": {
|
||||
"kind": "enum",
|
||||
"variants": [
|
||||
{
|
||||
"name": "Open"
|
||||
},
|
||||
{
|
||||
"name": "SignatureGated"
|
||||
},
|
||||
{
|
||||
"name": "ProgramGated"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ResolverEntry",
|
||||
"type": {
|
||||
@@ -302,6 +327,14 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "acceptance_policy",
|
||||
"type": {
|
||||
"defined": {
|
||||
"name": "AcceptancePolicy"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"type": "string"
|
||||
|
||||
Reference in New Issue
Block a user