@solana/instructions 2.0.0-experimental.eb951b0 → 2.0.0-experimental.ed41fe2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/instruction.ts","../src/roles.ts"],"names":["AccountRole"],"mappings":";AACA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAkBA,SAAS,wBACZ,aACA,gBAC0E;AAC1E,SAAO,YAAY,mBAAmB;AAC1C;AAEO,SAAS,8BACZ,aACA,gBACkF;AAClF,MAAI,YAAY,mBAAmB,gBAAgB;AAC/C,UAAM,IAAI,YAAY,gDAAgD;AAAA,MAClE,sBAAsB,YAAY;AAAA,MAClC,wBAAwB;AAAA,IAC5B,CAAC;AAAA,EACL;AACJ;AAEO,SAAS,0BAGd,aAA8F;AAC5F,SAAO,YAAY,aAAa;AACpC;AAEO,SAAS,gCAGd,aAAsG;AACpG,MAAI,YAAY,aAAa,QAAW;AACpC,UAAM,IAAI,YAAY,sDAAsD;AAAA,MACxE,MAAM,YAAY;AAAA,MAClB,gBAAgB,YAAY;AAAA,IAChC,CAAC;AAAA,EACL;AACJ;AAMO,SAAS,sBAGd,aAAsF;AACpF,SAAO,YAAY,SAAS;AAChC;AAEO,SAAS,4BAGd,aAA8F;AAC5F,MAAI,YAAY,SAAS,QAAW;AAChC,UAAM,IAAI,YAAY,kDAAkD;AAAA,MACpE,kBAAkB,YAAY,UAAU,IAAI,OAAK,EAAE,OAAO;AAAA,MAC1D,gBAAgB,YAAY;AAAA,IAChC,CAAC;AAAA,EACL;AACJ;;;AC/EO,IAAK,cAAL,kBAAKA,iBAAL;AAEH,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AALQ,SAAAA;AAAA,GAAA;AAQZ,IAAM,oBAAoB;AAC1B,IAAM,sBAAsB;AAKrB,SAAS,yBAAyB,MAAgC;AACrE,SAAO,OAAO,CAAC;AACnB;AAKO,SAAS,wBAAwB,MAAgC;AACpE,SAAO,OAAO,CAAC;AACnB;AAEO,SAAS,aAAa,MAAsF;AAC/G,SAAO,QAAQ;AACnB;AAEO,SAAS,eAAe,MAA+E;AAC1G,UAAQ,OAAO,yBAAyB;AAC5C;AAYO,SAAS,WAAW,OAAoB,OAAiC;AAC5E,SAAO,QAAQ;AACnB;AAKO,SAAS,oBAAoB,MAAgC;AAChE,SAAO,OAAO;AAClB;AAKO,SAAS,sBAAsB,MAAgC;AAClE,SAAO,OAAO;AAClB","sourcesContent":["import { Address } from '@solana/addresses';\nimport {\n SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS,\n SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA,\n SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH,\n SolanaError,\n} from '@solana/errors';\n\nimport { IAccountLookupMeta, IAccountMeta } from './accounts';\n\nexport interface IInstruction<\n TProgramAddress extends string = string,\n TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[],\n> {\n readonly accounts?: TAccounts;\n readonly data?: Uint8Array;\n readonly programAddress: Address<TProgramAddress>;\n}\n\nexport interface IInstructionWithAccounts<TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[]>\n extends IInstruction {\n readonly accounts: TAccounts;\n}\n\nexport function isInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n return instruction.programAddress === programAddress;\n}\n\nexport function assertIsInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): asserts instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n if (instruction.programAddress !== programAddress) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH, {\n actualProgramAddress: instruction.programAddress,\n expectedProgramAddress: programAddress,\n });\n }\n}\n\nexport function isInstructionWithAccounts<\n TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is TInstruction & IInstructionWithAccounts<TAccounts> {\n return instruction.accounts !== undefined;\n}\n\nexport function assertIsInstructionWithAccounts<\n TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is TInstruction & IInstructionWithAccounts<TAccounts> {\n if (instruction.accounts === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS, {\n data: instruction.data,\n programAddress: instruction.programAddress,\n });\n }\n}\n\nexport interface IInstructionWithData<TData extends Uint8Array> extends IInstruction {\n readonly data: TData;\n}\n\nexport function isInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is TInstruction & IInstructionWithData<TData> {\n return instruction.data !== undefined;\n}\n\nexport function assertIsInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is TInstruction & IInstructionWithData<TData> {\n if (instruction.data === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA, {\n accountAddresses: instruction.accounts?.map(a => a.address),\n programAddress: instruction.programAddress,\n });\n }\n}\n","/**\n * Quick primer on bitwise operations: https://stackoverflow.com/a/1436448/802047\n */\n\nexport enum AccountRole {\n // Bitflag guide: is signer ⌄⌄ is writable\n WRITABLE_SIGNER = /* 3 */ 0b11, // prettier-ignore\n READONLY_SIGNER = /* 2 */ 0b10, // prettier-ignore\n WRITABLE = /* 1 */ 0b01, // prettier-ignore\n READONLY = /* 0 */ 0b00, // prettier-ignore\n}\n\nconst IS_SIGNER_BITMASK = 0b10;\nconst IS_WRITABLE_BITMASK = 0b01;\n\nexport function downgradeRoleToNonSigner(role: AccountRole.READONLY_SIGNER): AccountRole.READONLY;\nexport function downgradeRoleToNonSigner(role: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole {\n return role & ~IS_SIGNER_BITMASK;\n}\n\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE): AccountRole.READONLY;\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE_SIGNER): AccountRole.READONLY_SIGNER;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole {\n return role & ~IS_WRITABLE_BITMASK;\n}\n\nexport function isSignerRole(role: AccountRole): role is AccountRole.READONLY_SIGNER | AccountRole.WRITABLE_SIGNER {\n return role >= AccountRole.READONLY_SIGNER;\n}\n\nexport function isWritableRole(role: AccountRole): role is AccountRole.WRITABLE | AccountRole.WRITABLE_SIGNER {\n return (role & IS_WRITABLE_BITMASK) !== 0;\n}\n\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE_SIGNER, roleB: AccountRole): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.READONLY_SIGNER): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY, roleB: AccountRole.READONLY): AccountRole.READONLY; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole {\n return roleA | roleB;\n}\n\nexport function upgradeRoleToSigner(role: AccountRole.READONLY): AccountRole.READONLY_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole {\n return role | IS_SIGNER_BITMASK;\n}\n\nexport function upgradeRoleToWritable(role: AccountRole.READONLY): AccountRole.WRITABLE;\nexport function upgradeRoleToWritable(role: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole {\n return role | IS_WRITABLE_BITMASK;\n}\n"]}
1
+ {"version":3,"sources":["../src/instruction.ts","../src/roles.ts"],"names":["AccountRole"],"mappings":";AACA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAkBA,SAAS,wBACZ,aACA,gBAC0E;AAC1E,SAAO,YAAY,mBAAmB;AAC1C;AAEO,SAAS,8BACZ,aACA,gBACkF;AAClF,MAAI,YAAY,mBAAmB,gBAAgB;AAC/C,UAAM,IAAI,YAA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SAAO,OAAO;AAClB","sourcesContent":["import { Address } from '@solana/addresses';\nimport {\n SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS,\n SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA,\n SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH,\n SolanaError,\n} from '@solana/errors';\n\nimport { IAccountLookupMeta, IAccountMeta } from './accounts';\n\nexport interface IInstruction<\n TProgramAddress extends string = string,\n TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[] = readonly (IAccountLookupMeta | IAccountMeta)[],\n> {\n readonly accounts?: TAccounts;\n readonly data?: Uint8Array;\n readonly programAddress: Address<TProgramAddress>;\n}\n\nexport interface IInstructionWithAccounts<TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[]>\n extends IInstruction {\n readonly accounts: TAccounts;\n}\n\nexport function isInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n return instruction.programAddress === programAddress;\n}\n\nexport function assertIsInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): asserts instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n if (instruction.programAddress !== programAddress) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH, {\n actualProgramAddress: instruction.programAddress,\n expectedProgramAddress: programAddress,\n });\n }\n}\n\nexport function isInstructionWithAccounts<\n TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[] = readonly (IAccountLookupMeta | IAccountMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is IInstructionWithAccounts<TAccounts> & TInstruction {\n return instruction.accounts !== undefined;\n}\n\nexport function assertIsInstructionWithAccounts<\n TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[] = readonly (IAccountLookupMeta | IAccountMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is IInstructionWithAccounts<TAccounts> & TInstruction {\n if (instruction.accounts === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS, {\n data: instruction.data,\n programAddress: instruction.programAddress,\n });\n }\n}\n\nexport interface IInstructionWithData<TData extends Uint8Array> extends IInstruction {\n readonly data: TData;\n}\n\nexport function isInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is IInstructionWithData<TData> & TInstruction {\n return instruction.data !== undefined;\n}\n\nexport function assertIsInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is IInstructionWithData<TData> & TInstruction {\n if (instruction.data === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA, {\n accountAddresses: instruction.accounts?.map(a => a.address),\n programAddress: instruction.programAddress,\n });\n }\n}\n","/**\n * Quick primer on bitwise operations: https://stackoverflow.com/a/1436448/802047\n */\n\nexport enum AccountRole {\n // Bitflag guide: is signer ⌄⌄ is writable\n WRITABLE_SIGNER = /* 3 */ 0b11, // prettier-ignore\n READONLY_SIGNER = /* 2 */ 0b10, // prettier-ignore\n WRITABLE = /* 1 */ 0b01, // prettier-ignore\n READONLY = /* 0 */ 0b00, // prettier-ignore\n}\n\nconst IS_SIGNER_BITMASK = 0b10;\nconst IS_WRITABLE_BITMASK = 0b01;\n\nexport function downgradeRoleToNonSigner(role: AccountRole.READONLY_SIGNER): AccountRole.READONLY;\nexport function downgradeRoleToNonSigner(role: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole {\n return role & ~IS_SIGNER_BITMASK;\n}\n\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE): AccountRole.READONLY;\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE_SIGNER): AccountRole.READONLY_SIGNER;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole {\n return role & ~IS_WRITABLE_BITMASK;\n}\n\nexport function isSignerRole(role: AccountRole): role is AccountRole.READONLY_SIGNER | AccountRole.WRITABLE_SIGNER {\n return role >= AccountRole.READONLY_SIGNER;\n}\n\nexport function isWritableRole(role: AccountRole): role is AccountRole.WRITABLE | AccountRole.WRITABLE_SIGNER {\n return (role & IS_WRITABLE_BITMASK) !== 0;\n}\n\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE_SIGNER, roleB: AccountRole): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.READONLY_SIGNER): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY, roleB: AccountRole.READONLY): AccountRole.READONLY; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole {\n return roleA | roleB;\n}\n\nexport function upgradeRoleToSigner(role: AccountRole.READONLY): AccountRole.READONLY_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole {\n return role | IS_SIGNER_BITMASK;\n}\n\nexport function upgradeRoleToWritable(role: AccountRole.READONLY): AccountRole.WRITABLE;\nexport function upgradeRoleToWritable(role: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole {\n return role | IS_WRITABLE_BITMASK;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/instruction.ts","../src/roles.ts"],"names":["AccountRole"],"mappings":";AACA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAkBA,SAAS,wBACZ,aACA,gBAC0E;AAC1E,SAAO,YAAY,mBAAmB;AAC1C;AAEO,SAAS,8BACZ,aACA,gBACkF;AAClF,MAAI,YAAY,mBAAmB,gBAAgB;AAC/C,UAAM,IAAI,YAAY,gDAAgD;AAAA,MAClE,sBAAsB,YAAY;AAAA,MAClC,wBAAwB;AAAA,IAC5B,CAAC;AAAA,EACL;AACJ;AAEO,SAAS,0BAGd,aAA8F;AAC5F,SAAO,YAAY,aAAa;AACpC;AAEO,SAAS,gCAGd,aAAsG;AACpG,MAAI,YAAY,aAAa,QAAW;AACpC,UAAM,IAAI,YAAY,sDAAsD;AAAA,MACxE,MAAM,YAAY;AAAA,MAClB,gBAAgB,YAAY;AAAA,IAChC,CAAC;AAAA,EACL;AACJ;AAMO,SAAS,sBAGd,aAAsF;AACpF,SAAO,YAAY,SAAS;AAChC;AAEO,SAAS,4BAGd,aAA8F;AAC5F,MAAI,YAAY,SAAS,QAAW;AAChC,UAAM,IAAI,YAAY,kDAAkD;AAAA,MACpE,kBAAkB,YAAY,UAAU,IAAI,OAAK,EAAE,OAAO;AAAA,MAC1D,gBAAgB,YAAY;AAAA,IAChC,CAAC;AAAA,EACL;AACJ;;;AC/EO,IAAK,cAAL,kBAAKA,iBAAL;AAEH,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AALQ,SAAAA;AAAA,GAAA;AAQZ,IAAM,oBAAoB;AAC1B,IAAM,sBAAsB;AAKrB,SAAS,yBAAyB,MAAgC;AACrE,SAAO,OAAO,CAAC;AACnB;AAKO,SAAS,wBAAwB,MAAgC;AACpE,SAAO,OAAO,CAAC;AACnB;AAEO,SAAS,aAAa,MAAsF;AAC/G,SAAO,QAAQ;AACnB;AAEO,SAAS,eAAe,MAA+E;AAC1G,UAAQ,OAAO,yBAAyB;AAC5C;AAYO,SAAS,WAAW,OAAoB,OAAiC;AAC5E,SAAO,QAAQ;AACnB;AAKO,SAAS,oBAAoB,MAAgC;AAChE,SAAO,OAAO;AAClB;AAKO,SAAS,sBAAsB,MAAgC;AAClE,SAAO,OAAO;AAClB","sourcesContent":["import { Address } from '@solana/addresses';\nimport {\n SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS,\n SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA,\n SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH,\n SolanaError,\n} from '@solana/errors';\n\nimport { IAccountLookupMeta, IAccountMeta } from './accounts';\n\nexport interface IInstruction<\n TProgramAddress extends string = string,\n TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[],\n> {\n readonly accounts?: TAccounts;\n readonly data?: Uint8Array;\n readonly programAddress: Address<TProgramAddress>;\n}\n\nexport interface IInstructionWithAccounts<TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[]>\n extends IInstruction {\n readonly accounts: TAccounts;\n}\n\nexport function isInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n return instruction.programAddress === programAddress;\n}\n\nexport function assertIsInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): asserts instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n if (instruction.programAddress !== programAddress) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH, {\n actualProgramAddress: instruction.programAddress,\n expectedProgramAddress: programAddress,\n });\n }\n}\n\nexport function isInstructionWithAccounts<\n TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is TInstruction & IInstructionWithAccounts<TAccounts> {\n return instruction.accounts !== undefined;\n}\n\nexport function assertIsInstructionWithAccounts<\n TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is TInstruction & IInstructionWithAccounts<TAccounts> {\n if (instruction.accounts === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS, {\n data: instruction.data,\n programAddress: instruction.programAddress,\n });\n }\n}\n\nexport interface IInstructionWithData<TData extends Uint8Array> extends IInstruction {\n readonly data: TData;\n}\n\nexport function isInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is TInstruction & IInstructionWithData<TData> {\n return instruction.data !== undefined;\n}\n\nexport function assertIsInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is TInstruction & IInstructionWithData<TData> {\n if (instruction.data === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA, {\n accountAddresses: instruction.accounts?.map(a => a.address),\n programAddress: instruction.programAddress,\n });\n }\n}\n","/**\n * Quick primer on bitwise operations: https://stackoverflow.com/a/1436448/802047\n */\n\nexport enum AccountRole {\n // Bitflag guide: is signer ⌄⌄ is writable\n WRITABLE_SIGNER = /* 3 */ 0b11, // prettier-ignore\n READONLY_SIGNER = /* 2 */ 0b10, // prettier-ignore\n WRITABLE = /* 1 */ 0b01, // prettier-ignore\n READONLY = /* 0 */ 0b00, // prettier-ignore\n}\n\nconst IS_SIGNER_BITMASK = 0b10;\nconst IS_WRITABLE_BITMASK = 0b01;\n\nexport function downgradeRoleToNonSigner(role: AccountRole.READONLY_SIGNER): AccountRole.READONLY;\nexport function downgradeRoleToNonSigner(role: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole {\n return role & ~IS_SIGNER_BITMASK;\n}\n\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE): AccountRole.READONLY;\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE_SIGNER): AccountRole.READONLY_SIGNER;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole {\n return role & ~IS_WRITABLE_BITMASK;\n}\n\nexport function isSignerRole(role: AccountRole): role is AccountRole.READONLY_SIGNER | AccountRole.WRITABLE_SIGNER {\n return role >= AccountRole.READONLY_SIGNER;\n}\n\nexport function isWritableRole(role: AccountRole): role is AccountRole.WRITABLE | AccountRole.WRITABLE_SIGNER {\n return (role & IS_WRITABLE_BITMASK) !== 0;\n}\n\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE_SIGNER, roleB: AccountRole): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.READONLY_SIGNER): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY, roleB: AccountRole.READONLY): AccountRole.READONLY; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole {\n return roleA | roleB;\n}\n\nexport function upgradeRoleToSigner(role: AccountRole.READONLY): AccountRole.READONLY_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole {\n return role | IS_SIGNER_BITMASK;\n}\n\nexport function upgradeRoleToWritable(role: AccountRole.READONLY): AccountRole.WRITABLE;\nexport function upgradeRoleToWritable(role: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole {\n return role | IS_WRITABLE_BITMASK;\n}\n"]}
1
+ {"version":3,"sources":["../src/instruction.ts","../src/roles.ts"],"names":["AccountRole"],"mappings":";AACA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAkBA,SAAS,wBACZ,aACA,gBAC0E;AAC1E,SAAO,YAAY,mBAAmB;AAC1C;AAEO,SAAS,8BACZ,aACA,gBACkF;AAClF,MAAI,YAAY,mBAAmB,gBAAgB;AAC/C,UAAM,IAAI,YAAY,gDAAgD;AAAA,MAClE,sBAAsB,YAAY;AAAA,MAClC,wBAAwB;AAAA,IAC5B,CAAC;AAAA,EACL;AACJ;AAEO,SAAS,0BAGd,aAA8F;AAC5F,SAAO,YAAY,aAAa;AACpC;AAEO,SAAS,gCAGd,aAAsG;AACpG,MAAI,YAAY,aAAa,QAAW;AACpC,UAAM,IAAI,YAAY,sDAAsD;AAAA,MACxE,MAAM,YAAY;AAAA,MAClB,gBAAgB,YAAY;AAAA,IAChC,CAAC;AAAA,EACL;AACJ;AAMO,SAAS,sBAGd,aAAsF;AACpF,SAAO,YAAY,SAAS;AAChC;AAEO,SAAS,4BAGd,aAA8F;AAC5F,MAAI,YAAY,SAAS,QAAW;AAChC,UAAM,IAAI,YAAY,kDAAkD;AAAA,MACpE,kBAAkB,YAAY,UAAU,IAAI,OAAK,EAAE,OAAO;AAAA,MAC1D,gBAAgB,YAAY;AAAA,IAChC,CAAC;AAAA,EACL;AACJ;;;AC/EO,IAAK,cAAL,kBAAKA,iBAAL;AAEH,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AALQ,SAAAA;AAAA,GAAA;AAQZ,IAAM,oBAAoB;AAC1B,IAAM,sBAAsB;AAKrB,SAAS,yBAAyB,MAAgC;AACrE,SAAO,OAAO,CAAC;AACnB;AAKO,SAAS,wBAAwB,MAAgC;AACpE,SAAO,OAAO,CAAC;AACnB;AAEO,SAAS,aAAa,MAAsF;AAC/G,SAAO,QAAQ;AACnB;AAEO,SAAS,eAAe,MAA+E;AAC1G,UAAQ,OAAO,yBAAyB;AAC5C;AAYO,SAAS,WAAW,OAAoB,OAAiC;AAC5E,SAAO,QAAQ;AACnB;AAKO,SAAS,oBAAoB,MAAgC;AAChE,SAAO,OAAO;AAClB;AAKO,SAAS,sBAAsB,MAAgC;AAClE,SAAO,OAAO;AAClB","sourcesContent":["import { Address } from '@solana/addresses';\nimport {\n SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS,\n SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA,\n SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH,\n SolanaError,\n} from '@solana/errors';\n\nimport { IAccountLookupMeta, IAccountMeta } from './accounts';\n\nexport interface IInstruction<\n TProgramAddress extends string = string,\n TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[] = readonly (IAccountLookupMeta | IAccountMeta)[],\n> {\n readonly accounts?: TAccounts;\n readonly data?: Uint8Array;\n readonly programAddress: Address<TProgramAddress>;\n}\n\nexport interface IInstructionWithAccounts<TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[]>\n extends IInstruction {\n readonly accounts: TAccounts;\n}\n\nexport function isInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n return instruction.programAddress === programAddress;\n}\n\nexport function assertIsInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): asserts instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n if (instruction.programAddress !== programAddress) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH, {\n actualProgramAddress: instruction.programAddress,\n expectedProgramAddress: programAddress,\n });\n }\n}\n\nexport function isInstructionWithAccounts<\n TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[] = readonly (IAccountLookupMeta | IAccountMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is IInstructionWithAccounts<TAccounts> & TInstruction {\n return instruction.accounts !== undefined;\n}\n\nexport function assertIsInstructionWithAccounts<\n TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[] = readonly (IAccountLookupMeta | IAccountMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is IInstructionWithAccounts<TAccounts> & TInstruction {\n if (instruction.accounts === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS, {\n data: instruction.data,\n programAddress: instruction.programAddress,\n });\n }\n}\n\nexport interface IInstructionWithData<TData extends Uint8Array> extends IInstruction {\n readonly data: TData;\n}\n\nexport function isInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is IInstructionWithData<TData> & TInstruction {\n return instruction.data !== undefined;\n}\n\nexport function assertIsInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is IInstructionWithData<TData> & TInstruction {\n if (instruction.data === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA, {\n accountAddresses: instruction.accounts?.map(a => a.address),\n programAddress: instruction.programAddress,\n });\n }\n}\n","/**\n * Quick primer on bitwise operations: https://stackoverflow.com/a/1436448/802047\n */\n\nexport enum AccountRole {\n // Bitflag guide: is signer ⌄⌄ is writable\n WRITABLE_SIGNER = /* 3 */ 0b11, // prettier-ignore\n READONLY_SIGNER = /* 2 */ 0b10, // prettier-ignore\n WRITABLE = /* 1 */ 0b01, // prettier-ignore\n READONLY = /* 0 */ 0b00, // prettier-ignore\n}\n\nconst IS_SIGNER_BITMASK = 0b10;\nconst IS_WRITABLE_BITMASK = 0b01;\n\nexport function downgradeRoleToNonSigner(role: AccountRole.READONLY_SIGNER): AccountRole.READONLY;\nexport function downgradeRoleToNonSigner(role: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole {\n return role & ~IS_SIGNER_BITMASK;\n}\n\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE): AccountRole.READONLY;\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE_SIGNER): AccountRole.READONLY_SIGNER;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole {\n return role & ~IS_WRITABLE_BITMASK;\n}\n\nexport function isSignerRole(role: AccountRole): role is AccountRole.READONLY_SIGNER | AccountRole.WRITABLE_SIGNER {\n return role >= AccountRole.READONLY_SIGNER;\n}\n\nexport function isWritableRole(role: AccountRole): role is AccountRole.WRITABLE | AccountRole.WRITABLE_SIGNER {\n return (role & IS_WRITABLE_BITMASK) !== 0;\n}\n\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE_SIGNER, roleB: AccountRole): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.READONLY_SIGNER): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY, roleB: AccountRole.READONLY): AccountRole.READONLY; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole {\n return roleA | roleB;\n}\n\nexport function upgradeRoleToSigner(role: AccountRole.READONLY): AccountRole.READONLY_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole {\n return role | IS_SIGNER_BITMASK;\n}\n\nexport function upgradeRoleToWritable(role: AccountRole.READONLY): AccountRole.WRITABLE;\nexport function upgradeRoleToWritable(role: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole {\n return role | IS_WRITABLE_BITMASK;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/instruction.ts","../src/roles.ts"],"names":["AccountRole"],"mappings":";AACA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAkBA,SAAS,wBACZ,aACA,gBAC0E;AAC1E,SAAO,YAAY,mBAAmB;AAC1C;AAEO,SAAS,8BACZ,aACA,gBACkF;AAClF,MAAI,YAAY,mBAAmB,gBAAgB;AAC/C,UAAM,IAAI,YAAY,gDAAgD;AAAA,MAClE,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Content":["import { Address } from '@solana/addresses';\nimport {\n SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS,\n SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA,\n SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH,\n SolanaError,\n} from '@solana/errors';\n\nimport { IAccountLookupMeta, IAccountMeta } from './accounts';\n\nexport interface IInstruction<\n TProgramAddress extends string = string,\n TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[],\n> {\n readonly accounts?: TAccounts;\n readonly data?: Uint8Array;\n readonly programAddress: Address<TProgramAddress>;\n}\n\nexport interface IInstructionWithAccounts<TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[]>\n extends IInstruction {\n readonly accounts: TAccounts;\n}\n\nexport function isInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n return instruction.programAddress === programAddress;\n}\n\nexport function assertIsInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): asserts instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n if (instruction.programAddress !== programAddress) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH, {\n actualProgramAddress: instruction.programAddress,\n expectedProgramAddress: programAddress,\n });\n }\n}\n\nexport function isInstructionWithAccounts<\n TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is TInstruction & IInstructionWithAccounts<TAccounts> {\n return instruction.accounts !== undefined;\n}\n\nexport function assertIsInstructionWithAccounts<\n TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is TInstruction & IInstructionWithAccounts<TAccounts> {\n if (instruction.accounts === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS, {\n data: instruction.data,\n programAddress: instruction.programAddress,\n });\n }\n}\n\nexport interface IInstructionWithData<TData extends Uint8Array> extends IInstruction {\n readonly data: TData;\n}\n\nexport function isInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is TInstruction & IInstructionWithData<TData> {\n return instruction.data !== undefined;\n}\n\nexport function assertIsInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is TInstruction & IInstructionWithData<TData> {\n if (instruction.data === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA, {\n accountAddresses: instruction.accounts?.map(a => a.address),\n programAddress: instruction.programAddress,\n });\n }\n}\n","/**\n * Quick primer on bitwise operations: https://stackoverflow.com/a/1436448/802047\n */\n\nexport enum AccountRole {\n // Bitflag guide: is signer ⌄⌄ is writable\n WRITABLE_SIGNER = /* 3 */ 0b11, // prettier-ignore\n READONLY_SIGNER = /* 2 */ 0b10, // prettier-ignore\n WRITABLE = /* 1 */ 0b01, // prettier-ignore\n READONLY = /* 0 */ 0b00, // prettier-ignore\n}\n\nconst IS_SIGNER_BITMASK = 0b10;\nconst IS_WRITABLE_BITMASK = 0b01;\n\nexport function downgradeRoleToNonSigner(role: AccountRole.READONLY_SIGNER): AccountRole.READONLY;\nexport function downgradeRoleToNonSigner(role: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole {\n return role & ~IS_SIGNER_BITMASK;\n}\n\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE): AccountRole.READONLY;\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE_SIGNER): AccountRole.READONLY_SIGNER;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole {\n return role & ~IS_WRITABLE_BITMASK;\n}\n\nexport function isSignerRole(role: AccountRole): role is AccountRole.READONLY_SIGNER | AccountRole.WRITABLE_SIGNER {\n return role >= AccountRole.READONLY_SIGNER;\n}\n\nexport function isWritableRole(role: AccountRole): role is AccountRole.WRITABLE | AccountRole.WRITABLE_SIGNER {\n return (role & IS_WRITABLE_BITMASK) !== 0;\n}\n\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE_SIGNER, roleB: AccountRole): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.READONLY_SIGNER): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY, roleB: AccountRole.READONLY): AccountRole.READONLY; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole {\n return roleA | roleB;\n}\n\nexport function upgradeRoleToSigner(role: AccountRole.READONLY): AccountRole.READONLY_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole {\n return role | IS_SIGNER_BITMASK;\n}\n\nexport function upgradeRoleToWritable(role: AccountRole.READONLY): AccountRole.WRITABLE;\nexport function upgradeRoleToWritable(role: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole {\n return role | IS_WRITABLE_BITMASK;\n}\n"]}
1
+ {"version":3,"sources":["../src/instruction.ts","../src/roles.ts"],"names":["AccountRole"],"mappings":";AACA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAkBA,SAAS,wBACZ,aACA,gBAC0E;AAC1E,SAAO,YAAY,mBAAmB;AAC1C;AAEO,SAAS,8BACZ,aACA,gBACkF;AAClF,MAAI,YAAY,mBAAmB,gBAAgB;AAC/C,UAAM,IAAI,YAAY,gDAAgD;AAAA,MAClE,sBAAsB,YAAY;AAAA,MAClC,wBAAwB;AAAA,IAC5B,CAAC;AAAA,EACL;AACJ;AAEO,SAAS,0BAGd,aAA8F;AAC5F,SAAO,YAAY,aAAa;AACpC;AAEO,SAAS,gCAGd,aAAsG;AACpG,MAAI,YAAY,aAAa,QAAW;AACpC,UAAM,IAAI,YAAY,sDAAsD;AAAA,MACxE,MAAM,YAAY;AAAA,MAClB,gBAAgB,YAAY;AAAA,IAChC,CAAC;AAAA,EACL;AACJ;AAMO,SAAS,sBAGd,aAAsF;AACpF,SAAO,YAAY,SAAS;AAChC;AAEO,SAAS,4BAGd,aAA8F;AAC5F,MAAI,YAAY,SAAS,QAAW;AAChC,UAAM,IAAI,YAAY,kDAAkD;AAAA,MACpE,kBAAkB,YAAY,UAAU,IAAI,OAAK,EAAE,OAAO;AAAA,MAC1D,gBAAgB,YAAY;AAAA,IAChC,CAAC;AAAA,EACL;AACJ;;;AC/EO,IAAK,cAAL,kBAAKA,iBAAL;AAEH,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AALQ,SAAAA;AAAA,GAAA;AAQZ,IAAM,oBAAoB;AAC1B,IAAM,sBAAsB;AAKrB,SAAS,yBAAyB,MAAgC;AACrE,SAAO,OAAO,CAAC;AACnB;AAKO,SAAS,wBAAwB,MAAgC;AACpE,SAAO,OAAO,CAAC;AACnB;AAEO,SAAS,aAAa,MAAsF;AAC/G,SAAO,QAAQ;AACnB;AAEO,SAAS,eAAe,MAA+E;AAC1G,UAAQ,OAAO,yBAAyB;AAC5C;AAYO,SAAS,WAAW,OAAoB,OAAiC;AAC5E,SAAO,QAAQ;AACnB;AAKO,SAAS,oBAAoB,MAAgC;AAChE,SAAO,OAAO;AAClB;AAKO,SAAS,sBAAsB,MAAgC;AAClE,SAAO,OAAO;AAClB","sourcesContent":["import { Address } from '@solana/addresses';\nimport {\n SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS,\n SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA,\n SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH,\n SolanaError,\n} from '@solana/errors';\n\nimport { IAccountLookupMeta, IAccountMeta } from './accounts';\n\nexport interface IInstruction<\n TProgramAddress extends string = string,\n TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[] = readonly (IAccountLookupMeta | IAccountMeta)[],\n> {\n readonly accounts?: TAccounts;\n readonly data?: Uint8Array;\n readonly programAddress: Address<TProgramAddress>;\n}\n\nexport interface IInstructionWithAccounts<TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[]>\n extends IInstruction {\n readonly accounts: TAccounts;\n}\n\nexport function isInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n return instruction.programAddress === programAddress;\n}\n\nexport function assertIsInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): asserts instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n if (instruction.programAddress !== programAddress) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH, {\n actualProgramAddress: instruction.programAddress,\n expectedProgramAddress: programAddress,\n });\n }\n}\n\nexport function isInstructionWithAccounts<\n TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[] = readonly (IAccountLookupMeta | IAccountMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is IInstructionWithAccounts<TAccounts> & TInstruction {\n return instruction.accounts !== undefined;\n}\n\nexport function assertIsInstructionWithAccounts<\n TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[] = readonly (IAccountLookupMeta | IAccountMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is IInstructionWithAccounts<TAccounts> & TInstruction {\n if (instruction.accounts === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS, {\n data: instruction.data,\n programAddress: instruction.programAddress,\n });\n }\n}\n\nexport interface IInstructionWithData<TData extends Uint8Array> extends IInstruction {\n readonly data: TData;\n}\n\nexport function isInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is IInstructionWithData<TData> & TInstruction {\n return instruction.data !== undefined;\n}\n\nexport function assertIsInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is IInstructionWithData<TData> & TInstruction {\n if (instruction.data === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA, {\n accountAddresses: instruction.accounts?.map(a => a.address),\n programAddress: instruction.programAddress,\n });\n }\n}\n","/**\n * Quick primer on bitwise operations: https://stackoverflow.com/a/1436448/802047\n */\n\nexport enum AccountRole {\n // Bitflag guide: is signer ⌄⌄ is writable\n WRITABLE_SIGNER = /* 3 */ 0b11, // prettier-ignore\n READONLY_SIGNER = /* 2 */ 0b10, // prettier-ignore\n WRITABLE = /* 1 */ 0b01, // prettier-ignore\n READONLY = /* 0 */ 0b00, // prettier-ignore\n}\n\nconst IS_SIGNER_BITMASK = 0b10;\nconst IS_WRITABLE_BITMASK = 0b01;\n\nexport function downgradeRoleToNonSigner(role: AccountRole.READONLY_SIGNER): AccountRole.READONLY;\nexport function downgradeRoleToNonSigner(role: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole {\n return role & ~IS_SIGNER_BITMASK;\n}\n\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE): AccountRole.READONLY;\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE_SIGNER): AccountRole.READONLY_SIGNER;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole {\n return role & ~IS_WRITABLE_BITMASK;\n}\n\nexport function isSignerRole(role: AccountRole): role is AccountRole.READONLY_SIGNER | AccountRole.WRITABLE_SIGNER {\n return role >= AccountRole.READONLY_SIGNER;\n}\n\nexport function isWritableRole(role: AccountRole): role is AccountRole.WRITABLE | AccountRole.WRITABLE_SIGNER {\n return (role & IS_WRITABLE_BITMASK) !== 0;\n}\n\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE_SIGNER, roleB: AccountRole): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.READONLY_SIGNER): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY, roleB: AccountRole.READONLY): AccountRole.READONLY; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole {\n return roleA | roleB;\n}\n\nexport function upgradeRoleToSigner(role: AccountRole.READONLY): AccountRole.READONLY_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole {\n return role | IS_SIGNER_BITMASK;\n}\n\nexport function upgradeRoleToWritable(role: AccountRole.READONLY): AccountRole.WRITABLE;\nexport function upgradeRoleToWritable(role: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole {\n return role | IS_WRITABLE_BITMASK;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/instruction.ts","../src/roles.ts"],"names":["AccountRole"],"mappings":";AACA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAkBA,SAAS,wBACZ,aACA,gBAC0E;AAC1E,SAAO,YAAY,mBAAmB;AAC1C;AAEO,SAAS,8BACZ,aACA,gBACkF;AAClF,MAAI,YAAY,mBAAmB,gBAAgB;AAC/C,UAAM,IAAI,YAAY,gDAAgD;AAAA,MAClE,sBAAsB,YAAY;AAAA,MAClC,wBAAwB;AAAA,IAC5B,CAAC;AAAA,EACL;AACJ;AAEO,SAAS,0BAGd,aAA8F;AAC5F,SAAO,YAAY,aAAa;AACpC;AAEO,SAAS,gCAGd,aAAsG;AACpG,MAAI,YAAY,aAAa,QAAW;AACpC,UAAM,IAAI,YAAY,sDAAsD;AAAA,MACxE,MAAM,YAAY;AAAA,MAClB,gBAAgB,YAAY;AAAA,IAChC,CAAC;AAAA,EACL;AACJ;AAMO,SAAS,sBAGd,aAAsF;AACpF,SAAO,YAAY,SAAS;AAChC;AAEO,SAAS,4BAGd,aAA8F;AAC5F,MAAI,YAAY,SAAS,QAAW;AAChC,UAAM,IAAI,YAAY,kDAAkD;AAAA,MACpE,kBAAkB,YAAY,UAAU,IAAI,OAAK,EAAE,OAAO;AAAA,MAC1D,gBAAgB,YAAY;AAAA,IAChC,CAAC;AAAA,EACL;AACJ;;;AC/EO,IAAK,cAAL,kBAAKA,iBAAL;AAEH,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AALQ,SAAAA;AAAA,GAAA;AAQZ,IAAM,oBAAoB;AAC1B,IAAM,sBAAsB;AAKrB,SAAS,yBAAyB,MAAgC;AACrE,SAAO,OAAO,CAAC;AACnB;AAKO,SAAS,wBAAwB,MAAgC;AACpE,SAAO,OAAO,CAAC;AACnB;AAEO,SAAS,aAAa,MAAsF;AAC/G,SAAO,QAAQ;AACnB;AAEO,SAAS,eAAe,MAA+E;AAC1G,UAAQ,OAAO,yBAAyB;AAC5C;AAYO,SAAS,WAAW,OAAoB,OAAiC;AAC5E,SAAO,QAAQ;AACnB;AAKO,SAAS,oBAAoB,MAAgC;AAChE,SAAO,OAAO;AAClB;AAKO,SAAS,sBAAsB,MAAgC;AAClE,SAAO,OAAO;AAClB","sourcesContent":["import { Address } from '@solana/addresses';\nimport {\n SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS,\n SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA,\n SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH,\n SolanaError,\n} from '@solana/errors';\n\nimport { IAccountLookupMeta, IAccountMeta } from './accounts';\n\nexport interface IInstruction<\n TProgramAddress extends string = string,\n TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[],\n> {\n readonly accounts?: TAccounts;\n readonly data?: Uint8Array;\n readonly programAddress: Address<TProgramAddress>;\n}\n\nexport interface IInstructionWithAccounts<TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[]>\n extends IInstruction {\n readonly accounts: TAccounts;\n}\n\nexport function isInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n return instruction.programAddress === programAddress;\n}\n\nexport function assertIsInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): asserts instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n if (instruction.programAddress !== programAddress) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH, {\n actualProgramAddress: instruction.programAddress,\n expectedProgramAddress: programAddress,\n });\n }\n}\n\nexport function isInstructionWithAccounts<\n TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is TInstruction & IInstructionWithAccounts<TAccounts> {\n return instruction.accounts !== undefined;\n}\n\nexport function assertIsInstructionWithAccounts<\n TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is TInstruction & IInstructionWithAccounts<TAccounts> {\n if (instruction.accounts === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS, {\n data: instruction.data,\n programAddress: instruction.programAddress,\n });\n }\n}\n\nexport interface IInstructionWithData<TData extends Uint8Array> extends IInstruction {\n readonly data: TData;\n}\n\nexport function isInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is TInstruction & IInstructionWithData<TData> {\n return instruction.data !== undefined;\n}\n\nexport function assertIsInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is TInstruction & IInstructionWithData<TData> {\n if (instruction.data === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA, {\n accountAddresses: instruction.accounts?.map(a => a.address),\n programAddress: instruction.programAddress,\n });\n }\n}\n","/**\n * Quick primer on bitwise operations: https://stackoverflow.com/a/1436448/802047\n */\n\nexport enum AccountRole {\n // Bitflag guide: is signer ⌄⌄ is writable\n WRITABLE_SIGNER = /* 3 */ 0b11, // prettier-ignore\n READONLY_SIGNER = /* 2 */ 0b10, // prettier-ignore\n WRITABLE = /* 1 */ 0b01, // prettier-ignore\n READONLY = /* 0 */ 0b00, // prettier-ignore\n}\n\nconst IS_SIGNER_BITMASK = 0b10;\nconst IS_WRITABLE_BITMASK = 0b01;\n\nexport function downgradeRoleToNonSigner(role: AccountRole.READONLY_SIGNER): AccountRole.READONLY;\nexport function downgradeRoleToNonSigner(role: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole {\n return role & ~IS_SIGNER_BITMASK;\n}\n\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE): AccountRole.READONLY;\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE_SIGNER): AccountRole.READONLY_SIGNER;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole {\n return role & ~IS_WRITABLE_BITMASK;\n}\n\nexport function isSignerRole(role: AccountRole): role is AccountRole.READONLY_SIGNER | AccountRole.WRITABLE_SIGNER {\n return role >= AccountRole.READONLY_SIGNER;\n}\n\nexport function isWritableRole(role: AccountRole): role is AccountRole.WRITABLE | AccountRole.WRITABLE_SIGNER {\n return (role & IS_WRITABLE_BITMASK) !== 0;\n}\n\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE_SIGNER, roleB: AccountRole): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.READONLY_SIGNER): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY, roleB: AccountRole.READONLY): AccountRole.READONLY; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole {\n return roleA | roleB;\n}\n\nexport function upgradeRoleToSigner(role: AccountRole.READONLY): AccountRole.READONLY_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole {\n return role | IS_SIGNER_BITMASK;\n}\n\nexport function upgradeRoleToWritable(role: AccountRole.READONLY): AccountRole.WRITABLE;\nexport function upgradeRoleToWritable(role: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole {\n return role | IS_WRITABLE_BITMASK;\n}\n"]}
1
+ {"version":3,"sources":["../src/instruction.ts","../src/roles.ts"],"names":["AccountRole"],"mappings":";AACA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAkBA,SAAS,wBACZ,aACA,gBAC0E;AAC1E,SAAO,YAAY,mBAAmB;AAC1C;AAEO,SAAS,8BACZ,aACA,gBACkF;AAClF,MAAI,YAAY,mBAAmB,gBAAgB;AAC/C,UAAM,IAAI,YAAY,gDAAgD;AAAA,MAClE,sBAAsB,YAAY;AAAA,MAClC,wBAAwB;A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A_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS,\n SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA,\n SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH,\n SolanaError,\n} from '@solana/errors';\n\nimport { IAccountLookupMeta, IAccountMeta } from './accounts';\n\nexport interface IInstruction<\n TProgramAddress extends string = string,\n TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[] = readonly (IAccountLookupMeta | IAccountMeta)[],\n> {\n readonly accounts?: TAccounts;\n readonly data?: Uint8Array;\n readonly programAddress: Address<TProgramAddress>;\n}\n\nexport interface IInstructionWithAccounts<TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[]>\n extends IInstruction {\n readonly accounts: TAccounts;\n}\n\nexport function isInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n return instruction.programAddress === programAddress;\n}\n\nexport function assertIsInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): asserts instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n if (instruction.programAddress !== programAddress) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH, {\n actualProgramAddress: instruction.programAddress,\n expectedProgramAddress: programAddress,\n });\n }\n}\n\nexport function isInstructionWithAccounts<\n TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[] = readonly (IAccountLookupMeta | IAccountMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is IInstructionWithAccounts<TAccounts> & TInstruction {\n return instruction.accounts !== undefined;\n}\n\nexport function assertIsInstructionWithAccounts<\n TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[] = readonly (IAccountLookupMeta | IAccountMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is IInstructionWithAccounts<TAccounts> & TInstruction {\n if (instruction.accounts === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS, {\n data: instruction.data,\n programAddress: instruction.programAddress,\n });\n }\n}\n\nexport interface IInstructionWithData<TData extends Uint8Array> extends IInstruction {\n readonly data: TData;\n}\n\nexport function isInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is IInstructionWithData<TData> & TInstruction {\n return instruction.data !== undefined;\n}\n\nexport function assertIsInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is IInstructionWithData<TData> & TInstruction {\n if (instruction.data === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA, {\n accountAddresses: instruction.accounts?.map(a => a.address),\n programAddress: instruction.programAddress,\n });\n }\n}\n","/**\n * Quick primer on bitwise operations: https://stackoverflow.com/a/1436448/802047\n */\n\nexport enum AccountRole {\n // Bitflag guide: is signer ⌄⌄ is writable\n WRITABLE_SIGNER = /* 3 */ 0b11, // prettier-ignore\n READONLY_SIGNER = /* 2 */ 0b10, // prettier-ignore\n WRITABLE = /* 1 */ 0b01, // prettier-ignore\n READONLY = /* 0 */ 0b00, // prettier-ignore\n}\n\nconst IS_SIGNER_BITMASK = 0b10;\nconst IS_WRITABLE_BITMASK = 0b01;\n\nexport function downgradeRoleToNonSigner(role: AccountRole.READONLY_SIGNER): AccountRole.READONLY;\nexport function downgradeRoleToNonSigner(role: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole {\n return role & ~IS_SIGNER_BITMASK;\n}\n\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE): AccountRole.READONLY;\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE_SIGNER): AccountRole.READONLY_SIGNER;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole {\n return role & ~IS_WRITABLE_BITMASK;\n}\n\nexport function isSignerRole(role: AccountRole): role is AccountRole.READONLY_SIGNER | AccountRole.WRITABLE_SIGNER {\n return role >= AccountRole.READONLY_SIGNER;\n}\n\nexport function isWritableRole(role: AccountRole): role is AccountRole.WRITABLE | AccountRole.WRITABLE_SIGNER {\n return (role & IS_WRITABLE_BITMASK) !== 0;\n}\n\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE_SIGNER, roleB: AccountRole): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.READONLY_SIGNER): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY, roleB: AccountRole.READONLY): AccountRole.READONLY; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole {\n return roleA | roleB;\n}\n\nexport function upgradeRoleToSigner(role: AccountRole.READONLY): AccountRole.READONLY_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole {\n return role | IS_SIGNER_BITMASK;\n}\n\nexport function upgradeRoleToWritable(role: AccountRole.READONLY): AccountRole.WRITABLE;\nexport function upgradeRoleToWritable(role: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole {\n return role | IS_WRITABLE_BITMASK;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/instruction.ts","../src/roles.ts"],"names":["AccountRole"],"mappings":";AACA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAkBA,SAAS,wBACZ,aACA,gBAC0E;AAC1E,SAAO,YAAY,mBAAmB;AAC1C;AAEO,SAAS,8BACZ,aACA,gBACkF;AAClF,MAAI,YAAY,mBAAmB,gBAAgB;AAC/C,UAAM,IAAI,YAAY,gDAAgD;AAAA,MAClE,sBAAsB,YAAY;AAAA,MAClC,wBAAwB;AAAA,IAC5B,CAAC;AAAA,EACL;AACJ;AAEO,SAAS,0BAGd,aAA8F;AAC5F,SAAO,YAAY,aAAa;AACpC;AAEO,SAAS,gCAGd,aAAsG;AACpG,MAAI,YAAY,aAAa,QAAW;AACpC,UAAM,IAAI,YAAY,sDAAsD;AAAA,MACxE,MAAM,YAAY;AAAA,MAClB,gBAAgB,YAAY;AAAA,IAChC,CAAC;AAAA,EACL;AACJ;AAMO,SAAS,sBAGd,aAAsF;AACpF,SAAO,YAAY,SAAS;AAChC;AAEO,SAAS,4BAGd,aAA8F;AAC5F,MAAI,YAAY,SAAS,QAAW;AAChC,UAAM,IAAI,YAAY,kDAAkD;AAAA,MACpE,kBAAkB,YAAY,UAAU,IAAI,OAAK,EAAE,OAAO;AAAA,MAC1D,gBAAgB,YAAY;AAAA,IAChC,CAAC;AAAA,EACL;AACJ;;;AC/EO,IAAK,cAAL,kBAAKA,iBAAL;AAEH,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AALQ,SAAAA;AAAA,GAAA;AAQZ,IAAM,oBAAoB;AAC1B,IAAM,sBAAsB;AAKrB,SAAS,yBAAyB,MAAgC;AACrE,SAAO,OAAO,CAAC;AACnB;AAKO,SAAS,wBAAwB,MAAgC;AACpE,SAAO,OAAO,CAAC;AACnB;AAEO,SAAS,aAAa,MAAsF;AAC/G,SAAO,QAAQ;AACnB;AAEO,SAAS,eAAe,MAA+E;AAC1G,UAAQ,OAAO,yBAAyB;AAC5C;AAYO,SAAS,WAAW,OAAoB,OAAiC;AAC5E,SAAO,QAAQ;AACnB;AAKO,SAAS,oBAAoB,MAAgC;AAChE,SAAO,OAAO;AAClB;AAKO,SAAS,sBAAsB,MAAgC;AAClE,SAAO,OAAO;AAClB","sourcesContent":["import { Address } from '@solana/addresses';\nimport {\n SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS,\n SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA,\n SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH,\n SolanaError,\n} from '@solana/errors';\n\nimport { IAccountLookupMeta, IAccountMeta } from './accounts';\n\nexport interface IInstruction<\n TProgramAddress extends string = string,\n TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[],\n> {\n readonly accounts?: TAccounts;\n readonly data?: Uint8Array;\n readonly programAddress: Address<TProgramAddress>;\n}\n\nexport interface IInstructionWithAccounts<TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[]>\n extends IInstruction {\n readonly accounts: TAccounts;\n}\n\nexport function isInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n return instruction.programAddress === programAddress;\n}\n\nexport function assertIsInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): asserts instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n if (instruction.programAddress !== programAddress) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH, {\n actualProgramAddress: instruction.programAddress,\n expectedProgramAddress: programAddress,\n });\n }\n}\n\nexport function isInstructionWithAccounts<\n TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is TInstruction & IInstructionWithAccounts<TAccounts> {\n return instruction.accounts !== undefined;\n}\n\nexport function assertIsInstructionWithAccounts<\n TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is TInstruction & IInstructionWithAccounts<TAccounts> {\n if (instruction.accounts === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS, {\n data: instruction.data,\n programAddress: instruction.programAddress,\n });\n }\n}\n\nexport interface IInstructionWithData<TData extends Uint8Array> extends IInstruction {\n readonly data: TData;\n}\n\nexport function isInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is TInstruction & IInstructionWithData<TData> {\n return instruction.data !== undefined;\n}\n\nexport function assertIsInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is TInstruction & IInstructionWithData<TData> {\n if (instruction.data === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA, {\n accountAddresses: instruction.accounts?.map(a => a.address),\n programAddress: instruction.programAddress,\n });\n }\n}\n","/**\n * Quick primer on bitwise operations: https://stackoverflow.com/a/1436448/802047\n */\n\nexport enum AccountRole {\n // Bitflag guide: is signer ⌄⌄ is writable\n WRITABLE_SIGNER = /* 3 */ 0b11, // prettier-ignore\n READONLY_SIGNER = /* 2 */ 0b10, // prettier-ignore\n WRITABLE = /* 1 */ 0b01, // prettier-ignore\n READONLY = /* 0 */ 0b00, // prettier-ignore\n}\n\nconst IS_SIGNER_BITMASK = 0b10;\nconst IS_WRITABLE_BITMASK = 0b01;\n\nexport function downgradeRoleToNonSigner(role: AccountRole.READONLY_SIGNER): AccountRole.READONLY;\nexport function downgradeRoleToNonSigner(role: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole {\n return role & ~IS_SIGNER_BITMASK;\n}\n\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE): AccountRole.READONLY;\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE_SIGNER): AccountRole.READONLY_SIGNER;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole {\n return role & ~IS_WRITABLE_BITMASK;\n}\n\nexport function isSignerRole(role: AccountRole): role is AccountRole.READONLY_SIGNER | AccountRole.WRITABLE_SIGNER {\n return role >= AccountRole.READONLY_SIGNER;\n}\n\nexport function isWritableRole(role: AccountRole): role is AccountRole.WRITABLE | AccountRole.WRITABLE_SIGNER {\n return (role & IS_WRITABLE_BITMASK) !== 0;\n}\n\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE_SIGNER, roleB: AccountRole): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.READONLY_SIGNER): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY, roleB: AccountRole.READONLY): AccountRole.READONLY; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole {\n return roleA | roleB;\n}\n\nexport function upgradeRoleToSigner(role: AccountRole.READONLY): AccountRole.READONLY_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole {\n return role | IS_SIGNER_BITMASK;\n}\n\nexport function upgradeRoleToWritable(role: AccountRole.READONLY): AccountRole.WRITABLE;\nexport function upgradeRoleToWritable(role: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole {\n return role | IS_WRITABLE_BITMASK;\n}\n"]}
1
+ {"version":3,"sources":["../src/instruction.ts","../src/roles.ts"],"names":["AccountRole"],"mappings":";AACA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAkBA,SAAS,wBACZ,aACA,gBAC0E;AAC1E,SAAO,YAAY,mBAAmB;AAC1C;AAEO,SAAS,8BACZ,aACA,gBACkF;AAClF,MAAI,YAAY,mBAAmB,gBAAgB;AAC/C,UAAM,IAAI,YAAY,gDAAgD;AAAA,MAClE,sBAAsB,YAAY;AAAA,MAClC,wBAAwB;AAAA,IAC5B,CAAC;AAAA,EACL;AACJ;AAEO,SAAS,0BAGd,aAA8F;AAC5F,SAAO,YAAY,aAAa;AACpC;AAEO,SAAS,gCAGd,aAAsG;AACpG,MAAI,YAAY,aAAa,QAAW;AACpC,UAAM,IAAI,YAAY,sDAAsD;AAAA,MACxE,MAAM,YAAY;AAAA,MAClB,gBAAgB,YAAY;AAAA,IAChC,CAAC;AAAA,EACL;AACJ;AAMO,SAAS,sBAGd,aAAsF;AACpF,SAAO,YAAY,SAAS;AAChC;AAEO,SAAS,4BAGd,aAA8F;AAC5F,MAAI,YAAY,SAAS,QAAW;AAChC,UAAM,IAAI,YAAY,kDAAkD;AAAA,MACpE,kBAAkB,YAAY,UAAU,IAAI,OAAK,EAAE,OAAO;AAAA,MAC1D,gBAAgB,YAAY;AAAA,IAChC,CAAC;AAAA,EACL;AACJ;;;AC/EO,IAAK,cAAL,kBAAKA,iBAAL;AAEH,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AACA,EAAAA,0BAAA;AAAA,EAA0B,KAA1B;AALQ,SAAAA;AAAA,GAAA;AAQZ,IAAM,oBAAoB;AAC1B,IAAM,sBAAsB;AAKrB,SAAS,yBAAyB,MAAgC;AACrE,SAAO,OAAO,CAAC;AACnB;AAKO,SAAS,wBAAwB,MAAgC;AACpE,SAAO,OAAO,CAAC;AACnB;AAEO,SAAS,aAAa,MAAsF;AAC/G,SAAO,QAAQ;AACnB;AAEO,SAAS,eAAe,MAA+E;AAC1G,UAAQ,OAAO,yBAAyB;AAC5C;AAYO,SAAS,WAAW,OAAoB,OAAiC;AAC5E,SAAO,QAAQ;AACnB;AAKO,SAAS,oBAAoB,MAAgC;AAChE,SAAO,OAAO;AAClB;AAKO,SAAS,sBAAsB,MAAgC;AAClE,SAAO,OAAO;AAClB","sourcesContent":["import { Address } from '@solana/addresses';\nimport {\n SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS,\n SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA,\n SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH,\n SolanaError,\n} from '@solana/errors';\n\nimport { IAccountLookupMeta, IAccountMeta } from './accounts';\n\nexport interface IInstruction<\n TProgramAddress extends string = string,\n TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[] = readonly (IAccountLookupMeta | IAccountMeta)[],\n> {\n readonly accounts?: TAccounts;\n readonly data?: Uint8Array;\n readonly programAddress: Address<TProgramAddress>;\n}\n\nexport interface IInstructionWithAccounts<TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[]>\n extends IInstruction {\n readonly accounts: TAccounts;\n}\n\nexport function isInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n return instruction.programAddress === programAddress;\n}\n\nexport function assertIsInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(\n instruction: TInstruction,\n programAddress: Address<TProgramAddress>,\n): asserts instruction is TInstruction & { programAddress: Address<TProgramAddress> } {\n if (instruction.programAddress !== programAddress) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__PROGRAM_ID_MISMATCH, {\n actualProgramAddress: instruction.programAddress,\n expectedProgramAddress: programAddress,\n });\n }\n}\n\nexport function isInstructionWithAccounts<\n TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[] = readonly (IAccountLookupMeta | IAccountMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is IInstructionWithAccounts<TAccounts> & TInstruction {\n return instruction.accounts !== undefined;\n}\n\nexport function assertIsInstructionWithAccounts<\n TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[] = readonly (IAccountLookupMeta | IAccountMeta)[],\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is IInstructionWithAccounts<TAccounts> & TInstruction {\n if (instruction.accounts === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_ACCOUNTS, {\n data: instruction.data,\n programAddress: instruction.programAddress,\n });\n }\n}\n\nexport interface IInstructionWithData<TData extends Uint8Array> extends IInstruction {\n readonly data: TData;\n}\n\nexport function isInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): instruction is IInstructionWithData<TData> & TInstruction {\n return instruction.data !== undefined;\n}\n\nexport function assertIsInstructionWithData<\n TData extends Uint8Array = Uint8Array,\n TInstruction extends IInstruction = IInstruction,\n>(instruction: TInstruction): asserts instruction is IInstructionWithData<TData> & TInstruction {\n if (instruction.data === undefined) {\n throw new SolanaError(SOLANA_ERROR__INSTRUCTION__EXPECTED_TO_HAVE_DATA, {\n accountAddresses: instruction.accounts?.map(a => a.address),\n programAddress: instruction.programAddress,\n });\n }\n}\n","/**\n * Quick primer on bitwise operations: https://stackoverflow.com/a/1436448/802047\n */\n\nexport enum AccountRole {\n // Bitflag guide: is signer ⌄⌄ is writable\n WRITABLE_SIGNER = /* 3 */ 0b11, // prettier-ignore\n READONLY_SIGNER = /* 2 */ 0b10, // prettier-ignore\n WRITABLE = /* 1 */ 0b01, // prettier-ignore\n READONLY = /* 0 */ 0b00, // prettier-ignore\n}\n\nconst IS_SIGNER_BITMASK = 0b10;\nconst IS_WRITABLE_BITMASK = 0b01;\n\nexport function downgradeRoleToNonSigner(role: AccountRole.READONLY_SIGNER): AccountRole.READONLY;\nexport function downgradeRoleToNonSigner(role: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole;\nexport function downgradeRoleToNonSigner(role: AccountRole): AccountRole {\n return role & ~IS_SIGNER_BITMASK;\n}\n\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE): AccountRole.READONLY;\nexport function downgradeRoleToReadonly(role: AccountRole.WRITABLE_SIGNER): AccountRole.READONLY_SIGNER;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole;\nexport function downgradeRoleToReadonly(role: AccountRole): AccountRole {\n return role & ~IS_WRITABLE_BITMASK;\n}\n\nexport function isSignerRole(role: AccountRole): role is AccountRole.READONLY_SIGNER | AccountRole.WRITABLE_SIGNER {\n return role >= AccountRole.READONLY_SIGNER;\n}\n\nexport function isWritableRole(role: AccountRole): role is AccountRole.WRITABLE | AccountRole.WRITABLE_SIGNER {\n return (role & IS_WRITABLE_BITMASK) !== 0;\n}\n\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE_SIGNER): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE_SIGNER, roleB: AccountRole): AccountRole.WRITABLE_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.READONLY_SIGNER): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY_SIGNER, roleB: AccountRole): AccountRole.READONLY_SIGNER; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole.WRITABLE): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.WRITABLE, roleB: AccountRole): AccountRole.WRITABLE; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole.READONLY, roleB: AccountRole.READONLY): AccountRole.READONLY; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole; // prettier-ignore\nexport function mergeRoles(roleA: AccountRole, roleB: AccountRole): AccountRole {\n return roleA | roleB;\n}\n\nexport function upgradeRoleToSigner(role: AccountRole.READONLY): AccountRole.READONLY_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole.WRITABLE): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole;\nexport function upgradeRoleToSigner(role: AccountRole): AccountRole {\n return role | IS_SIGNER_BITMASK;\n}\n\nexport function upgradeRoleToWritable(role: AccountRole.READONLY): AccountRole.WRITABLE;\nexport function upgradeRoleToWritable(role: AccountRole.READONLY_SIGNER): AccountRole.WRITABLE_SIGNER;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole;\nexport function upgradeRoleToWritable(role: AccountRole): AccountRole {\n return role | IS_WRITABLE_BITMASK;\n}\n"]}
@@ -1,11 +1,11 @@
1
1
  import { Address } from '@solana/addresses';
