@coral-xyz/barter-sdk
Version:
Node.js client for the Barter protocol
459 lines • 14 kB
JavaScript
export const IDL = {
version: "0.1.2",
name: "barter",
constants: [
{
name: "MAX_FREE_ITEMS",
type: {
defined: "usize",
},
value: "3",
},
{
name: "ITEM_LAMPORT_FEE_AMOUNT",
type: "u64",
value: "2039280",
},
],
instructions: [
{
name: "cancel",
docs: [
"Invoked by the initiater of the barter agreement prior to the second party finalizing",
"their offer to cancel and close the agreement and revoke the token account delegations.",
],
accounts: [
{
name: "agreement",
isMut: true,
isSigner: false,
relations: ["initiater"],
},
{
name: "delegate",
isMut: false,
isSigner: false,
},
{
name: "initiater",
isMut: true,
isSigner: true,
},
{
name: "tokenProgram",
isMut: false,
isSigner: false,
},
],
args: [],
},
{
name: "create",
docs: [
"Creates a barter agreement program account and assigns the appropriate delegation on the",
"token accounts of the initiater's barter item offer.",
],
accounts: [
{
name: "agreement",
isMut: true,
isSigner: false,
},
{
name: "delegate",
isMut: true,
isSigner: false,
pda: {
seeds: [
{
kind: "const",
type: "string",
value: "delegate",
},
{
kind: "account",
type: "publicKey",
path: "authority",
},
],
},
},
{
name: "participant",
isMut: false,
isSigner: false,
},
{
name: "authority",
isMut: true,
isSigner: true,
},
{
name: "systemProgram",
isMut: false,
isSigner: false,
},
{
name: "tokenProgram",
isMut: false,
isSigner: false,
},
],
args: [
{
name: "amounts",
type: {
vec: "u64",
},
},
{
name: "expecting",
type: {
vec: {
defined: "BarterItem",
},
},
},
],
},
{
name: "finalize",
docs: [
"Invoked by the second party of the barter agreement after its initial creation in order",
"for them to finalize the second half of the agreement and lock it in for automated settlement.",
],
accounts: [
{
name: "agreement",
isMut: true,
isSigner: false,
relations: ["initiater"],
},
{
name: "delegate",
isMut: true,
isSigner: false,
pda: {
seeds: [
{
kind: "const",
type: "string",
value: "delegate",
},
{
kind: "account",
type: "publicKey",
path: "authority",
},
],
},
},
{
name: "initiater",
isMut: false,
isSigner: false,
},
{
name: "authority",
isMut: true,
isSigner: true,
},
{
name: "systemProgram",
isMut: false,
isSigner: false,
},
{
name: "tokenProgram",
isMut: false,
isSigner: false,
},
],
args: [
{
name: "amounts",
type: {
vec: "u64",
},
},
{
name: "expecting",
type: {
vec: {
defined: "BarterItem",
},
},
},
],
},
{
name: "settle",
docs: [
"Invoked by an asynchronous third-party to settle and transfer the barter items proposed",
"by the two parties partaking in the barter agreement.",
],
accounts: [
{
name: "agreement",
isMut: true,
isSigner: false,
relations: ["initiater", "participant"],
},
{
name: "initiaterDelegate",
isMut: false,
isSigner: false,
},
{
name: "initiater",
isMut: true,
isSigner: false,
},
{
name: "participantDelegate",
isMut: false,
isSigner: false,
},
{
name: "participant",
isMut: true,
isSigner: false,
},
{
name: "authority",
isMut: false,
isSigner: true,
},
{
name: "tokenProgram",
isMut: false,
isSigner: false,
},
],
args: [],
returns: "bool",
},
],
accounts: [
{
name: "agreement",
docs: [
"The program account state struct for a barter agreement to hold the required",
"data to ensure an agreement is secure and is fully processed.",
],
type: {
kind: "struct",
fields: [
{
name: "bump",
type: {
array: ["u8", 1],
},
},
{
name: "finalized",
type: "bool",
},
{
name: "initiater",
type: "publicKey",
},
{
name: "participant",
type: "publicKey",
},
{
name: "offer",
type: {
vec: {
defined: "BarterItemStatus",
},
},
},
{
name: "expecting",
type: {
vec: {
defined: "BarterItemStatus",
},
},
},
],
},
},
{
name: "delegate",
type: {
kind: "struct",
fields: [
{
name: "authority",
type: "publicKey",
},
{
name: "bump",
type: {
array: ["u8", 1],
},
},
],
},
},
],
types: [
{
name: "BarterItem",
docs: ["A standard barter item that can be proposed by either part of an agreement."],
type: {
kind: "struct",
fields: [
{
name: "amount",
type: "u64",
},
{
name: "mint",
type: "publicKey",
},
],
},
},
{
name: "BarterItemStatus",
docs: [
"A superset of the base `BarterItem` struct to add a boolean flag",
"to mark in state whether the item has been settled.",
],
type: {
kind: "struct",
fields: [
{
name: "item",
type: {
defined: "BarterItem",
},
},
{
name: "settled",
type: "bool",
},
],
},
},
],
events: [
{
name: "AgreementCanceled",
fields: [
{
name: "pubkey",
type: "publicKey",
index: false,
},
],
},
{
name: "AgreementCreated",
fields: [
{
name: "pubkey",
type: "publicKey",
index: false,
},
],
},
{
name: "AgreementFinalized",
fields: [
{
name: "agreement",
type: "publicKey",
index: false,
},
],
},
{
name: "AgreementSettled",
fields: [
{
name: "pubkey",
type: "publicKey",
index: false,
},
],
},
],
errors: [
{
code: 6000,
name: "CancelingAfterFinalized",
msg: "Attempting to cancel an agreement that is already finalized",
},
{
code: 6001,
name: "DelegateAuthorityMismatch",
msg: "The authority is not associated with the delegate program account",
},
{
code: 6002,
name: "InsufficientItemsAvailable",
msg: "The item amount in the proposal is higher than the available balance",
},
{
code: 6003,
name: "ItemAccountsOppositeOwnershipFailure",
msg: "The source and destination token accounts during settlement do not have opposite valid owners",
},
{
code: 6004,
name: "ItemAlreadySettled",
msg: "A barter item was submitted for settlement after already being settled",
},
{
code: 6005,
name: "ItemDelegateMismatch",
msg: "A provided item has a delegate that is not the active barter agreement",
},
{
code: 6006,
name: "ItemForAccountNotFound",
msg: "No agreement item found that matches the bounds of the token account",
},
{
code: 6007,
name: "ItemInvalidDelegation",
msg: "A provided item has no active delegate or incorrect delegated amount",
},
{
code: 6008,
name: "ItemsLengthMismatch",
msg: "The number of token amounts does not match the number of token mints",
},
{
code: 6009,
name: "ItemsMismatch",
msg: "The asset accounts provided to not match the current state's accounts",
},
{
code: 6010,
name: "ItemOwnershipMismatch",
msg: "The owner of the barter item account does not match the signer or delegate",
},
{
code: 6011,
name: "ProposingAfterFinalized",
msg: "Proposal made on an agreement that is already finalized",
},
{
code: 6012,
name: "SettlementAuthorityMismatch",
msg: "The account signing for an agreement settlement is not authorized",
},
{
code: 6013,
name: "SettlingUnfinalized",
msg: "Attempting to settle a barter agreement that has not been finalized",
},
],
};
//# sourceMappingURL=barter.js.map