| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203 |
- export type MessageBuffer = {
- version: "0.1.0";
- name: "message_buffer";
- instructions: [
- {
- name: "initialize";
- docs: [
- "Initializes the whitelist and sets it's admin. Once initialized,",
- "the admin must sign all further changes to the whitelist."
- ];
- accounts: [
- {
- name: "admin";
- isMut: false;
- isSigner: true;
- docs: [
- "Admin that can update the whitelist and create/resize/delete buffers"
- ];
- },
- {
- name: "payer";
- isMut: true;
- isSigner: true;
- },
- {
- name: "whitelist";
- isMut: true;
- isSigner: false;
- pda: {
- seeds: [
- {
- kind: "const";
- type: "string";
- value: "message";
- },
- {
- kind: "const";
- type: "string";
- value: "whitelist";
- }
- ];
- };
- },
- {
- name: "systemProgram";
- isMut: false;
- isSigner: false;
- }
- ];
- args: [];
- },
- {
- name: "setAllowedPrograms";
- docs: [
- "Sets the programs that are allowed to invoke this program through CPI",
- "",
- "* `allowed_programs` - Entire list of programs that are allowed to",
- "invoke this program through CPI"
- ];
- accounts: [
- {
- name: "admin";
- isMut: false;
- isSigner: true;
- },
- {
- name: "whitelist";
- isMut: true;
- isSigner: false;
- pda: {
- seeds: [
- {
- kind: "const";
- type: "string";
- value: "message";
- },
- {
- kind: "const";
- type: "string";
- value: "whitelist";
- }
- ];
- };
- relations: ["admin"];
- }
- ];
- args: [
- {
- name: "allowedPrograms";
- type: {
- vec: "publicKey";
- };
- }
- ];
- },
- {
- name: "updateWhitelistAdmin";
- docs: ["Sets the new admin for the whitelist"];
- accounts: [
- {
- name: "admin";
- isMut: false;
- isSigner: true;
- },
- {
- name: "whitelist";
- isMut: true;
- isSigner: false;
- pda: {
- seeds: [
- {
- kind: "const";
- type: "string";
- value: "message";
- },
- {
- kind: "const";
- type: "string";
- value: "whitelist";
- }
- ];
- };
- relations: ["admin"];
- }
- ];
- args: [
- {
- name: "newAdmin";
- type: "publicKey";
- }
- ];
- },
- {
- name: "putAll";
- docs: [
- "Put messages into the Accumulator. All messages put for the same",
- "`base_account_key` go into the same buffer PDA. The PDA's address is",
- "`[allowed_program_auth, MESSAGE, base_account_key]`, where `allowed_program_auth`",
- "is the whitelisted pubkey who authorized this call.",
- "",
- "* `base_account_key` - Pubkey of the original account the",
- "`MessageBuffer` is derived from",
- "(e.g. pyth price account)",
- "* `messages` - Vec of vec of bytes, each representing a message",
- "to be hashed and accumulated",
- "",
- "This ix will write as many of the messages up to the length",
- "of the `accumulator_input.data`.",
- "If `accumulator_input.data.len() < messages.map(|x| x.len()).sum()`",
- "then the remaining messages will be ignored.",
- "",
- "The current implementation assumes that each invocation of this",
- "ix is independent of any previous invocations. It will overwrite",
- "any existing contents.",
- "",
- "TODO:",
- '- handle updates ("paging/batches of messages")',
- ""
- ];
- accounts: [
- {
- name: "whitelistVerifier";
- accounts: [
- {
- name: "whitelist";
- isMut: false;
- isSigner: false;
- pda: {
- seeds: [
- {
- kind: "const";
- type: "string";
- value: "message";
- },
- {
- kind: "const";
- type: "string";
- value: "whitelist";
- }
- ];
- };
- },
- {
- name: "cpiCallerAuth";
- isMut: false;
- isSigner: true;
- docs: ["PDA representing authorized cpi caller"];
- }
- ];
- },
- {
- name: "messageBuffer";
- isMut: true;
- isSigner: false;
- pda: {
- seeds: [
- {
- kind: "account";
- type: {
- defined: "Signer<'info>";
- };
- account: "WhitelistVerifier";
- path: "whitelist_verifier.cpi_caller_auth";
- },
- {
- kind: "const";
- type: "string";
- value: "message";
- },
- {
- kind: "arg";
- type: "publicKey";
- path: "base_account_key";
- }
- ];
- };
- }
- ];
- args: [
- {
- name: "baseAccountKey";
- type: "publicKey";
- },
- {
- name: "messages";
- type: {
- vec: "bytes";
- };
- }
- ];
- },
- {
- name: "createBuffer";
- docs: [
- "Initializes the buffer account with the `target_size`",
- "",
- "*`allowed_program_auth` - The whitelisted pubkey representing an",
- "allowed program. Used as one of the seeds",
- "for deriving the `MessageBuffer` PDA.",
- "* `base_account_key` - Pubkey of the original account the",
- "`MessageBuffer` is derived from",
- "(e.g. pyth price account)",
- "*`target_size` - Initial size to allocate for the",
- "`MessageBuffer` PDA. `target_size`",
- "must be >= HEADER_LEN && <= 10240"
- ];
- accounts: [
- {
- name: "whitelist";
- isMut: false;
- isSigner: false;
- pda: {
- seeds: [
- {
- kind: "const";
- type: "string";
- value: "message";
- },
- {
- kind: "const";
- type: "string";
- value: "whitelist";
- }
- ];
- };
- relations: ["admin"];
- },
- {
- name: "admin";
- isMut: false;
- isSigner: true;
- },
- {
- name: "payer";
- isMut: true;
- isSigner: true;
- docs: ["pays for account initialization"];
- },
- {
- name: "systemProgram";
- isMut: false;
- isSigner: false;
- }
- ];
- args: [
- {
- name: "allowedProgramAuth";
- type: "publicKey";
- },
- {
- name: "baseAccountKey";
- type: "publicKey";
- },
- {
- name: "targetSize";
- type: "u32";
- }
- ];
- },
- {
- name: "resizeBuffer";
- docs: [
- "Resizes the buffer account to the `target_size`",
- "",
- "*`allowed_program_auth` - The whitelisted pubkey representing an",
- "allowed program. Used as one of the seeds",
- "for deriving the `MessageBuffer` PDA.",
- "* `base_account_key` - Pubkey of the original account the",
- "`MessageBuffer` is derived from",
- "(e.g. pyth price account)",
- "*`target_size` - Size to re-allocate for the",
- "`MessageBuffer` PDA. If increasing the size,",
- "max delta of current_size & target_size is 10240"
- ];
- accounts: [
- {
- name: "whitelist";
- isMut: false;
- isSigner: false;
- pda: {
- seeds: [
- {
- kind: "const";
- type: "string";
- value: "message";
- },
- {
- kind: "const";
- type: "string";
- value: "whitelist";
- }
- ];
- };
- relations: ["admin"];
- },
- {
- name: "admin";
- isMut: false;
- isSigner: true;
- },
- {
- name: "payer";
- isMut: true;
- isSigner: true;
- docs: [
- "Pays for any additional rent needed to increase the buffer size"
- ];
- },
- {
- name: "systemProgram";
- isMut: false;
- isSigner: false;
- },
- {
- name: "messageBuffer";
- isMut: true;
- isSigner: false;
- docs: [
- "If decreasing, Anchor will automatically check",
- "if target_size is < MessageBuffer::INIT_SPACE + 8",
- "and if so,then load() will fail.",
- "If increasing, Anchor also automatically checks if target_size delta",
- "exceeds MAX_PERMITTED_DATA_INCREASE"
- ];
- pda: {
- seeds: [
- {
- kind: "arg";
- type: "publicKey";
- path: "allowed_program_auth";
- },
- {
- kind: "const";
- type: "string";
- value: "message";
- },
- {
- kind: "arg";
- type: "publicKey";
- path: "base_account_key";
- }
- ];
- };
- }
- ];
- args: [
- {
- name: "allowedProgramAuth";
- type: "publicKey";
- },
- {
- name: "baseAccountKey";
- type: "publicKey";
- },
- {
- name: "targetSize";
- type: "u32";
- }
- ];
- },
- {
- name: "deleteBuffer";
- docs: [
- "Closes the buffer account and transfers the remaining lamports to the",
- "`admin` account",
- "",
- "*`allowed_program_auth` - The whitelisted pubkey representing an",
- "allowed program. Used as one of the seeds",
- "for deriving the `MessageBuffer` PDA.",
- "* `base_account_key` - Pubkey of the original account the",
- "`MessageBuffer` is derived from",
- "(e.g. pyth price account)"
- ];
- accounts: [
- {
- name: "whitelist";
- isMut: false;
- isSigner: false;
- pda: {
- seeds: [
- {
- kind: "const";
- type: "string";
- value: "message";
- },
- {
- kind: "const";
- type: "string";
- value: "whitelist";
- }
- ];
- };
- relations: ["admin"];
- },
- {
- name: "admin";
- isMut: false;
- isSigner: true;
- },
- {
- name: "payer";
- isMut: true;
- isSigner: true;
- docs: ["Recipient of the lamports from closing the buffer account"];
- },
- {
- name: "messageBuffer";
- isMut: true;
- isSigner: false;
- pda: {
- seeds: [
- {
- kind: "arg";
- type: "publicKey";
- path: "allowed_program_auth";
- },
- {
- kind: "const";
- type: "string";
- value: "message";
- },
- {
- kind: "arg";
- type: "publicKey";
- path: "base_account_key";
- }
- ];
- };
- }
- ];
- args: [
- {
- name: "allowedProgramAuth";
- type: "publicKey";
- },
- {
- name: "baseAccountKey";
- type: "publicKey";
- }
- ];
- }
- ];
- accounts: [
- {
- name: "messageBuffer";
- docs: [
- "A MessageBuffer will have the following structure",
- "```ignore",
- "struct MessageBuffer {",
- "header: BufferHeader,",
- "messages: [u8; accountInfo.data.len - header.header_len]",
- "}",
- "```",
- "",
- "where `MESSAGES_LEN` can be dynamic. There is actual",
- "no messages field in the `MessageBuffer` struct definition due to messages",
- "needing to be a dynamic length while supporting zero_copy",
- "at the same time.",
- "",
- "A `MessageBuffer` AccountInfo.data will look like:",
- "[ <discrimintator>, <buffer_header>, <messages> ]",
- "(0..8) (8..header_len) (header_len...accountInfo.data.len)",
- "",
- "<br>",
- "",
- "NOTE: The defined fields are read as *Little Endian*. The actual messages",
- "are read as *Big Endian*. The MessageBuffer fields are only ever read",
- "by the Pythnet validator & Hermes so don't need to be in Big Endian",
- "for cross-platform compatibility."
- ];
- type: {
- kind: "struct";
- fields: [
- {
- name: "bump";
- type: "u8";
- },
- {
- name: "version";
- type: "u8";
- },
- {
- name: "headerLen";
- type: "u16";
- },
- {
- name: "endOffsets";
- docs: [
- "endpoints of every message.",
- "ex: [10, 14]",
- "=> msg1 = account_info.data[(header_len + 0)..(header_len + 10)]",
- "=> msg2 = account_info.data[(header_len + 10)..(header_len + 14)]"
- ];
- type: {
- array: ["u16", 255];
- };
- }
- ];
- };
- },
- {
- name: "whitelist";
- type: {
- kind: "struct";
- fields: [
- {
- name: "bump";
- type: "u8";
- },
- {
- name: "admin";
- type: "publicKey";
- },
- {
- name: "allowedPrograms";
- type: {
- vec: "publicKey";
- };
- }
- ];
- };
- }
- ];
- errors: [
- {
- code: 6000;
- name: "CallerNotAllowed";
- msg: "CPI Caller not allowed";
- },
- {
- code: 6001;
- name: "InvalidAllowedProgram";
- msg: "Invalid allowed program";
- },
- {
- code: 6002;
- name: "MaximumAllowedProgramsExceeded";
- msg: "Maximum number of allowed programs exceeded";
- },
- {
- code: 6003;
- name: "MessageBufferNotProvided";
- msg: "Message Buffer not provided";
- },
- {
- code: 6004;
- name: "MessageBufferTooSmall";
- msg: "Message Buffer target size is not sufficiently large";
- },
- {
- code: 6005;
- name: "TargetSizeDeltaExceeded";
- msg: "Target size too large for reallocation/initialization. Max delta is 10240";
- },
- {
- code: 6006;
- name: "TargetSizeExceedsMaxLen";
- msg: "Target size exceeds MessageBuffer::MAX_LEN";
- }
- ];
- };
- export const IDL: MessageBuffer = {
- version: "0.1.0",
- name: "message_buffer",
- instructions: [
- {
- name: "initialize",
- docs: [
- "Initializes the whitelist and sets it's admin. Once initialized,",
- "the admin must sign all further changes to the whitelist.",
- ],
- accounts: [
- {
- name: "admin",
- isMut: false,
- isSigner: true,
- docs: [
- "Admin that can update the whitelist and create/resize/delete buffers",
- ],
- },
- {
- name: "payer",
- isMut: true,
- isSigner: true,
- },
- {
- name: "whitelist",
- isMut: true,
- isSigner: false,
- pda: {
- seeds: [
- {
- kind: "const",
- type: "string",
- value: "message",
- },
- {
- kind: "const",
- type: "string",
- value: "whitelist",
- },
- ],
- },
- },
- {
- name: "systemProgram",
- isMut: false,
- isSigner: false,
- },
- ],
- args: [],
- },
- {
- name: "setAllowedPrograms",
- docs: [
- "Sets the programs that are allowed to invoke this program through CPI",
- "",
- "* `allowed_programs` - Entire list of programs that are allowed to",
- "invoke this program through CPI",
- ],
- accounts: [
- {
- name: "admin",
- isMut: false,
- isSigner: true,
- },
- {
- name: "whitelist",
- isMut: true,
- isSigner: false,
- pda: {
- seeds: [
- {
- kind: "const",
- type: "string",
- value: "message",
- },
- {
- kind: "const",
- type: "string",
- value: "whitelist",
- },
- ],
- },
- relations: ["admin"],
- },
- ],
- args: [
- {
- name: "allowedPrograms",
- type: {
- vec: "publicKey",
- },
- },
- ],
- },
- {
- name: "updateWhitelistAdmin",
- docs: ["Sets the new admin for the whitelist"],
- accounts: [
- {
- name: "admin",
- isMut: false,
- isSigner: true,
- },
- {
- name: "whitelist",
- isMut: true,
- isSigner: false,
- pda: {
- seeds: [
- {
- kind: "const",
- type: "string",
- value: "message",
- },
- {
- kind: "const",
- type: "string",
- value: "whitelist",
- },
- ],
- },
- relations: ["admin"],
- },
- ],
- args: [
- {
- name: "newAdmin",
- type: "publicKey",
- },
- ],
- },
- {
- name: "putAll",
- docs: [
- "Put messages into the Accumulator. All messages put for the same",
- "`base_account_key` go into the same buffer PDA. The PDA's address is",
- "`[allowed_program_auth, MESSAGE, base_account_key]`, where `allowed_program_auth`",
- "is the whitelisted pubkey who authorized this call.",
- "",
- "* `base_account_key` - Pubkey of the original account the",
- "`MessageBuffer` is derived from",
- "(e.g. pyth price account)",
- "* `messages` - Vec of vec of bytes, each representing a message",
- "to be hashed and accumulated",
- "",
- "This ix will write as many of the messages up to the length",
- "of the `accumulator_input.data`.",
- "If `accumulator_input.data.len() < messages.map(|x| x.len()).sum()`",
- "then the remaining messages will be ignored.",
- "",
- "The current implementation assumes that each invocation of this",
- "ix is independent of any previous invocations. It will overwrite",
- "any existing contents.",
- "",
- "TODO:",
- '- handle updates ("paging/batches of messages")',
- "",
- ],
- accounts: [
- {
- name: "whitelistVerifier",
- accounts: [
- {
- name: "whitelist",
- isMut: false,
- isSigner: false,
- pda: {
- seeds: [
- {
- kind: "const",
- type: "string",
- value: "message",
- },
- {
- kind: "const",
- type: "string",
- value: "whitelist",
- },
- ],
- },
- },
- {
- name: "cpiCallerAuth",
- isMut: false,
- isSigner: true,
- docs: ["PDA representing authorized cpi caller"],
- },
- ],
- },
- {
- name: "messageBuffer",
- isMut: true,
- isSigner: false,
- pda: {
- seeds: [
- {
- kind: "account",
- type: {
- defined: "Signer<'info>",
- },
- account: "WhitelistVerifier",
- path: "whitelist_verifier.cpi_caller_auth",
- },
- {
- kind: "const",
- type: "string",
- value: "message",
- },
- {
- kind: "arg",
- type: "publicKey",
- path: "base_account_key",
- },
- ],
- },
- },
- ],
- args: [
- {
- name: "baseAccountKey",
- type: "publicKey",
- },
- {
- name: "messages",
- type: {
- vec: "bytes",
- },
- },
- ],
- },
- {
- name: "createBuffer",
- docs: [
- "Initializes the buffer account with the `target_size`",
- "",
- "*`allowed_program_auth` - The whitelisted pubkey representing an",
- "allowed program. Used as one of the seeds",
- "for deriving the `MessageBuffer` PDA.",
- "* `base_account_key` - Pubkey of the original account the",
- "`MessageBuffer` is derived from",
- "(e.g. pyth price account)",
- "*`target_size` - Initial size to allocate for the",
- "`MessageBuffer` PDA. `target_size`",
- "must be >= HEADER_LEN && <= 10240",
- ],
- accounts: [
- {
- name: "whitelist",
- isMut: false,
- isSigner: false,
- pda: {
- seeds: [
- {
- kind: "const",
- type: "string",
- value: "message",
- },
- {
- kind: "const",
- type: "string",
- value: "whitelist",
- },
- ],
- },
- relations: ["admin"],
- },
- {
- name: "admin",
- isMut: false,
- isSigner: true,
- },
- {
- name: "payer",
- isMut: true,
- isSigner: true,
- docs: ["pays for account initialization"],
- },
- {
- name: "systemProgram",
- isMut: false,
- isSigner: false,
- },
- ],
- args: [
- {
- name: "allowedProgramAuth",
- type: "publicKey",
- },
- {
- name: "baseAccountKey",
- type: "publicKey",
- },
- {
- name: "targetSize",
- type: "u32",
- },
- ],
- },
- {
- name: "resizeBuffer",
- docs: [
- "Resizes the buffer account to the `target_size`",
- "",
- "*`allowed_program_auth` - The whitelisted pubkey representing an",
- "allowed program. Used as one of the seeds",
- "for deriving the `MessageBuffer` PDA.",
- "* `base_account_key` - Pubkey of the original account the",
- "`MessageBuffer` is derived from",
- "(e.g. pyth price account)",
- "*`target_size` - Size to re-allocate for the",
- "`MessageBuffer` PDA. If increasing the size,",
- "max delta of current_size & target_size is 10240",
- ],
- accounts: [
- {
- name: "whitelist",
- isMut: false,
- isSigner: false,
- pda: {
- seeds: [
- {
- kind: "const",
- type: "string",
- value: "message",
- },
- {
- kind: "const",
- type: "string",
- value: "whitelist",
- },
- ],
- },
- relations: ["admin"],
- },
- {
- name: "admin",
- isMut: false,
- isSigner: true,
- },
- {
- name: "payer",
- isMut: true,
- isSigner: true,
- docs: [
- "Pays for any additional rent needed to increase the buffer size",
- ],
- },
- {
- name: "systemProgram",
- isMut: false,
- isSigner: false,
- },
- {
- name: "messageBuffer",
- isMut: true,
- isSigner: false,
- docs: [
- "If decreasing, Anchor will automatically check",
- "if target_size is < MessageBuffer::INIT_SPACE + 8",
- "and if so,then load() will fail.",
- "If increasing, Anchor also automatically checks if target_size delta",
- "exceeds MAX_PERMITTED_DATA_INCREASE",
- ],
- pda: {
- seeds: [
- {
- kind: "arg",
- type: "publicKey",
- path: "allowed_program_auth",
- },
- {
- kind: "const",
- type: "string",
- value: "message",
- },
- {
- kind: "arg",
- type: "publicKey",
- path: "base_account_key",
- },
- ],
- },
- },
- ],
- args: [
- {
- name: "allowedProgramAuth",
- type: "publicKey",
- },
- {
- name: "baseAccountKey",
- type: "publicKey",
- },
- {
- name: "targetSize",
- type: "u32",
- },
- ],
- },
- {
- name: "deleteBuffer",
- docs: [
- "Closes the buffer account and transfers the remaining lamports to the",
- "`admin` account",
- "",
- "*`allowed_program_auth` - The whitelisted pubkey representing an",
- "allowed program. Used as one of the seeds",
- "for deriving the `MessageBuffer` PDA.",
- "* `base_account_key` - Pubkey of the original account the",
- "`MessageBuffer` is derived from",
- "(e.g. pyth price account)",
- ],
- accounts: [
- {
- name: "whitelist",
- isMut: false,
- isSigner: false,
- pda: {
- seeds: [
- {
- kind: "const",
- type: "string",
- value: "message",
- },
- {
- kind: "const",
- type: "string",
- value: "whitelist",
- },
- ],
- },
- relations: ["admin"],
- },
- {
- name: "admin",
- isMut: false,
- isSigner: true,
- },
- {
- name: "payer",
- isMut: true,
- isSigner: true,
- docs: ["Recipient of the lamports from closing the buffer account"],
- },
- {
- name: "messageBuffer",
- isMut: true,
- isSigner: false,
- pda: {
- seeds: [
- {
- kind: "arg",
- type: "publicKey",
- path: "allowed_program_auth",
- },
- {
- kind: "const",
- type: "string",
- value: "message",
- },
- {
- kind: "arg",
- type: "publicKey",
- path: "base_account_key",
- },
- ],
- },
- },
- ],
- args: [
- {
- name: "allowedProgramAuth",
- type: "publicKey",
- },
- {
- name: "baseAccountKey",
- type: "publicKey",
- },
- ],
- },
- ],
- accounts: [
- {
- name: "messageBuffer",
- docs: [
- "A MessageBuffer will have the following structure",
- "```ignore",
- "struct MessageBuffer {",
- "header: BufferHeader,",
- "messages: [u8; accountInfo.data.len - header.header_len]",
- "}",
- "```",
- "",
- "where `MESSAGES_LEN` can be dynamic. There is actual",
- "no messages field in the `MessageBuffer` struct definition due to messages",
- "needing to be a dynamic length while supporting zero_copy",
- "at the same time.",
- "",
- "A `MessageBuffer` AccountInfo.data will look like:",
- "[ <discrimintator>, <buffer_header>, <messages> ]",
- "(0..8) (8..header_len) (header_len...accountInfo.data.len)",
- "",
- "<br>",
- "",
- "NOTE: The defined fields are read as *Little Endian*. The actual messages",
- "are read as *Big Endian*. The MessageBuffer fields are only ever read",
- "by the Pythnet validator & Hermes so don't need to be in Big Endian",
- "for cross-platform compatibility.",
- ],
- type: {
- kind: "struct",
- fields: [
- {
- name: "bump",
- type: "u8",
- },
- {
- name: "version",
- type: "u8",
- },
- {
- name: "headerLen",
- type: "u16",
- },
- {
- name: "endOffsets",
- docs: [
- "endpoints of every message.",
- "ex: [10, 14]",
- "=> msg1 = account_info.data[(header_len + 0)..(header_len + 10)]",
- "=> msg2 = account_info.data[(header_len + 10)..(header_len + 14)]",
- ],
- type: {
- array: ["u16", 255],
- },
- },
- ],
- },
- },
- {
- name: "whitelist",
- type: {
- kind: "struct",
- fields: [
- {
- name: "bump",
- type: "u8",
- },
- {
- name: "admin",
- type: "publicKey",
- },
- {
- name: "allowedPrograms",
- type: {
- vec: "publicKey",
- },
- },
- ],
- },
- },
- ],
- errors: [
- {
- code: 6000,
- name: "CallerNotAllowed",
- msg: "CPI Caller not allowed",
- },
- {
- code: 6001,
- name: "InvalidAllowedProgram",
- msg: "Invalid allowed program",
- },
- {
- code: 6002,
- name: "MaximumAllowedProgramsExceeded",
- msg: "Maximum number of allowed programs exceeded",
- },
- {
- code: 6003,
- name: "MessageBufferNotProvided",
- msg: "Message Buffer not provided",
- },
- {
- code: 6004,
- name: "MessageBufferTooSmall",
- msg: "Message Buffer target size is not sufficiently large",
- },
- {
- code: 6005,
- name: "TargetSizeDeltaExceeded",
- msg: "Target size too large for reallocation/initialization. Max delta is 10240",
- },
- {
- code: 6006,
- name: "TargetSizeExceedsMaxLen",
- msg: "Target size exceeds MessageBuffer::MAX_LEN",
- },
- ],
- };
|