diff --git a/.github/actions/build-anchor/action.yaml b/.github/actions/build-anchor/action.yaml new file mode 100644 index 00000000..a32da816 --- /dev/null +++ b/.github/actions/build-anchor/action.yaml @@ -0,0 +1,49 @@ +name: "Anchor Build" +description: "Build a program using Anchor" +inputs: + program: + description: "The program to build" + required: true + program_id: + description: "The program address" + required: true + replace_program_id: + description: "Whether to replace current program id with `program_id` in lib.rs, e.g. when deploying to a staging address" + +runs: + using: "composite" + steps: + - name: Cache Anchor build + uses: actions/cache@v3 + id: cache-anchor-build + if: env.CACHE != 'true' || steps.cache-anchor-build.outputs.cache-hit != 'true' + with: + path: | + ./target/ + key: build-${{ runner.os }}-${{env.ANCHOR_VERSION}}-${{ hashFiles(format('./programs/{0}/**', inputs.program)) }}-${{ inputs.program }}-${{ inputs.staging }} + + - name: Replace program ID if needed + if: inputs.replace_program_id == 'true' + env: + PROGRAM_ID: ${{ inputs.program_id }} + run: | + sed -i "s/declare_id!(\".*\")/declare_id!(\"${PROGRAM_ID}\")/g" ./programs/${{ inputs.program }}/src/lib.rs + shell: bash + + - name: Build with Anchor + run: ~/.cargo/bin/anchor build -p ${{ inputs.program }} + shell: bash + + - name: Store .so files + uses: actions/upload-artifact@v3 + with: + name: ${{inputs.program}}-so + path: | + ./target/deploy/${{inputs.program}}.so + + - name: Store IDL files + uses: actions/upload-artifact@v3 + with: + name: ${{inputs.program}}-idl + path: | + ./target/idl/${{inputs.program}}.json diff --git a/.github/actions/deploy-anchor/action.yaml b/.github/actions/deploy-anchor/action.yaml new file mode 100644 index 00000000..d7cff5d3 --- /dev/null +++ b/.github/actions/deploy-anchor/action.yaml @@ -0,0 +1,49 @@ +name: "Deploy Program with Anchor" +description: "Deploy a program to a cluster using Anchor" + +inputs: + program: + description: "The program to build" + required: true + program_id: + description: "The program address" + required: true + rpc_url: + description: "The RPC url for the cluster to deploy to" + required: true + upgrade_authority_keypair: + description: "The keypair to use as the upgrade authority" + required: true + +runs: + using: "composite" + steps: + - name: Save Upgrade Authority keypair on disk + run: | + echo $UPGRADE_AUTHORITY_KEYPAIR > ./upgrade-authority.json && chmod 600 ./upgrade-authority.json + shell: bash + env: + UPGRADE_AUTHORITY_KEYPAIR: ${{ inputs.upgrade_authority_keypair }} + + - name: Deploy .so with Anchor + run: | + ~/.cargo/bin/anchor upgrade --program-id $PROGRAM_ID --provider.cluster $RPC_URL --provider.wallet ./upgrade-authority.json ./target/deploy/${PROGRAM_NAME}.so + shell: bash + env: + RPC_URL: ${{ inputs.rpc_url }} + PROGRAM_NAME: ${{ inputs.program }} + PROGRAM_ID: ${{ inputs.program_id }} + + - name: Deploy IDL with Anchor + run: | + anchor idl upgrade --provider.cluster $RPC_URL --provider.wallet ./upgrade-authority.json --filepath target/idl/${PROGRAM_NAME}.json $PROGRAM_ID + shell: bash + env: + RPC_URL: ${{ inputs.rpc_url }} + PROGRAM_NAME: ${{ inputs.program }} + PROGRAM_ID: ${{ inputs.program_id }} + + - name: Remove Upgrade Authority keypair from disk + run: | + rm ./upgrade-authority.json + shell: bash diff --git a/.github/workflows/check-staging-deployer-balance.yaml b/.github/workflows/check-staging-deployer-balance.yaml new file mode 100644 index 00000000..5831a757 --- /dev/null +++ b/.github/workflows/check-staging-deployer-balance.yaml @@ -0,0 +1,49 @@ +# Checks that the balance of the Solana public key +# associated with the UPGRADE_AUTHORITY_KEYPAIR_STAGING is greater than +# the estimated balance required to deploy a program. +name: Check Staging Deployer Balance + +on: + pull_request: + branches: + - main + paths: + - 'programs/squads_multisig_program/**' + +jobs: + check-balance: + if: contains(github.event.pull_request.labels.*.name, 'deploy-staging') + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Solana + uses: ./.github/actions/setup-solana/ + + - name: Check Solana Balance + env: + UPGRADE_AUTHORITY_KEYPAIR: ${{ secrets.UPGRADE_AUTHORITY_KEYPAIR_STAGING }} + RPC_URL: ${{ secrets.RPC_URL_MAINNET }} + run: | + # Write the keypair to a file so it can be used with solana-keygen + echo $UPGRADE_AUTHORITY_KEYPAIR > ./upgrade-authority.json && chmod 600 ./upgrade-authority.json + + # Extract the public key from the keypair file + PUBLIC_KEY=$(solana-keygen pubkey ./upgrade-authority.json) + + # Remove the keypair file + rm ./upgrade-authority.json + + # Fetch the balance of the public key + BALANCE=$(solana balance $PUBLIC_KEY --url $RPC_URL | awk '{print $1}') + + MIN_BALANCE=10 + + # Check if the balance is less than the minimum balance using floating point comparison with `bc` + if (( $(echo "$BALANCE < $MIN_BALANCE" | bc -l) )); then + echo "Balance of $PUBLIC_KEY is $BALANCE, which is less than the minimum balance of $MIN_BALANCE" + exit 1 + fi + + echo "Balance of $PUBLIC_KEY is $BALANCE SOL" diff --git a/.github/workflows/publish-staging.yaml b/.github/workflows/publish-staging.yaml new file mode 100644 index 00000000..631549bb --- /dev/null +++ b/.github/workflows/publish-staging.yaml @@ -0,0 +1,25 @@ +name: Publish to Staging + +on: + pull_request: + types: + - closed + branches: + - main + paths: + - 'programs/squads_multisig_program/**' + +jobs: + publish-staging: + if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'deploy-staging') + uses: ./.github/workflows/reusable-publish-staging.yaml + with: + cache: true + solana_cli_version: 1.17.0 + anchor_version: 0.29.0 + program: "squads_multisig_program" + program_id: "STAG3xkFMyVK3sRtQhipsKuLpRGbgospDpVdNyJqDpS" + replace_program_id: true + secrets: + RPC_URL: ${{ secrets.RPC_URL_MAINNET }} + UPGRADE_AUTHORITY_KEYPAIR: ${{ secrets.UPGRADE_AUTHORITY_KEYPAIR_STAGING }} diff --git a/.github/workflows/reusable-publish-staging.yaml b/.github/workflows/reusable-publish-staging.yaml new file mode 100644 index 00000000..4d5282d3 --- /dev/null +++ b/.github/workflows/reusable-publish-staging.yaml @@ -0,0 +1,73 @@ +name: Reusable Publish to Staging + +on: + workflow_call: + inputs: + cache: + required: true + type: boolean + solana_cli_version: + required: true + type: string + anchor_version: + required: true + type: string + program: + description: "The program to build" + required: true + type: string + program_id: + description: "The program address" + required: true + type: string + replace_program_id: + description: "Whether to replace current program id with `program_id` in lib.rs, e.g. when deploying to a staging address" + type: boolean + + secrets: + RPC_URL: + required: true + UPGRADE_AUTHORITY_KEYPAIR: + required: true + +env: + CACHE: inputs.cache + SOLANA_CLI_VERSION: ${{ inputs.solana_cli_version }} + NODE_VERSION: ${{ inputs.node_version }} + CARGO_PROFILE: ${{ inputs.cargo_profile }} + ANCHOR_VERSION: ${{ inputs.anchor_version }} + +jobs: + publish: + name: Publish + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Rust + uses: ./.github/actions/setup-rust/ + + - name: Setup Solana + uses: ./.github/actions/setup-solana/ + + - name: Setup Anchor + uses: ./.github/actions/setup-anchor/ + + - name: Build Anchor + uses: ./.github/actions/build-anchor/ + with: + program: ${{ inputs.program }} + program_id: ${{ inputs.program_id }} + replace_program_id: ${{ inputs.replace_program_id }} + + - name: Deploy with Anchor + uses: ./.github/actions/deploy-anchor/ + with: + program: ${{ inputs.program }} + program_id: ${{ inputs.program_id }} + rpc_url: ${{ secrets.RPC_URL }} + upgrade_authority_keypair: ${{ secrets.UPGRADE_AUTHORITY_KEYPAIR }} + + diff --git a/package.json b/package.json index d6b36a59..aec14a2d 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,9 @@ ], "scripts": { "build": "turbo run build", - "test": "turbo run build && anchor test", - "ts": "turbo run ts && yarn tsc --noEmit", - "deploy": "anchor deploy --provider.cluster mainnet-beta --provider.wallet .keys/upgrade-authority.json --program-name multisig" + "test": "turbo run build && anchor test -- --features=testing && echo \"\n⚠️ Don't forget to recompile the .so file before deployment\n\"", + "pretest": "mkdir -p target/deploy && cp ./test-program-keypair.json ./target/deploy/squads_multisig_program-keypair.json", + "ts": "turbo run ts && yarn tsc --noEmit" }, "devDependencies": { "@solana/spl-token": "*", diff --git a/programs/squads_multisig_program/Cargo.toml b/programs/squads_multisig_program/Cargo.toml index 170fe2d0..62e8b71d 100644 --- a/programs/squads_multisig_program/Cargo.toml +++ b/programs/squads_multisig_program/Cargo.toml @@ -14,9 +14,11 @@ no-entrypoint = [] no-idl = [] no-log-ix-name = [] cpi = ["no-entrypoint"] +testing = [] default = [] [dependencies] anchor-lang = { version = "=0.29.0", features = ["allow-missing-optionals"] } anchor-spl = { version="=0.29.0", features=["token"] } solana-security-txt = "1.1.1" +# \ No newline at end of file diff --git a/programs/squads_multisig_program/src/lib.rs b/programs/squads_multisig_program/src/lib.rs index 111c18f6..9c4f5b97 100644 --- a/programs/squads_multisig_program/src/lib.rs +++ b/programs/squads_multisig_program/src/lib.rs @@ -34,8 +34,12 @@ security_txt! { auditors: "OtterSec, Neodyme" } +#[cfg(not(feature = "testing"))] declare_id!("SQDS4ep65T869zMMBKyuUq6aD6EgTu8psMjkvj52pCf"); +#[cfg(feature = "testing")] +declare_id!("GyhGAqjokLwF9UXdQ2dR5Zwiup242j4mX4J1tSMKyAmD"); + #[program] pub mod squads_multisig_program { use super::*; diff --git a/sdk/multisig/.solitarc.js b/sdk/multisig/.solitarc.js index 1abe89a2..ec492e37 100644 --- a/sdk/multisig/.solitarc.js +++ b/sdk/multisig/.solitarc.js @@ -18,32 +18,10 @@ const ignoredTypes = new Set([ "MessageAddressTableLookup", ]); -function loadKeypairFromFile(relativePath) { - try { - const absolutePath = path.join(__dirname, relativePath); - return Keypair.fromSecretKey( - Buffer.from(JSON.parse(readFileSync(absolutePath, "utf-8"))) - ); - } catch (error) { - console.error("Error reading keypair from file:", error); - return { - publicKey: { - toBase58: () => "SQDS4ep65T869zMMBKyuUq6aD6EgTu8psMjkvj52pCf", - }, - }; - } -} - -const keypair = loadKeypairFromFile( - `../../target/deploy/${PROGRAM_NAME}-keypair.json` -); - -const pubkey = keypair.publicKey.toBase58(); - module.exports = { idlGenerator: "anchor", programName: PROGRAM_NAME, - programId: pubkey, + programId: "SQDS4ep65T869zMMBKyuUq6aD6EgTu8psMjkvj52pCf", idlDir, sdkDir, binaryInstallDir, diff --git a/sdk/multisig/src/instructions/batchAddTransaction.ts b/sdk/multisig/src/instructions/batchAddTransaction.ts index 5e0e1582..b33f773f 100644 --- a/sdk/multisig/src/instructions/batchAddTransaction.ts +++ b/sdk/multisig/src/instructions/batchAddTransaction.ts @@ -3,7 +3,7 @@ import { PublicKey, TransactionMessage, } from "@solana/web3.js"; -import { createBatchAddTransactionInstruction } from "../generated"; +import { createBatchAddTransactionInstruction, PROGRAM_ID } from "../generated"; import { getBatchTransactionPda, getProposalPda, @@ -22,6 +22,7 @@ export function batchAddTransaction({ ephemeralSigners, transactionMessage, addressLookupTableAccounts, + programId = PROGRAM_ID, }: { vaultIndex: number; multisigPda: PublicKey; @@ -37,23 +38,28 @@ export function batchAddTransaction({ transactionMessage: TransactionMessage; /** `AddressLookupTableAccount`s referenced in `transaction_message`. */ addressLookupTableAccounts?: AddressLookupTableAccount[]; + programId?: PublicKey; }) { const [proposalPda] = getProposalPda({ multisigPda, transactionIndex: batchIndex, + programId, }); const [batchPda] = getTransactionPda({ multisigPda, index: batchIndex, + programId, }); const [batchTransactionPda] = getBatchTransactionPda({ multisigPda, batchIndex, transactionIndex, + programId, }); const [vaultPda] = getVaultPda({ multisigPda, index: vaultIndex, + programId, }); const transactionMessageBytes = @@ -77,6 +83,7 @@ export function batchAddTransaction({ ephemeralSigners, transactionMessage: transactionMessageBytes, }, - } + }, + programId ); } diff --git a/sdk/multisig/src/instructions/batchCreate.ts b/sdk/multisig/src/instructions/batchCreate.ts index 2d1b13ec..6662bebd 100644 --- a/sdk/multisig/src/instructions/batchCreate.ts +++ b/sdk/multisig/src/instructions/batchCreate.ts @@ -1,5 +1,5 @@ import { PublicKey } from "@solana/web3.js"; -import { createBatchCreateInstruction } from "../generated"; +import { createBatchCreateInstruction, PROGRAM_ID } from "../generated"; import { getTransactionPda } from "../pda"; export function batchCreate({ @@ -9,6 +9,7 @@ export function batchCreate({ batchIndex, vaultIndex, memo, + programId = PROGRAM_ID, }: { multisigPda: PublicKey; /** Member of the multisig that is creating the batch. */ @@ -18,10 +19,12 @@ export function batchCreate({ batchIndex: bigint; vaultIndex: number; memo?: string; + programId?: PublicKey; }) { const [batchPda] = getTransactionPda({ multisigPda, index: batchIndex, + programId, }); return createBatchCreateInstruction( @@ -31,6 +34,7 @@ export function batchCreate({ rentPayer: rentPayer ?? creator, batch: batchPda, }, - { args: { vaultIndex, memo: memo ?? null } } + { args: { vaultIndex, memo: memo ?? null } }, + programId ); } diff --git a/sdk/multisig/src/instructions/batchExecuteTransaction.ts b/sdk/multisig/src/instructions/batchExecuteTransaction.ts index 160b28ec..4419a70a 100644 --- a/sdk/multisig/src/instructions/batchExecuteTransaction.ts +++ b/sdk/multisig/src/instructions/batchExecuteTransaction.ts @@ -7,6 +7,7 @@ import { import { Batch, createBatchExecuteTransactionInstruction, + PROGRAM_ID, VaultBatchTransaction, } from "../generated"; import { @@ -23,12 +24,14 @@ export async function batchExecuteTransaction({ member, batchIndex, transactionIndex, + programId = PROGRAM_ID, }: { connection: Connection; multisigPda: PublicKey; member: PublicKey; batchIndex: bigint; transactionIndex: number; + programId?: PublicKey; }): Promise<{ instruction: TransactionInstruction; lookupTableAccounts: AddressLookupTableAccount[]; @@ -36,21 +39,25 @@ export async function batchExecuteTransaction({ const [proposalPda] = getProposalPda({ multisigPda, transactionIndex: batchIndex, + programId, }); const [batchPda] = getTransactionPda({ multisigPda, index: batchIndex, + programId, }); const [batchTransactionPda] = getBatchTransactionPda({ multisigPda, batchIndex, transactionIndex, + programId, }); const batchAccount = await Batch.fromAccountAddress(connection, batchPda); const [vaultPda] = getVaultPda({ multisigPda, index: batchAccount.vaultIndex, + programId, }); const batchTransactionAccount = @@ -69,14 +76,17 @@ export async function batchExecuteTransaction({ }); return { - instruction: createBatchExecuteTransactionInstruction({ - multisig: multisigPda, - member, - proposal: proposalPda, - batch: batchPda, - transaction: batchTransactionPda, - anchorRemainingAccounts: accountMetas, - }), + instruction: createBatchExecuteTransactionInstruction( + { + multisig: multisigPda, + member, + proposal: proposalPda, + batch: batchPda, + transaction: batchTransactionPda, + anchorRemainingAccounts: accountMetas, + }, + programId + ), lookupTableAccounts, }; } diff --git a/sdk/multisig/src/instructions/configTransactionCreate.ts b/sdk/multisig/src/instructions/configTransactionCreate.ts index 9b1027aa..5117ac8e 100644 --- a/sdk/multisig/src/instructions/configTransactionCreate.ts +++ b/sdk/multisig/src/instructions/configTransactionCreate.ts @@ -2,6 +2,7 @@ import { PublicKey } from "@solana/web3.js"; import { ConfigAction, createConfigTransactionCreateInstruction, + PROGRAM_ID, } from "../generated"; import { getTransactionPda } from "../pda"; @@ -12,6 +13,7 @@ export function configTransactionCreate({ rentPayer, actions, memo, + programId = PROGRAM_ID, }: { multisigPda: PublicKey; /** Member of the multisig that is creating the transaction. */ @@ -21,10 +23,12 @@ export function configTransactionCreate({ transactionIndex: bigint; actions: ConfigAction[]; memo?: string; + programId?: PublicKey; }) { const [transactionPda] = getTransactionPda({ multisigPda, index: transactionIndex, + programId, }); return createConfigTransactionCreateInstruction( @@ -34,6 +38,7 @@ export function configTransactionCreate({ creator, rentPayer: rentPayer ?? creator, }, - { args: { actions, memo: memo ?? null } } + { args: { actions, memo: memo ?? null } }, + programId ); } diff --git a/sdk/multisig/src/instructions/configTransactionExecute.ts b/sdk/multisig/src/instructions/configTransactionExecute.ts index 968913b1..fe6699ce 100644 --- a/sdk/multisig/src/instructions/configTransactionExecute.ts +++ b/sdk/multisig/src/instructions/configTransactionExecute.ts @@ -1,5 +1,8 @@ import { PublicKey, SystemProgram } from "@solana/web3.js"; -import { createConfigTransactionExecuteInstruction } from "../generated"; +import { + createConfigTransactionExecuteInstruction, + PROGRAM_ID, +} from "../generated"; import { getProposalPda, getTransactionPda } from "../pda"; export function configTransactionExecute({ @@ -8,6 +11,7 @@ export function configTransactionExecute({ member, rentPayer, spendingLimits, + programId = PROGRAM_ID, }: { multisigPda: PublicKey; transactionIndex: bigint; @@ -15,27 +19,33 @@ export function configTransactionExecute({ rentPayer?: PublicKey; /** In case the transaction adds or removes SpendingLimits, pass the array of their Pubkeys here. */ spendingLimits?: PublicKey[]; + programId?: PublicKey; }) { const [proposalPda] = getProposalPda({ multisigPda, transactionIndex, + programId, }); const [transactionPda] = getTransactionPda({ multisigPda, index: transactionIndex, + programId, }); - return createConfigTransactionExecuteInstruction({ - multisig: multisigPda, - member, - proposal: proposalPda, - transaction: transactionPda, - rentPayer, - systemProgram: SystemProgram.programId, - anchorRemainingAccounts: spendingLimits?.map((spendingLimit) => ({ - pubkey: spendingLimit, - isWritable: true, - isSigner: false, - })), - }); + return createConfigTransactionExecuteInstruction( + { + multisig: multisigPda, + member, + proposal: proposalPda, + transaction: transactionPda, + rentPayer, + systemProgram: SystemProgram.programId, + anchorRemainingAccounts: spendingLimits?.map((spendingLimit) => ({ + pubkey: spendingLimit, + isWritable: true, + isSigner: false, + })), + }, + programId + ); } diff --git a/sdk/multisig/src/instructions/multisigAddMember.ts b/sdk/multisig/src/instructions/multisigAddMember.ts index 3900ef21..1390069d 100644 --- a/sdk/multisig/src/instructions/multisigAddMember.ts +++ b/sdk/multisig/src/instructions/multisigAddMember.ts @@ -1,5 +1,9 @@ import { PublicKey, SystemProgram } from "@solana/web3.js"; -import { createMultisigAddMemberInstruction, Member } from "../generated"; +import { + createMultisigAddMemberInstruction, + Member, + PROGRAM_ID, +} from "../generated"; export function multisigAddMember({ multisigPda, @@ -7,12 +11,14 @@ export function multisigAddMember({ rentPayer, newMember, memo, + programId = PROGRAM_ID, }: { multisigPda: PublicKey; configAuthority: PublicKey; rentPayer: PublicKey; newMember: Member; memo?: string; + programId?: PublicKey; }) { return createMultisigAddMemberInstruction( { @@ -21,6 +27,7 @@ export function multisigAddMember({ rentPayer, systemProgram: SystemProgram.programId, }, - { args: { newMember, memo: memo ?? null } } + { args: { newMember, memo: memo ?? null } }, + programId ); } diff --git a/sdk/multisig/src/instructions/multisigAddSpendingLimit.ts b/sdk/multisig/src/instructions/multisigAddSpendingLimit.ts index 6b5dee93..b69bd810 100644 --- a/sdk/multisig/src/instructions/multisigAddSpendingLimit.ts +++ b/sdk/multisig/src/instructions/multisigAddSpendingLimit.ts @@ -3,6 +3,7 @@ import BN from "bn.js"; import { createMultisigAddSpendingLimitInstruction, Period, + PROGRAM_ID, } from "../generated"; export function multisigAddSpendingLimit({ @@ -18,6 +19,7 @@ export function multisigAddSpendingLimit({ members, destinations, memo, + programId = PROGRAM_ID, }: { multisigPda: PublicKey; spendingLimit: PublicKey; @@ -31,6 +33,7 @@ export function multisigAddSpendingLimit({ members: PublicKey[]; destinations: PublicKey[]; memo?: string; + programId?: PublicKey; }) { return createMultisigAddSpendingLimitInstruction( { @@ -50,6 +53,7 @@ export function multisigAddSpendingLimit({ destinations, memo: memo ?? null, }, - } + }, + programId ); } diff --git a/sdk/multisig/src/instructions/multisigCreate.ts b/sdk/multisig/src/instructions/multisigCreate.ts index 12088d74..a1eca83d 100644 --- a/sdk/multisig/src/instructions/multisigCreate.ts +++ b/sdk/multisig/src/instructions/multisigCreate.ts @@ -1,5 +1,9 @@ import { PublicKey, TransactionInstruction } from "@solana/web3.js"; -import { createMultisigCreateInstruction, Member } from "../generated"; +import { + createMultisigCreateInstruction, + Member, + PROGRAM_ID, +} from "../generated"; export function multisigCreate({ creator, @@ -10,6 +14,7 @@ export function multisigCreate({ timeLock, createKey, memo, + programId = PROGRAM_ID, }: { creator: PublicKey; multisigPda: PublicKey; @@ -19,6 +24,7 @@ export function multisigCreate({ timeLock: number; createKey: PublicKey; memo?: string; + programId?: PublicKey; }): TransactionInstruction { return createMultisigCreateInstruction( { @@ -34,6 +40,7 @@ export function multisigCreate({ timeLock, memo: memo ?? null, }, - } + }, + programId ); } diff --git a/sdk/multisig/src/instructions/multisigRemoveSpendingLimit.ts b/sdk/multisig/src/instructions/multisigRemoveSpendingLimit.ts index 666795dc..5e902981 100644 --- a/sdk/multisig/src/instructions/multisigRemoveSpendingLimit.ts +++ b/sdk/multisig/src/instructions/multisigRemoveSpendingLimit.ts @@ -3,6 +3,7 @@ import BN from "bn.js"; import { createMultisigRemoveSpendingLimitInstruction, Period, + PROGRAM_ID, } from "../generated"; export function multisigRemoveSpendingLimit({ @@ -11,12 +12,14 @@ export function multisigRemoveSpendingLimit({ spendingLimit, rentCollector, memo, + programId = PROGRAM_ID, }: { multisigPda: PublicKey; spendingLimit: PublicKey; configAuthority: PublicKey; rentCollector: PublicKey; memo?: string; + programId?: PublicKey; }) { return createMultisigRemoveSpendingLimitInstruction( { @@ -29,6 +32,7 @@ export function multisigRemoveSpendingLimit({ args: { memo: memo ?? null, }, - } + }, + programId ); } diff --git a/sdk/multisig/src/instructions/multisigSetConfigAuthority.ts b/sdk/multisig/src/instructions/multisigSetConfigAuthority.ts index 5786f82b..9a24eb6b 100644 --- a/sdk/multisig/src/instructions/multisigSetConfigAuthority.ts +++ b/sdk/multisig/src/instructions/multisigSetConfigAuthority.ts @@ -6,11 +6,13 @@ export function multisigSetConfigAuthority({ configAuthority, newConfigAuthority, memo, + programId, }: { multisigPda: PublicKey; configAuthority: PublicKey; newConfigAuthority: PublicKey; memo?: string; + programId?: PublicKey; }) { return createMultisigSetConfigAuthorityInstruction( { @@ -22,6 +24,7 @@ export function multisigSetConfigAuthority({ configAuthority: newConfigAuthority, memo: memo ?? null, }, - } + }, + programId ); } diff --git a/sdk/multisig/src/instructions/multisigSetTimeLock.ts b/sdk/multisig/src/instructions/multisigSetTimeLock.ts index 4f406b6d..8591d676 100644 --- a/sdk/multisig/src/instructions/multisigSetTimeLock.ts +++ b/sdk/multisig/src/instructions/multisigSetTimeLock.ts @@ -6,11 +6,13 @@ export function multisigSetTimeLock({ configAuthority, timeLock, memo, + programId, }: { multisigPda: PublicKey; configAuthority: PublicKey; timeLock: number; memo?: string; + programId?: PublicKey; }) { return createMultisigSetTimeLockInstruction( { @@ -22,6 +24,7 @@ export function multisigSetTimeLock({ timeLock, memo: memo ?? null, }, - } + }, + programId ); } diff --git a/sdk/multisig/src/instructions/proposalActivate.ts b/sdk/multisig/src/instructions/proposalActivate.ts index 18c490e1..842f34ed 100644 --- a/sdk/multisig/src/instructions/proposalActivate.ts +++ b/sdk/multisig/src/instructions/proposalActivate.ts @@ -1,24 +1,30 @@ import { PublicKey } from "@solana/web3.js"; import { getProposalPda } from "../pda"; -import { createProposalActivateInstruction } from "../generated"; +import { createProposalActivateInstruction, PROGRAM_ID } from "../generated"; export function proposalActivate({ multisigPda, transactionIndex, member, + programId = PROGRAM_ID, }: { multisigPda: PublicKey; transactionIndex: bigint; member: PublicKey; + programId?: PublicKey; }) { const [proposalPda] = getProposalPda({ multisigPda, transactionIndex, + programId, }); - return createProposalActivateInstruction({ - multisig: multisigPda, - proposal: proposalPda, - member, - }); + return createProposalActivateInstruction( + { + multisig: multisigPda, + proposal: proposalPda, + member, + }, + programId + ); } diff --git a/sdk/multisig/src/instructions/proposalApprove.ts b/sdk/multisig/src/instructions/proposalApprove.ts index cbbefc3e..baaa2d6e 100644 --- a/sdk/multisig/src/instructions/proposalApprove.ts +++ b/sdk/multisig/src/instructions/proposalApprove.ts @@ -7,19 +7,23 @@ export function proposalApprove({ transactionIndex, member, memo, + programId, }: { multisigPda: PublicKey; transactionIndex: bigint; member: PublicKey; memo?: string; + programId?: PublicKey; }) { const [proposalPda] = getProposalPda({ multisigPda, transactionIndex, + programId, }); return createProposalApproveInstruction( { multisig: multisigPda, proposal: proposalPda, member }, - { args: { memo: memo ?? null } } + { args: { memo: memo ?? null } }, + programId ); } diff --git a/sdk/multisig/src/instructions/proposalCancel.ts b/sdk/multisig/src/instructions/proposalCancel.ts index e493c54f..b6a1cc88 100644 --- a/sdk/multisig/src/instructions/proposalCancel.ts +++ b/sdk/multisig/src/instructions/proposalCancel.ts @@ -1,5 +1,5 @@ import { getProposalPda } from "../pda"; -import { createProposalCancelInstruction } from "../generated"; +import { createProposalCancelInstruction, PROGRAM_ID } from "../generated"; import { PublicKey } from "@solana/web3.js"; export function proposalCancel({ @@ -7,19 +7,23 @@ export function proposalCancel({ transactionIndex, member, memo, + programId = PROGRAM_ID, }: { multisigPda: PublicKey; transactionIndex: bigint; member: PublicKey; memo?: string; + programId?: PublicKey; }) { const [proposalPda] = getProposalPda({ multisigPda, transactionIndex, + programId, }); return createProposalCancelInstruction( { multisig: multisigPda, proposal: proposalPda, member }, - { args: { memo: memo ?? null } } + { args: { memo: memo ?? null } }, + programId ); } diff --git a/sdk/multisig/src/instructions/proposalCreate.ts b/sdk/multisig/src/instructions/proposalCreate.ts index b2ea084a..6277c1e5 100644 --- a/sdk/multisig/src/instructions/proposalCreate.ts +++ b/sdk/multisig/src/instructions/proposalCreate.ts @@ -1,5 +1,5 @@ import { PublicKey } from "@solana/web3.js"; -import { createProposalCreateInstruction } from "../generated"; +import { createProposalCreateInstruction, PROGRAM_ID } from "../generated"; import { getProposalPda } from "../pda"; export function proposalCreate({ @@ -8,6 +8,7 @@ export function proposalCreate({ rentPayer, transactionIndex, isDraft = false, + programId = PROGRAM_ID, }: { multisigPda: PublicKey; /** Member of the multisig that is creating the proposal. */ @@ -16,10 +17,12 @@ export function proposalCreate({ rentPayer?: PublicKey; transactionIndex: bigint; isDraft?: boolean; + programId?: PublicKey; }) { const [proposalPda] = getProposalPda({ multisigPda, transactionIndex, + programId, }); if (transactionIndex > Number.MAX_SAFE_INTEGER) { @@ -33,6 +36,7 @@ export function proposalCreate({ multisig: multisigPda, proposal: proposalPda, }, - { args: { transactionIndex: Number(transactionIndex), draft: isDraft } } + { args: { transactionIndex: Number(transactionIndex), draft: isDraft } }, + programId ); } diff --git a/sdk/multisig/src/instructions/proposalReject.ts b/sdk/multisig/src/instructions/proposalReject.ts index 9e4ffec3..940393c7 100644 --- a/sdk/multisig/src/instructions/proposalReject.ts +++ b/sdk/multisig/src/instructions/proposalReject.ts @@ -1,5 +1,5 @@ import { getProposalPda } from "../pda"; -import { createProposalRejectInstruction } from "../generated"; +import { createProposalRejectInstruction, PROGRAM_ID } from "../generated"; import { PublicKey } from "@solana/web3.js"; export function proposalReject({ @@ -7,19 +7,23 @@ export function proposalReject({ transactionIndex, member, memo, + programId = PROGRAM_ID, }: { multisigPda: PublicKey; transactionIndex: bigint; member: PublicKey; memo?: string; + programId?: PublicKey; }) { const [proposalPda] = getProposalPda({ multisigPda, transactionIndex, + programId, }); return createProposalRejectInstruction( { multisig: multisigPda, proposal: proposalPda, member }, - { args: { memo: memo ?? null } } + { args: { memo: memo ?? null } }, + programId ); } diff --git a/sdk/multisig/src/instructions/spendingLimitUse.ts b/sdk/multisig/src/instructions/spendingLimitUse.ts index e370ebcb..802bf647 100644 --- a/sdk/multisig/src/instructions/spendingLimitUse.ts +++ b/sdk/multisig/src/instructions/spendingLimitUse.ts @@ -8,7 +8,7 @@ import { TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, } from "@solana/spl-token"; -import { createSpendingLimitUseInstruction } from "../generated"; +import { createSpendingLimitUseInstruction, PROGRAM_ID } from "../generated"; import { getVaultPda } from "../pda"; export function spendingLimitUse({ @@ -22,6 +22,7 @@ export function spendingLimitUse({ destination, tokenProgram = TOKEN_PROGRAM_ID, memo, + programId = PROGRAM_ID, }: { multisigPda: PublicKey; member: PublicKey; @@ -34,8 +35,9 @@ export function spendingLimitUse({ destination: PublicKey; tokenProgram?: PublicKey; memo?: string; + programId?: PublicKey; }): TransactionInstruction { - const [vaultPda] = getVaultPda({ multisigPda, index: vaultIndex }); + const [vaultPda] = getVaultPda({ multisigPda, index: vaultIndex, programId }); const vaultTokenAccount = mint && @@ -70,6 +72,7 @@ export function spendingLimitUse({ destinationTokenAccount, tokenProgram: mint ? tokenProgram : undefined, }, - { args: { amount, decimals, memo: memo ?? null } } + { args: { amount, decimals, memo: memo ?? null } }, + programId ); } diff --git a/sdk/multisig/src/instructions/vaultTransactionCreate.ts b/sdk/multisig/src/instructions/vaultTransactionCreate.ts index 114f5185..dbb21e66 100644 --- a/sdk/multisig/src/instructions/vaultTransactionCreate.ts +++ b/sdk/multisig/src/instructions/vaultTransactionCreate.ts @@ -1,4 +1,7 @@ -import { createVaultTransactionCreateInstruction } from "../generated"; +import { + createVaultTransactionCreateInstruction, + PROGRAM_ID, +} from "../generated"; import { AddressLookupTableAccount, PublicKey, @@ -17,6 +20,7 @@ export function vaultTransactionCreate({ transactionMessage, addressLookupTableAccounts, memo, + programId = PROGRAM_ID, }: { multisigPda: PublicKey; transactionIndex: bigint; @@ -30,15 +34,18 @@ export function vaultTransactionCreate({ /** `AddressLookupTableAccount`s referenced in `transaction_message`. */ addressLookupTableAccounts?: AddressLookupTableAccount[]; memo?: string; + programId?: PublicKey; }) { const [vaultPda] = getVaultPda({ multisigPda, index: vaultIndex, + programId, }); const [transactionPda] = getTransactionPda({ multisigPda, index: transactionIndex, + programId, }); const transactionMessageBytes = @@ -62,6 +69,7 @@ export function vaultTransactionCreate({ transactionMessage: transactionMessageBytes, memo: memo ?? null, }, - } + }, + programId ); } diff --git a/sdk/multisig/src/instructions/vaultTransactionExecute.ts b/sdk/multisig/src/instructions/vaultTransactionExecute.ts index cbe260fd..6740ec4b 100644 --- a/sdk/multisig/src/instructions/vaultTransactionExecute.ts +++ b/sdk/multisig/src/instructions/vaultTransactionExecute.ts @@ -7,6 +7,7 @@ import { import { getProposalPda, getTransactionPda, getVaultPda } from "../pda"; import { createVaultTransactionExecuteInstruction, + PROGRAM_ID, VaultTransaction, } from "../generated"; import { accountsForTransactionExecute } from "../utils"; @@ -16,11 +17,13 @@ export async function vaultTransactionExecute({ multisigPda, transactionIndex, member, + programId = PROGRAM_ID, }: { connection: Connection; multisigPda: PublicKey; transactionIndex: bigint; member: PublicKey; + programId?: PublicKey; }): Promise<{ instruction: TransactionInstruction; lookupTableAccounts: AddressLookupTableAccount[]; @@ -28,10 +31,12 @@ export async function vaultTransactionExecute({ const [proposalPda] = getProposalPda({ multisigPda, transactionIndex, + programId, }); const [transactionPda] = getTransactionPda({ multisigPda, index: transactionIndex, + programId, }); const transactionAccount = await VaultTransaction.fromAccountAddress( connection, @@ -41,6 +46,7 @@ export async function vaultTransactionExecute({ const [vaultPda] = getVaultPda({ multisigPda, index: transactionAccount.vaultIndex, + programId, }); const { accountMetas, lookupTableAccounts } = @@ -50,16 +56,20 @@ export async function vaultTransactionExecute({ ephemeralSignerBumps: [...transactionAccount.ephemeralSignerBumps], vaultPda, transactionPda, + programId, }); return { - instruction: createVaultTransactionExecuteInstruction({ - multisig: multisigPda, - member, - proposal: proposalPda, - transaction: transactionPda, - anchorRemainingAccounts: accountMetas, - }), + instruction: createVaultTransactionExecuteInstruction( + { + multisig: multisigPda, + member, + proposal: proposalPda, + transaction: transactionPda, + anchorRemainingAccounts: accountMetas, + }, + programId + ), lookupTableAccounts, }; } diff --git a/sdk/multisig/src/rpc/batchAddTransaction.ts b/sdk/multisig/src/rpc/batchAddTransaction.ts index 304dc675..cc795ab3 100644 --- a/sdk/multisig/src/rpc/batchAddTransaction.ts +++ b/sdk/multisig/src/rpc/batchAddTransaction.ts @@ -25,6 +25,7 @@ export async function batchAddTransaction({ addressLookupTableAccounts, signers, sendOptions, + programId, }: { connection: Connection; feePayer: Signer; @@ -44,6 +45,7 @@ export async function batchAddTransaction({ addressLookupTableAccounts?: AddressLookupTableAccount[]; signers?: Signer[]; sendOptions?: SendOptions; + programId?: PublicKey; }): Promise { const tx = await transactions.batchAddTransaction({ connection, @@ -57,6 +59,7 @@ export async function batchAddTransaction({ ephemeralSigners, transactionMessage, addressLookupTableAccounts, + programId, }); const allSigners = [feePayer, member]; diff --git a/sdk/multisig/src/rpc/batchCreate.ts b/sdk/multisig/src/rpc/batchCreate.ts index 83398b57..d5bf9eb1 100644 --- a/sdk/multisig/src/rpc/batchCreate.ts +++ b/sdk/multisig/src/rpc/batchCreate.ts @@ -20,6 +20,7 @@ export async function batchCreate({ memo, signers, sendOptions, + programId, }: { connection: Connection; feePayer: Signer; @@ -33,6 +34,7 @@ export async function batchCreate({ memo?: string; signers?: Signer[]; sendOptions?: SendOptions; + programId?: PublicKey; }): Promise { const blockhash = (await connection.getLatestBlockhash()).blockhash; @@ -45,6 +47,7 @@ export async function batchCreate({ rentPayer: rentPayer?.publicKey ?? creator.publicKey, vaultIndex, memo, + programId, }); const allSigners = [feePayer, creator]; diff --git a/sdk/multisig/src/rpc/batchExecuteTransaction.ts b/sdk/multisig/src/rpc/batchExecuteTransaction.ts index d9003b22..69c09a4f 100644 --- a/sdk/multisig/src/rpc/batchExecuteTransaction.ts +++ b/sdk/multisig/src/rpc/batchExecuteTransaction.ts @@ -18,6 +18,7 @@ export async function batchExecuteTransaction({ transactionIndex, signers, sendOptions, + programId, }: { connection: Connection; feePayer: Signer; @@ -27,6 +28,7 @@ export async function batchExecuteTransaction({ transactionIndex: number; signers?: Signer[]; sendOptions?: SendOptions; + programId?: PublicKey; }): Promise { const blockhash = (await connection.getLatestBlockhash()).blockhash; @@ -38,6 +40,7 @@ export async function batchExecuteTransaction({ member: member.publicKey, batchIndex, transactionIndex, + programId, }); tx.sign([feePayer, member, ...(signers ?? [])]); diff --git a/sdk/multisig/src/rpc/configTransactionCreate.ts b/sdk/multisig/src/rpc/configTransactionCreate.ts index d8a55d07..de6bb0d7 100644 --- a/sdk/multisig/src/rpc/configTransactionCreate.ts +++ b/sdk/multisig/src/rpc/configTransactionCreate.ts @@ -21,6 +21,7 @@ export async function configTransactionCreate({ memo, signers, sendOptions, + programId, }: { connection: Connection; feePayer: Signer; @@ -34,6 +35,7 @@ export async function configTransactionCreate({ memo?: string; signers?: Signer[]; sendOptions?: SendOptions; + programId?: PublicKey; }): Promise { const blockhash = (await connection.getLatestBlockhash()).blockhash; @@ -46,6 +48,7 @@ export async function configTransactionCreate({ rentPayer, actions, memo, + programId, }); tx.sign([feePayer, ...(signers ?? [])]); diff --git a/sdk/multisig/src/rpc/configTransactionExecute.ts b/sdk/multisig/src/rpc/configTransactionExecute.ts index 5e847471..41885a24 100644 --- a/sdk/multisig/src/rpc/configTransactionExecute.ts +++ b/sdk/multisig/src/rpc/configTransactionExecute.ts @@ -19,6 +19,7 @@ export async function configTransactionExecute({ spendingLimits, signers, sendOptions, + programId, }: { connection: Connection; feePayer: Signer; @@ -30,6 +31,7 @@ export async function configTransactionExecute({ spendingLimits?: PublicKey[]; signers?: Signer[]; sendOptions?: SendOptions; + programId?: PublicKey; }): Promise { const blockhash = (await connection.getLatestBlockhash()).blockhash; @@ -41,6 +43,7 @@ export async function configTransactionExecute({ member: member.publicKey, rentPayer: rentPayer.publicKey, spendingLimits, + programId, }); tx.sign([feePayer, member, rentPayer, ...(signers ?? [])]); diff --git a/sdk/multisig/src/rpc/multisigAddMember.ts b/sdk/multisig/src/rpc/multisigAddMember.ts index 2bbb6424..618c2d53 100644 --- a/sdk/multisig/src/rpc/multisigAddMember.ts +++ b/sdk/multisig/src/rpc/multisigAddMember.ts @@ -20,6 +20,7 @@ export async function multisigAddMember({ memo, signers, sendOptions, + programId, }: { connection: Connection; feePayer: Signer; @@ -30,6 +31,7 @@ export async function multisigAddMember({ memo?: string; signers?: Signer[]; sendOptions?: SendOptions; + programId?: PublicKey; }): Promise { const blockhash = (await connection.getLatestBlockhash()).blockhash; @@ -41,6 +43,7 @@ export async function multisigAddMember({ rentPayer: rentPayer.publicKey, newMember, memo, + programId, }); tx.sign([feePayer, rentPayer, ...(signers ?? [])]); diff --git a/sdk/multisig/src/rpc/multisigAddSpendingLimit.ts b/sdk/multisig/src/rpc/multisigAddSpendingLimit.ts index 16143fff..23c3afb8 100644 --- a/sdk/multisig/src/rpc/multisigAddSpendingLimit.ts +++ b/sdk/multisig/src/rpc/multisigAddSpendingLimit.ts @@ -29,6 +29,7 @@ export async function multisigAddSpendingLimit({ memo, signers, sendOptions, + programId, }: { connection: Connection; feePayer: Signer; @@ -46,6 +47,7 @@ export async function multisigAddSpendingLimit({ memo?: string; signers?: Signer[]; sendOptions?: SendOptions; + programId?: PublicKey; }): Promise { const blockhash = (await connection.getLatestBlockhash()).blockhash; @@ -64,6 +66,7 @@ export async function multisigAddSpendingLimit({ members, destinations, memo, + programId, }); tx.sign([feePayer, rentPayer, ...(signers ?? [])]); diff --git a/sdk/multisig/src/rpc/multisigCreate.ts b/sdk/multisig/src/rpc/multisigCreate.ts index 06498d04..7e623cbd 100644 --- a/sdk/multisig/src/rpc/multisigCreate.ts +++ b/sdk/multisig/src/rpc/multisigCreate.ts @@ -21,6 +21,7 @@ export async function multisigCreate({ timeLock, memo, sendOptions, + programId, }: { connection: Connection; createKey: Signer; @@ -32,6 +33,7 @@ export async function multisigCreate({ timeLock: number; memo?: string; sendOptions?: SendOptions; + programId?: PublicKey; }): Promise { const blockhash = (await connection.getLatestBlockhash()).blockhash; @@ -45,6 +47,7 @@ export async function multisigCreate({ members, timeLock, memo, + programId, }); tx.sign([creator, createKey]); diff --git a/sdk/multisig/src/rpc/multisigRemoveSpendingLimit.ts b/sdk/multisig/src/rpc/multisigRemoveSpendingLimit.ts index 796d560a..ee8eb87f 100644 --- a/sdk/multisig/src/rpc/multisigRemoveSpendingLimit.ts +++ b/sdk/multisig/src/rpc/multisigRemoveSpendingLimit.ts @@ -22,6 +22,7 @@ export async function multisigRemoveSpendingLimit({ memo, signers, sendOptions, + programId, }: { connection: Connection; feePayer: Signer; @@ -32,6 +33,7 @@ export async function multisigRemoveSpendingLimit({ memo?: string; signers?: Signer[]; sendOptions?: SendOptions; + programId?: PublicKey; }): Promise { const blockhash = (await connection.getLatestBlockhash()).blockhash; @@ -43,6 +45,7 @@ export async function multisigRemoveSpendingLimit({ spendingLimit, rentCollector, memo, + programId, }); tx.sign([feePayer, ...(signers ?? [])]); diff --git a/sdk/multisig/src/rpc/multisigSetConfigAuthority.ts b/sdk/multisig/src/rpc/multisigSetConfigAuthority.ts index 25b52efd..a720ba4d 100644 --- a/sdk/multisig/src/rpc/multisigSetConfigAuthority.ts +++ b/sdk/multisig/src/rpc/multisigSetConfigAuthority.ts @@ -18,6 +18,7 @@ export async function multisigSetConfigAuthority({ memo, signers, sendOptions, + programId, }: { connection: Connection; feePayer: Signer; @@ -27,6 +28,7 @@ export async function multisigSetConfigAuthority({ memo?: string; signers?: Signer[]; sendOptions?: SendOptions; + programId?: PublicKey; }): Promise { const blockhash = (await connection.getLatestBlockhash()).blockhash; @@ -37,6 +39,7 @@ export async function multisigSetConfigAuthority({ configAuthority, newConfigAuthority, memo, + programId, }); tx.sign([feePayer, ...(signers ?? [])]); diff --git a/sdk/multisig/src/rpc/multisigSetTimeLock.ts b/sdk/multisig/src/rpc/multisigSetTimeLock.ts index d0fe374f..9c5a3a52 100644 --- a/sdk/multisig/src/rpc/multisigSetTimeLock.ts +++ b/sdk/multisig/src/rpc/multisigSetTimeLock.ts @@ -18,6 +18,7 @@ export async function multisigSetTimeLock({ memo, signers, sendOptions, + programId, }: { connection: Connection; feePayer: Signer; @@ -27,6 +28,7 @@ export async function multisigSetTimeLock({ memo?: string; signers?: Signer[]; sendOptions?: SendOptions; + programId?: PublicKey; }): Promise { const blockhash = (await connection.getLatestBlockhash()).blockhash; @@ -37,6 +39,7 @@ export async function multisigSetTimeLock({ configAuthority, timeLock, memo, + programId, }); tx.sign([feePayer, ...(signers ?? [])]); diff --git a/sdk/multisig/src/rpc/proposalActivate.ts b/sdk/multisig/src/rpc/proposalActivate.ts index 40e4741c..020cc2a4 100644 --- a/sdk/multisig/src/rpc/proposalActivate.ts +++ b/sdk/multisig/src/rpc/proposalActivate.ts @@ -15,6 +15,7 @@ export async function proposalActivate({ multisigPda, transactionIndex, sendOptions, + programId, }: { connection: Connection; feePayer: Signer; @@ -22,6 +23,7 @@ export async function proposalActivate({ multisigPda: PublicKey; transactionIndex: bigint; sendOptions?: SendOptions; + programId?: PublicKey; }): Promise { const blockhash = (await connection.getLatestBlockhash()).blockhash; @@ -31,6 +33,7 @@ export async function proposalActivate({ multisigPda, transactionIndex, member: member.publicKey, + programId, }); tx.sign([feePayer, member]); diff --git a/sdk/multisig/src/rpc/proposalApprove.ts b/sdk/multisig/src/rpc/proposalApprove.ts index 05e52926..80b32de2 100644 --- a/sdk/multisig/src/rpc/proposalApprove.ts +++ b/sdk/multisig/src/rpc/proposalApprove.ts @@ -16,6 +16,7 @@ export async function proposalApprove({ transactionIndex, memo, sendOptions, + programId, }: { connection: Connection; feePayer: Signer; @@ -24,6 +25,7 @@ export async function proposalApprove({ transactionIndex: bigint; memo?: string; sendOptions?: SendOptions; + programId?: PublicKey; }): Promise { const blockhash = (await connection.getLatestBlockhash()).blockhash; @@ -34,6 +36,7 @@ export async function proposalApprove({ transactionIndex, member: member.publicKey, memo, + programId, }); tx.sign([feePayer, member]); diff --git a/sdk/multisig/src/rpc/proposalCancel.ts b/sdk/multisig/src/rpc/proposalCancel.ts index 653b2644..639d916b 100644 --- a/sdk/multisig/src/rpc/proposalCancel.ts +++ b/sdk/multisig/src/rpc/proposalCancel.ts @@ -17,6 +17,7 @@ export async function proposalCancel({ transactionIndex, memo, sendOptions, + programId, }: { connection: Connection; feePayer: Signer; @@ -25,6 +26,7 @@ export async function proposalCancel({ transactionIndex: bigint; memo?: string; sendOptions?: SendOptions; + programId?: PublicKey; }): Promise { const blockhash = (await connection.getLatestBlockhash()).blockhash; @@ -35,6 +37,7 @@ export async function proposalCancel({ transactionIndex, member: member.publicKey, memo, + programId, }); tx.sign([feePayer, member]); diff --git a/sdk/multisig/src/rpc/proposalCreate.ts b/sdk/multisig/src/rpc/proposalCreate.ts index 6ba94149..e4942e8a 100644 --- a/sdk/multisig/src/rpc/proposalCreate.ts +++ b/sdk/multisig/src/rpc/proposalCreate.ts @@ -17,6 +17,7 @@ export async function proposalCreate({ transactionIndex, isDraft, sendOptions, + programId, }: { connection: Connection; feePayer: Signer; @@ -28,6 +29,7 @@ export async function proposalCreate({ transactionIndex: bigint; isDraft?: boolean; sendOptions?: SendOptions; + programId?: PublicKey; }): Promise { const blockhash = (await connection.getLatestBlockhash()).blockhash; @@ -38,6 +40,7 @@ export async function proposalCreate({ transactionIndex, creator: creator.publicKey, isDraft, + programId, }); const allSigners = [feePayer, creator]; diff --git a/sdk/multisig/src/rpc/proposalReject.ts b/sdk/multisig/src/rpc/proposalReject.ts index d021a8c8..65143399 100644 --- a/sdk/multisig/src/rpc/proposalReject.ts +++ b/sdk/multisig/src/rpc/proposalReject.ts @@ -16,6 +16,7 @@ export async function proposalReject({ transactionIndex, memo, sendOptions, + programId, }: { connection: Connection; feePayer: Signer; @@ -24,6 +25,7 @@ export async function proposalReject({ transactionIndex: bigint; memo?: string; sendOptions?: SendOptions; + programId?: PublicKey; }): Promise { const blockhash = (await connection.getLatestBlockhash()).blockhash; @@ -34,6 +36,7 @@ export async function proposalReject({ transactionIndex, member: member.publicKey, memo, + programId, }); tx.sign([feePayer, member]); diff --git a/sdk/multisig/src/rpc/spendingLimitUse.ts b/sdk/multisig/src/rpc/spendingLimitUse.ts index f0702ab5..9a91565f 100644 --- a/sdk/multisig/src/rpc/spendingLimitUse.ts +++ b/sdk/multisig/src/rpc/spendingLimitUse.ts @@ -22,6 +22,7 @@ export async function spendingLimitUse({ tokenProgram, memo, sendOptions, + programId, }: { connection: Connection; feePayer: Signer; @@ -37,6 +38,7 @@ export async function spendingLimitUse({ tokenProgram?: PublicKey; memo?: string; sendOptions?: SendOptions; + programId?: PublicKey; }): Promise { const blockhash = (await connection.getLatestBlockhash()).blockhash; @@ -53,6 +55,7 @@ export async function spendingLimitUse({ destination, tokenProgram, memo, + programId, }); tx.sign([feePayer, member]); diff --git a/sdk/multisig/src/rpc/vaultTransactionCreate.ts b/sdk/multisig/src/rpc/vaultTransactionCreate.ts index 71b73749..3c33bd12 100644 --- a/sdk/multisig/src/rpc/vaultTransactionCreate.ts +++ b/sdk/multisig/src/rpc/vaultTransactionCreate.ts @@ -25,6 +25,7 @@ export async function vaultTransactionCreate({ memo, signers, sendOptions, + programId, }: { connection: Connection; feePayer: Signer; @@ -44,6 +45,7 @@ export async function vaultTransactionCreate({ memo?: string; signers?: Signer[]; sendOptions?: SendOptions; + programId?: PublicKey; }): Promise { const blockhash = (await connection.getLatestBlockhash()).blockhash; @@ -59,6 +61,7 @@ export async function vaultTransactionCreate({ transactionMessage, addressLookupTableAccounts, memo, + programId, }); tx.sign([feePayer, ...(signers ?? [])]); diff --git a/sdk/multisig/src/rpc/vaultTransactionExecute.ts b/sdk/multisig/src/rpc/vaultTransactionExecute.ts index 51641caa..31402976 100644 --- a/sdk/multisig/src/rpc/vaultTransactionExecute.ts +++ b/sdk/multisig/src/rpc/vaultTransactionExecute.ts @@ -20,6 +20,7 @@ export async function vaultTransactionExecute({ member, signers, sendOptions, + programId, }: { connection: Connection; feePayer: Signer; @@ -28,6 +29,7 @@ export async function vaultTransactionExecute({ member: PublicKey; signers?: Signer[]; sendOptions?: SendOptions; + programId?: PublicKey; }): Promise { const blockhash = (await connection.getLatestBlockhash()).blockhash; @@ -38,6 +40,7 @@ export async function vaultTransactionExecute({ multisigPda, transactionIndex, member, + programId, }); tx.sign([feePayer, ...(signers ?? [])]); diff --git a/sdk/multisig/src/transactions/batchAddTransaction.ts b/sdk/multisig/src/transactions/batchAddTransaction.ts index d93d09b4..b297c16b 100644 --- a/sdk/multisig/src/transactions/batchAddTransaction.ts +++ b/sdk/multisig/src/transactions/batchAddTransaction.ts @@ -23,6 +23,7 @@ export async function batchAddTransaction({ ephemeralSigners, transactionMessage, addressLookupTableAccounts, + programId, }: { connection: Connection; feePayer: PublicKey; @@ -40,6 +41,7 @@ export async function batchAddTransaction({ transactionMessage: TransactionMessage; /** `AddressLookupTableAccount`s referenced in `transaction_message`. */ addressLookupTableAccounts?: AddressLookupTableAccount[]; + programId?: PublicKey; }): Promise { const blockhash = (await connection.getLatestBlockhash()).blockhash; @@ -57,6 +59,7 @@ export async function batchAddTransaction({ ephemeralSigners, transactionMessage, addressLookupTableAccounts, + programId, }), ], }).compileToV0Message(); diff --git a/sdk/multisig/src/transactions/batchCreate.ts b/sdk/multisig/src/transactions/batchCreate.ts index 06cdaaf7..2908c69e 100644 --- a/sdk/multisig/src/transactions/batchCreate.ts +++ b/sdk/multisig/src/transactions/batchCreate.ts @@ -18,6 +18,7 @@ export function batchCreate({ rentPayer, vaultIndex, memo, + programId, }: { blockhash: string; feePayer: PublicKey; @@ -29,6 +30,7 @@ export function batchCreate({ rentPayer?: PublicKey; vaultIndex: number; memo?: string; + programId?: PublicKey; }): VersionedTransaction { const message = new TransactionMessage({ payerKey: feePayer, @@ -41,6 +43,7 @@ export function batchCreate({ batchIndex, vaultIndex, memo, + programId, }), ], }).compileToV0Message(); diff --git a/sdk/multisig/src/transactions/batchExecuteTransaction.ts b/sdk/multisig/src/transactions/batchExecuteTransaction.ts index 01903c27..30149b8f 100644 --- a/sdk/multisig/src/transactions/batchExecuteTransaction.ts +++ b/sdk/multisig/src/transactions/batchExecuteTransaction.ts @@ -18,6 +18,7 @@ export async function batchExecuteTransaction({ member, batchIndex, transactionIndex, + programId, }: { connection: Connection; blockhash: string; @@ -26,6 +27,7 @@ export async function batchExecuteTransaction({ member: PublicKey; batchIndex: bigint; transactionIndex: number; + programId?: PublicKey; }): Promise { const { instruction, lookupTableAccounts } = await instructions.batchExecuteTransaction({ @@ -34,6 +36,7 @@ export async function batchExecuteTransaction({ member, batchIndex, transactionIndex, + programId, }); const message = new TransactionMessage({ diff --git a/sdk/multisig/src/transactions/configTransactionCreate.ts b/sdk/multisig/src/transactions/configTransactionCreate.ts index 5b463649..8e008fbb 100644 --- a/sdk/multisig/src/transactions/configTransactionCreate.ts +++ b/sdk/multisig/src/transactions/configTransactionCreate.ts @@ -19,6 +19,7 @@ export function configTransactionCreate({ transactionIndex, actions, memo, + programId, }: { blockhash: string; feePayer: PublicKey; @@ -30,6 +31,7 @@ export function configTransactionCreate({ transactionIndex: bigint; actions: ConfigAction[]; memo?: string; + programId?: PublicKey; }): VersionedTransaction { const message = new TransactionMessage({ payerKey: feePayer, @@ -42,6 +44,7 @@ export function configTransactionCreate({ transactionIndex, actions, memo, + programId, }), ], }).compileToV0Message(); diff --git a/sdk/multisig/src/transactions/configTransactionExecute.ts b/sdk/multisig/src/transactions/configTransactionExecute.ts index 96767d4d..e6cb2c05 100644 --- a/sdk/multisig/src/transactions/configTransactionExecute.ts +++ b/sdk/multisig/src/transactions/configTransactionExecute.ts @@ -17,6 +17,7 @@ export function configTransactionExecute({ rentPayer, transactionIndex, spendingLimits, + programId, }: { blockhash: string; feePayer: PublicKey; @@ -26,6 +27,7 @@ export function configTransactionExecute({ rentPayer: PublicKey; /** In case the transaction adds or removes SpendingLimits, pass the array of their Pubkeys here. */ spendingLimits?: PublicKey[]; + programId?: PublicKey; }): VersionedTransaction { const message = new TransactionMessage({ payerKey: feePayer, @@ -37,6 +39,7 @@ export function configTransactionExecute({ member, rentPayer, spendingLimits, + programId, }), ], }).compileToV0Message(); diff --git a/sdk/multisig/src/transactions/multisigAddMember.ts b/sdk/multisig/src/transactions/multisigAddMember.ts index 87732abd..36f8098f 100644 --- a/sdk/multisig/src/transactions/multisigAddMember.ts +++ b/sdk/multisig/src/transactions/multisigAddMember.ts @@ -19,6 +19,7 @@ export function multisigAddMember({ rentPayer, newMember, memo, + programId, }: { blockhash: string; feePayer: PublicKey; @@ -27,6 +28,7 @@ export function multisigAddMember({ rentPayer: PublicKey; newMember: Member; memo?: string; + programId?: PublicKey; }): VersionedTransaction { const message = new TransactionMessage({ payerKey: feePayer, @@ -38,6 +40,7 @@ export function multisigAddMember({ rentPayer, newMember, memo, + programId, }), ], }).compileToV0Message(); diff --git a/sdk/multisig/src/transactions/multisigAddSpendingLimit.ts b/sdk/multisig/src/transactions/multisigAddSpendingLimit.ts index 55a95757..ee8d937d 100644 --- a/sdk/multisig/src/transactions/multisigAddSpendingLimit.ts +++ b/sdk/multisig/src/transactions/multisigAddSpendingLimit.ts @@ -25,6 +25,7 @@ export function multisigAddSpendingLimit({ members, destinations, memo, + programId, }: { blockhash: string; feePayer: PublicKey; @@ -40,6 +41,7 @@ export function multisigAddSpendingLimit({ members: PublicKey[]; destinations: PublicKey[]; memo?: string; + programId?: PublicKey; }): VersionedTransaction { const message = new TransactionMessage({ payerKey: feePayer, @@ -58,6 +60,7 @@ export function multisigAddSpendingLimit({ members, destinations, memo, + programId, }), ], }).compileToV0Message(); diff --git a/sdk/multisig/src/transactions/multisigCreate.ts b/sdk/multisig/src/transactions/multisigCreate.ts index 2a2ed15e..1a7a0134 100644 --- a/sdk/multisig/src/transactions/multisigCreate.ts +++ b/sdk/multisig/src/transactions/multisigCreate.ts @@ -17,6 +17,7 @@ export function multisigCreate({ members, timeLock, memo, + programId, }: { blockhash: string; createKey: PublicKey; @@ -27,6 +28,7 @@ export function multisigCreate({ members: Member[]; timeLock: number; memo?: string; + programId?: PublicKey; }): VersionedTransaction { const ix = instructions.multisigCreate({ creator, @@ -37,6 +39,7 @@ export function multisigCreate({ timeLock, createKey, memo, + programId, }); const message = new TransactionMessage({ diff --git a/sdk/multisig/src/transactions/multisigRemoveSpendingLimit.ts b/sdk/multisig/src/transactions/multisigRemoveSpendingLimit.ts index 425b5e6d..8c997d09 100644 --- a/sdk/multisig/src/transactions/multisigRemoveSpendingLimit.ts +++ b/sdk/multisig/src/transactions/multisigRemoveSpendingLimit.ts @@ -18,6 +18,7 @@ export function multisigRemoveSpendingLimit({ spendingLimit, rentCollector, memo, + programId, }: { blockhash: string; feePayer: PublicKey; @@ -26,6 +27,7 @@ export function multisigRemoveSpendingLimit({ configAuthority: PublicKey; rentCollector: PublicKey; memo?: string; + programId?: PublicKey; }): VersionedTransaction { const message = new TransactionMessage({ payerKey: feePayer, @@ -37,6 +39,7 @@ export function multisigRemoveSpendingLimit({ spendingLimit, rentCollector, memo, + programId, }), ], }).compileToV0Message(); diff --git a/sdk/multisig/src/transactions/multisigSetConfigAuthority.ts b/sdk/multisig/src/transactions/multisigSetConfigAuthority.ts index 55cfcfc0..7abc68dc 100644 --- a/sdk/multisig/src/transactions/multisigSetConfigAuthority.ts +++ b/sdk/multisig/src/transactions/multisigSetConfigAuthority.ts @@ -16,6 +16,7 @@ export function multisigSetConfigAuthority({ configAuthority, newConfigAuthority, memo, + programId, }: { blockhash: string; feePayer: PublicKey; @@ -23,6 +24,7 @@ export function multisigSetConfigAuthority({ configAuthority: PublicKey; newConfigAuthority: PublicKey; memo?: string; + programId?: PublicKey; }): VersionedTransaction { const message = new TransactionMessage({ payerKey: feePayer, @@ -33,6 +35,7 @@ export function multisigSetConfigAuthority({ configAuthority, newConfigAuthority, memo, + programId, }), ], }).compileToV0Message(); diff --git a/sdk/multisig/src/transactions/multisigSetTimeLock.ts b/sdk/multisig/src/transactions/multisigSetTimeLock.ts index 4321e180..c29a7015 100644 --- a/sdk/multisig/src/transactions/multisigSetTimeLock.ts +++ b/sdk/multisig/src/transactions/multisigSetTimeLock.ts @@ -16,6 +16,7 @@ export function multisigSetTimeLock({ configAuthority, timeLock, memo, + programId, }: { blockhash: string; feePayer: PublicKey; @@ -23,6 +24,7 @@ export function multisigSetTimeLock({ configAuthority: PublicKey; timeLock: number; memo?: string; + programId?: PublicKey; }): VersionedTransaction { const message = new TransactionMessage({ payerKey: feePayer, @@ -33,6 +35,7 @@ export function multisigSetTimeLock({ configAuthority, timeLock, memo, + programId, }), ], }).compileToV0Message(); diff --git a/sdk/multisig/src/transactions/proposalActivate.ts b/sdk/multisig/src/transactions/proposalActivate.ts index e67d46db..f9251098 100644 --- a/sdk/multisig/src/transactions/proposalActivate.ts +++ b/sdk/multisig/src/transactions/proposalActivate.ts @@ -15,12 +15,14 @@ export function proposalActivate({ multisigPda, transactionIndex, member, + programId, }: { blockhash: string; feePayer: PublicKey; multisigPda: PublicKey; transactionIndex: bigint; member: PublicKey; + programId?: PublicKey; }): VersionedTransaction { const message = new TransactionMessage({ payerKey: feePayer, @@ -30,6 +32,7 @@ export function proposalActivate({ member, multisigPda, transactionIndex, + programId, }), ], }).compileToV0Message(); diff --git a/sdk/multisig/src/transactions/proposalApprove.ts b/sdk/multisig/src/transactions/proposalApprove.ts index d47b2785..d7f07bb1 100644 --- a/sdk/multisig/src/transactions/proposalApprove.ts +++ b/sdk/multisig/src/transactions/proposalApprove.ts @@ -17,6 +17,7 @@ export function proposalApprove({ transactionIndex, member, memo, + programId, }: { blockhash: string; feePayer: PublicKey; @@ -24,6 +25,7 @@ export function proposalApprove({ transactionIndex: bigint; member: PublicKey; memo?: string; + programId?: PublicKey; }): VersionedTransaction { const message = new TransactionMessage({ payerKey: feePayer, @@ -34,6 +36,7 @@ export function proposalApprove({ multisigPda, transactionIndex, memo, + programId, }), ], }).compileToV0Message(); diff --git a/sdk/multisig/src/transactions/proposalCancel.ts b/sdk/multisig/src/transactions/proposalCancel.ts index 215cd0aa..a5b585c5 100644 --- a/sdk/multisig/src/transactions/proposalCancel.ts +++ b/sdk/multisig/src/transactions/proposalCancel.ts @@ -17,6 +17,7 @@ export function proposalCancel({ transactionIndex, member, memo, + programId, }: { blockhash: string; feePayer: PublicKey; @@ -24,6 +25,7 @@ export function proposalCancel({ transactionIndex: bigint; member: PublicKey; memo?: string; + programId?: PublicKey; }): VersionedTransaction { const message = new TransactionMessage({ payerKey: feePayer, @@ -34,6 +36,7 @@ export function proposalCancel({ multisigPda, transactionIndex, memo, + programId, }), ], }).compileToV0Message(); diff --git a/sdk/multisig/src/transactions/proposalCreate.ts b/sdk/multisig/src/transactions/proposalCreate.ts index afb940f3..10671a32 100644 --- a/sdk/multisig/src/transactions/proposalCreate.ts +++ b/sdk/multisig/src/transactions/proposalCreate.ts @@ -18,6 +18,7 @@ export function proposalCreate({ creator, rentPayer, isDraft, + programId, }: { blockhash: string; feePayer: PublicKey; @@ -28,6 +29,7 @@ export function proposalCreate({ /** Payer for the proposal account rent. If not provided, `creator` is used. */ rentPayer?: PublicKey; isDraft?: boolean; + programId?: PublicKey; }): VersionedTransaction { const message = new TransactionMessage({ payerKey: feePayer, @@ -39,6 +41,7 @@ export function proposalCreate({ rentPayer, transactionIndex, isDraft, + programId, }), ], }).compileToV0Message(); diff --git a/sdk/multisig/src/transactions/proposalReject.ts b/sdk/multisig/src/transactions/proposalReject.ts index c5bf584b..af21d634 100644 --- a/sdk/multisig/src/transactions/proposalReject.ts +++ b/sdk/multisig/src/transactions/proposalReject.ts @@ -17,6 +17,7 @@ export function proposalReject({ transactionIndex, member, memo, + programId, }: { blockhash: string; feePayer: PublicKey; @@ -24,6 +25,7 @@ export function proposalReject({ transactionIndex: bigint; member: PublicKey; memo?: string; + programId?: PublicKey; }): VersionedTransaction { const message = new TransactionMessage({ payerKey: feePayer, @@ -34,6 +36,7 @@ export function proposalReject({ multisigPda, transactionIndex, memo, + programId, }), ], }).compileToV0Message(); diff --git a/sdk/multisig/src/transactions/spendingLimitUse.ts b/sdk/multisig/src/transactions/spendingLimitUse.ts index 754d4d2a..ff973ad1 100644 --- a/sdk/multisig/src/transactions/spendingLimitUse.ts +++ b/sdk/multisig/src/transactions/spendingLimitUse.ts @@ -22,6 +22,7 @@ export function spendingLimitUse({ destination, tokenProgram, memo, + programId, }: { blockhash: string; feePayer: PublicKey; @@ -36,6 +37,7 @@ export function spendingLimitUse({ destination: PublicKey; tokenProgram?: PublicKey; memo?: string; + programId?: PublicKey; }): VersionedTransaction { const message = new TransactionMessage({ payerKey: feePayer, @@ -52,6 +54,7 @@ export function spendingLimitUse({ destination, tokenProgram, memo, + programId, }), ], }).compileToV0Message(); diff --git a/sdk/multisig/src/transactions/vaultTransactionCreate.ts b/sdk/multisig/src/transactions/vaultTransactionCreate.ts index 3049fc8c..067548d1 100644 --- a/sdk/multisig/src/transactions/vaultTransactionCreate.ts +++ b/sdk/multisig/src/transactions/vaultTransactionCreate.ts @@ -22,6 +22,7 @@ export function vaultTransactionCreate({ transactionMessage, addressLookupTableAccounts, memo, + programId, }: { blockhash: string; feePayer: PublicKey; @@ -39,6 +40,7 @@ export function vaultTransactionCreate({ /** `AddressLookupTableAccount`s referenced in `transaction_message`. */ addressLookupTableAccounts?: AddressLookupTableAccount[]; memo?: string; + programId?: PublicKey; }): VersionedTransaction { const message = new TransactionMessage({ payerKey: feePayer, @@ -54,6 +56,7 @@ export function vaultTransactionCreate({ transactionMessage, addressLookupTableAccounts, memo, + programId, }), ], }).compileToV0Message(); diff --git a/sdk/multisig/src/transactions/vaultTransactionExecute.ts b/sdk/multisig/src/transactions/vaultTransactionExecute.ts index c8034edc..ad9c526b 100644 --- a/sdk/multisig/src/transactions/vaultTransactionExecute.ts +++ b/sdk/multisig/src/transactions/vaultTransactionExecute.ts @@ -17,6 +17,7 @@ export async function vaultTransactionExecute({ multisigPda, transactionIndex, member, + programId, }: { connection: Connection; blockhash: string; @@ -24,6 +25,7 @@ export async function vaultTransactionExecute({ multisigPda: PublicKey; transactionIndex: bigint; member: PublicKey; + programId?: PublicKey; }): Promise { const { instruction, lookupTableAccounts } = await instructions.vaultTransactionExecute({ @@ -31,6 +33,7 @@ export async function vaultTransactionExecute({ multisigPda, member, transactionIndex, + programId, }); const message = new TransactionMessage({ diff --git a/sdk/multisig/src/utils.ts b/sdk/multisig/src/utils.ts index d155a9e4..1c2cde73 100644 --- a/sdk/multisig/src/utils.ts +++ b/sdk/multisig/src/utils.ts @@ -150,12 +150,14 @@ export async function accountsForTransactionExecute({ vaultPda, message, ephemeralSignerBumps, + programId, }: { connection: Connection; message: VaultTransactionMessage; ephemeralSignerBumps: number[]; vaultPda: PublicKey; transactionPda: PublicKey; + programId?: PublicKey; }): Promise<{ /** Account metas used in the `message`. */ accountMetas: AccountMeta[]; @@ -167,6 +169,7 @@ export async function accountsForTransactionExecute({ return getEphemeralSignerPda({ transactionPda, ephemeralSignerIndex: additionalSignerIndex, + programId, })[0]; } ); diff --git a/test-program-keypair.json b/test-program-keypair.json new file mode 100644 index 00000000..c2aa4086 --- /dev/null +++ b/test-program-keypair.json @@ -0,0 +1 @@ +[149,119,70,75,45,22,123,188,187,220,178,197,40,225,179,132,47,190,7,63,9,221,4,42,82,164,0,233,28,254,168,252,237,101,90,99,90,225,153,19,150,14,112,117,39,184,124,3,6,215,40,129,144,226,241,237,44,118,135,253,189,190,158,104] \ No newline at end of file diff --git a/tests/suites/examples/batch-sol-transfer.ts b/tests/suites/examples/batch-sol-transfer.ts index a2a12c18..6bcfab07 100644 --- a/tests/suites/examples/batch-sol-transfer.ts +++ b/tests/suites/examples/batch-sol-transfer.ts @@ -14,12 +14,15 @@ import { createTestTransferInstruction, generateFundedKeypair, generateMultisigMembers, + getTestProgramId, range, TestMembers, } from "../../utils"; const { Multisig, Proposal } = multisig.accounts; +const programId = getTestProgramId(); + describe("Examples / Batch SOL Transfer", () => { const connection = createLocalhostConnection(); @@ -37,6 +40,7 @@ describe("Examples / Batch SOL Transfer", () => { members, threshold: 2, timeLock: 0, + programId, }); let multisigAccount = await Multisig.fromAccountAddress( @@ -51,12 +55,14 @@ describe("Examples / Batch SOL Transfer", () => { const [proposalPda] = multisig.getProposalPda({ multisigPda, transactionIndex: batchIndex, + programId, }); // Default vault, index 0. const [vaultPda] = multisig.getVaultPda({ multisigPda, index: 0, + programId, }); // Prepare transactions for the batch. @@ -156,6 +162,7 @@ describe("Examples / Batch SOL Transfer", () => { batchIndex, vaultIndex, memo: "Distribute funds to members", + programId, }); await connection.confirmTransaction(signature); @@ -167,6 +174,7 @@ describe("Examples / Batch SOL Transfer", () => { transactionIndex: batchIndex, creator: members.proposer, isDraft: true, + programId, }); await connection.confirmTransaction(signature); @@ -187,6 +195,7 @@ describe("Examples / Batch SOL Transfer", () => { ephemeralSigners: 0, transactionMessage: message, addressLookupTableAccounts, + programId, }); await connection.confirmTransaction(signature); } @@ -198,6 +207,7 @@ describe("Examples / Batch SOL Transfer", () => { multisigPda, member: members.proposer, transactionIndex: batchIndex, + programId, }); await connection.confirmTransaction(signature); @@ -209,6 +219,7 @@ describe("Examples / Batch SOL Transfer", () => { member: members.voter, transactionIndex: batchIndex, memo: "LGTM", + programId, }); await connection.confirmTransaction(signature); @@ -220,6 +231,7 @@ describe("Examples / Batch SOL Transfer", () => { member: members.almighty, transactionIndex: batchIndex, memo: "LGTM too", + programId, }); await connection.confirmTransaction(signature); @@ -240,6 +252,7 @@ describe("Examples / Batch SOL Transfer", () => { member: members.executor, batchIndex, transactionIndex, + programId, }); await connection.confirmTransaction(signature); } diff --git a/tests/suites/examples/create-mint.ts b/tests/suites/examples/create-mint.ts index afcf0d85..c7441bd8 100644 --- a/tests/suites/examples/create-mint.ts +++ b/tests/suites/examples/create-mint.ts @@ -12,11 +12,14 @@ import { createAutonomousMultisig, createLocalhostConnection, generateMultisigMembers, + getTestProgramId, TestMembers, } from "../../utils"; const { Multisig } = multisig.accounts; +const programId = getTestProgramId(); + describe("Examples / Create Mint", () => { const connection = createLocalhostConnection(); @@ -31,6 +34,7 @@ describe("Examples / Create Mint", () => { members, threshold: 2, timeLock: 0, + programId, }); let multisigAccount = await Multisig.fromAccountAddress( @@ -44,12 +48,14 @@ describe("Examples / Create Mint", () => { const [transactionPda] = multisig.getTransactionPda({ multisigPda, index: transactionIndex, + programId, }); // Default vault, index 0. const [vaultPda] = multisig.getVaultPda({ multisigPda, index: 0, + programId, }); const lamportsForMintRent = await getMinimumBalanceForRentExemptMint( @@ -68,6 +74,7 @@ describe("Examples / Create Mint", () => { const [mintPda, mintBump] = multisig.getEphemeralSignerPda({ transactionPda, ephemeralSignerIndex: 0, + programId, }); const testTransactionMessage = new TransactionMessage({ @@ -102,6 +109,7 @@ describe("Examples / Create Mint", () => { ephemeralSigners: 1, transactionMessage: testTransactionMessage, memo: "Create new mint", + programId, }); await connection.confirmTransaction(signature); @@ -112,6 +120,7 @@ describe("Examples / Create Mint", () => { multisigPda, transactionIndex, creator: members.voter, + programId, }); await connection.confirmTransaction(signature); @@ -123,6 +132,7 @@ describe("Examples / Create Mint", () => { transactionIndex, member: members.voter, memo: "LGTM", + programId, }); await connection.confirmTransaction(signature); @@ -134,6 +144,7 @@ describe("Examples / Create Mint", () => { transactionIndex, member: members.almighty, memo: "LGTM too", + programId, }); await connection.confirmTransaction(signature); @@ -146,6 +157,7 @@ describe("Examples / Create Mint", () => { member: members.executor.publicKey, signers: [members.executor], sendOptions: { skipPreflight: true }, + programId, }); await connection.confirmTransaction(signature); diff --git a/tests/suites/examples/immediate-execution.ts b/tests/suites/examples/immediate-execution.ts index 6eb33b01..43bcdbf8 100644 --- a/tests/suites/examples/immediate-execution.ts +++ b/tests/suites/examples/immediate-execution.ts @@ -5,11 +5,14 @@ import { createAutonomousMultisig, createLocalhostConnection, generateMultisigMembers, + getTestProgramId, TestMembers, } from "../../utils"; const { Multisig } = multisig.accounts; +const programId = getTestProgramId(); + /** * If user can sign a transaction with enough member keys to reach the threshold, * they can batch all multisig instructions required to create, approve and execute the multisig transaction @@ -29,6 +32,7 @@ describe("Examples / Immediate Execution", () => { members, threshold: 1, timeLock: 0, + programId, }); const transactionIndex = 1n; @@ -39,17 +43,20 @@ describe("Examples / Immediate Execution", () => { creator: members.almighty.publicKey, // Change threshold to 2. actions: [{ __kind: "ChangeThreshold", newThreshold: 2 }], + programId, }); const createProposalIx = multisig.instructions.proposalCreate({ multisigPda, transactionIndex, creator: members.almighty.publicKey, + programId, }); const approveProposalIx = multisig.instructions.proposalApprove({ multisigPda, transactionIndex, member: members.almighty.publicKey, + programId, }); const executeTransactionIx = multisig.instructions.configTransactionExecute( @@ -58,6 +65,7 @@ describe("Examples / Immediate Execution", () => { transactionIndex, member: members.almighty.publicKey, rentPayer: members.almighty.publicKey, + programId, } ); diff --git a/tests/suites/examples/spending-limits.ts b/tests/suites/examples/spending-limits.ts index 61ae6d99..3cc41a5b 100644 --- a/tests/suites/examples/spending-limits.ts +++ b/tests/suites/examples/spending-limits.ts @@ -21,6 +21,7 @@ import { createLocalhostConnection, generateFundedKeypair, generateMultisigMembers, + getTestProgramId, isCloseToNow, TestMembers, } from "../../utils"; @@ -28,6 +29,8 @@ import { const { SpendingLimit } = multisig.accounts; const { Period } = multisig.types; +const programId = getTestProgramId(); + describe("Examples / Spending Limits", () => { const connection = createLocalhostConnection(); @@ -45,6 +48,7 @@ describe("Examples / Spending Limits", () => { members, threshold: 1, timeLock: 0, + programId, }) )[0]; @@ -67,6 +71,7 @@ describe("Examples / Spending Limits", () => { const [vaultPda] = multisig.getVaultPda({ multisigPda, index: solSpendingLimitParams.vaultIndex, + programId, }); let signature = await connection.requestAirdrop( vaultPda, @@ -163,16 +168,19 @@ describe("Examples / Spending Limits", () => { ...splSpendingLimitParams, }, ], + programId, }), multisig.instructions.proposalCreate({ multisigPda, transactionIndex, creator: members.almighty.publicKey, + programId, }), multisig.instructions.proposalApprove({ multisigPda, transactionIndex, member: members.almighty.publicKey, + programId, }), ], }).compileToV0Message(); @@ -194,12 +202,14 @@ describe("Examples / Spending Limits", () => { multisig.getSpendingLimitPda({ multisigPda, createKey: solSpendingLimitParams.createKey, + programId, }); const [splSpendingLimitPda, splSpendingLimitBump] = multisig.getSpendingLimitPda({ multisigPda, createKey: splSpendingLimitParams.createKey, + programId, }); // Execute the Config Transaction which will create the Spending Limit. @@ -212,6 +222,7 @@ describe("Examples / Spending Limits", () => { member: members.executor, rentPayer: members.executor, spendingLimits: [solSpendingLimitPda, splSpendingLimitPda], + programId, }) .catch((err) => { console.log(err.logs); @@ -276,6 +287,7 @@ describe("Examples / Spending Limits", () => { const [solSpendingLimitPda] = multisig.getSpendingLimitPda({ multisigPda, createKey: solSpendingLimitParams.createKey, + programId, }); const signature = await multisig.rpc @@ -297,6 +309,7 @@ describe("Examples / Spending Limits", () => { destination: solSpendingLimitParams.destinations[0], // You can optionally add a memo. memo: "Using my allowance!", + programId, }) .catch((err) => { console.log(err.logs); @@ -327,6 +340,7 @@ describe("Examples / Spending Limits", () => { amount: 1, decimals: 9, destination: solSpendingLimitParams.destinations[0], + programId, }), /Spending limit exceeded/ ); @@ -348,6 +362,7 @@ describe("Examples / Spending Limits", () => { const [splSpendingLimitPda] = multisig.getSpendingLimitPda({ multisigPda, createKey: splSpendingLimitParams.createKey, + programId, }); let signature = await multisig.rpc @@ -369,6 +384,7 @@ describe("Examples / Spending Limits", () => { tokenProgram: TOKEN_PROGRAM_ID, // You can optionally add a memo. memo: "Using my allowance!", + programId, }) .catch((err) => { console.log(err.logs); @@ -400,6 +416,7 @@ describe("Examples / Spending Limits", () => { decimals: 6, destination, tokenProgram: TOKEN_PROGRAM_ID, + programId, }), /Spending limit exceeded/ ); @@ -409,10 +426,12 @@ describe("Examples / Spending Limits", () => { const [solSpendingLimitPda] = multisig.getSpendingLimitPda({ multisigPda, createKey: solSpendingLimitParams.createKey, + programId, }); const [splSpendingLimitPda] = multisig.getSpendingLimitPda({ multisigPda, createKey: splSpendingLimitParams.createKey, + programId, }); const transactionIndex = 2n; @@ -436,16 +455,19 @@ describe("Examples / Spending Limits", () => { spendingLimit: splSpendingLimitPda, }, ], + programId, }), multisig.instructions.proposalCreate({ multisigPda, transactionIndex, creator: members.almighty.publicKey, + programId, }), multisig.instructions.proposalApprove({ multisigPda, transactionIndex, member: members.almighty.publicKey, + programId, }), ], }).compileToV0Message(); @@ -473,6 +495,7 @@ describe("Examples / Spending Limits", () => { member: members.executor, rentPayer: members.executor, spendingLimits: [solSpendingLimitPda, splSpendingLimitPda], + programId, }) .catch((err) => { console.log(err.logs); diff --git a/tests/suites/multisig-sdk.ts b/tests/suites/multisig-sdk.ts index dc531c4d..988a9a00 100644 --- a/tests/suites/multisig-sdk.ts +++ b/tests/suites/multisig-sdk.ts @@ -6,6 +6,8 @@ import { } from "@solana/web3.js"; import * as multisig from "@sqds/multisig"; import * as assert from "assert"; +import * as path from "path"; +import { readFileSync } from "fs"; import { createAutonomousMultisig, createControlledMultisig, @@ -13,6 +15,7 @@ import { createTestTransferInstruction, generateFundedKeypair, generateMultisigMembers, + getTestProgramId, isCloseToNow, TestMembers, } from "../utils"; @@ -22,6 +25,8 @@ const { Multisig, VaultTransaction, ConfigTransaction, Proposal, Batch } = multisig.accounts; const { Permission, Permissions } = multisig.types; +const programId = getTestProgramId(); + describe("Multisig SDK", () => { const connection = createLocalhostConnection(); @@ -38,6 +43,7 @@ describe("Multisig SDK", () => { const createKey = Keypair.generate(); const [multisigPda] = multisig.getMultisigPda({ createKey: createKey.publicKey, + programId, }); await assert.rejects( @@ -61,6 +67,7 @@ describe("Multisig SDK", () => { ], createKey, sendOptions: { skipPreflight: true }, + programId, }), /Found multiple members with the same pubkey/ ); @@ -72,6 +79,7 @@ describe("Multisig SDK", () => { const createKey = Keypair.generate(); const [multisigPda] = multisig.getMultisigPda({ createKey: createKey.publicKey, + programId, }); const tx = multisig.transactions.multisigCreate({ @@ -92,6 +100,7 @@ describe("Multisig SDK", () => { permissions: Permissions.all(), }, ], + programId, }); // Missing signature from `createKey`. @@ -109,6 +118,7 @@ describe("Multisig SDK", () => { const createKey = Keypair.generate(); const [multisigPda] = multisig.getMultisigPda({ createKey: createKey.publicKey, + programId, }); await assert.rejects( @@ -123,6 +133,7 @@ describe("Multisig SDK", () => { threshold: 1, members: [], sendOptions: { skipPreflight: true }, + programId, }), /Members don't include any proposers/ ); @@ -135,6 +146,7 @@ describe("Multisig SDK", () => { const createKey = Keypair.generate(); const [multisigPda] = multisig.getMultisigPda({ createKey: createKey.publicKey, + programId, }); await assert.rejects( @@ -156,6 +168,7 @@ describe("Multisig SDK", () => { }, ], sendOptions: { skipPreflight: true }, + programId, }), /Member has unknown permission/ ); @@ -170,6 +183,7 @@ describe("Multisig SDK", () => { const createKey = Keypair.generate(); const [multisigPda] = multisig.getMultisigPda({ createKey: createKey.publicKey, + programId, }); await assert.rejects( @@ -187,6 +201,7 @@ describe("Multisig SDK", () => { permissions: Permissions.all(), })), sendOptions: { skipPreflight: true }, + programId, }), /Invalid threshold, must be between 1 and number of members/ ); @@ -198,6 +213,7 @@ describe("Multisig SDK", () => { const createKey = Keypair.generate(); const [multisigPda] = multisig.getMultisigPda({ createKey: createKey.publicKey, + programId, }); await assert.rejects( @@ -233,6 +249,7 @@ describe("Multisig SDK", () => { // Threshold is 3, but there are only 2 voters. threshold: 3, sendOptions: { skipPreflight: true }, + programId, }), /Invalid threshold, must be between 1 and number of members with Vote permission/ ); @@ -247,6 +264,7 @@ describe("Multisig SDK", () => { members, threshold: 2, timeLock: 0, + programId, }); const multisigAccount = await Multisig.fromAccountAddress( @@ -308,6 +326,7 @@ describe("Multisig SDK", () => { members, threshold: 2, timeLock: 0, + programId, }); const multisigAccount = await Multisig.fromAccountAddress( @@ -349,6 +368,7 @@ describe("Multisig SDK", () => { members, threshold: 2, timeLock: 0, + programId, }) )[0]; }); @@ -370,6 +390,7 @@ describe("Multisig SDK", () => { }, signers: [configAuthority], sendOptions: { skipPreflight: true }, + programId, }), /Found multiple members with the same pubkey/ ); @@ -390,6 +411,7 @@ describe("Multisig SDK", () => { /* missing authority signature */ ], sendOptions: { skipPreflight: true }, + programId, }), /Transaction signature verification failure/ ); @@ -408,6 +430,7 @@ describe("Multisig SDK", () => { newMember, signers: [fakeAuthority], sendOptions: { skipPreflight: true }, + programId, }), /Attempted to perform an unauthorized action/ ); @@ -442,6 +465,7 @@ describe("Multisig SDK", () => { memo: "Adding my good friend to the multisig", signers: [configAuthority], sendOptions: { skipPreflight: true }, + programId, }); await connection.confirmTransaction(signature); @@ -481,6 +505,7 @@ describe("Multisig SDK", () => { newMember: newMember2, signers: [configAuthority], sendOptions: { skipPreflight: true }, + programId, }); await connection.confirmTransaction(signature); // Re-fetch the multisig account. @@ -534,6 +559,7 @@ describe("Multisig SDK", () => { members, threshold: 2, timeLock: 0, + programId, }) )[0]; }); @@ -548,6 +574,7 @@ describe("Multisig SDK", () => { feePayer, multisigPda, vaultIndex: 1, + programId, }); await connection.confirmTransaction(createBatchSignature); }); @@ -567,6 +594,7 @@ describe("Multisig SDK", () => { members, threshold: 1, timeLock: 0, + programId, }) )[0]; }); @@ -580,6 +608,7 @@ describe("Multisig SDK", () => { transactionIndex: 1n, creator: members.proposer.publicKey, actions: [{ __kind: "SetTimeLock", newTimeLock: 300 }], + programId, }) ), /Attempted to perform an unauthorized action/; @@ -593,6 +622,7 @@ describe("Multisig SDK", () => { transactionIndex: 1n, creator: members.proposer.publicKey, actions: [{ __kind: "SetTimeLock", newTimeLock: 300 }], + programId, }); await connection.confirmTransaction(signature); }); @@ -615,6 +645,7 @@ describe("Multisig SDK", () => { threshold: 1, configAuthority: configAuthority.publicKey, timeLock: 0, + programId, }) )[0]; }); @@ -628,6 +659,7 @@ describe("Multisig SDK", () => { configAuthority: wrongConfigAuthority.publicKey, timeLock: 300, signers: [feePayer, wrongConfigAuthority], + programId, }) ), /Attempted to perform an unauthorized action/; @@ -642,63 +674,20 @@ describe("Multisig SDK", () => { configAuthority: configAuthority.publicKey, timeLock: 300, signers: [feePayer, configAuthority], + programId, }); await connection.confirmTransaction(signature); }); }); describe("multisig_remove_member", () => { - let multisigPda: PublicKey; - let configAuthority: Keypair; - let wrongConfigAuthority: Keypair; - before(async () => { - configAuthority = await generateFundedKeypair(connection); - wrongConfigAuthority = await generateFundedKeypair(connection); - - // Create new controlled multisig. - multisigPda = ( - await createControlledMultisig({ - connection, - createKey: Keypair.generate(), - members, - threshold: 1, - configAuthority: configAuthority.publicKey, - timeLock: 0, - }) - )[0]; - }); - it("error: invalid authority", async () => { - const feePayer = await generateFundedKeypair(connection); - await assert.rejects( - multisig.rpc.multisigSetTimeLock({ - connection, - feePayer, - multisigPda: multisigPda, - configAuthority: wrongConfigAuthority.publicKey, - timeLock: 300, - signers: [feePayer, wrongConfigAuthority], - }) - ), - /Attempted to perform an unauthorized action/; - }); - - it("set `time_lock` for the controlled multisig", async () => { - const feePayer = await generateFundedKeypair(connection); - const signature = await multisig.rpc.multisigSetTimeLock({ - connection, - feePayer, - multisigPda: multisigPda, - configAuthority: configAuthority.publicKey, - timeLock: 300, - signers: [feePayer, configAuthority], - }); - await connection.confirmTransaction(signature); - }); + it("error: invalid authority"); }); describe("multisig_set_config_authority", () => { let multisigPda: PublicKey; let configAuthority: Keypair; + before(async () => { configAuthority = await generateFundedKeypair(connection); @@ -711,9 +700,11 @@ describe("Multisig SDK", () => { threshold: 1, timeLock: 0, configAuthority: configAuthority.publicKey, + programId, }) )[0]; }); + it("error: invalid authority", async () => { const feePayer = await generateFundedKeypair(connection); await assert.rejects( @@ -723,6 +714,7 @@ describe("Multisig SDK", () => { multisigPda: multisigPda, configAuthority: members.voter.publicKey, newConfigAuthority: members.voter.publicKey, + programId, }) ), /Attempted to perform an unauthorized action/; @@ -737,6 +729,7 @@ describe("Multisig SDK", () => { configAuthority: configAuthority.publicKey, newConfigAuthority: members.voter.publicKey, signers: [feePayer, configAuthority], + programId, }); await connection.confirmTransaction(signature); }); @@ -745,6 +738,7 @@ describe("Multisig SDK", () => { describe("multisig_change_threshold", () => { let multisigPda: PublicKey; let configAuthority: Keypair; + before(async () => { configAuthority = await generateFundedKeypair(connection); @@ -756,9 +750,11 @@ describe("Multisig SDK", () => { members, threshold: 1, timeLock: 0, + programId, }) )[0]; }); + it("error: invalid authority", async () => { const feePayer = await generateFundedKeypair(connection); await assert.rejects( @@ -769,6 +765,7 @@ describe("Multisig SDK", () => { transactionIndex: 1n, creator: members.proposer.publicKey, actions: [{ __kind: "ChangeThreshold", newThreshold: 1 }], + programId, }) ), /Attempted to perform an unauthorized action/; @@ -785,6 +782,7 @@ describe("Multisig SDK", () => { creator: members.proposer.publicKey, actions: [{ __kind: "ChangeThreshold", newThreshold: 10 }], signers: [members.proposer, feePayer], + programId, }); await connection.confirmTransaction(configTransactionCreateSignature); @@ -795,6 +793,7 @@ describe("Multisig SDK", () => { feePayer, transactionIndex: 1n, isDraft: false, + programId, }); await connection.confirmTransaction(createProposalSignature); @@ -804,6 +803,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex: 1n, member: members.voter, + programId, }); await connection.confirmTransaction(approveSignature); @@ -815,6 +815,7 @@ describe("Multisig SDK", () => { transactionIndex: 1n, member: members.executor, rentPayer: feePayer, + programId, }), /Invalid threshold, must be between 1 and number of members with Vote permission/ ); @@ -828,6 +829,7 @@ describe("Multisig SDK", () => { transactionIndex: 2n, creator: members.proposer.publicKey, actions: [{ __kind: "ChangeThreshold", newThreshold: 1 }], + programId, }); await connection.confirmTransaction(signature); }); @@ -847,6 +849,7 @@ describe("Multisig SDK", () => { members, threshold: 2, timeLock: 0, + programId, }) )[0]; }); @@ -862,6 +865,7 @@ describe("Multisig SDK", () => { actions: [ { __kind: "RemoveMember", oldMember: members.voter.publicKey }, ], + programId, }) ), /Attempted to perform an unauthorized action/; @@ -877,6 +881,7 @@ describe("Multisig SDK", () => { actions: [ { __kind: "RemoveMember", oldMember: members.voter.publicKey }, ], + programId, }); await connection.confirmTransaction(signature); }); @@ -897,6 +902,7 @@ describe("Multisig SDK", () => { members, threshold: 1, timeLock: 0, + programId, }) )[0]; }); @@ -919,6 +925,7 @@ describe("Multisig SDK", () => { }, }, ], + programId, }) ), /Attempted to perform an unauthorized action/; @@ -941,6 +948,7 @@ describe("Multisig SDK", () => { }, }, ], + programId, }); await connection.confirmTransaction(signature); // create the proposal @@ -951,6 +959,7 @@ describe("Multisig SDK", () => { feePayer, transactionIndex: 1n, isDraft: false, + programId, }); await connection.confirmTransaction(createProposalSignature); @@ -960,6 +969,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex: 1n, member: members.voter, + programId, }); await connection.confirmTransaction(approveSignature); }); @@ -973,6 +983,7 @@ describe("Multisig SDK", () => { transactionIndex: 1n, member: members.executor, rentPayer: fundedKeypair, + programId, }); await connection.confirmTransaction(signature); }); @@ -993,6 +1004,7 @@ describe("Multisig SDK", () => { members, threshold: 1, timeLock: 0, + programId, }) )[0]; }); @@ -1005,6 +1017,7 @@ describe("Multisig SDK", () => { threshold: 2, timeLock: 0, createKey: Keypair.generate(), + programId, }); }); }); @@ -1023,6 +1036,7 @@ describe("Multisig SDK", () => { members, threshold: 2, timeLock: 0, + programId, }) )[0]; @@ -1033,6 +1047,7 @@ describe("Multisig SDK", () => { spendingLimitPda = multisig.getSpendingLimitPda({ multisigPda: controlledMultisigPda, createKey: spendingLimitCreateKey, + programId, })[0]; }); @@ -1055,6 +1070,7 @@ describe("Multisig SDK", () => { vaultIndex: 1, signers: [feePayer, members.voter], sendOptions: { skipPreflight: true }, + programId, }), /Attempted to perform an unauthorized action/ ); @@ -1077,6 +1093,7 @@ describe("Multisig SDK", () => { vaultIndex: 1, signers: [feePayer, members.almighty], sendOptions: { skipPreflight: true }, + programId, }); await connection.confirmTransaction(signature); @@ -1097,6 +1114,7 @@ describe("Multisig SDK", () => { members, threshold: 2, timeLock: 0, + programId, }) )[0]; @@ -1107,6 +1125,7 @@ describe("Multisig SDK", () => { spendingLimitPda = multisig.getSpendingLimitPda({ multisigPda: controlledMultisigPda, createKey: spendingLimitCreateKey, + programId, })[0]; const signature = await multisig.rpc.multisigAddSpendingLimit({ @@ -1125,6 +1144,7 @@ describe("Multisig SDK", () => { vaultIndex: 1, signers: [feePayer, members.almighty], sendOptions: { skipPreflight: true }, + programId, }); await connection.confirmTransaction(signature); @@ -1141,13 +1161,13 @@ describe("Multisig SDK", () => { feePayer: feePayer, rentCollector: members.voter.publicKey, signers: [feePayer, members.voter], - sendOptions: { - skipPreflight: true, - }, + sendOptions: { skipPreflight: true }, + programId, }), /Attempted to perform an unauthorized action/ ); }); + it("error: Spending Limit doesn't belong to the multisig", async () => { const wrongControlledMultisigPda = ( await createControlledMultisig({ @@ -1156,13 +1176,17 @@ describe("Multisig SDK", () => { members, threshold: 2, timeLock: 0, + programId, }) )[0]; + const wrongCreateKey = Keypair.generate().publicKey; const wrongSpendingLimitPda = multisig.getSpendingLimitPda({ multisigPda: wrongControlledMultisigPda, createKey: wrongCreateKey, + programId, })[0]; + const addSpendingLimitSignature = await multisig.rpc.multisigAddSpendingLimit({ connection, @@ -1180,6 +1204,7 @@ describe("Multisig SDK", () => { vaultIndex: 1, signers: [feePayer, members.almighty], sendOptions: { skipPreflight: true }, + programId, }); await connection.confirmTransaction(addSpendingLimitSignature); @@ -1193,9 +1218,8 @@ describe("Multisig SDK", () => { feePayer: feePayer, rentCollector: members.almighty.publicKey, signers: [feePayer, members.almighty], - sendOptions: { - skipPreflight: true, - }, + sendOptions: { skipPreflight: true }, + programId, }), /Invalid account provided/ ); @@ -1211,6 +1235,7 @@ describe("Multisig SDK", () => { rentCollector: members.almighty.publicKey, sendOptions: { skipPreflight: true }, signers: [feePayer, members.almighty], + programId, }); await connection.confirmTransaction(signature); }); @@ -1228,6 +1253,7 @@ describe("Multisig SDK", () => { members, threshold: 2, timeLock: 0, + programId, }) )[0]; @@ -1239,6 +1265,7 @@ describe("Multisig SDK", () => { members, threshold: 2, timeLock: 0, + programId, }) )[0]; }); @@ -1253,6 +1280,7 @@ describe("Multisig SDK", () => { transactionIndex: 1n, creator: members.proposer.publicKey, actions: [{ __kind: "ChangeThreshold", newThreshold: 3 }], + programId, }), /Instruction not supported for controlled multisig/ ); @@ -1268,6 +1296,7 @@ describe("Multisig SDK", () => { transactionIndex: 1n, creator: members.proposer.publicKey, actions: [], + programId, }), /Config transaction must have at least one action/ ); @@ -1285,6 +1314,7 @@ describe("Multisig SDK", () => { transactionIndex: 1n, creator: nonMember.publicKey, actions: [{ __kind: "ChangeThreshold", newThreshold: 3 }], + programId, }), /Provided pubkey is not a member of multisig/ ); @@ -1301,6 +1331,7 @@ describe("Multisig SDK", () => { // Voter is not authorized to initialize config transactions. creator: members.voter.publicKey, actions: [{ __kind: "ChangeThreshold", newThreshold: 3 }], + programId, }), /Attempted to perform an unauthorized action/ ); @@ -1316,6 +1347,7 @@ describe("Multisig SDK", () => { transactionIndex, creator: members.proposer.publicKey, actions: [{ __kind: "ChangeThreshold", newThreshold: 1 }], + programId, }); await connection.confirmTransaction(signature); @@ -1333,6 +1365,7 @@ describe("Multisig SDK", () => { const [transactionPda, transactionBump] = multisig.getTransactionPda({ multisigPda: autonomousMultisigPda, index: transactionIndex, + programId, }); const configTransactionAccount = await ConfigTransaction.fromAccountAddress(connection, transactionPda); @@ -1374,6 +1407,7 @@ describe("Multisig SDK", () => { members, threshold: 2, timeLock: 0, + programId, }) )[0]; }); @@ -1385,6 +1419,7 @@ describe("Multisig SDK", () => { const [vaultPda] = multisig.getVaultPda({ multisigPda, index: 0, + programId, }); // Test transfer instruction. @@ -1410,6 +1445,7 @@ describe("Multisig SDK", () => { vaultIndex: 0, ephemeralSigners: 0, transactionMessage: testTransferMessage, + programId, }), /Provided pubkey is not a member of multisig/ ); @@ -1420,6 +1456,7 @@ describe("Multisig SDK", () => { const [vaultPda] = multisig.getVaultPda({ multisigPda, index: 0, + programId, }); // Test transfer instruction. @@ -1445,6 +1482,7 @@ describe("Multisig SDK", () => { vaultIndex: 0, ephemeralSigners: 0, transactionMessage: testTransferMessage, + programId, }), /Attempted to perform an unauthorized action/ ); @@ -1457,6 +1495,7 @@ describe("Multisig SDK", () => { const [vaultPda, vaultBump] = multisig.getVaultPda({ multisigPda, index: 0, + programId, }); // Test transfer instruction (2x) @@ -1487,6 +1526,7 @@ describe("Multisig SDK", () => { ephemeralSigners: 0, transactionMessage: testTransferMessage, memo: "Transfer 2 SOL to a test account", + programId, }); await connection.confirmTransaction(signature); @@ -1502,6 +1542,7 @@ describe("Multisig SDK", () => { const [transactionPda, transactionBump] = multisig.getTransactionPda({ multisigPda, index: transactionIndex, + programId, }); const transactionAccount = await VaultTransaction.fromAccountAddress( connection, @@ -1544,6 +1585,7 @@ describe("Multisig SDK", () => { members, threshold: 2, timeLock: 0, + programId, }) )[0]; @@ -1560,6 +1602,7 @@ describe("Multisig SDK", () => { transactionIndex: 1n, creator: members.proposer.publicKey, actions: [{ __kind: "AddMember", newMember }], + programId, }); await connection.confirmTransaction(signature); }); @@ -1575,6 +1618,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex, creator: members.almighty, + programId, }), /Invalid transaction index/ ); @@ -1593,6 +1637,7 @@ describe("Multisig SDK", () => { transactionIndex, creator: members.proposer.publicKey, actions: [{ __kind: "ChangeThreshold", newThreshold: 1 }], + programId, }); await connection.confirmTransaction(signature); @@ -1604,6 +1649,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex, creator: nonMember, + programId, }), /Provided pubkey is not a member of multisig/ ); @@ -1620,6 +1666,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex, creator: members.executor, + programId, }), /Attempted to perform an unauthorized action/ ); @@ -1637,6 +1684,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex, creator: members.voter, + programId, }); await connection.confirmTransaction(signature); @@ -1644,6 +1692,7 @@ describe("Multisig SDK", () => { const [proposalPda, proposalBump] = multisig.getProposalPda({ multisigPda, transactionIndex, + programId, }); const proposalAccount = await Proposal.fromAccountAddress( connection, @@ -1675,6 +1724,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex: 2n, member: members.voter, + programId, }); await connection.confirmTransaction(signature); @@ -1684,6 +1734,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex: 2n, member: members.almighty, + programId, }); await connection.confirmTransaction(signature); @@ -1695,6 +1746,7 @@ describe("Multisig SDK", () => { transactionIndex: 2n, member: members.almighty, rentPayer: members.almighty, + programId, }); await connection.confirmTransaction(signature); @@ -1710,6 +1762,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex: 1n, creator: members.almighty, + programId, }), /Proposal is stale/ ); @@ -1731,6 +1784,7 @@ describe("Multisig SDK", () => { members, threshold: 2, timeLock: 0, + programId, }) )[0]; @@ -1744,6 +1798,7 @@ describe("Multisig SDK", () => { transactionIndex, creator: members.proposer.publicKey, actions: [{ __kind: "ChangeThreshold", newThreshold: 1 }], + programId, }); await connection.confirmTransaction(signature); @@ -1754,6 +1809,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex, creator: members.proposer, + programId, }); await connection.confirmTransaction(signature); }); @@ -1772,6 +1828,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex, member: nonMember, + programId, }), /Provided pubkey is not a member of multisig/ ); @@ -1789,6 +1846,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex, member: members.executor, + programId, }), /Attempted to perform an unauthorized action/ ); @@ -1804,6 +1862,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex, member: members.voter, + programId, }); await connection.confirmTransaction(signature); @@ -1811,6 +1870,7 @@ describe("Multisig SDK", () => { const [proposalPda] = multisig.getProposalPda({ multisigPda, transactionIndex, + programId, }); const proposalAccount = await Proposal.fromAccountAddress( connection, @@ -1837,6 +1897,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex, member: members.voter, + programId, }), /Member already approved the transaction/ ); @@ -1852,6 +1913,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex, member: members.almighty, + programId, }); await connection.confirmTransaction(signature); @@ -1859,6 +1921,7 @@ describe("Multisig SDK", () => { const [proposalPda] = multisig.getProposalPda({ multisigPda, transactionIndex, + programId, }); const proposalAccount = await Proposal.fromAccountAddress( connection, @@ -1902,6 +1965,7 @@ describe("Multisig SDK", () => { members, threshold: 2, timeLock: 0, + programId, }) )[0]; @@ -1913,6 +1977,7 @@ describe("Multisig SDK", () => { transactionIndex: 1n, creator: members.proposer.publicKey, actions: [{ __kind: "ChangeThreshold", newThreshold: 1 }], + programId, }); await connection.confirmTransaction(signature); @@ -1924,6 +1989,7 @@ describe("Multisig SDK", () => { transactionIndex: 2n, creator: members.proposer.publicKey, actions: [{ __kind: "SetTimeLock", newTimeLock: 60 }], + programId, }); await connection.confirmTransaction(signature); @@ -1934,6 +2000,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex: 1n, creator: members.proposer, + programId, }); await connection.confirmTransaction(signature); @@ -1944,6 +2011,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex: 2n, creator: members.proposer, + programId, }); await connection.confirmTransaction(signature); @@ -1954,6 +2022,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex: 1n, member: members.voter, + programId, }); await connection.confirmTransaction(signature); signature = await multisig.rpc.proposalApprove({ @@ -1962,6 +2031,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex: 1n, member: members.almighty, + programId, }); await connection.confirmTransaction(signature); }); @@ -1978,6 +2048,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex, member: members.voter, + programId, }), /Invalid proposal status/ ); @@ -1986,6 +2057,7 @@ describe("Multisig SDK", () => { multisig.getProposalPda({ multisigPda, transactionIndex, + programId, })[0] ); assert.ok( @@ -2007,6 +2079,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex, member: nonMember, + programId, }), /Provided pubkey is not a member of multisig/ ); @@ -2024,6 +2097,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex, member: members.executor, + programId, }), /Attempted to perform an unauthorized action/ ); @@ -2045,6 +2119,7 @@ describe("Multisig SDK", () => { transactionIndex, member: members.voter, memo: "LGTM", + programId, }); await connection.confirmTransaction(signature); @@ -2052,6 +2127,7 @@ describe("Multisig SDK", () => { const [proposalPda] = multisig.getProposalPda({ multisigPda, transactionIndex, + programId, }); const proposalAccount = await Proposal.fromAccountAddress( connection, @@ -2086,6 +2162,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex, member: members.almighty, + programId, }), /Invalid proposal status/ ); @@ -2095,6 +2172,7 @@ describe("Multisig SDK", () => { multisig.getProposalPda({ multisigPda, transactionIndex, + programId, })[0] ); assert.ok( @@ -2122,6 +2200,7 @@ describe("Multisig SDK", () => { members, threshold: 2, timeLock: 0, + programId, }) )[0]; @@ -2133,6 +2212,7 @@ describe("Multisig SDK", () => { transactionIndex: 1n, creator: members.proposer.publicKey, actions: [{ __kind: "ChangeThreshold", newThreshold: 1 }], + programId, }); await connection.confirmTransaction(signature); @@ -2143,6 +2223,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex: 1n, creator: members.proposer, + programId, }); await connection.confirmTransaction(signature); @@ -2153,6 +2234,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex: 1n, member: members.voter, + programId, }); await connection.confirmTransaction(signature); signature = await multisig.rpc.proposalApprove({ @@ -2161,6 +2243,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex: 1n, member: members.almighty, + programId, }); await connection.confirmTransaction(signature); @@ -2168,6 +2251,7 @@ describe("Multisig SDK", () => { const [proposalPda] = multisig.getProposalPda({ multisigPda, transactionIndex: 1n, + programId, }); let proposalAccount = await Proposal.fromAccountAddress( connection, @@ -2188,12 +2272,14 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex, member: members.voter, + programId, }); await connection.confirmTransaction(signature); const proposalPda = multisig.getProposalPda({ multisigPda, transactionIndex, + programId, })[0]; let proposalAccount = await Proposal.fromAccountAddress( connection, @@ -2211,6 +2297,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex, member: members.almighty, + programId, }); await connection.confirmTransaction(signature); @@ -2236,6 +2323,7 @@ describe("Multisig SDK", () => { members, threshold: 2, timeLock: 0, + programId, }) )[0]; @@ -2243,6 +2331,7 @@ describe("Multisig SDK", () => { const [vaultPda, vaultBump] = multisig.getVaultPda({ multisigPda, index: 0, + programId, }); // Airdrop 2 SOL to the Vault, we'll need it for the test transfer instructions. @@ -2283,6 +2372,7 @@ describe("Multisig SDK", () => { ephemeralSigners: 0, transactionMessage: testTransferMessage, memo: "Transfer 2 SOL to a test account", + programId, }); await connection.confirmTransaction(signature); @@ -2293,6 +2383,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex, creator: members.proposer, + programId, }); await connection.confirmTransaction(signature); @@ -2303,6 +2394,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex, member: members.voter, + programId, }); await connection.confirmTransaction(signature); @@ -2313,6 +2405,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex, member: members.almighty, + programId, }); await connection.confirmTransaction(signature); }); @@ -2324,6 +2417,7 @@ describe("Multisig SDK", () => { const [transactionPda] = multisig.getTransactionPda({ multisigPda, index: transactionIndex, + programId, }); let transactionAccount = await VaultTransaction.fromAccountAddress( connection, @@ -2333,11 +2427,13 @@ describe("Multisig SDK", () => { const [proposalPda] = multisig.getProposalPda({ multisigPda, transactionIndex, + programId, }); const [vaultPda] = multisig.getVaultPda({ multisigPda, index: transactionAccount.vaultIndex, + programId, }); const preVaultBalance = await connection.getBalance(vaultPda); assert.strictEqual(preVaultBalance, 2 * LAMPORTS_PER_SOL); @@ -2350,6 +2446,7 @@ describe("Multisig SDK", () => { transactionIndex, member: members.executor.publicKey, signers: [members.executor], + programId, }); await connection.confirmTransaction(signature); @@ -2391,6 +2488,7 @@ describe("Multisig SDK", () => { members, threshold: 2, timeLock: 0, + programId, }) )[0]; @@ -2402,6 +2500,7 @@ describe("Multisig SDK", () => { transactionIndex: approvedTransactionIndex, creator: members.proposer.publicKey, actions: [{ __kind: "ChangeThreshold", newThreshold: 1 }], + programId, }); await connection.confirmTransaction(signature); @@ -2412,6 +2511,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex: approvedTransactionIndex, creator: members.proposer, + programId, }); await connection.confirmTransaction(signature); @@ -2422,6 +2522,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex: approvedTransactionIndex, member: members.voter, + programId, }); await connection.confirmTransaction(signature); @@ -2432,6 +2533,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex: approvedTransactionIndex, member: members.almighty, + programId, }); await connection.confirmTransaction(signature); @@ -2443,6 +2545,7 @@ describe("Multisig SDK", () => { transactionIndex: rejectedTransactionIndex, creator: members.proposer.publicKey, actions: [{ __kind: "ChangeThreshold", newThreshold: 3 }], + programId, }); await connection.confirmTransaction(signature); @@ -2453,6 +2556,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex: rejectedTransactionIndex, creator: members.proposer, + programId, }); await connection.confirmTransaction(signature); @@ -2464,6 +2568,7 @@ describe("Multisig SDK", () => { multisigPda, transactionIndex: rejectedTransactionIndex, member: members.voter, + programId, }); await connection.confirmTransaction(signature); }); @@ -2479,6 +2584,7 @@ describe("Multisig SDK", () => { transactionIndex, member: members.almighty, rentPayer: members.almighty, + programId, }); await connection.confirmTransaction(signature); @@ -2486,6 +2592,7 @@ describe("Multisig SDK", () => { const [proposalPda] = multisig.getProposalPda({ multisigPda, transactionIndex, + programId, }); const proposalAccount = await Proposal.fromAccountAddress( connection, @@ -2515,6 +2622,7 @@ describe("Multisig SDK", () => { transactionIndex: rejectedTransactionIndex, rentPayer: members.almighty, member: members.almighty, + programId, }), /Invalid proposal status/ ); @@ -2528,10 +2636,12 @@ describe("Multisig SDK", () => { const createKey = Keypair.generate(); const [multisigPda] = multisig.getMultisigPda({ createKey: createKey.publicKey, + programId, }); const [configAuthority] = multisig.getVaultPda({ multisigPda, index: 0, + programId, }); const multisigCreateArgs: Parameters< @@ -2550,6 +2660,7 @@ describe("Multisig SDK", () => { }, ], threshold: 1, + programId, }; const createMultisigTxWithoutMemo = diff --git a/tests/utils.ts b/tests/utils.ts index 85b25cbf..d88f2c74 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -6,9 +6,29 @@ import { SystemProgram, } from "@solana/web3.js"; import * as multisig from "@sqds/multisig"; +import { readFileSync } from "fs"; +import path from "path"; const { Permission, Permissions } = multisig.types; +export function getTestProgramId() { + const programKeypair = Keypair.fromSecretKey( + Buffer.from( + JSON.parse( + readFileSync( + path.join( + __dirname, + "../target/deploy/squads_multisig_program-keypair.json" + ), + "utf-8" + ) + ) + ) + ); + + return programKeypair.publicKey; +} + export type TestMembers = { almighty: Keypair; proposer: Keypair; @@ -52,17 +72,20 @@ export async function createAutonomousMultisig({ members, threshold, timeLock, + programId, }: { createKey?: Keypair; members: TestMembers; threshold: number; timeLock: number; connection: Connection; + programId: PublicKey; }) { const creator = await generateFundedKeypair(connection); const [multisigPda, multisigBump] = multisig.getMultisigPda({ createKey: createKey.publicKey, + programId, }); const signature = await multisig.rpc.multisigCreate({ @@ -89,6 +112,7 @@ export async function createAutonomousMultisig({ ], createKey: createKey, sendOptions: { skipPreflight: true }, + programId, }); await connection.confirmTransaction(signature); @@ -103,6 +127,7 @@ export async function createControlledMultisig({ members, threshold, timeLock, + programId, }: { createKey?: Keypair; configAuthority: PublicKey; @@ -110,11 +135,13 @@ export async function createControlledMultisig({ threshold: number; timeLock: number; connection: Connection; + programId: PublicKey; }) { const creator = await generateFundedKeypair(connection); const [multisigPda, multisigBump] = multisig.getMultisigPda({ createKey: createKey.publicKey, + programId, }); const signature = await multisig.rpc.multisigCreate({ @@ -141,6 +168,7 @@ export async function createControlledMultisig({ ], createKey: createKey, sendOptions: { skipPreflight: true }, + programId, }); await connection.confirmTransaction(signature);