@whetstone-research/doppler-sdk 1.0.15 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { transferAdminArgsCodec, swapExactInArgsCodec, sortPositionsByShares, sortPoolsByReserves, setRouteArgsCodec, setHookArgsCodec, setFeesArgsCodec, removeLiquidityArgsCodec, ratioToNumber, quoteToNumeraireArgsCodec, q64ToNumber, q64Mul, q64Div, positionDataCodec, poolExists, poolDataCodec, oracleStateDataCodec, oracleConsultArgsCodec, observationCodec, numberToQ64, minBigInt, maxBigInt, isqrt, isOracleStale, initializePoolArgsCodec, initializeOracleArgsCodec, initializeConfigArgsCodec, getTvl, getSwapQuoteExactOut, getSwapQuote, getSpotPrice1, getSpotPrice0, getRemoveLiquidityQuote, getPositionValue, getPositionAddressFromParams, getPoolByMints, getPoolAddressFromMints, getPendingFees, getOracleSpotPrices, getOracleForPool, getOracleDeviation, getOracleBufferStats, getOracleAge, getOracleAddressFromPool, getK, getAddLiquidityQuote, filterPoolsByMint, filterActivePositions, fetchUserPositions, fetchPositionsBatch, fetchPositionByParams, fetchPosition, fetchPoolsBatch, fetchPoolPositions, fetchPool, fetchOraclesBatch, fetchOracle, fetchAllPools, encodeTransferAdminArgs, encodeSwapExactInArgs, encodeSetRouteArgs, encodeSetHookArgs, encodeSetFeesArgs, encodeRemoveLiquidityArgs, encodeQuoteToNumeraireArgs, encodeOracleConsultArgs, encodeInstructionData, encodeInitializePoolArgs, encodeInitializeOracleArgs, encodeInitializeConfigArgs, encodeCreatePositionArgs, encodeCollectProtocolFeesArgs, encodeCollectFeesArgs, encodeAddLiquidityArgs, decodePosition, decodePool, decodeOracleState, decodeAmmConfig, createPositionArgsCodec, consultTwap, computePrice1Q64, computePrice0Q64, comparePoolAndOraclePrices, collectProtocolFeesArgsCodec, collectFeesArgsCodec, ceilDiv, calculateTwapNumber, calculateTwap, calculateAccruedFees, ammConfigDataCodec, addLiquidityArgsCodec } from '../chunk-NMTYI3TB.js';
2
2
  import { sortMints, getSwapAddresses, getProtocolFeePositionAddress, getPositionAddress, getPoolVault1Address, getPoolVault0Address, getPoolInitAddresses, getPoolAuthorityAddress, getPoolAddress, getOracleAddress, getLiquidityAddresses, getConfigAddress, CPMM_PROGRAM_ID, areMintsOrdered, TOKEN_METADATA_PROGRAM_ID, SEED_PROTOCOL_FEE_POSITION, SEED_POSITION, SEED_POOL, SEED_ORACLE, SEED_CONFIG, SEED_AUTHORITY, Q64_ONE, MAX_ORACLE_OBSERVATIONS, MAX_HOOK_ALLOWLIST, INSTRUCTION_DISCRIMINATORS, HOOK_NO_CHANGE, HF_REQUIRE_ORACLE, HF_FORWARD_READONLY_SIGNERS, HF_BEFORE_SWAP, HF_BEFORE_REMOVE_LIQ, HF_BEFORE_ADD_LIQ, HF_AFTER_SWAP, HF_AFTER_REMOVE_LIQ, HF_AFTER_ADD_LIQ, BPS_DENOM, ACCOUNT_VERSION, ACCOUNT_DISCRIMINATORS, TOKEN_PROGRAM_ADDRESS, SYSTEM_PROGRAM_ADDRESS } from '../chunk-TVBSIQIX.js';
3
3
  import { __export } from '../chunk-PZ5AY32C.js';
4
- import { getAddressCodec, getProgramDerivedAddress, fixEncoderSize, getBytesEncoder, transformEncoder, getStructEncoder, getU64Encoder, getU128Encoder, getBooleanEncoder, getStructDecoder, fixDecoderSize, getU64Decoder, getU128Decoder, getBooleanDecoder, getBytesDecoder, combineCodec, getAddressEncoder, SolanaError, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, getU16Encoder, getU8Encoder, getArrayEncoder, getAddressDecoder, getU16Decoder, getU8Decoder, getArrayDecoder, getU32Encoder, getU32Decoder, getOptionEncoder, getOptionDecoder, createNoopSigner, address, addEncoderSizePrefix, getUtf8Encoder, addDecoderSizePrefix, getUtf8Decoder, AccountRole, getStructCodec, getU64Codec, compressTransactionMessageUsingAddressLookupTables, mergeBytes, isProgramError, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, containsBytes, SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT, SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, assertIsInstructionWithAccounts } from '@solana/kit';
4
+ import { getAddressCodec, getProgramDerivedAddress, fixEncoderSize, getBytesEncoder, transformEncoder, getStructEncoder, getU64Encoder, getU128Encoder, getBooleanEncoder, getStructDecoder, fixDecoderSize, getU64Decoder, getU128Decoder, getBooleanDecoder, getBytesDecoder, combineCodec, getAddressEncoder, SolanaError, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, getU16Encoder, getU8Encoder, getArrayEncoder, getAddressDecoder, getU16Decoder, getU8Decoder, getArrayDecoder, getU32Encoder, getU32Decoder, getOptionEncoder, getOptionDecoder, createNoopSigner, decodeAccount, assertAccountExists, fetchEncodedAccount, assertAccountsExist, fetchEncodedAccounts, containsBytes, SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT, SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, assertIsInstructionWithAccounts, isProgramError, address, addEncoderSizePrefix, getUtf8Encoder, addDecoderSizePrefix, getUtf8Decoder, AccountRole, getStructCodec, getU64Codec, compressTransactionMessageUsingAddressLookupTables, mergeBytes } from '@solana/kit';
5
5
  import { getAddressFromResolvedInstructionAccount, getAccountMetaFactory, getNonNullResolvedInstructionInput, addSelfPlanAndSendFunctions, addSelfFetchFunctions } from '@solana/program-client-core';
6
6
  import { keccak_256 } from '@noble/hashes/sha3.js';
7
7
  import { findAddressLookupTablePda, getCreateLookupTableInstruction, getExtendLookupTableInstruction } from '@solana-program/address-lookup-table';
@@ -3601,6 +3601,930 @@ async function fetchConfigWithAddress(rpc, programId = CPMM_PROGRAM_ID, commitme
3601
3601
  return { address: configAddress, account };
3602
3602
  }
3603
3603
 
