Skip to content

Commit

Permalink
chore: restucture message files
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry committed Aug 12, 2022
1 parent 9823da7 commit 53dd609
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 37 deletions.
32 changes: 32 additions & 0 deletions src/message/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export * from './legacy';

/**
* The message header, identifying signed and read-only account
*/
export type MessageHeader = {
/**
* The number of signatures required for this message to be considered valid. The
* signatures must match the first `numRequiredSignatures` of `accountKeys`.
*/
numRequiredSignatures: number;
/** The last `numReadonlySignedAccounts` of the signed keys are read-only accounts */
numReadonlySignedAccounts: number;
/** The last `numReadonlySignedAccounts` of the unsigned keys are read-only accounts */
numReadonlyUnsignedAccounts: number;
};

/**
* An instruction to execute by a program
*
* @property {number} programIdIndex
* @property {number[]} accounts
* @property {string} data
*/
export type CompiledInstruction = {
/** Index into the transaction keys array indicating the program account that executes this instruction */
programIdIndex: number;
/** Ordered indices into the transaction keys array indicating which accounts to pass to the program */
accounts: number[];
/** The program input data encoded as base 58 */
data: string;
};
44 changes: 7 additions & 37 deletions src/message.ts → src/message/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,13 @@ import bs58 from 'bs58';
import {Buffer} from 'buffer';
import * as BufferLayout from '@solana/buffer-layout';

import {PublicKey} from './publickey';
import type {Blockhash} from './blockhash';
import * as Layout from './layout';
import {PACKET_DATA_SIZE} from './transaction/constants';
import * as shortvec from './util/shortvec-encoding';
import {toBuffer} from './util/to-buffer';

/**
* The message header, identifying signed and read-only account
*/
export type MessageHeader = {
/**
* The number of signatures required for this message to be considered valid. The
* signatures must match the first `numRequiredSignatures` of `accountKeys`.
*/
numRequiredSignatures: number;
/** The last `numReadonlySignedAccounts` of the signed keys are read-only accounts */
numReadonlySignedAccounts: number;
/** The last `numReadonlySignedAccounts` of the unsigned keys are read-only accounts */
numReadonlyUnsignedAccounts: number;
};

/**
* An instruction to execute by a program
*
* @property {number} programIdIndex
* @property {number[]} accounts
* @property {string} data
*/
export type CompiledInstruction = {
/** Index into the transaction keys array indicating the program account that executes this instruction */
programIdIndex: number;
/** Ordered indices into the transaction keys array indicating which accounts to pass to the program */
accounts: number[];
/** The program input data encoded as base 58 */
data: string;
};
import {PublicKey} from '../publickey';
import type {Blockhash} from '../blockhash';
import * as Layout from '../layout';
import {PACKET_DATA_SIZE} from '../transaction/constants';
import * as shortvec from '../util/shortvec-encoding';
import {toBuffer} from '../util/to-buffer';
import {CompiledInstruction, MessageHeader} from './index';

/**
* Message constructor arguments
Expand Down

0 comments on commit 53dd609

Please sign in to comment.