{"_id":"@atlaschain/instructions","name":"@atlaschain/instructions","dist-tags":{"latest":"3.0.0"},"versions":{"3.0.0":{"name":"@atlaschain/instructions","version":"3.0.0","description":"Helpers for creating transaction instructions","exports":{"edge-light":{"import":"./dist/index.node.mjs","require":"./dist/index.node.cjs"},"workerd":{"import":"./dist/index.node.mjs","require":"./dist/index.node.cjs"},"browser":{"import":"./dist/index.browser.mjs","require":"./dist/index.browser.cjs"},"node":{"import":"./dist/index.node.mjs","require":"./dist/index.node.cjs"},"react-native":"./dist/index.native.mjs","types":"./dist/types/index.d.ts"},"browser":{"./dist/index.node.cjs":"./dist/index.browser.cjs","./dist/index.node.mjs":"./dist/index.browser.mjs"},"main":"./dist/index.node.cjs","module":"./dist/index.node.mjs","react-native":"./dist/index.native.mjs","types":"./dist/types/index.d.ts","type":"commonjs","sideEffects":false,"keywords":["blockchain","atlas","web3"],"scripts":{"compile:docs":"typedoc","compile:js":"tsup --config build-scripts/tsup.config.package.ts","compile:typedefs":"tsc -p ./tsconfig.declarations.json","dev":"jest -c ../../node_modules/@atlas/test-config/jest-dev.config.ts --rootDir . --watch","prepublishOnly":"pnpm pkg delete devDependencies","publish-impl":"npm view $npm_package_name@$npm_package_version > /dev/null 2>&1 || (pnpm publish --tag ${PUBLISH_TAG:-canary} --access public --no-git-checks && (([ -n \"${GITHUB_OUTPUT:-}\" ] && echo 'published=true' >> \"$GITHUB_OUTPUT\") || true) && (([ \"$PUBLISH_TAG\" != \"canary\" ] && ../build-scripts/maybe-tag-latest.ts $npm_package_name@$npm_package_version) || true))","publish-packages":"pnpm prepublishOnly && pnpm publish-impl","style:fix":"pnpm eslint --fix src && pnpm prettier --log-level warn --ignore-unknown --write ./*","test:lint":"TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@atlas/test-config/jest-lint.config.ts --rootDir . --silent","test:prettier":"TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@atlas/test-config/jest-prettier.config.ts --rootDir . --silent","test:treeshakability:browser":"agadoo dist/index.browser.mjs","test:treeshakability:native":"agadoo dist/index.native.mjs","test:treeshakability:node":"agadoo dist/index.node.mjs","test:typecheck":"tsc --noEmit","test:unit:browser":"TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@atlas/test-config/jest-unit.config.browser.ts --rootDir . --silent","test:unit:node":"TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@atlas/test-config/jest-unit.config.node.ts --rootDir . --silent"},"author":{"name":"Atlas Chain Foundation"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/anza-xyz/kit.git"},"bugs":{"url":"https://github.com/anza-xyz/kit/issues"},"browserslist":["supports bigint and not dead","maintained node versions"],"dependencies":{"@atlaschain/codecs-core":"workspace:*","@atlaschain/errors":"workspace:*"},"peerDependencies":{"typescript":">=5.3.3"},"engines":{"node":">=20.18.0"},"_id":"@atlaschain/instructions@3.0.0","homepage":"https://github.com/anza-xyz/kit#readme","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-m7iWtHr1gdvaZXFer/O1plVDlcBA8V93/2LqIqEtgP+3fJuomhXTYcYxtPRqS4ATKUiZx3ZZGHIcHjSqs82EwA==","shasum":"78965a7a2586480403aa6f147c04614da296506a","tarball":"https://registry.npmjs.org/@atlaschain/instructions/-/instructions-3.0.0.tgz","fileCount":5,"unpackedSize":17977,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDhlJi+2+4146CwlarIcbWQwIK7BsTg2PnaM0rFGOD84QIgLm9ok9j3Uu0jA49KOCGARG8UcOsEMyTQvGaJkyi3C9g="}]},"_npmUser":{"name":"atlaschain","email":"jq@atlaschain.org"},"directories":{},"maintainers":[{"name":"atlaschain","email":"jq@atlaschain.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/instructions_3.0.0_1756885277488_0.7818418793073234"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-03T07:41:17.330Z","3.0.0":"2025-09-03T07:41:17.696Z","modified":"2025-09-03T07:41:17.987Z"},"maintainers":[{"name":"atlaschain","email":"jq@atlaschain.org"}],"description":"Helpers for creating transaction instructions","homepage":"https://github.com/anza-xyz/kit#readme","keywords":["blockchain","atlas","web3"],"repository":{"type":"git","url":"git+https://github.com/anza-xyz/kit.git"},"author":{"name":"Atlas Chain Foundation"},"bugs":{"url":"https://github.com/anza-xyz/kit/issues"},"license":"MIT","readme":"[![npm][npm-image]][npm-url]\n[![npm-downloads][npm-downloads-image]][npm-url]\n<br />\n[![code-style-prettier][code-style-prettier-image]][code-style-prettier-url]\n\n[code-style-prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square\n[code-style-prettier-url]: https://github.com/prettier/prettier\n[npm-downloads-image]: https://img.shields.io/npm/dm/@atlas/instructions?style=flat\n[npm-image]: https://img.shields.io/npm/v/@atlas/instructions?style=flat\n[npm-url]: https://www.npmjs.com/package/@atlas/instructions\n\n# @atlas/instructions\n\nThis package contains types for creating transaction instructions. It can be used standalone, but it is also exported as part of Kit [`@atlas/kit`](https://github.com/anza-xyz/kit/tree/main/packages/kit).\n\n## Types\n\n### `AccountRole`\n\nThe purpose for which an account participates in a transaction is described by the `AccountRole` type. Every account that participates in a transaction can be read from, but only ones that you mark as writable may be written to, and only ones that you indicate must sign the transaction will gain the privileges associated with signers at runtime.\n\n|                               | `isSigner` | `isWritable` |\n| ----------------------------- | ---------- | ------------ |\n| `AccountRole.READONLY`        | &#x274c;   | &#x274c;     |\n| `AccountRole.WRITABLE`        | &#x274c;   | &#x2705;     |\n| `AccountRole.READONLY_SIGNER` | &#x2705;   | &#x274c;     |\n| `AccountRole.WRITABLE_SIGNER` | &#x2705;   | &#x2705;     |\n\n### `AccountMeta<TAddress>`\n\nThis type represents an account's address and metadata about its mutability and whether it must be a signer of the transaction.\n\nTypically, you will use one of its subtypes.\n\n|                                   | `role`                        | `isSigner` | `isWritable` |\n| --------------------------------- | ----------------------------- | ---------- | ------------ |\n| `ReadonlyAccount<TAddress>`       | `AccountRole.READONLY`        | &#x274c;   | &#x274c;     |\n| `WritableAccount<TAddress>`       | `AccountRole.WRITABLE`        | &#x274c;   | &#x2705;     |\n| `ReadonlySignerAccount<TAddress>` | `AccountRole.READONLY_SIGNER` | &#x2705;   | &#x274c;     |\n| `WritableSignerAccount<TAddress>` | `AccountRole.WRITABLE_SIGNER` | &#x2705;   | &#x2705;     |\n\nFor example, you could type the rent sysvar account like this:\n\n```ts\ntype RentSysvar = ReadonlyAccount<'SysvarRent111111111111111111111111111111111'>;\n```\n\n### `AccountLookupMeta<TAddress, TLookupTableAddress>`\n\nThis type represents a lookup of the account's address in an address lookup table. It specifies which lookup table account in which to perform the lookup, the index of the desired account address in that table, and metadata about its mutability. Notably, account addresses obtained via lookups may not act as signers.\n\nTypically, you will use one of its subtypes.\n\n|                                                        | `role`                 | `isSigner` | `isWritable` |\n| ------------------------------------------------------ | ---------------------- | ---------- | ------------ |\n| `ReadonlyLookupAccount<TAddress, TLookupTableAddress>` | `AccountRole.READONLY` | &#x274c;   | &#x274c;     |\n| `WritableLookupAccount<TAddress, TLookupTableAddress>` | `AccountRole.WRITABLE` | &#x274c;   | &#x2705;     |\n\nFor example, you could type the rent sysvar account that you looked up in a lookup table like this:\n\n```ts\ntype RentSysvar = ReadonlyLookupAccount<\n    'SysvarRent111111111111111111111111111111111',\n    'MyLookupTable111111111111111111111111111111'\n>;\n```\n\n### `Instruction<TProgramAddress>`\n\nUse this to specify an instruction destined for a given program.\n\n```ts\ntype StakeProgramInstruction = Instruction<'StakeConfig11111111111111111111111111111111'>;\n```\n\n### `InstructionWithAccounts<TAccounts>`\n\nUse this type to specify an instruction that loads certain accounts.\n\n```ts\ntype InstructionWithTwoAccounts = InstructionWithAccounts<\n    [\n        WritableAccount, // First account\n        RentSysvar, // Second account\n    ]\n>;\n```\n\n### `InstructionWithData<TData>`\n\nUse this type to specify an instruction whose data conforms to a certain type. This is most useful when you have a branded `Uint8Array` that represents a particular instruction's data.\n\nFor example, here is how the `AdvanceNonce` instruction is typed.\n\n```ts\ntype AdvanceNonceAccountInstruction<\n    TNonceAccountAddress extends string = string,\n    TNonceAuthorityAddress extends string = string,\n> = Instruction<'11111111111111111111111111111111'> &\n    InstructionWithAccounts<\n        [\n            WritableAccount<TNonceAccountAddress>,\n            ReadonlyAccount<'SysvarRecentB1ockHashes11111111111111111111'>,\n            ReadonlySignerAccount<TNonceAuthorityAddress>,\n        ]\n    > &\n    InstructionWithData<AdvanceNonceAccountInstructionData>;\n```\n\n## Functions\n\n### `isSignerRole(role: AccountRole)`\n\nReturns `true` if the `AccountRole` given represents that of a signer. Also refines the TypeScript type of the supplied role.\n\n### `isWritable(role: AccountRole)`\n\nReturns `true` if the `AccountRole` given represents that of a writable account. Also refines the TypeScript type of the supplied role.\n\n### `mergeRoles(roleA: AccountRole, roleB: AccountRole)`\n\nGiven two `AccountRoles`, will return the `AccountRole` that grants the highest privileges of both.\n\nExample:\n\n```ts\n// Returns `AccountRole.WRITABLE_SIGNER`\nmergeRoles(AccountRole.READONLY_SIGNER, AccountRole.WRITABLE);\n```\n\n### `downgradeRoleToNonSigner(role: AccountRole)`\n\nReturns an `AccountRole` representing the non-signer variant of the supplied role.\n\n### `downgradeRoleToReadonly(role: AccountRole)`\n\nReturns an `AccountRole` representing the read-only variant of the supplied role.\n\n### `upgradeRoleToSigner(role: AccountRole)`\n\nReturns an `AccountRole` representing the signer variant of the supplied role.\n\n### `upgradeRoleToWritable(role: AccountRole)`\n\nReturns an `AccountRole` representing the writable variant of the supplied role.\n","readmeFilename":"README.md","_rev":"1-34d96b1d7f0a90be3d81b6930bdf6658"}