3604
+ // src/solana/cosignerHook/index.ts
3605
+ var cosignerHook_exports = {};
3606
+ __export(cosignerHook_exports, {
3607
+ ADD_COSIGNER_DISCRIMINATOR: () => ADD_COSIGNER_DISCRIMINATOR,
3608
+ COSIGNER_CONFIG_DISCRIMINATOR: () => COSIGNER_CONFIG_DISCRIMINATOR,
3609
+ COSIGNER_HOOK_ERROR__COSIGNER_ALREADY_EXISTS: () => COSIGNER_HOOK_ERROR__COSIGNER_ALREADY_EXISTS,
3610
+ COSIGNER_HOOK_ERROR__COSIGNER_LIST_FULL: () => COSIGNER_HOOK_ERROR__COSIGNER_LIST_FULL,
3611
+ COSIGNER_HOOK_ERROR__COSIGNER_NOT_FOUND: () => COSIGNER_HOOK_ERROR__COSIGNER_NOT_FOUND,
3612
+ COSIGNER_HOOK_ERROR__INVALID_AUTHORITY: () => COSIGNER_HOOK_ERROR__INVALID_AUTHORITY,
3613
+ COSIGNER_HOOK_ERROR__INVALID_CONFIG: () => COSIGNER_HOOK_ERROR__INVALID_CONFIG,
3614
+ COSIGNER_HOOK_ERROR__INVALID_COSIGNER: () => COSIGNER_HOOK_ERROR__INVALID_COSIGNER,
3615
+ COSIGNER_HOOK_PROGRAM_ADDRESS: () => COSIGNER_HOOK_PROGRAM_ADDRESS,
3616
+ COSIGNER_HOOK_PROGRAM_ID: () => COSIGNER_HOOK_PROGRAM_ID,
3617
+ CosignerHookAccount: () => CosignerHookAccount,
3618
+ CosignerHookInstruction: () => CosignerHookInstruction,
3619
+ INITIALIZE_CONFIG_DISCRIMINATOR: () => INITIALIZE_CONFIG_DISCRIMINATOR2,
3620
+ MAX_COSIGNERS: () => MAX_COSIGNERS,
3621
+ REMOVE_COSIGNER_DISCRIMINATOR: () => REMOVE_COSIGNER_DISCRIMINATOR,
3622
+ SEED_COSIGNER_HOOK_CONFIG: () => SEED_COSIGNER_HOOK_CONFIG,
3623
+ SET_AUTHORITY_DISCRIMINATOR: () => SET_AUTHORITY_DISCRIMINATOR,
3624
+ cosignerHookProgram: () => cosignerHookProgram,
3625
+ decodeCosignerConfig: () => decodeCosignerConfig,
3626
+ fetchAllCosignerConfig: () => fetchAllCosignerConfig,
3627
+ fetchAllMaybeCosignerConfig: () => fetchAllMaybeCosignerConfig,
3628
+ fetchCosignerConfig: () => fetchCosignerConfig,
3629
+ fetchMaybeCosignerConfig: () => fetchMaybeCosignerConfig,
3630
+ getAddCosignerDiscriminatorBytes: () => getAddCosignerDiscriminatorBytes,
3631
+ getAddCosignerInstruction: () => getAddCosignerInstruction,
3632
+ getAddCosignerInstructionAsync: () => getAddCosignerInstructionAsync,
3633
+ getAddCosignerInstructionDataCodec: () => getAddCosignerInstructionDataCodec,
3634
+ getAddCosignerInstructionDataDecoder: () => getAddCosignerInstructionDataDecoder,
3635
+ getAddCosignerInstructionDataEncoder: () => getAddCosignerInstructionDataEncoder,
3636
+ getCosignerArgCodec: () => getCosignerArgCodec,
3637
+ getCosignerArgDecoder: () => getCosignerArgDecoder,
3638
+ getCosignerArgEncoder: () => getCosignerArgEncoder,
3639
+ getCosignerConfigCodec: () => getCosignerConfigCodec,
3640
+ getCosignerConfigDecoder: () => getCosignerConfigDecoder,
3641
+ getCosignerConfigDiscriminatorBytes: () => getCosignerConfigDiscriminatorBytes,
3642
+ getCosignerConfigEncoder: () => getCosignerConfigEncoder,
3643
+ getCosignerConfigSize: () => getCosignerConfigSize,
3644
+ getCosignerHookConfigAddress: () => getCosignerHookConfigAddress,
3645
+ getCosignerHookErrorMessage: () => getCosignerHookErrorMessage,
3646
+ getInitializeConfigArgsCodec: () => getInitializeConfigArgsCodec,
3647
+ getInitializeConfigArgsDecoder: () => getInitializeConfigArgsDecoder,
3648
+ getInitializeConfigArgsEncoder: () => getInitializeConfigArgsEncoder,
3649
+ getInitializeConfigDiscriminatorBytes: () => getInitializeConfigDiscriminatorBytes2,
3650
+ getInitializeConfigInstruction: () => getInitializeConfigInstruction2,
3651
+ getInitializeConfigInstructionAsync: () => getInitializeConfigInstructionAsync2,
3652
+ getInitializeConfigInstructionDataCodec: () => getInitializeConfigInstructionDataCodec2,
3653
+ getInitializeConfigInstructionDataDecoder: () => getInitializeConfigInstructionDataDecoder2,
3654
+ getInitializeConfigInstructionDataEncoder: () => getInitializeConfigInstructionDataEncoder2,
3655
+ getRemoveCosignerDiscriminatorBytes: () => getRemoveCosignerDiscriminatorBytes,
3656
+ getRemoveCosignerInstruction: () => getRemoveCosignerInstruction,
3657
+ getRemoveCosignerInstructionAsync: () => getRemoveCosignerInstructionAsync,
3658
+ getRemoveCosignerInstructionDataCodec: () => getRemoveCosignerInstructionDataCodec,
3659
+ getRemoveCosignerInstructionDataDecoder: () => getRemoveCosignerInstructionDataDecoder,
3660
+ getRemoveCosignerInstructionDataEncoder: () => getRemoveCosignerInstructionDataEncoder,
3661
+ getSetAuthorityArgsCodec: () => getSetAuthorityArgsCodec,
3662
+ getSetAuthorityArgsDecoder: () => getSetAuthorityArgsDecoder,
3663
+ getSetAuthorityArgsEncoder: () => getSetAuthorityArgsEncoder,
3664
+ getSetAuthorityDiscriminatorBytes: () => getSetAuthorityDiscriminatorBytes,
3665
+ getSetAuthorityInstruction: () => getSetAuthorityInstruction,
3666
+ getSetAuthorityInstructionAsync: () => getSetAuthorityInstructionAsync,
3667
+ getSetAuthorityInstructionDataCodec: () => getSetAuthorityInstructionDataCodec,
3668
+ getSetAuthorityInstructionDataDecoder: () => getSetAuthorityInstructionDataDecoder,
3669
+ getSetAuthorityInstructionDataEncoder: () => getSetAuthorityInstructionDataEncoder,
3670
+ identifyCosignerHookAccount: () => identifyCosignerHookAccount,
3671
+ identifyCosignerHookInstruction: () => identifyCosignerHookInstruction,
3672
+ isCosignerHookError: () => isCosignerHookError,
3673
+ parseAddCosignerInstruction: () => parseAddCosignerInstruction,
3674
+ parseCosignerHookInstruction: () => parseCosignerHookInstruction,
3675
+ parseInitializeConfigInstruction: () => parseInitializeConfigInstruction2,
3676
+ parseRemoveCosignerInstruction: () => parseRemoveCosignerInstruction,
3677
+ parseSetAuthorityInstruction: () => parseSetAuthorityInstruction
3678
+ });
3679
+ var COSIGNER_CONFIG_DISCRIMINATOR = new Uint8Array([
3680
+ 133,
3681
+ 227,
3682
+ 177,
3683
+ 74,
3684
+ 145,
3685
+ 74,
3686
+ 247,
3687
+ 183
3688
+ ]);
3689
+ function getCosignerConfigDiscriminatorBytes() {
3690
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
3691
+ COSIGNER_CONFIG_DISCRIMINATOR
3692
+ );
3693
+ }
3694
+ function getCosignerConfigEncoder() {
3695
+ return transformEncoder(
3696
+ getStructEncoder([
3697
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
3698
+ ["adminAuthority", getAddressEncoder()],
3699
+ ["cosignerCount", getU8Encoder()],
3700
+ ["bump", getU8Encoder()],
3701
+ ["version", getU8Encoder()],
3702
+ ["reserved", fixEncoderSize(getBytesEncoder(), 37)],
3703
+ ["cosigners", getArrayEncoder(getAddressEncoder(), { size: 32 })]
3704
+ ]),
3705
+ (value) => ({ ...value, discriminator: COSIGNER_CONFIG_DISCRIMINATOR })
3706
+ );
3707
+ }
3708
+ function getCosignerConfigDecoder() {
3709
+ return getStructDecoder([
3710
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
3711
+ ["adminAuthority", getAddressDecoder()],
3712
+ ["cosignerCount", getU8Decoder()],
3713
+ ["bump", getU8Decoder()],
3714
+ ["version", getU8Decoder()],
3715
+ ["reserved", fixDecoderSize(getBytesDecoder(), 37)],
3716
+ ["cosigners", getArrayDecoder(getAddressDecoder(), { size: 32 })]
3717
+ ]);
3718
+ }
3719
+ function getCosignerConfigCodec() {
3720
+ return combineCodec(getCosignerConfigEncoder(), getCosignerConfigDecoder());
3721
+ }
3722
+ function decodeCosignerConfig(encodedAccount) {
3723
+ return decodeAccount(
3724
+ encodedAccount,
3725
+ getCosignerConfigDecoder()
3726
+ );
3727
+ }
3728
+ async function fetchCosignerConfig(rpc, address3, config) {
3729
+ const maybeAccount = await fetchMaybeCosignerConfig(rpc, address3, config);
3730
+ assertAccountExists(maybeAccount);
3731
+ return maybeAccount;
3732
+ }
3733
+ async function fetchMaybeCosignerConfig(rpc, address3, config) {
3734
+ const maybeAccount = await fetchEncodedAccount(rpc, address3, config);
3735
+ return decodeCosignerConfig(maybeAccount);
3736
+ }
3737
+ async function fetchAllCosignerConfig(rpc, addresses, config) {
3738
+ const maybeAccounts = await fetchAllMaybeCosignerConfig(
3739
+ rpc,
3740
+ addresses,
3741
+ config
3742
+ );
3743
+ assertAccountsExist(maybeAccounts);
3744
+ return maybeAccounts;
3745
+ }
3746
+ async function fetchAllMaybeCosignerConfig(rpc, addresses, config) {
3747
+ const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
3748
+ return maybeAccounts.map(
3749
+ (maybeAccount) => decodeCosignerConfig(maybeAccount)
3750
+ );
3751
+ }
3752
+ function getCosignerConfigSize() {
3753
+ return 1104;
3754
+ }
3755
+ var ADD_COSIGNER_DISCRIMINATOR = new Uint8Array([
3756
+ 17,
3757
+ 34,
3758
+ 183,
3759
+ 119,
3760
+ 202,
3761
+ 255,
3762
+ 218,
3763
+ 233
3764
+ ]);
3765
+ function getAddCosignerDiscriminatorBytes() {
3766
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
3767
+ ADD_COSIGNER_DISCRIMINATOR
3768
+ );
3769
+ }
3770
+ function getAddCosignerInstructionDataEncoder() {
3771
+ return transformEncoder(
3772
+ getStructEncoder([
3773
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
3774
+ ["cosigner", getAddressEncoder()]
3775
+ ]),
3776
+ (value) => ({ ...value, discriminator: ADD_COSIGNER_DISCRIMINATOR })
3777
+ );
3778
+ }
3779
+ function getAddCosignerInstructionDataDecoder() {
3780
+ return getStructDecoder([
3781
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
3782
+ ["cosigner", getAddressDecoder()]
3783
+ ]);
3784
+ }
3785
+ function getAddCosignerInstructionDataCodec() {
3786
+ return combineCodec(
3787
+ getAddCosignerInstructionDataEncoder(),
3788
+ getAddCosignerInstructionDataDecoder()
3789
+ );
3790
+ }
3791
+ async function getAddCosignerInstructionAsync(input, config) {
3792
+ const programAddress = config?.programAddress ?? COSIGNER_HOOK_PROGRAM_ADDRESS;
3793
+ const originalAccounts = {
3794
+ adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
3795
+ config: { value: input.config ?? null, isWritable: true }
3796
+ };
3797
+ const accounts = originalAccounts;
3798
+ const args = { ...input };
3799
+ if (!accounts.config.value) {
3800
+ accounts.config.value = await getProgramDerivedAddress({
3801
+ programAddress,
3802
+ seeds: [
3803
+ getBytesEncoder().encode(
3804
+ new Uint8Array([
3805
+ 99,
3806
+ 111,
3807
+ 115,
3808
+ 105,
3809
+ 103,
3810
+ 110,
3811
+ 101,
3812
+ 114,
3813
+ 95,
3814
+ 104,
3815
+ 111,
3816
+ 111,
3817
+ 107,
3818
+ 95,
3819
+ 99,
3820
+ 111,
3821
+ 110,
3822
+ 102,
3823
+ 105,
3824
+ 103
3825
+ ])
3826
+ )
3827
+ ]
3828
+ });
3829
+ }
3830
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
3831
+ return Object.freeze({
3832
+ accounts: [
3833
+ getAccountMeta("adminAuthority", accounts.adminAuthority),
3834
+ getAccountMeta("config", accounts.config)
3835
+ ],
3836
+ data: getAddCosignerInstructionDataEncoder().encode(
3837
+ args
3838
+ ),
3839
+ programAddress
3840
+ });
3841
+ }
3842
+ function getAddCosignerInstruction(input, config) {
3843
+ const programAddress = config?.programAddress ?? COSIGNER_HOOK_PROGRAM_ADDRESS;
3844
+ const originalAccounts = {
3845
+ adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
3846
+ config: { value: input.config ?? null, isWritable: true }
3847
+ };
3848
+ const accounts = originalAccounts;
3849
+ const args = { ...input };
3850
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
3851
+ return Object.freeze({
3852
+ accounts: [
3853
+ getAccountMeta("adminAuthority", accounts.adminAuthority),
3854
+ getAccountMeta("config", accounts.config)
3855
+ ],
3856
+ data: getAddCosignerInstructionDataEncoder().encode(
3857
+ args
3858
+ ),
3859
+ programAddress
3860
+ });
3861
+ }
3862
+ function parseAddCosignerInstruction(instruction) {
3863
+ if (instruction.accounts.length < 2) {
3864
+ throw new SolanaError(
3865
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
3866
+ {
3867
+ actualAccountMetas: instruction.accounts.length,
3868
+ expectedAccountMetas: 2
3869
+ }
3870
+ );
3871
+ }
3872
+ let accountIndex = 0;
3873
+ const getNextAccount = () => {
3874
+ const accountMeta = instruction.accounts[accountIndex];
3875
+ accountIndex += 1;
3876
+ return accountMeta;
3877
+ };
3878
+ return {
3879
+ programAddress: instruction.programAddress,
3880
+ accounts: { adminAuthority: getNextAccount(), config: getNextAccount() },
3881
+ data: getAddCosignerInstructionDataDecoder().decode(instruction.data)
3882
+ };
3883
+ }
3884
+ var INITIALIZE_CONFIG_DISCRIMINATOR2 = new Uint8Array([
3885
+ 208,
3886
+ 127,
3887
+ 21,
3888
+ 1,
3889
+ 194,
3890
+ 190,
3891
+ 196,
3892
+ 70
3893
+ ]);
3894
+ function getInitializeConfigDiscriminatorBytes2() {
3895
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
3896
+ INITIALIZE_CONFIG_DISCRIMINATOR2
3897
+ );
3898
+ }
3899
+ function getInitializeConfigInstructionDataEncoder2() {
3900
+ return transformEncoder(
3901
+ getStructEncoder([
3902
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
3903
+ ["cosigners", getArrayEncoder(getAddressEncoder())]
3904
+ ]),
3905
+ (value) => ({ ...value, discriminator: INITIALIZE_CONFIG_DISCRIMINATOR2 })
3906
+ );
3907
+ }
3908
+ function getInitializeConfigInstructionDataDecoder2() {
3909
+ return getStructDecoder([
3910
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
3911
+ ["cosigners", getArrayDecoder(getAddressDecoder())]
3912
+ ]);
3913
+ }
3914
+ function getInitializeConfigInstructionDataCodec2() {
3915
+ return combineCodec(
3916
+ getInitializeConfigInstructionDataEncoder2(),
3917
+ getInitializeConfigInstructionDataDecoder2()
3918
+ );
3919
+ }
3920
+ async function getInitializeConfigInstructionAsync2(input, config) {
3921
+ const programAddress = config?.programAddress ?? COSIGNER_HOOK_PROGRAM_ADDRESS;
3922
+ const originalAccounts = {
3923
+ payer: { value: input.payer ?? null, isWritable: true },
3924
+ adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
3925
+ config: { value: input.config ?? null, isWritable: true },
3926
+ programData: { value: input.programData ?? null, isWritable: false },
3927
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
3928
+ };
3929
+ const accounts = originalAccounts;
3930
+ const args = { ...input };
3931
+ if (!accounts.config.value) {
3932
+ accounts.config.value = await getProgramDerivedAddress({
3933
+ programAddress,
3934
+ seeds: [
3935
+ getBytesEncoder().encode(
3936
+ new Uint8Array([
3937
+ 99,
3938
+ 111,
3939
+ 115,
3940
+ 105,
3941
+ 103,
3942
+ 110,
3943
+ 101,
3944
+ 114,
3945
+ 95,
3946
+ 104,
3947
+ 111,
3948
+ 111,
3949
+ 107,
3950
+ 95,
3951
+ 99,
3952
+ 111,
3953
+ 110,
3954
+ 102,
3955
+ 105,
3956
+ 103
3957
+ ])
3958
+ )
3959
+ ]
3960
+ });
3961
+ }
3962
+ if (!accounts.systemProgram.value) {
3963
+ accounts.systemProgram.value = "11111111111111111111111111111111";
3964
+ }
3965
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
3966
+ return Object.freeze({
3967
+ accounts: [
3968
+ getAccountMeta("payer", accounts.payer),
3969
+ getAccountMeta("adminAuthority", accounts.adminAuthority),
3970
+ getAccountMeta("config", accounts.config),
3971
+ getAccountMeta("programData", accounts.programData),
3972
+ getAccountMeta("systemProgram", accounts.systemProgram)
3973
+ ],
3974
+ data: getInitializeConfigInstructionDataEncoder2().encode(
3975
+ args
3976
+ ),
3977
+ programAddress
3978
+ });
3979
+ }
3980
+ function getInitializeConfigInstruction2(input, config) {
3981
+ const programAddress = config?.programAddress ?? COSIGNER_HOOK_PROGRAM_ADDRESS;
3982
+ const originalAccounts = {
3983
+ payer: { value: input.payer ?? null, isWritable: true },
3984
+ adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
3985
+ config: { value: input.config ?? null, isWritable: true },
3986
+ programData: { value: input.programData ?? null, isWritable: false },
3987
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false }
3988
+ };
3989
+ const accounts = originalAccounts;
3990
+ const args = { ...input };
3991
+ if (!accounts.systemProgram.value) {
3992
+ accounts.systemProgram.value = "11111111111111111111111111111111";
3993
+ }
3994
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
3995
+ return Object.freeze({
3996
+ accounts: [
3997
+ getAccountMeta("payer", accounts.payer),
3998
+ getAccountMeta("adminAuthority", accounts.adminAuthority),
3999
+ getAccountMeta("config", accounts.config),
4000
+ getAccountMeta("programData", accounts.programData),
4001
+ getAccountMeta("systemProgram", accounts.systemProgram)
4002
+ ],
4003
+ data: getInitializeConfigInstructionDataEncoder2().encode(
4004
+ args
4005
+ ),
4006
+ programAddress
4007
+ });
4008
+ }
4009
+ function parseInitializeConfigInstruction2(instruction) {
4010
+ if (instruction.accounts.length < 5) {
4011
+ throw new SolanaError(
4012
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
4013
+ {
4014
+ actualAccountMetas: instruction.accounts.length,
4015
+ expectedAccountMetas: 5
4016
+ }
4017
+ );
4018
+ }
4019
+ let accountIndex = 0;
4020
+ const getNextAccount = () => {
4021
+ const accountMeta = instruction.accounts[accountIndex];
4022
+ accountIndex += 1;
4023
+ return accountMeta;
4024
+ };
4025
+ return {
4026
+ programAddress: instruction.programAddress,
4027
+ accounts: {
4028
+ payer: getNextAccount(),
4029
+ adminAuthority: getNextAccount(),
4030
+ config: getNextAccount(),
4031
+ programData: getNextAccount(),
4032
+ systemProgram: getNextAccount()
4033
+ },
4034
+ data: getInitializeConfigInstructionDataDecoder2().decode(instruction.data)
4035
+ };
4036
+ }
4037
+ var REMOVE_COSIGNER_DISCRIMINATOR = new Uint8Array([
4038
+ 174,
4039
+ 11,
4040
+ 171,
4041
+ 252,
4042
+ 179,
4043
+ 99,
4044
+ 220,
4045
+ 27
4046
+ ]);
4047
+ function getRemoveCosignerDiscriminatorBytes() {
4048
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
4049
+ REMOVE_COSIGNER_DISCRIMINATOR
4050
+ );
4051
+ }
4052
+ function getRemoveCosignerInstructionDataEncoder() {
4053
+ return transformEncoder(
4054
+ getStructEncoder([
4055
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
4056
+ ["cosigner", getAddressEncoder()]
4057
+ ]),
4058
+ (value) => ({ ...value, discriminator: REMOVE_COSIGNER_DISCRIMINATOR })
4059
+ );
4060
+ }
4061
+ function getRemoveCosignerInstructionDataDecoder() {
4062
+ return getStructDecoder([
4063
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
4064
+ ["cosigner", getAddressDecoder()]
4065
+ ]);
4066
+ }
4067
+ function getRemoveCosignerInstructionDataCodec() {
4068
+ return combineCodec(
4069
+ getRemoveCosignerInstructionDataEncoder(),
4070
+ getRemoveCosignerInstructionDataDecoder()
4071
+ );
4072
+ }
4073
+ async function getRemoveCosignerInstructionAsync(input, config) {
4074
+ const programAddress = config?.programAddress ?? COSIGNER_HOOK_PROGRAM_ADDRESS;
4075
+ const originalAccounts = {
4076
+ adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
4077
+ config: { value: input.config ?? null, isWritable: true }
4078
+ };
4079
+ const accounts = originalAccounts;
4080
+ const args = { ...input };
4081
+ if (!accounts.config.value) {
4082
+ accounts.config.value = await getProgramDerivedAddress({
4083
+ programAddress,
4084
+ seeds: [
4085
+ getBytesEncoder().encode(
4086
+ new Uint8Array([
4087
+ 99,
4088
+ 111,
4089
+ 115,
4090
+ 105,
4091
+ 103,
4092
+ 110,
4093
+ 101,
4094
+ 114,
4095
+ 95,
4096
+ 104,
4097
+ 111,
4098
+ 111,
4099
+ 107,
4100
+ 95,
4101
+ 99,
4102
+ 111,
4103
+ 110,
4104
+ 102,
4105
+ 105,
4106
+ 103
4107
+ ])
4108
+ )
4109
+ ]
4110
+ });
4111
+ }
4112
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
4113
+ return Object.freeze({
4114
+ accounts: [
4115
+ getAccountMeta("adminAuthority", accounts.adminAuthority),
4116
+ getAccountMeta("config", accounts.config)
4117
+ ],
4118
+ data: getRemoveCosignerInstructionDataEncoder().encode(
4119
+ args
4120
+ ),
4121
+ programAddress
4122
+ });
4123
+ }
4124
+ function getRemoveCosignerInstruction(input, config) {
4125
+ const programAddress = config?.programAddress ?? COSIGNER_HOOK_PROGRAM_ADDRESS;
4126
+ const originalAccounts = {
4127
+ adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
4128
+ config: { value: input.config ?? null, isWritable: true }
4129
+ };
4130
+ const accounts = originalAccounts;
4131
+ const args = { ...input };
4132
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
4133
+ return Object.freeze({
4134
+ accounts: [
4135
+ getAccountMeta("adminAuthority", accounts.adminAuthority),
4136
+ getAccountMeta("config", accounts.config)
4137
+ ],
4138
+ data: getRemoveCosignerInstructionDataEncoder().encode(
4139
+ args
4140
+ ),
4141
+ programAddress
4142
+ });
4143
+ }
4144
+ function parseRemoveCosignerInstruction(instruction) {
4145
+ if (instruction.accounts.length < 2) {
4146
+ throw new SolanaError(
4147
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
4148
+ {
4149
+ actualAccountMetas: instruction.accounts.length,
4150
+ expectedAccountMetas: 2
4151
+ }
4152
+ );
4153
+ }
4154
+ let accountIndex = 0;
4155
+ const getNextAccount = () => {
4156
+ const accountMeta = instruction.accounts[accountIndex];
4157
+ accountIndex += 1;
4158
+ return accountMeta;
4159
+ };
4160
+ return {
4161
+ programAddress: instruction.programAddress,
4162
+ accounts: { adminAuthority: getNextAccount(), config: getNextAccount() },
4163
+ data: getRemoveCosignerInstructionDataDecoder().decode(instruction.data)
4164
+ };
4165
+ }
4166
+ var SET_AUTHORITY_DISCRIMINATOR = new Uint8Array([
4167
+ 133,
4168
+ 250,
4169
+ 37,
4170
+ 21,
4171
+ 110,
4172
+ 163,
4173
+ 26,
4174
+ 121
4175
+ ]);
4176
+ function getSetAuthorityDiscriminatorBytes() {
4177
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
4178
+ SET_AUTHORITY_DISCRIMINATOR
4179
+ );
4180
+ }
4181
+ function getSetAuthorityInstructionDataEncoder() {
4182
+ return transformEncoder(
4183
+ getStructEncoder([
4184
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
4185
+ ["adminAuthority", getAddressEncoder()]
4186
+ ]),
4187
+ (value) => ({ ...value, discriminator: SET_AUTHORITY_DISCRIMINATOR })
4188
+ );
4189
+ }
4190
+ function getSetAuthorityInstructionDataDecoder() {
4191
+ return getStructDecoder([
4192
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
4193
+ ["adminAuthority", getAddressDecoder()]
4194
+ ]);
4195
+ }
4196
+ function getSetAuthorityInstructionDataCodec() {
4197
+ return combineCodec(
4198
+ getSetAuthorityInstructionDataEncoder(),
4199
+ getSetAuthorityInstructionDataDecoder()
4200
+ );
4201
+ }
4202
+ async function getSetAuthorityInstructionAsync(input, config) {
4203
+ const programAddress = config?.programAddress ?? COSIGNER_HOOK_PROGRAM_ADDRESS;
4204
+ const originalAccounts = {
4205
+ adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
4206
+ config: { value: input.config ?? null, isWritable: true }
4207
+ };
4208
+ const accounts = originalAccounts;
4209
+ const args = { ...input, adminAuthority: input.adminAuthorityArg };
4210
+ if (!accounts.config.value) {
4211
+ accounts.config.value = await getProgramDerivedAddress({
4212
+ programAddress,
4213
+ seeds: [
4214
+ getBytesEncoder().encode(
4215
+ new Uint8Array([
4216
+ 99,
4217
+ 111,
4218
+ 115,
4219
+ 105,
4220
+ 103,
4221
+ 110,
4222
+ 101,
4223
+ 114,
4224
+ 95,
4225
+ 104,
4226
+ 111,
4227
+ 111,
4228
+ 107,
4229
+ 95,
4230
+ 99,
4231
+ 111,
4232
+ 110,
4233
+ 102,
4234
+ 105,
4235
+ 103
4236
+ ])
4237
+ )
4238
+ ]
4239
+ });
4240
+ }
4241
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
4242
+ return Object.freeze({
4243
+ accounts: [
4244
+ getAccountMeta("adminAuthority", accounts.adminAuthority),
4245
+ getAccountMeta("config", accounts.config)
4246
+ ],
4247
+ data: getSetAuthorityInstructionDataEncoder().encode(
4248
+ args
4249
+ ),
4250
+ programAddress
4251
+ });
4252
+ }
4253
+ function getSetAuthorityInstruction(input, config) {
4254
+ const programAddress = config?.programAddress ?? COSIGNER_HOOK_PROGRAM_ADDRESS;
4255
+ const originalAccounts = {
4256
+ adminAuthority: { value: input.adminAuthority ?? null, isWritable: false },
4257
+ config: { value: input.config ?? null, isWritable: true }
4258
+ };
4259
+ const accounts = originalAccounts;
4260
+ const args = { ...input, adminAuthority: input.adminAuthorityArg };
4261
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
4262
+ return Object.freeze({
4263
+ accounts: [
4264
+ getAccountMeta("adminAuthority", accounts.adminAuthority),
4265
+ getAccountMeta("config", accounts.config)
4266
+ ],
4267
+ data: getSetAuthorityInstructionDataEncoder().encode(
4268
+ args
4269
+ ),
4270
+ programAddress
4271
+ });
4272
+ }
4273
+ function parseSetAuthorityInstruction(instruction) {
4274
+ if (instruction.accounts.length < 2) {
4275
+ throw new SolanaError(
4276
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
4277
+ {
4278
+ actualAccountMetas: instruction.accounts.length,
4279
+ expectedAccountMetas: 2
4280
+ }
4281
+ );
4282
+ }
4283
+ let accountIndex = 0;
4284
+ const getNextAccount = () => {
4285
+ const accountMeta = instruction.accounts[accountIndex];
4286
+ accountIndex += 1;
4287
+ return accountMeta;
4288
+ };
4289
+ return {
4290
+ programAddress: instruction.programAddress,
4291
+ accounts: { adminAuthority: getNextAccount(), config: getNextAccount() },
4292
+ data: getSetAuthorityInstructionDataDecoder().decode(instruction.data)
4293
+ };
4294
+ }
4295
+
4296
+ // src/solana/generated/cosignerHook/programs/cosignerHook.ts
4297
+ var COSIGNER_HOOK_PROGRAM_ADDRESS = "JDwnBoYE2NsmkQjQLHi1btQxeHirtJ9XjU1dM641QZt";
4298
+ var CosignerHookAccount = /* @__PURE__ */ ((CosignerHookAccount2) => {
4299
+ CosignerHookAccount2[CosignerHookAccount2["CosignerConfig"] = 0] = "CosignerConfig";
4300
+ return CosignerHookAccount2;
4301
+ })(CosignerHookAccount || {});
4302
+ function identifyCosignerHookAccount(account) {
4303
+ const data = "data" in account ? account.data : account;
4304
+ if (containsBytes(
4305
+ data,
4306
+ fixEncoderSize(getBytesEncoder(), 8).encode(
4307
+ new Uint8Array([133, 227, 177, 74, 145, 74, 247, 183])
4308
+ ),
4309
+ 0
4310
+ )) {
4311
+ return 0 /* CosignerConfig */;
4312
+ }
4313
+ throw new SolanaError(
4314
+ SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT,
4315
+ { accountData: data, programName: "cosignerHook" }
4316
+ );
4317
+ }
4318
+ var CosignerHookInstruction = /* @__PURE__ */ ((CosignerHookInstruction2) => {
4319
+ CosignerHookInstruction2[CosignerHookInstruction2["AddCosigner"] = 0] = "AddCosigner";
4320
+ CosignerHookInstruction2[CosignerHookInstruction2["InitializeConfig"] = 1] = "InitializeConfig";
4321
+ CosignerHookInstruction2[CosignerHookInstruction2["RemoveCosigner"] = 2] = "RemoveCosigner";
4322
+ CosignerHookInstruction2[CosignerHookInstruction2["SetAuthority"] = 3] = "SetAuthority";
4323
+ return CosignerHookInstruction2;
4324
+ })(CosignerHookInstruction || {});
4325
+ function identifyCosignerHookInstruction(instruction) {
4326
+ const data = "data" in instruction ? instruction.data : instruction;
4327
+ if (containsBytes(
4328
+ data,
4329
+ fixEncoderSize(getBytesEncoder(), 8).encode(
4330
+ new Uint8Array([17, 34, 183, 119, 202, 255, 218, 233])
4331
+ ),
4332
+ 0
4333
+ )) {
4334
+ return 0 /* AddCosigner */;
4335
+ }
4336
+ if (containsBytes(
4337
+ data,
4338
+ fixEncoderSize(getBytesEncoder(), 8).encode(
4339
+ new Uint8Array([208, 127, 21, 1, 194, 190, 196, 70])
4340
+ ),
4341
+ 0
4342
+ )) {
4343
+ return 1 /* InitializeConfig */;
4344
+ }
4345
+ if (containsBytes(
4346
+ data,
4347
+ fixEncoderSize(getBytesEncoder(), 8).encode(
4348
+ new Uint8Array([174, 11, 171, 252, 179, 99, 220, 27])
4349
+ ),
4350
+ 0
4351
+ )) {
4352
+ return 2 /* RemoveCosigner */;
4353
+ }
4354
+ if (containsBytes(
4355
+ data,
4356
+ fixEncoderSize(getBytesEncoder(), 8).encode(
4357
+ new Uint8Array([133, 250, 37, 21, 110, 163, 26, 121])
4358
+ ),
4359
+ 0
4360
+ )) {
4361
+ return 3 /* SetAuthority */;
4362
+ }
4363
+ throw new SolanaError(
4364
+ SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,
4365
+ { instructionData: data, programName: "cosignerHook" }
4366
+ );
4367
+ }
4368
+ function parseCosignerHookInstruction(instruction) {
4369
+ const instructionType = identifyCosignerHookInstruction(instruction);
4370
+ switch (instructionType) {
4371
+ case 0 /* AddCosigner */: {
4372
+ assertIsInstructionWithAccounts(instruction);
4373
+ return {
4374
+ instructionType: 0 /* AddCosigner */,
4375
+ ...parseAddCosignerInstruction(instruction)
4376
+ };
4377
+ }
4378
+ case 1 /* InitializeConfig */: {
4379
+ assertIsInstructionWithAccounts(instruction);
4380
+ return {
4381
+ instructionType: 1 /* InitializeConfig */,
4382
+ ...parseInitializeConfigInstruction2(instruction)
4383
+ };
4384
+ }
4385
+ case 2 /* RemoveCosigner */: {
4386
+ assertIsInstructionWithAccounts(instruction);
4387
+ return {
4388
+ instructionType: 2 /* RemoveCosigner */,
4389
+ ...parseRemoveCosignerInstruction(instruction)
4390
+ };
4391
+ }
4392
+ case 3 /* SetAuthority */: {
4393
+ assertIsInstructionWithAccounts(instruction);
4394
+ return {
4395
+ instructionType: 3 /* SetAuthority */,
4396
+ ...parseSetAuthorityInstruction(instruction)
4397
+ };
4398
+ }
4399
+ default:
4400
+ throw new SolanaError(
4401
+ SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,
4402
+ {
4403
+ instructionType,
4404
+ programName: "cosignerHook"
4405
+ }
4406
+ );
4407
+ }
4408
+ }
4409
+ function cosignerHookProgram() {
4410
+ return (client) => {
4411
+ return {
4412
+ ...client,
4413
+ cosignerHook: {
4414
+ accounts: {
4415
+ cosignerConfig: addSelfFetchFunctions(
4416
+ client,
4417
+ getCosignerConfigCodec()
4418
+ )
4419
+ },
4420
+ instructions: {
4421
+ addCosigner: (input) => addSelfPlanAndSendFunctions(
4422
+ client,
4423
+ getAddCosignerInstructionAsync(input)
4424
+ ),
4425
+ initializeConfig: (input) => addSelfPlanAndSendFunctions(
4426
+ client,
4427
+ getInitializeConfigInstructionAsync2({
4428
+ ...input,
4429
+ payer: input.payer ?? client.payer
4430
+ })
4431
+ ),
4432
+ removeCosigner: (input) => addSelfPlanAndSendFunctions(
4433
+ client,
4434
+ getRemoveCosignerInstructionAsync(input)
4435
+ ),
4436
+ setAuthority: (input) => addSelfPlanAndSendFunctions(
4437
+ client,
4438
+ getSetAuthorityInstructionAsync(input)
4439
+ )
4440
+ }
4441
+ }
4442
+ };
4443
+ };
4444
+ }
4445
+
4446
+ // src/solana/generated/cosignerHook/errors/cosignerHook.ts
4447
+ var COSIGNER_HOOK_ERROR__INVALID_CONFIG = 6e3;
4448
+ var COSIGNER_HOOK_ERROR__INVALID_AUTHORITY = 6001;
4449
+ var COSIGNER_HOOK_ERROR__INVALID_COSIGNER = 6002;
4450
+ var COSIGNER_HOOK_ERROR__COSIGNER_ALREADY_EXISTS = 6003;
4451
+ var COSIGNER_HOOK_ERROR__COSIGNER_NOT_FOUND = 6004;
4452
+ var COSIGNER_HOOK_ERROR__COSIGNER_LIST_FULL = 6005;
4453
+ var cosignerHookErrorMessages;
4454
+ if (process.env.NODE_ENV !== "production") {
4455
+ cosignerHookErrorMessages = {
4456
+ [COSIGNER_HOOK_ERROR__COSIGNER_ALREADY_EXISTS]: `Cosigner already exists`,
4457
+ [COSIGNER_HOOK_ERROR__COSIGNER_LIST_FULL]: `Cosigner list is full`,
4458
+ [COSIGNER_HOOK_ERROR__COSIGNER_NOT_FOUND]: `Cosigner not found`,
4459
+ [COSIGNER_HOOK_ERROR__INVALID_AUTHORITY]: `Invalid cosigner hook authority`,
4460
+ [COSIGNER_HOOK_ERROR__INVALID_CONFIG]: `Invalid cosigner hook config`,
4461
+ [COSIGNER_HOOK_ERROR__INVALID_COSIGNER]: `Invalid cosigner key`
4462
+ };
4463
+ }
4464
+ function getCosignerHookErrorMessage(code) {
4465
+ if (process.env.NODE_ENV !== "production") {
4466
+ return cosignerHookErrorMessages[code];
4467
+ }
4468
+ return "Error message not available in production bundles.";
4469
+ }
4470
+ function isCosignerHookError(error, transactionMessage, code) {
4471
+ return isProgramError(
4472
+ error,
4473
+ transactionMessage,
4474
+ COSIGNER_HOOK_PROGRAM_ADDRESS,
4475
+ code
4476
+ );
4477
+ }
4478
+ function getCosignerArgEncoder() {
4479
+ return getStructEncoder([["cosigner", getAddressEncoder()]]);
4480
+ }
4481
+ function getCosignerArgDecoder() {
4482
+ return getStructDecoder([["cosigner", getAddressDecoder()]]);
4483
+ }
4484
+ function getCosignerArgCodec() {
4485
+ return combineCodec(getCosignerArgEncoder(), getCosignerArgDecoder());
4486
+ }
4487
+ function getInitializeConfigArgsEncoder() {
4488
+ return getStructEncoder([
4489
+ ["cosigners", getArrayEncoder(getAddressEncoder())]
4490
+ ]);
4491
+ }
4492
+ function getInitializeConfigArgsDecoder() {
4493
+ return getStructDecoder([
4494
+ ["cosigners", getArrayDecoder(getAddressDecoder())]
4495
+ ]);
4496
+ }
4497
+ function getInitializeConfigArgsCodec() {
4498
+ return combineCodec(
4499
+ getInitializeConfigArgsEncoder(),
4500
+ getInitializeConfigArgsDecoder()
4501
+ );
4502
+ }
4503
+ function getSetAuthorityArgsEncoder() {
4504
+ return getStructEncoder([["adminAuthority", getAddressEncoder()]]);
4505
+ }
4506
+ function getSetAuthorityArgsDecoder() {
4507
+ return getStructDecoder([["adminAuthority", getAddressDecoder()]]);
4508
+ }
4509
+ function getSetAuthorityArgsCodec() {
4510
+ return combineCodec(
4511
+ getSetAuthorityArgsEncoder(),
4512
+ getSetAuthorityArgsDecoder()
4513
+ );
4514
+ }
4515
+
4516
+ // src/solana/cosignerHook/constants.ts
4517
+ var COSIGNER_HOOK_PROGRAM_ID = COSIGNER_HOOK_PROGRAM_ADDRESS;
4518
+ var SEED_COSIGNER_HOOK_CONFIG = "cosigner_hook_config";
4519
+ var MAX_COSIGNERS = 32;
4520
+ var textEncoder2 = new TextEncoder();
4521
+ async function getCosignerHookConfigAddress(programId = COSIGNER_HOOK_PROGRAM_ID) {
4522
+ return getProgramDerivedAddress({
4523
+ programAddress: programId,
4524
+ seeds: [textEncoder2.encode(SEED_COSIGNER_HOOK_CONFIG)]
4525
+ });
4526
+ }
4527
+
3604
4528
  // src/solana/initializer/index.ts
