resolver picker
This commit is contained in:
@@ -21,6 +21,8 @@ import {
|
||||
getBytesEncoder,
|
||||
getI64Decoder,
|
||||
getI64Encoder,
|
||||
getOptionDecoder,
|
||||
getOptionEncoder,
|
||||
getStructDecoder,
|
||||
getStructEncoder,
|
||||
getU64Decoder,
|
||||
@@ -38,6 +40,8 @@ import {
|
||||
type FetchAccountsConfig,
|
||||
type MaybeAccount,
|
||||
type MaybeEncodedAccount,
|
||||
type Option,
|
||||
type OptionOrNullable,
|
||||
type ReadonlyUint8Array,
|
||||
} from "@solana/kit";
|
||||
import {
|
||||
@@ -61,7 +65,7 @@ export type SolistingStateOrderAccount = {
|
||||
listing: Address;
|
||||
buyer: Address;
|
||||
seller: Address;
|
||||
resolver: Address;
|
||||
resolver: Option<Address>;
|
||||
/** The currency the buyer chose to pay in. */
|
||||
paymentCurrency: SolistingStateCurrency;
|
||||
/** Actual amount paid (may differ from price when oracle-converted). */
|
||||
@@ -79,7 +83,7 @@ export type SolistingStateOrderAccountArgs = {
|
||||
listing: Address;
|
||||
buyer: Address;
|
||||
seller: Address;
|
||||
resolver: Address;
|
||||
resolver: OptionOrNullable<Address>;
|
||||
/** The currency the buyer chose to pay in. */
|
||||
paymentCurrency: SolistingStateCurrencyArgs;
|
||||
/** Actual amount paid (may differ from price when oracle-converted). */
|
||||
@@ -101,7 +105,7 @@ export function getSolistingStateOrderAccountEncoder(): Encoder<SolistingStateOr
|
||||
["listing", getAddressEncoder()],
|
||||
["buyer", getAddressEncoder()],
|
||||
["seller", getAddressEncoder()],
|
||||
["resolver", getAddressEncoder()],
|
||||
["resolver", getOptionEncoder(getAddressEncoder())],
|
||||
["paymentCurrency", getSolistingStateCurrencyEncoder()],
|
||||
["amount", getU64Encoder()],
|
||||
["escrowAccount", getAddressEncoder()],
|
||||
@@ -124,7 +128,7 @@ export function getSolistingStateOrderAccountDecoder(): Decoder<SolistingStateOr
|
||||
["listing", getAddressDecoder()],
|
||||
["buyer", getAddressDecoder()],
|
||||
["seller", getAddressDecoder()],
|
||||
["resolver", getAddressDecoder()],
|
||||
["resolver", getOptionDecoder(getAddressDecoder())],
|
||||
["paymentCurrency", getSolistingStateCurrencyDecoder()],
|
||||
["amount", getU64Decoder()],
|
||||
["escrowAccount", getAddressDecoder()],
|
||||
|
||||
@@ -14,6 +14,8 @@ import {
|
||||
getAddressEncoder,
|
||||
getBytesDecoder,
|
||||
getBytesEncoder,
|
||||
getOptionDecoder,
|
||||
getOptionEncoder,
|
||||
getProgramDerivedAddress,
|
||||
getStructDecoder,
|
||||
getStructEncoder,
|
||||
@@ -33,6 +35,8 @@ import {
|
||||
type Instruction,
|
||||
type InstructionWithAccounts,
|
||||
type InstructionWithData,
|
||||
type Option,
|
||||
type OptionOrNullable,
|
||||
type ReadonlyAccount,
|
||||
type ReadonlyUint8Array,
|
||||
type TransactionSigner,
|
||||
@@ -121,7 +125,7 @@ export type CreateOrderInstructionData = {
|
||||
discriminator: ReadonlyUint8Array;
|
||||
orderId: bigint;
|
||||
escrowId: bigint;
|
||||
resolver: Address;
|
||||
resolver: Option<Address>;
|
||||
paymentCurrency: SolistingStateCurrency;
|
||||
expectedAmount: bigint;
|
||||
maxSlippageBps: number;
|
||||
@@ -130,7 +134,7 @@ export type CreateOrderInstructionData = {
|
||||
export type CreateOrderInstructionDataArgs = {
|
||||
orderId: number | bigint;
|
||||
escrowId: number | bigint;
|
||||
resolver: Address;
|
||||
resolver: OptionOrNullable<Address>;
|
||||
paymentCurrency: SolistingStateCurrencyArgs;
|
||||
expectedAmount: number | bigint;
|
||||
maxSlippageBps: number;
|
||||
@@ -142,7 +146,7 @@ export function getCreateOrderInstructionDataEncoder(): Encoder<CreateOrderInstr
|
||||
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
||||
["orderId", getU64Encoder()],
|
||||
["escrowId", getU64Encoder()],
|
||||
["resolver", getAddressEncoder()],
|
||||
["resolver", getOptionEncoder(getAddressEncoder())],
|
||||
["paymentCurrency", getSolistingStateCurrencyEncoder()],
|
||||
["expectedAmount", getU64Encoder()],
|
||||
["maxSlippageBps", getU16Encoder()],
|
||||
@@ -156,7 +160,7 @@ export function getCreateOrderInstructionDataDecoder(): Decoder<CreateOrderInstr
|
||||
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
||||
["orderId", getU64Decoder()],
|
||||
["escrowId", getU64Decoder()],
|
||||
["resolver", getAddressDecoder()],
|
||||
["resolver", getOptionDecoder(getAddressDecoder())],
|
||||
["paymentCurrency", getSolistingStateCurrencyDecoder()],
|
||||
["expectedAmount", getU64Decoder()],
|
||||
["maxSlippageBps", getU16Decoder()],
|
||||
|
||||
@@ -21,15 +21,15 @@ type GetRpc = Rpc<GetAccountInfoApi>
|
||||
// 8: listing (32)
|
||||
// 40: buyer (32)
|
||||
// 72: seller (32)
|
||||
// 104: resolver (32)
|
||||
// 136: paymentCurrency — Sol variant = 1 byte tag + 0 data = 1 byte total
|
||||
// 137: amount (8)
|
||||
// 145: escrowAccount (32)
|
||||
// 104: resolver Option<Pubkey> = 1 byte tag + 32 bytes = 33 bytes
|
||||
// 137: paymentCurrency — Sol variant = 1 byte tag + 0 data = 1 byte total
|
||||
// 138: amount (8)
|
||||
// 146: escrowAccount (32)
|
||||
const LISTING_OFFSET = 8n
|
||||
const BUYER_OFFSET = 40n
|
||||
// escrowAccount offset is only valid for Sol-currency orders.
|
||||
// SPL orders (currently rejected by the program with SplNotImplemented) would sit at offset 178.
|
||||
const ESCROW_ACCOUNT_OFFSET = 145n
|
||||
// SPL orders (currently rejected by the program with SplNotImplemented) would sit at offset 179.
|
||||
const ESCROW_ACCOUNT_OFFSET = 146n
|
||||
|
||||
type RawGpaResult = Array<{
|
||||
pubkey: Address
|
||||
|
||||
Reference in New Issue
Block a user