{"_id":"@_koii/sqds-sdk","name":"@_koii/sqds-sdk","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.2":{"name":"@_koii/sqds-sdk","version":"1.0.2","description":"An SDK for easily interacting with Squads Multisig Programs","main":"lib/sdk/src/index.js","scripts":{"test":"ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts","build":"./build.sh","prepublishOnly":"npm run build"},"dependencies":{"@project-serum/anchor":"^0.24.2","bn.js":"^5.2.1"},"devDependencies":{"@types/bn.js":"^5.1.0","@types/chai":"^4.3.1","@types/expect":"^24.3.0","@types/mocha":"^9.1.1","chai":"^4.3.4","mocha":"^9.0.3","prettier":"^2.7.1","ts-mocha":"10.0.0","typescript":"^4.3.5"},"author":{"name":"Evan Doyle"},"license":"AGPL-3.0-or-later","_id":"@_koii/sqds-sdk@1.0.2","gitHead":"fded01965e9c1f3ecfcdc16e8611e78a31d7827c","types":"./lib/sdk/src/index.d.ts","_nodeVersion":"22.0.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-HbRnIP/N9EjKm5LoOY24RiZlxW0SK9t5w3+vM6VhVkXRsW+mdcKLedMe0s8/lWvFc4UQ5+q3tyobyQ0/OI8PLQ==","shasum":"adc867a5d976296fedfa8304985082881b669568","tarball":"https://registry.npmjs.org/@_koii/sqds-sdk/-/sqds-sdk-1.0.2.tgz","fileCount":21,"unpackedSize":182047,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC0L2as5BPzDqbixdNX7BFbzIoOdvieNOkPG1HYvm0j3wIgN2f+2F5NWPN7/TxmuwBiOWEDtvWtkMWwA6BqZ3ISTsU="}]},"_npmUser":{"name":"syedghazanfer","email":"s.ghazanfer@koii.network"},"directories":{},"maintainers":[{"name":"sid09","email":"sid@koii.network"},{"name":"syedghazanfer","email":"s.ghazanfer@koii.network"},{"name":"muscular_developer","email":"wjelen30@gmail.com"},{"name":"npm-koii","email":"npm@koii.network"},{"name":"josh-koii","email":"josh@koii.network"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sqds-sdk_1.0.2_1731600871786_0.4879931981913874"},"_hasShrinkwrap":false}},"time":{"created":"2024-11-14T16:14:31.677Z","1.0.2":"2024-11-14T16:14:32.001Z","modified":"2024-11-14T16:14:32.367Z"},"maintainers":[{"name":"sid09","email":"sid@koii.network"},{"name":"syedghazanfer","email":"s.ghazanfer@koii.network"},{"name":"muscular_developer","email":"wjelen30@gmail.com"},{"name":"npm-koii","email":"npm@koii.network"},{"name":"josh-koii","email":"josh@koii.network"}],"description":"An SDK for easily interacting with Squads Multisig Programs","author":{"name":"Evan Doyle"},"license":"AGPL-3.0-or-later","readme":"# Squads SDK\nThis package provides classes and utilities to make it easier to interact with Squads programs.\n\n## Contents\n* [Get Started](#get-started)\n* [Important Classes](#important-classes)\n  * [Squads](#squads)\n  * [TransactionBuilder](#transactionbuilder)\n* [Contributing](#contributing)\n  * [Building & Testing](#building--testing)\n\n## Get started\n\n```typescript\nimport Squads from \"@sqds/sdk\";\n\n// By default, the canonical Program IDs for SquadsMPL and ProgramManager will be used\n// The 'wallet' passed in will be the signer/feePayer on all transactions through the Squads object.\nconst squads = Squads.localnet(wallet); // or Squads.devnet(...); Squads.mainnet(...)\n\nconst multisigAccount = await squads.createMultisig(threshold, createKey, members);\n```\n\nGenerally you will want to import the default `Squads` class from `@sqds/sdk` and pass in a `Wallet` instance. This would come from your preferred client-side wallet adapter or would likely be a `NodeWallet` if running server-side.\n\nThis class gives you access to essentially all instructions on the main Squads-MPL program as well as the ProgramManager program to handle program upgrades with multisig ownership and approval.\n\nFor more information about the instructions and program capabilities, see the `/programs/` README in this repo.\n\n## Important Classes\n### Squads\nThis class has an extensive interface covering instructions from both the main Squads-MPL program and the ProgramManager program. It is configured with a wallet, connection-related parameters, and program IDs. All operations that originate from the instance will use these parameters to send RPC requests, submit Transactions and pay fees.\n\n#### Getters\nSome of the methods on `Squads` are simple 'getters' which take an address (of something like a Multisig or an MsTransaction) and return the deserialized account data.\n```typescript\nconst multisigAccount = await squads.getMultisig(...);\nconst multisigAccounts = await squads.getMultisigs([...]);\nconst msTransaction = await squads.getTransaction(...);\n// etc.\n```\n\n#### Immediate Instructions\nOther methods immediately execute an instruction against one of the configured program IDs and often return relevant account data.\n```typescript\nconst multisigAccount = await squads.createMultisig(...);\nconst msInstruction = await squads.addInstruction(...);\nconst msTransaction = await squads.executeTransaction(...);\n// etc.\n```\n\n#### Built Instructions\nFor most 'immediate' instructions, there is an alternate form which does not execute the instruction, but instead returns it so that the caller can handle wrapping it in a Transaction and sending it to the cluster. These can be identified by the prefix `build` in front of the immediate counterpart.\n```typescript\nconst createMultisigInstruction = await squads.buildCreateMultisig(...);\nconst addInstructionInstruction = await squads.buildAddInstruction(...);\nconst executeTransactionInstruction = await squads.buildExecuteTransaction(...);\n\nconst tx = new Transaction(...);\ntx.add(createMultisigInstruction, addInstructionInstruction, executeTransactionInstruction);\nawait squads.wallet.signTransaction(tx);\nawait sendAndConfirmTransaction(...);\n// etc.\n```\n\n\n### TransactionBuilder\nWhen it comes to 'internal instructions' which don't make sense as 'immediate' instructions (since the user cannot execute them unilaterally), the SDK includes a `TransactionBuilder` which can prepare them as an `MsTransaction` for execution via CPI.\n```typescript\nlet txBuilder = await squads.getTransactionBuilder(...);\ntxBuilder = await txBuilder.withAddMember(...);\ntxBuilder = await txBuilder.withChangeThreshold(...);\ntxBuilder = await txBuilder.withRemoveMember(...);\n\n// This will create an MsTransaction and add the appropriate MsInstructions (addMember, changeThreshold, removeMember)\n// The txPDA can be used in calls to activateTransaction, approveTransaction, executeTransaction etc.\nconst [_txInstructions, txPDA] = await txBuilder.executeInstructions();\n```\n\n\n## Contributing\n\nThe community is encouraged to contribute to the Squads SDK by proposing fixes or updates. \nFor any proposed fixes and features, please submit a pull request for review.\n\n### Building & Testing\n`yarn build` will build the package into the `lib/` directory. The directory will contain compiled CommonJS files (.cjs), TypeScript declaration files (.d.ts), and Anchor IDL files (.json) which comprise the package. This command must be run in order to have changes to `src/` reflected in tests or actual package use.\n\n`yarn test` will run only the tests within the `sdk/` directory (not much at the moment). More robust testing (including localnet-deployed programs and RPC calls) is done by running `yarn test` in the root directory of this repository (`../`).\n","readmeFilename":"README.md"}