3605
4529
  var initializer_exports = {};
3606
4530
  __export(initializer_exports, {
@@ -3616,6 +4540,7 @@ __export(initializer_exports, {
3616
4540
  HF_BEFORE_CREATE: () => HF_BEFORE_CREATE,
3617
4541
  HF_BEFORE_MIGRATE: () => HF_BEFORE_MIGRATE,
3618
4542
  HF_BEFORE_SWAP: () => HF_BEFORE_SWAP2,
4543
+ HF_FORWARD_READONLY_SIGNERS: () => HF_FORWARD_READONLY_SIGNERS2,
3619
4544
  HOOK_NO_CHANGE: () => HOOK_NO_CHANGE2,
3620
4545
  INITIALIZER_ACCOUNT_DISCRIMINATORS: () => INITIALIZER_ACCOUNT_DISCRIMINATORS,
3621
4546
  INITIALIZER_INSTRUCTION_DISCRIMINATORS: () => INITIALIZER_INSTRUCTION_DISCRIMINATORS,
@@ -3653,9 +4578,9 @@ __export(initializer_exports, {
3653
4578
  getInitConfigCodec: () => getInitConfigCodec,
3654
4579
  getInitConfigDecoder: () => getInitConfigDecoder,
3655
4580
  getInitConfigEncoder: () => getInitConfigEncoder,
3656
- getInitializeConfigArgsCodec: () => getInitializeConfigArgsCodec,
3657
- getInitializeConfigArgsDecoder: () => getInitializeConfigArgsDecoder,
3658
- getInitializeConfigArgsEncoder: () => getInitializeConfigArgsEncoder,
4581
+ getInitializeConfigArgsCodec: () => getInitializeConfigArgsCodec2,
4582
+ getInitializeConfigArgsDecoder: () => getInitializeConfigArgsDecoder2,
4583
+ getInitializeConfigArgsEncoder: () => getInitializeConfigArgsEncoder2,
3659
4584
  getInitializeLaunchArgsCodec: () => getInitializeLaunchArgsCodec,
3660
4585
  getInitializeLaunchArgsDecoder: () => getInitializeLaunchArgsDecoder,
3661
4586
  getInitializeLaunchArgsEncoder: () => getInitializeLaunchArgsEncoder,
@@ -3736,6 +4661,7 @@ var HF_BEFORE_CREATE = 1 << 2;
3736
4661
  var HF_AFTER_CREATE = 1 << 3;
3737
4662
  var HF_BEFORE_MIGRATE = 1 << 4;
3738
4663
  var HF_AFTER_MIGRATE = 1 << 5;
4664
+ var HF_FORWARD_READONLY_SIGNERS2 = 1 << 6;
3739
4665
  var HOOK_NO_CHANGE2 = 65535;
3740
4666
  var INITIALIZER_INSTRUCTION_DISCRIMINATORS = {
3741
4667
  // SHA256("global:initialize_config")[0:8]
@@ -3875,22 +4801,22 @@ function getInitConfigDecoder() {
3875
4801
  function getInitConfigCodec() {
3876
4802
  return combineCodec(getInitConfigEncoder(), getInitConfigDecoder());
3877
4803
  }
3878
- function getInitializeConfigArgsEncoder() {
4804
+ function getInitializeConfigArgsEncoder2() {
3879
4805
  return getStructEncoder([
3880
4806
  ["migratorAllowlist", getArrayEncoder(getAddressEncoder())],
3881
4807
  ["hookAllowlist", getArrayEncoder(getAddressEncoder())]
3882
4808
  ]);
3883
4809
  }
3884
- function getInitializeConfigArgsDecoder() {
4810
+ function getInitializeConfigArgsDecoder2() {
3885
4811
  return getStructDecoder([
3886
4812
  ["migratorAllowlist", getArrayDecoder(getAddressDecoder())],
3887
4813
  ["hookAllowlist", getArrayDecoder(getAddressDecoder())]
3888
4814
  ]);
3889
4815
  }
3890
- function getInitializeConfigArgsCodec() {
4816
+ function getInitializeConfigArgsCodec2() {
3891
4817
  return combineCodec(
3892
- getInitializeConfigArgsEncoder(),
3893
- getInitializeConfigArgsDecoder()
4818
+ getInitializeConfigArgsEncoder2(),
4819
+ getInitializeConfigArgsDecoder2()
3894
4820
  );
3895
4821
  }
3896
4822
  function getInitializeLaunchArgsEncoder() {
@@ -4110,7 +5036,7 @@ function getCurveSwapExactInInstructionDataEncoder() {
4110
5036
  (value) => ({ ...value, discriminator: CURVE_SWAP_EXACT_IN_DISCRIMINATOR })
4111
5037
  );
4112
5038
  }
4113
- var INITIALIZE_CONFIG_DISCRIMINATOR2 = new Uint8Array([
5039
+ var INITIALIZE_CONFIG_DISCRIMINATOR3 = new Uint8Array([
4114
5040
  208,
4115
5041
  127,
4116
5042
  21,
@@ -4120,14 +5046,14 @@ var INITIALIZE_CONFIG_DISCRIMINATOR2 = new Uint8Array([
4120
5046
  196,
4121
5047
  70
4122
5048
  ]);
4123
- function getInitializeConfigInstructionDataEncoder2() {
5049
+ function getInitializeConfigInstructionDataEncoder3() {
4124
5050
  return transformEncoder(
4125
5051
  getStructEncoder([
4126
5052
  ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
4127
5053
  ["migratorAllowlist", getArrayEncoder(getAddressEncoder())],
4128
5054
  ["hookAllowlist", getArrayEncoder(getAddressEncoder())]
4129
5055
  ]),
4130
- (value) => ({ ...value, discriminator: INITIALIZE_CONFIG_DISCRIMINATOR2 })
5056
+ (value) => ({ ...value, discriminator: INITIALIZE_CONFIG_DISCRIMINATOR3 })
4131
5057
  );
4132
5058
  }
4133
5059
  var INITIALIZE_LAUNCH_DISCRIMINATOR = new Uint8Array([
@@ -4256,7 +5182,7 @@ function getSetMigratorAllowlistInstructionDataEncoder() {
4256
5182
  }
4257
5183
  if (process.env.NODE_ENV !== "production") ;
4258
5184
  var addressCodec2 = getAddressCodec();
4259
- var textEncoder2 = new TextEncoder();
5185
+ var textEncoder3 = new TextEncoder();
4260
5186
  function encodeU64LE(value) {
4261
5187
  const bytes = new Uint8Array(8);
4262
5188
  const view = new DataView(bytes.buffer);
@@ -4266,7 +5192,7 @@ function encodeU64LE(value) {
4266
5192
  async function getConfigAddress2(programId = INITIALIZER_PROGRAM_ID) {
4267
5193
  return getProgramDerivedAddress({
4268
5194
  programAddress: programId,
4269
- seeds: [textEncoder2.encode(SEED_CONFIG2)]
5195
+ seeds: [textEncoder3.encode(SEED_CONFIG2)]
4270
5196
  });
4271
5197
  }
4272
5198
  async function getProgramDataAddress(programId = INITIALIZER_PROGRAM_ID) {
@@ -4282,7 +5208,7 @@ async function getLaunchAddress(namespace, launchId, programId = INITIALIZER_PRO
4282
5208
  return getProgramDerivedAddress({
4283
5209
  programAddress: programId,
4284
5210
  seeds: [
4285
- textEncoder2.encode(SEED_LAUNCH),
5211
+ textEncoder3.encode(SEED_LAUNCH),
4286
5212
  addressCodec2.encode(namespace),
4287
5213
  launchId
4288
5214
  ]
@@ -4292,7 +5218,7 @@ async function getLaunchAuthorityAddress(launch, programId = INITIALIZER_PROGRAM
4292
5218
  return getProgramDerivedAddress({
4293
5219
  programAddress: programId,
4294
5220
  seeds: [
4295
- textEncoder2.encode(SEED_LAUNCH_AUTHORITY),
5221
+ textEncoder3.encode(SEED_LAUNCH_AUTHORITY),
4296
5222
  addressCodec2.encode(launch)
4297
5223
  ]
4298
5224
  });
@@ -4325,7 +5251,7 @@ function createInitializeConfigInstruction(accounts, args, programId = INITIALIZ
4325
5251
  { address: systemProgram, role: AccountRole.READONLY }
4326
5252
  ];
4327
5253
  const data = new Uint8Array(
4328
- getInitializeConfigInstructionDataEncoder2().encode(args)
5254
+ getInitializeConfigInstructionDataEncoder3().encode(args)
4329
5255
  );
4330
5256
  return { programAddress: programId, accounts: keys, data };
4331
5257
  }
@@ -4425,17 +5351,17 @@ var CPMM_MIGRATOR_ACCOUNT_DISCRIMINATORS = {
4425
5351
  ])
4426
5352
  };
4427
5353
  var addressCodec3 = getAddressCodec();
4428
- var textEncoder3 = new TextEncoder();
5354
+ var textEncoder4 = new TextEncoder();
4429
5355
  async function getCpmmMigratorStateAddress(launch, programId = CPMM_MIGRATOR_PROGRAM_ID) {
4430
5356
  return getProgramDerivedAddress({
4431
5357
  programAddress: programId,
4432
- seeds: [textEncoder3.encode(SEED_STATE), addressCodec3.encode(launch)]
5358
+ seeds: [textEncoder4.encode(SEED_STATE), addressCodec3.encode(launch)]
4433
5359
  });
4434
5360
  }
4435
5361
  async function getCpmmMigrationAuthorityAddress(programId = CPMM_MIGRATOR_PROGRAM_ID) {
4436
5362
  return getProgramDerivedAddress({
4437
5363
  programAddress: programId,
4438
- seeds: [textEncoder3.encode(SEED_MIGRATION_AUTHORITY)]
5364
+ seeds: [textEncoder4.encode(SEED_MIGRATION_AUTHORITY)]
4439
5365
  });
4440
5366
  }
4441
5367
  var CLAIM_RECEIPT_DISCRIMINATOR = new Uint8Array([
@@ -6318,12 +7244,12 @@ function predictionMigratorProgram() {
6318
7244
  };
6319
7245
  }
6320
7246
  var addressCodec4 = getAddressCodec();
6321
- var textEncoder4 = new TextEncoder();
7247
+ var textEncoder5 = new TextEncoder();
6322
7248
  async function getPredictionMarketAddress(oracleState, quoteMint, programId = PREDICTION_MIGRATOR_PROGRAM_ADDRESS) {
6323
7249
  return getProgramDerivedAddress({
6324
7250
  programAddress: programId,
6325
7251
  seeds: [
6326
- textEncoder4.encode("market"),
7252
+ textEncoder5.encode("market"),
6327
7253
  addressCodec4.encode(oracleState),
6328
7254
  addressCodec4.encode(quoteMint)
6329
7255
  ]
@@ -6333,7 +7259,7 @@ async function getPredictionMarketAuthorityAddress(market, programId = PREDICTIO
6333
7259
  return getProgramDerivedAddress({
6334
7260
  programAddress: programId,
6335
7261
  seeds: [
6336
- textEncoder4.encode("market_authority"),
7262
+ textEncoder5.encode("market_authority"),
6337
7263
  addressCodec4.encode(market)
6338
7264
  ]
6339
7265
  });
@@ -6341,20 +7267,20 @@ async function getPredictionMarketAuthorityAddress(market, programId = PREDICTIO
6341
7267
  async function getPredictionPotVaultAddress(market, programId = PREDICTION_MIGRATOR_PROGRAM_ADDRESS) {
6342
7268
  return getProgramDerivedAddress({
6343
7269
  programAddress: programId,
6344
- seeds: [textEncoder4.encode("pot_vault"), addressCodec4.encode(market)]
7270
+ seeds: [textEncoder5.encode("pot_vault"), addressCodec4.encode(market)]
6345
7271
  });
6346
7272
  }
6347
7273
  async function getPredictionEntryAddress(market, entryId, programId = PREDICTION_MIGRATOR_PROGRAM_ADDRESS) {
6348
7274
  return getProgramDerivedAddress({
6349
7275
  programAddress: programId,
6350
- seeds: [textEncoder4.encode("entry"), addressCodec4.encode(market), entryId]
7276
+ seeds: [textEncoder5.encode("entry"), addressCodec4.encode(market), entryId]
6351
7277
  });
6352
7278
  }
6353
7279
  async function getPredictionEntryByMintAddress(market, mint, programId = PREDICTION_MIGRATOR_PROGRAM_ADDRESS) {
6354
7280
  return getProgramDerivedAddress({
6355
7281
  programAddress: programId,
6356
7282
  seeds: [
6357
- textEncoder4.encode("entry_by_mint"),
7283
+ textEncoder5.encode("entry_by_mint"),
6358
7284
  addressCodec4.encode(market),
6359
7285
  addressCodec4.encode(mint)
6360
7286
  ]
@@ -6524,6 +7450,19 @@ function createAccountMeta2(value, role) {
6524
7450
  }
6525
7451
  return { address: value, role };
6526
7452
  }
7453
+ function createRemainingAccountMeta(value) {
7454
+ if (typeof value === "string") {
7455
+ return { address: value, role: AccountRole.READONLY };
7456
+ }
7457
+ if (isTransactionSigner6(value)) {
7458
+ return {
7459
+ address: value.address,
7460
+ role: AccountRole.READONLY_SIGNER,
7461
+ signer: value
7462
+ };
7463
+ }
7464
+ return value;
7465
+ }
6527
7466
  function createCurveSwapExactInInstruction(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
6528
7467
  const {
6529
7468
  config,
@@ -6538,7 +7477,8 @@ function createCurveSwapExactInInstruction(accounts, args, programId = INITIALIZ
6538
7477
  user,
6539
7478
  hookProgram = SYSTEM_PROGRAM_ADDRESS,
6540
7479
  baseTokenProgram = TOKEN_PROGRAM_ADDRESS,
6541
- quoteTokenProgram = TOKEN_PROGRAM_ADDRESS
7480
+ quoteTokenProgram = TOKEN_PROGRAM_ADDRESS,
7481
+ remainingAccounts = []
6542
7482
  } = accounts;
6543
7483
  const keys = [
6544
7484
  { address: config, role: AccountRole.READONLY },
@@ -6556,7 +7496,8 @@ function createCurveSwapExactInInstruction(accounts, args, programId = INITIALIZ
6556
7496
  // no-op placeholder when no real hook is configured.
6557
7497
  { address: hookProgram, role: AccountRole.READONLY },
6558
7498
  { address: baseTokenProgram, role: AccountRole.READONLY },
6559
- { address: quoteTokenProgram, role: AccountRole.READONLY }
7499
+ { address: quoteTokenProgram, role: AccountRole.READONLY },
7500
+ ...remainingAccounts.map(createRemainingAccountMeta)
6560
7501
  ];
6561
7502
  const data = new Uint8Array(
6562
7503
  getCurveSwapExactInInstructionDataEncoder().encode(args)
@@ -6608,22 +7549,48 @@ function createMigrateLaunchInstruction(accounts, programId = INITIALIZER_PROGRA
6608
7549
  );
6609
7550
  return { programAddress: programId, accounts: keys, data };
6610
7551
  }
7552
+ function isTransactionSigner8(value) {
7553
+ return typeof value === "object" && value !== null && "address" in value && "signTransactions" in value;
7554
+ }
7555
+ function createRemainingAccountMeta2(value) {
7556
+ if (typeof value === "string") {
7557
+ return { address: value, role: AccountRole.READONLY };
7558
+ }
7559
+ if (isTransactionSigner8(value)) {
7560
+ return {
7561
+ address: value.address,
7562
+ role: AccountRole.READONLY_SIGNER,
7563
+ signer: value
7564
+ };
7565
+ }
7566
+ return value;
7567
+ }
6611
7568
  var previewSwapExactInResultCodec = getStructCodec([
6612
7569
  ["amountOut", getU64Codec()],
6613
7570
  ["feePaid", getU64Codec()]
6614
7571
  ]);
6615
7572
  function createPreviewSwapExactInInstruction(accounts, args, programId = INITIALIZER_PROGRAM_ID) {
6616
- const { launch, baseVault, quoteVault, hookProgram } = accounts;
7573
+ const {
7574
+ launch,
7575
+ baseVault,
7576
+ quoteVault,
7577
+ hookProgram,
7578
+ remainingAccounts = []
7579
+ } = accounts;
6617
7580
  const keys = [
6618
7581
  { address: launch, role: AccountRole.READONLY },
6619
7582
  { address: baseVault, role: AccountRole.READONLY },
6620
7583
  { address: quoteVault, role: AccountRole.READONLY }
6621
7584
  ];
6622
7585
  const accountsList = hookProgram ? [...keys, { address: hookProgram, role: AccountRole.READONLY }] : keys;
7586
+ const accountsWithRemaining = [
7587
+ ...accountsList,
7588
+ ...remainingAccounts.map(createRemainingAccountMeta2)
7589
+ ];
6623
7590
  const data = new Uint8Array(
6624
7591
  getPreviewSwapExactInInstructionDataEncoder2().encode(args)
6625
7592
  );
6626
- return { programAddress: programId, accounts: accountsList, data };
7593
+ return { programAddress: programId, accounts: accountsWithRemaining, data };
6627
7594
  }
6628
7595
  function decodePreviewSwapExactInResult(data) {
6629
7596
  return previewSwapExactInResultCodec.decode(data);
@@ -7775,7 +8742,8 @@ var DOPPLER_SOLANA_DEVNET_PROGRAM_ADDRESSES = {
7775
8742
  cpmmProgram: CPMM_PROGRAM_ID,
7776
8743
  initializerProgram: INITIALIZER_PROGRAM_ID,
7777
8744
  cpmmMigratorProgram: CPMM_MIGRATOR_PROGRAM_ID,
7778
- cpmmHookProgram: CPMM_HOOK_PROGRAM_ID
8745
+ cpmmHookProgram: CPMM_HOOK_PROGRAM_ID,
8746
+ cosignerHookProgram: COSIGNER_HOOK_PROGRAM_ID
7779
8747
  };
7780
8748
  async function deriveSolanaCpmmDeployment(programs = DOPPLER_SOLANA_DEVNET_PROGRAM_ADDRESSES) {
7781
8749
  const [cpmmConfig] = await getConfigAddress(programs.cpmmProgram);
@@ -7789,6 +8757,6 @@ async function deriveSolanaCpmmDeployment(programs = DOPPLER_SOLANA_DEVNET_PROGR
7789
8757
  };
7790
8758
  }
7791
8759
 
7792
- export { DOPPLER_SOLANA_DEVNET_PROGRAM_ADDRESSES, cpmm_exports as cpmm, cpmmMigrator_exports as cpmmMigrator, deriveSolanaCpmmDeployment, initializer_exports as initializer, predictionMigrator_exports as predictionMigrator, trustedOracle_exports as trustedOracle };
8760
+ export { DOPPLER_SOLANA_DEVNET_PROGRAM_ADDRESSES, cosignerHook_exports as cosignerHook, cpmm_exports as cpmm, cpmmMigrator_exports as cpmmMigrator, deriveSolanaCpmmDeployment, initializer_exports as initializer, predictionMigrator_exports as predictionMigrator, trustedOracle_exports as trustedOracle };
7793
8761
  //# sourceMappingURL=index.js.map
7794
8762
  //# sourceMappingURL=index.js.map