2
2
  import { IAccountLookupMeta, IAccountMeta } from './accounts.js';
3
- export interface IInstruction<TProgramAddress extends string = string, TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[]> {
3
+ export interface IInstruction<TProgramAddress extends string = string, TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[] = readonly (IAccountLookupMeta | IAccountMeta)[]> {
4
4
  readonly accounts?: TAccounts;
5
5
  readonly data?: Uint8Array;
6
6
  readonly programAddress: Address<TProgramAddress>;
7
7
  }
8
- export interface IInstructionWithAccounts<TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[]> extends IInstruction {
8
+ export interface IInstructionWithAccounts<TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[]> extends IInstruction {
9
9
  readonly accounts: TAccounts;
10
10
  }
11
11
  export declare function isInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(instruction: TInstruction, programAddress: Address<TProgramAddress>): instruction is TInstruction & {
@@ -14,11 +14,11 @@ export declare function isInstructionForProgram<TProgramAddress extends string,
14
14
  export declare function assertIsInstructionForProgram<TProgramAddress extends string, TInstruction extends IInstruction>(instruction: TInstruction, programAddress: Address<TProgramAddress>): asserts instruction is TInstruction & {
15
15
  programAddress: Address<TProgramAddress>;
16
16
  };
17
- export declare function isInstructionWithAccounts<TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[], TInstruction extends IInstruction = IInstruction>(instruction: TInstruction): instruction is TInstruction & IInstructionWithAccounts<TAccounts>;
18
- export declare function assertIsInstructionWithAccounts<TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[], TInstruction extends IInstruction = IInstruction>(instruction: TInstruction): asserts instruction is TInstruction & IInstructionWithAccounts<TAccounts>;
17
+ export declare function isInstructionWithAccounts<TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[] = readonly (IAccountLookupMeta | IAccountMeta)[], TInstruction extends IInstruction = IInstruction>(instruction: TInstruction): instruction is IInstructionWithAccounts<TAccounts> & TInstruction;
18
+ export declare function assertIsInstructionWithAccounts<TAccounts extends readonly (IAccountLookupMeta | IAccountMeta)[] = readonly (IAccountLookupMeta | IAccountMeta)[], TInstruction extends IInstruction = IInstruction>(instruction: TInstruction): asserts instruction is IInstructionWithAccounts<TAccounts> & TInstruction;
19
19
  export interface IInstructionWithData<TData extends Uint8Array> extends IInstruction {
20
20
  readonly data: TData;
21
21
  }
22
- export declare function isInstructionWithData<TData extends Uint8Array = Uint8Array, TInstruction extends IInstruction = IInstruction>(instruction: TInstruction): instruction is TInstruction & IInstructionWithData<TData>;
23
- export declare function assertIsInstructionWithData<TData extends Uint8Array = Uint8Array, TInstruction extends IInstruction = IInstruction>(instruction: TInstruction): asserts instruction is TInstruction & IInstructionWithData<TData>;
22
+ export declare function isInstructionWithData<TData extends Uint8Array = Uint8Array, TInstruction extends IInstruction = IInstruction>(instruction: TInstruction): instruction is IInstructionWithData<TData> & TInstruction;
23
+ export declare function assertIsInstructionWithData<TData extends Uint8Array = Uint8Array, TInstruction extends IInstruction = IInstruction>(instruction: TInstruction): asserts instruction is IInstructionWithData<TData> & TInstruction;
24
24
  //# sourceMappingURL=instruction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"instruction.d.ts","sourceRoot":"","sources":["../../src/instruction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAQ5C,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE9D,MAAM,WAAW,YAAY,CACzB,eAAe,SAAS,MAAM,GAAG,MAAM,EACvC,SAAS,SAAS,SAAS,CAAC,YAAY,GAAG,kBAAkB,CAAC,EAAE,GAAG,SAAS,CAAC,YAAY,GAAG,kBAAkB,CAAC,EAAE;IAEjH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,wBAAwB,CAAC,SAAS,SAAS,SAAS,CAAC,YAAY,GAAG,kBAAkB,CAAC,EAAE,CACtG,SAAQ,YAAY;IACpB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;CAChC;AAED,wBAAgB,uBAAuB,CAAC,eAAe,SAAS,MAAM,EAAE,YAAY,SAAS,Y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eb951b0",
3
+ "version": "2.0.0-experimental.ed41fe2",
4
4
  "description": "Helpers for creating transaction instructions",
5
5
  "exports": {
6
6
  "browser": {
@@ -46,7 +46,7 @@
46
46
  "maintained node versions"
47
47
  ],
48
48
  "dependencies": {
49
- "@solana/errors": "2.0.0-experimental.eb951b0"
49
+ "@solana/errors": "2.0.0-experimental.ed41fe2"
50
50
  },
51
51
  "bundlewatch": {
52
52
  "defaultCompression": "gzip",
@@ -58,18 +58,18 @@
58
58
  },
59
59
  "scripts": {
60
60
  "compile:js": "tsup --config build-scripts/tsup.config.package.ts",
61
- "compile:typedefs": "tsc -p ./tsconfig.declarations.json && node node_modules/@solana/build-scripts/add-js-extension-to-types.mjs",
62
- "dev": "jest -c node_modules/@solana/test-config/jest-dev.config.ts --rootDir . --watch",
61
+ "compile:typedefs": "tsc -p ./tsconfig.declarations.json && node ../../node_modules/@solana/build-scripts/add-js-extension-to-types.mjs",
62
+ "dev": "jest -c ../../node_modules/@solana/test-config/jest-dev.config.ts --rootDir . --watch",
63
63
  "publish-impl": "npm view $npm_package_name@$npm_package_version > /dev/null 2>&1 || pnpm publish --tag experimental --access public --no-git-checks",
64
64
  "publish-packages": "pnpm prepublishOnly && pnpm publish-impl",
65
65
  "style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/* package.json",
66
- "test:lint": "jest -c node_modules/@solana/test-config/jest-lint.config.ts --rootDir . --silent",
67
- "test:prettier": "jest -c node_modules/@solana/test-config/jest-prettier.config.ts --rootDir . --silent",
66
+ "test:lint": "jest -c ../../node_modules/@solana/test-config/jest-lint.config.ts --rootDir . --silent",
67
+ "test:prettier": "jest -c ../../node_modules/@solana/test-config/jest-prettier.config.ts --rootDir . --silent",
68
68
  "test:treeshakability:browser": "agadoo dist/index.browser.js",
69
69
  "test:treeshakability:native": "agadoo dist/index.native.js",
70
70
  "test:treeshakability:node": "agadoo dist/index.node.js",
71
71
  "test:typecheck": "tsc --noEmit",
72
- "test:unit:browser": "jest -c node_modules/@solana/test-config/jest-unit.config.browser.ts --rootDir . --silent",
73
- "test:unit:node": "jest -c node_modules/@solana/test-config/jest-unit.config.node.ts --rootDir . --silent"
72
+ "test:unit:browser": "jest -c ../../node_modules/@solana/test-config/jest-unit.config.browser.ts --rootDir . --silent",
73
+ "test:unit:node": "jest -c ../../node_modules/@solana/test-config/jest-unit.config.node.ts --rootDir . --silent"
74
74
  }
75
75
  }