@mcintyre94/instructions
Advanced tools
Comparing version 2.0.0-experimental.a537d8d to 2.0.0-experimental.ca9fd72
@@ -0,1 +1,38 @@ | ||
import { SolanaError, SOLANA_ERROR__INCORRECT_INSTRUCTION_PROGRAM_ID, SOLANA_ERROR__EXPECTED_INSTRUCTION_TO_HAVE_ACCOUNTS, SOLANA_ERROR__EXPECTED_INSTRUCTION_TO_HAVE_DATA } from '@solana/errors'; | ||
// src/instruction.ts | ||
function isInstructionWithKnownProgramAddress(instruction, programAddress) { | ||
return instruction.programAddress === programAddress; | ||
} | ||
function assertIsInstructionWithKnownProgramAddress(instruction, programAddress) { | ||
if (instruction.programAddress !== programAddress) { | ||
throw new SolanaError(SOLANA_ERROR__INCORRECT_INSTRUCTION_PROGRAM_ID, { | ||
actualProgramAddress: instruction.programAddress, | ||
expectedProgramAddress: programAddress | ||
}); | ||
} | ||
} | ||
function isInstructionWithAccounts(instruction) { | ||
return instruction.accounts !== void 0; | ||
} | ||
function assertIsInstructionWithAccounts(instruction) { | ||
if (instruction.accounts === void 0) { | ||
throw new SolanaError(SOLANA_ERROR__EXPECTED_INSTRUCTION_TO_HAVE_ACCOUNTS, { | ||
data: instruction.data, | ||
programAddress: instruction.programAddress | ||
}); | ||
} | ||
} | ||
function isInstructionWithData(instruction) { | ||
return instruction.data !== void 0; | ||
} | ||
function assertIsInstructionWithData(instruction) { | ||
if (instruction.data === void 0) { | ||
throw new SolanaError(SOLANA_ERROR__EXPECTED_INSTRUCTION_TO_HAVE_DATA, { | ||
accountAddresses: instruction.accounts?.map((a) => a.address), | ||
programAddress: instruction.programAddress | ||
}); | ||
} | ||
} | ||
// src/roles.ts | ||
@@ -37,4 +74,4 @@ var AccountRole = /* @__PURE__ */ ((AccountRole2) => { | ||
export { AccountRole, downgradeRoleToNonSigner, downgradeRoleToReadonly, isSignerRole, isWritableRole, mergeRoles, upgradeRoleToSigner, upgradeRoleToWritable }; | ||
export { AccountRole, assertIsInstructionWithAccounts, assertIsInstructionWithData, assertIsInstructionWithKnownProgramAddress, downgradeRoleToNonSigner, downgradeRoleToReadonly, isInstructionWithAccounts, isInstructionWithData, isInstructionWithKnownProgramAddress, isSignerRole, isWritableRole, mergeRoles, upgradeRoleToSigner, upgradeRoleToWritable }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.browser.js.map |
@@ -0,1 +1,38 @@ | ||
import { SolanaError, SOLANA_ERROR__INCORRECT_INSTRUCTION_PROGRAM_ID, SOLANA_ERROR__EXPECTED_INSTRUCTION_TO_HAVE_ACCOUNTS, SOLANA_ERROR__EXPECTED_INSTRUCTION_TO_HAVE_DATA } from '@solana/errors'; | ||
// src/instruction.ts | ||
function isInstructionWithKnownProgramAddress(instruction, programAddress) { | ||
return instruction.programAddress === programAddress; | ||
} | ||
function assertIsInstructionWithKnownProgramAddress(instruction, programAddress) { | ||
if (instruction.programAddress !== programAddress) { | ||
throw new SolanaError(SOLANA_ERROR__INCORRECT_INSTRUCTION_PROGRAM_ID, { | ||
actualProgramAddress: instruction.programAddress, | ||
expectedProgramAddress: programAddress | ||
}); | ||
} | ||
} | ||
function isInstructionWithAccounts(instruction) { | ||
return instruction.accounts !== void 0; | ||
} | ||
function assertIsInstructionWithAccounts(instruction) { | ||
if (instruction.accounts === void 0) { | ||
throw new SolanaError(SOLANA_ERROR__EXPECTED_INSTRUCTION_TO_HAVE_ACCOUNTS, { | ||
data: instruction.data, | ||
programAddress: instruction.programAddress | ||
}); | ||
} | ||
} | ||
function isInstructionWithData(instruction) { | ||
return instruction.data !== void 0; | ||
} | ||
function assertIsInstructionWithData(instruction) { | ||
if (instruction.data === void 0) { | ||
throw new SolanaError(SOLANA_ERROR__EXPECTED_INSTRUCTION_TO_HAVE_DATA, { | ||
accountAddresses: instruction.accounts?.map((a) => a.address), | ||
programAddress: instruction.programAddress | ||
}); | ||
} | ||
} | ||
// src/roles.ts | ||
@@ -37,4 +74,4 @@ var AccountRole = /* @__PURE__ */ ((AccountRole2) => { | ||
export { AccountRole, downgradeRoleToNonSigner, downgradeRoleToReadonly, isSignerRole, isWritableRole, mergeRoles, upgradeRoleToSigner, upgradeRoleToWritable }; | ||
export { AccountRole, assertIsInstructionWithAccounts, assertIsInstructionWithData, assertIsInstructionWithKnownProgramAddress, downgradeRoleToNonSigner, downgradeRoleToReadonly, isInstructionWithAccounts, isInstructionWithData, isInstructionWithKnownProgramAddress, isSignerRole, isWritableRole, mergeRoles, upgradeRoleToSigner, upgradeRoleToWritable }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.native.js.map |
@@ -0,1 +1,38 @@ | ||
import { SolanaError, SOLANA_ERROR__INCORRECT_INSTRUCTION_PROGRAM_ID, SOLANA_ERROR__EXPECTED_INSTRUCTION_TO_HAVE_ACCOUNTS, SOLANA_ERROR__EXPECTED_INSTRUCTION_TO_HAVE_DATA } from '@solana/errors'; | ||
// src/instruction.ts | ||
function isInstructionWithKnownProgramAddress(instruction, programAddress) { | ||
return instruction.programAddress === programAddress; | ||
} | ||
function assertIsInstructionWithKnownProgramAddress(instruction, programAddress) { | ||
if (instruction.programAddress !== programAddress) { | ||
throw new SolanaError(SOLANA_ERROR__INCORRECT_INSTRUCTION_PROGRAM_ID, { | ||
actualProgramAddress: instruction.programAddress, | ||
expectedProgramAddress: programAddress | ||
}); | ||
} | ||
} | ||
function isInstructionWithAccounts(instruction) { | ||
return instruction.accounts !== void 0; | ||
} | ||
function assertIsInstructionWithAccounts(instruction) { | ||
if (instruction.accounts === void 0) { | ||
throw new SolanaError(SOLANA_ERROR__EXPECTED_INSTRUCTION_TO_HAVE_ACCOUNTS, { | ||
data: instruction.data, | ||
programAddress: instruction.programAddress | ||
}); | ||
} | ||
} | ||
function isInstructionWithData(instruction) { | ||
return instruction.data !== void 0; | ||
} | ||
function assertIsInstructionWithData(instruction) { | ||
if (instruction.data === void 0) { | ||
throw new SolanaError(SOLANA_ERROR__EXPECTED_INSTRUCTION_TO_HAVE_DATA, { | ||
accountAddresses: instruction.accounts?.map((a) => a.address), | ||
programAddress: instruction.programAddress | ||
}); | ||
} | ||
} | ||
// src/roles.ts | ||
@@ -37,4 +74,4 @@ var AccountRole = /* @__PURE__ */ ((AccountRole2) => { | ||
export { AccountRole, downgradeRoleToNonSigner, downgradeRoleToReadonly, isSignerRole, isWritableRole, mergeRoles, upgradeRoleToSigner, upgradeRoleToWritable }; | ||
export { AccountRole, assertIsInstructionWithAccounts, assertIsInstructionWithData, assertIsInstructionWithKnownProgramAddress, downgradeRoleToNonSigner, downgradeRoleToReadonly, isInstructionWithAccounts, isInstructionWithData, isInstructionWithKnownProgramAddress, isSignerRole, isWritableRole, mergeRoles, upgradeRoleToSigner, upgradeRoleToWritable }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.node.js.map |
@@ -1,2 +0,2 @@ | ||
import { Address } from '@mcintyre94/addresses'; | ||
import { Address } from '@solana/addresses'; | ||
import { AccountRole } from './roles.js'; | ||
@@ -3,0 +3,0 @@ export interface IAccountMeta<TAddress extends string = string> { |
@@ -1,2 +0,2 @@ | ||
import { Address } from '@mcintyre94/addresses'; | ||
import { Address } from '@solana/addresses'; | ||
import { IAccountLookupMeta, IAccountMeta } from './accounts.js'; | ||
@@ -11,5 +11,11 @@ export interface IInstruction<TProgramAddress extends string = string, TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[]> { | ||
} | ||
export declare function isInstructionWithKnownProgramAddress<TProgramAddress extends string, TInstruction extends IInstruction>(instruction: TInstruction, programAddress: Address<TProgramAddress>): instruction is TInstruction & IInstruction<Address<TProgramAddress>>; | ||
export declare function assertIsInstructionWithKnownProgramAddress<TProgramAddress extends string, TInstruction extends IInstruction>(instruction: TInstruction, programAddress: Address<TProgramAddress>): asserts instruction is TInstruction & IInstruction<Address<TProgramAddress>>; | ||
export declare function isInstructionWithAccounts<TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[], TInstruction extends IInstruction = IInstruction>(instruction: TInstruction): instruction is TInstruction & IInstructionWithAccounts<TAccounts>; | ||
export declare function assertIsInstructionWithAccounts<TAccounts extends readonly (IAccountMeta | IAccountLookupMeta)[] = readonly (IAccountMeta | IAccountLookupMeta)[], TInstruction extends IInstruction = IInstruction>(instruction: TInstruction): asserts instruction is TInstruction & IInstructionWithAccounts<TAccounts>; | ||
export interface IInstructionWithData<TData extends Uint8Array> extends IInstruction { | ||
readonly data: TData; | ||
} | ||
export declare function isInstructionWithData<TData extends Uint8Array = Uint8Array, TInstruction extends IInstruction = IInstruction>(instruction: TInstruction): instruction is TInstruction & IInstructionWithData<TData>; | ||
export declare function assertIsInstructionWithData<TData extends Uint8Array = Uint8Array, TInstruction extends IInstruction = IInstruction>(instruction: TInstruction): asserts instruction is TInstruction & IInstructionWithData<TData>; | ||
//# sourceMappingURL=instruction.d.ts.map |
{ | ||
"name": "@mcintyre94/instructions", | ||
"version": "2.0.0-experimental.a537d8d", | ||
"version": "2.0.0-experimental.ca9fd72", | ||
"description": "Helpers for creating transaction instructions", | ||
@@ -48,22 +48,4 @@ "exports": { | ||
], | ||
"devDependencies": { | ||
"@solana/eslint-config-solana": "^1.0.2", | ||
"@swc/jest": "^0.2.29", | ||
"@types/jest": "^29.5.6", | ||
"@typescript-eslint/eslint-plugin": "^6.7.0", | ||
"@typescript-eslint/parser": "^6.3.0", | ||
"agadoo": "^3.0.0", | ||
"eslint": "^8.45.0", | ||
"eslint-plugin-sort-keys-fix": "^1.1.2", | ||
"jest": "^29.7.0", | ||
"jest-runner-eslint": "^2.1.2", | ||
"jest-runner-prettier": "^1.0.0", | ||
"prettier": "^3.1", | ||
"tsup": "^8.0.1", | ||
"typescript": "^5.2.2", | ||
"version-from-git": "^1.1.1", | ||
"@mcintyre94/addresses": "2.0.0-experimental.a537d8d", | ||
"build-scripts": "0.0.0", | ||
"test-config": "0.0.0", | ||
"tsconfig": "0.0.0" | ||
"dependencies": { | ||
"@solana/errors": "2.0.0-experimental.07c30c1" | ||
}, | ||
@@ -79,9 +61,10 @@ "bundlewatch": { | ||
"scripts": { | ||
"compile:js": "tsup --config build-scripts/tsup.config.library.ts", | ||
"compile:typedefs": "tsc -p ./tsconfig.declarations.json && node node_modules/build-scripts/add-js-extension-to-types.mjs", | ||
"dev": "jest -c node_modules/test-config/jest-dev.config.ts --rootDir . --watch", | ||
"publish-packages": "pnpm publish --tag experimental --access public --no-git-checks", | ||
"compile:js": "tsup --config build-scripts/tsup.config.package.ts", | ||
"compile:typedefs": "tsc -p ./tsconfig.declarations.json && node node_modules/@solana/build-scripts/add-js-extension-to-types.mjs", | ||
"dev": "jest -c node_modules/@solana/test-config/jest-dev.config.ts --rootDir . --watch", | ||
"publish-impl": "npm view $npm_package_name@$npm_package_version > /dev/null 2>&1 || pnpm publish --tag experimental --access public --no-git-checks", | ||
"publish-packages": "pnpm prepublishOnly && pnpm publish-impl", | ||
"style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/* package.json", | ||
"test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent", | ||
"test:prettier": "jest -c node_modules/test-config/jest-prettier.config.ts --rootDir . --silent", | ||
"test:lint": "jest -c node_modules/@solana/test-config/jest-lint.config.ts --rootDir . --silent", | ||
"test:prettier": "jest -c node_modules/@solana/test-config/jest-prettier.config.ts --rootDir . --silent", | ||
"test:treeshakability:browser": "agadoo dist/index.browser.js", | ||
@@ -91,5 +74,5 @@ "test:treeshakability:native": "agadoo dist/index.native.js", | ||
"test:typecheck": "tsc --noEmit", | ||
"test:unit:browser": "jest -c node_modules/test-config/jest-unit.config.browser.ts --rootDir . --silent", | ||
"test:unit:node": "jest -c node_modules/test-config/jest-unit.config.node.ts --rootDir . --silent" | ||
"test:unit:browser": "jest -c node_modules/@solana/test-config/jest-unit.config.browser.ts --rootDir . --silent", | ||
"test:unit:node": "jest -c node_modules/@solana/test-config/jest-unit.config.node.ts --rootDir . --silent" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
81807
0
479
1
21
+ Added@solana/errors@2.0.0-experimental.07c30c1(transitive)
+ Addedchalk@5.4.1(transitive)
+ Addedcommander@12.1.0(transitive)