@loyal-labs/loyal-smart-accounts-core 0.1.1
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.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal.d.ts +1 -0
- package/dist/internal.js +1 -0
- package/dist/loyal.d.ts +1 -0
- package/dist/loyal.js +1 -0
- package/dist/src/accounts.d.ts +1 -0
- package/dist/src/accounts.js +1 -0
- package/dist/src/codecs.d.ts +6 -0
- package/dist/src/codecs.js +6 -0
- package/dist/src/core/codecs/index.d.ts +6 -0
- package/dist/src/core/codecs/index.js +6 -0
- package/dist/src/core/codecs/primitives.d.ts +7 -0
- package/dist/src/core/codecs/primitives.js +28 -0
- package/dist/src/core/errors/index.d.ts +29 -0
- package/dist/src/core/errors/index.js +124 -0
- package/dist/src/core/generated/index.d.ts +1 -0
- package/dist/src/core/generated/index.js +1 -0
- package/dist/src/core/pda/index.d.ts +44 -0
- package/dist/src/core/pda/index.js +80 -0
- package/dist/src/core/spec/features.d.ts +1 -0
- package/dist/src/core/spec/features.js +1 -0
- package/dist/src/core/spec/idl.d.ts +1 -0
- package/dist/src/core/spec/idl.js +1 -0
- package/dist/src/core/spec/index.d.ts +4 -0
- package/dist/src/core/spec/index.js +4 -0
- package/dist/src/core/spec/pda-registry.d.ts +1 -0
- package/dist/src/core/spec/pda-registry.js +1 -0
- package/dist/src/core/transport/index.d.ts +54 -0
- package/dist/src/core/transport/index.js +96 -0
- package/dist/src/errors.d.ts +1 -0
- package/dist/src/errors.js +1 -0
- package/dist/src/generated/accounts/Batch.d.ts +130 -0
- package/dist/src/generated/accounts/Batch.js +158 -0
- package/dist/src/generated/accounts/BatchTransaction.d.ts +105 -0
- package/dist/src/generated/accounts/BatchTransaction.js +130 -0
- package/dist/src/generated/accounts/LegacyTransaction.d.ts +122 -0
- package/dist/src/generated/accounts/LegacyTransaction.js +163 -0
- package/dist/src/generated/accounts/Policy.d.ts +139 -0
- package/dist/src/generated/accounts/Policy.js +208 -0
- package/dist/src/generated/accounts/ProgramConfig.d.ts +116 -0
- package/dist/src/generated/accounts/ProgramConfig.js +153 -0
- package/dist/src/generated/accounts/Proposal.d.ts +119 -0
- package/dist/src/generated/accounts/Proposal.js +157 -0
- package/dist/src/generated/accounts/Settings.d.ts +140 -0
- package/dist/src/generated/accounts/Settings.js +210 -0
- package/dist/src/generated/accounts/SettingsTransaction.d.ts +113 -0
- package/dist/src/generated/accounts/SettingsTransaction.js +151 -0
- package/dist/src/generated/accounts/SpendingLimit.d.ts +137 -0
- package/dist/src/generated/accounts/SpendingLimit.js +206 -0
- package/dist/src/generated/accounts/Transaction.d.ts +110 -0
- package/dist/src/generated/accounts/Transaction.js +145 -0
- package/dist/src/generated/accounts/TransactionBuffer.d.ts +113 -0
- package/dist/src/generated/accounts/TransactionBuffer.js +143 -0
- package/dist/src/generated/accounts/index.d.ts +35 -0
- package/dist/src/generated/accounts/index.js +35 -0
- package/dist/src/generated/errors/index.d.ts +1420 -0
- package/dist/src/generated/errors/index.js +2312 -0
- package/dist/src/generated/index.d.ts +19 -0
- package/dist/src/generated/index.js +19 -0
- package/dist/src/generated/instructions/activateProposal.d.ts +42 -0
- package/dist/src/generated/instructions/activateProposal.js +58 -0
- package/dist/src/generated/instructions/addSignerAsAuthority.d.ts +59 -0
- package/dist/src/generated/instructions/addSignerAsAuthority.js +78 -0
- package/dist/src/generated/instructions/addSpendingLimitAsAuthority.d.ts +58 -0
- package/dist/src/generated/instructions/addSpendingLimitAsAuthority.js +80 -0
- package/dist/src/generated/instructions/addTransactionToBatch.d.ts +60 -0
- package/dist/src/generated/instructions/addTransactionToBatch.js +85 -0
- package/dist/src/generated/instructions/approveProposal.d.ts +59 -0
- package/dist/src/generated/instructions/approveProposal.js +78 -0
- package/dist/src/generated/instructions/cancelProposal.d.ts +59 -0
- package/dist/src/generated/instructions/cancelProposal.js +78 -0
- package/dist/src/generated/instructions/changeThresholdAsAuthority.d.ts +59 -0
- package/dist/src/generated/instructions/changeThresholdAsAuthority.js +78 -0
- package/dist/src/generated/instructions/closeBatch.d.ts +49 -0
- package/dist/src/generated/instructions/closeBatch.js +78 -0
- package/dist/src/generated/instructions/closeBatchTransaction.d.ts +47 -0
- package/dist/src/generated/instructions/closeBatchTransaction.js +73 -0
- package/dist/src/generated/instructions/closeEmptyPolicyTransaction.d.ts +51 -0
- package/dist/src/generated/instructions/closeEmptyPolicyTransaction.js +83 -0
- package/dist/src/generated/instructions/closeSettingsTransaction.d.ts +49 -0
- package/dist/src/generated/instructions/closeSettingsTransaction.js +78 -0
- package/dist/src/generated/instructions/closeTransaction.d.ts +49 -0
- package/dist/src/generated/instructions/closeTransaction.js +78 -0
- package/dist/src/generated/instructions/closeTransactionBuffer.d.ts +42 -0
- package/dist/src/generated/instructions/closeTransactionBuffer.js +58 -0
- package/dist/src/generated/instructions/createBatch.d.ts +56 -0
- package/dist/src/generated/instructions/createBatch.js +75 -0
- package/dist/src/generated/instructions/createProposal.d.ts +58 -0
- package/dist/src/generated/instructions/createProposal.js +80 -0
- package/dist/src/generated/instructions/createSettingsTransaction.d.ts +58 -0
- package/dist/src/generated/instructions/createSettingsTransaction.js +80 -0
- package/dist/src/generated/instructions/createSmartAccount.d.ts +56 -0
- package/dist/src/generated/instructions/createSmartAccount.js +75 -0
- package/dist/src/generated/instructions/createTransaction.d.ts +58 -0
- package/dist/src/generated/instructions/createTransaction.js +80 -0
- package/dist/src/generated/instructions/createTransactionBuffer.d.ts +56 -0
- package/dist/src/generated/instructions/createTransactionBuffer.js +75 -0
- package/dist/src/generated/instructions/createTransactionFromBuffer.d.ts +63 -0
- package/dist/src/generated/instructions/createTransactionFromBuffer.js +90 -0
- package/dist/src/generated/instructions/executeBatchTransaction.d.ts +46 -0
- package/dist/src/generated/instructions/executeBatchTransaction.js +68 -0
- package/dist/src/generated/instructions/executeSettingsTransaction.d.ts +52 -0
- package/dist/src/generated/instructions/executeSettingsTransaction.js +81 -0
- package/dist/src/generated/instructions/executeSettingsTransactionSync.d.ts +57 -0
- package/dist/src/generated/instructions/executeSettingsTransactionSync.js +73 -0
- package/dist/src/generated/instructions/executeTransaction.d.ts +46 -0
- package/dist/src/generated/instructions/executeTransaction.js +68 -0
- package/dist/src/generated/instructions/executeTransactionSync.d.ts +51 -0
- package/dist/src/generated/instructions/executeTransactionSync.js +60 -0
- package/dist/src/generated/instructions/executeTransactionSyncV2.d.ts +51 -0
- package/dist/src/generated/instructions/executeTransactionSyncV2.js +60 -0
- package/dist/src/generated/instructions/extendTransactionBuffer.d.ts +53 -0
- package/dist/src/generated/instructions/extendTransactionBuffer.js +65 -0
- package/dist/src/generated/instructions/index.d.ts +39 -0
- package/dist/src/generated/instructions/index.js +39 -0
- package/dist/src/generated/instructions/initializeProgramConfig.d.ts +52 -0
- package/dist/src/generated/instructions/initializeProgramConfig.js +65 -0
- package/dist/src/generated/instructions/logEvent.d.ts +49 -0
- package/dist/src/generated/instructions/logEvent.js +55 -0
- package/dist/src/generated/instructions/rejectProposal.d.ts +59 -0
- package/dist/src/generated/instructions/rejectProposal.js +78 -0
- package/dist/src/generated/instructions/removeSignerAsAuthority.d.ts +59 -0
- package/dist/src/generated/instructions/removeSignerAsAuthority.js +78 -0
- package/dist/src/generated/instructions/removeSpendingLimitAsAuthority.d.ts +57 -0
- package/dist/src/generated/instructions/removeSpendingLimitAsAuthority.js +75 -0
- package/dist/src/generated/instructions/setArchivalAuthorityAsAuthority.d.ts +59 -0
- package/dist/src/generated/instructions/setArchivalAuthorityAsAuthority.js +78 -0
- package/dist/src/generated/instructions/setNewSettingsAuthorityAsAuthority.d.ts +59 -0
- package/dist/src/generated/instructions/setNewSettingsAuthorityAsAuthority.js +78 -0
- package/dist/src/generated/instructions/setProgramConfigAuthority.d.ts +51 -0
- package/dist/src/generated/instructions/setProgramConfigAuthority.js +60 -0
- package/dist/src/generated/instructions/setProgramConfigSmartAccountCreationFee.d.ts +51 -0
- package/dist/src/generated/instructions/setProgramConfigSmartAccountCreationFee.js +60 -0
- package/dist/src/generated/instructions/setProgramConfigTreasury.d.ts +51 -0
- package/dist/src/generated/instructions/setProgramConfigTreasury.js +60 -0
- package/dist/src/generated/instructions/setTimeLockAsAuthority.d.ts +59 -0
- package/dist/src/generated/instructions/setTimeLockAsAuthority.js +78 -0
- package/dist/src/generated/instructions/useSpendingLimit.d.ts +70 -0
- package/dist/src/generated/instructions/useSpendingLimit.js +108 -0
- package/dist/src/generated/types/AccountConstraint.d.ts +19 -0
- package/dist/src/generated/types/AccountConstraint.js +18 -0
- package/dist/src/generated/types/AccountConstraintType.d.ts +49 -0
- package/dist/src/generated/types/AccountConstraintType.js +25 -0
- package/dist/src/generated/types/AddSignerArgs.d.ts +17 -0
- package/dist/src/generated/types/AddSignerArgs.js +16 -0
- package/dist/src/generated/types/AddSpendingLimitArgs.d.ts +25 -0
- package/dist/src/generated/types/AddSpendingLimitArgs.js +24 -0
- package/dist/src/generated/types/AddTransactionToBatchArgs.d.ts +16 -0
- package/dist/src/generated/types/AddTransactionToBatchArgs.js +15 -0
- package/dist/src/generated/types/AllowedSettingsChange.d.ts +60 -0
- package/dist/src/generated/types/AllowedSettingsChange.js +35 -0
- package/dist/src/generated/types/ChangeThresholdArgs.d.ts +16 -0
- package/dist/src/generated/types/ChangeThresholdArgs.js +15 -0
- package/dist/src/generated/types/ConsensusAccountType.d.ts +20 -0
- package/dist/src/generated/types/ConsensusAccountType.js +21 -0
- package/dist/src/generated/types/CreateBatchArgs.d.ts +16 -0
- package/dist/src/generated/types/CreateBatchArgs.js +15 -0
- package/dist/src/generated/types/CreateProposalArgs.d.ts +16 -0
- package/dist/src/generated/types/CreateProposalArgs.js +15 -0
- package/dist/src/generated/types/CreateSettingsTransactionArgs.d.ts +17 -0
- package/dist/src/generated/types/CreateSettingsTransactionArgs.js +16 -0
- package/dist/src/generated/types/CreateSmartAccountArgs.d.ts +22 -0
- package/dist/src/generated/types/CreateSmartAccountArgs.js +21 -0
- package/dist/src/generated/types/CreateTransactionArgs.d.ts +49 -0
- package/dist/src/generated/types/CreateTransactionArgs.js +25 -0
- package/dist/src/generated/types/CreateTransactionBufferArgs.d.ts +19 -0
- package/dist/src/generated/types/CreateTransactionBufferArgs.js +18 -0
- package/dist/src/generated/types/DataConstraint.d.ts +19 -0
- package/dist/src/generated/types/DataConstraint.js +18 -0
- package/dist/src/generated/types/DataOperator.d.ts +24 -0
- package/dist/src/generated/types/DataOperator.js +25 -0
- package/dist/src/generated/types/DataValue.d.ts +71 -0
- package/dist/src/generated/types/DataValue.js +43 -0
- package/dist/src/generated/types/ExtendTransactionBufferArgs.d.ts +15 -0
- package/dist/src/generated/types/ExtendTransactionBufferArgs.js +12 -0
- package/dist/src/generated/types/Hook.d.ts +21 -0
- package/dist/src/generated/types/Hook.js +20 -0
- package/dist/src/generated/types/InitProgramConfigArgs.d.ts +18 -0
- package/dist/src/generated/types/InitProgramConfigArgs.js +17 -0
- package/dist/src/generated/types/InstructionConstraint.d.ts +20 -0
- package/dist/src/generated/types/InstructionConstraint.js +19 -0
- package/dist/src/generated/types/InternalFundTransferPayload.d.ts +20 -0
- package/dist/src/generated/types/InternalFundTransferPayload.js +19 -0
- package/dist/src/generated/types/InternalFundTransferPolicy.d.ts +18 -0
- package/dist/src/generated/types/InternalFundTransferPolicy.js +17 -0
- package/dist/src/generated/types/InternalFundTransferPolicyCreationPayload.d.ts +18 -0
- package/dist/src/generated/types/InternalFundTransferPolicyCreationPayload.js +17 -0
- package/dist/src/generated/types/LegacySyncTransactionArgs.d.ts +17 -0
- package/dist/src/generated/types/LegacySyncTransactionArgs.js +16 -0
- package/dist/src/generated/types/LimitedQuantityConstraints.d.ts +15 -0
- package/dist/src/generated/types/LimitedQuantityConstraints.js +12 -0
- package/dist/src/generated/types/LimitedSettingsAction.d.ts +61 -0
- package/dist/src/generated/types/LimitedSettingsAction.js +35 -0
- package/dist/src/generated/types/LimitedSpendingLimit.d.ts +20 -0
- package/dist/src/generated/types/LimitedSpendingLimit.js +19 -0
- package/dist/src/generated/types/LimitedTimeConstraints.d.ts +18 -0
- package/dist/src/generated/types/LimitedTimeConstraints.js +17 -0
- package/dist/src/generated/types/LogEventArgs.d.ts +17 -0
- package/dist/src/generated/types/LogEventArgs.js +16 -0
- package/dist/src/generated/types/LogEventArgsV2.d.ts +15 -0
- package/dist/src/generated/types/LogEventArgsV2.js +12 -0
- package/dist/src/generated/types/Payload.d.ts +49 -0
- package/dist/src/generated/types/Payload.js +25 -0
- package/dist/src/generated/types/Period.d.ts +22 -0
- package/dist/src/generated/types/Period.js +23 -0
- package/dist/src/generated/types/PeriodV2.d.ts +57 -0
- package/dist/src/generated/types/PeriodV2.js +26 -0
- package/dist/src/generated/types/Permissions.d.ts +15 -0
- package/dist/src/generated/types/Permissions.js +12 -0
- package/dist/src/generated/types/PolicyActionPayloadDetails.d.ts +16 -0
- package/dist/src/generated/types/PolicyActionPayloadDetails.js +13 -0
- package/dist/src/generated/types/PolicyCreationPayload.d.ts +63 -0
- package/dist/src/generated/types/PolicyCreationPayload.js +42 -0
- package/dist/src/generated/types/PolicyEventType.d.ts +22 -0
- package/dist/src/generated/types/PolicyEventType.js +23 -0
- package/dist/src/generated/types/PolicyExecutionContext.d.ts +20 -0
- package/dist/src/generated/types/PolicyExecutionContext.js +21 -0
- package/dist/src/generated/types/PolicyExpiration.d.ts +47 -0
- package/dist/src/generated/types/PolicyExpiration.js +28 -0
- package/dist/src/generated/types/PolicyExpirationArgs.d.ts +45 -0
- package/dist/src/generated/types/PolicyExpirationArgs.js +20 -0
- package/dist/src/generated/types/PolicyPayload.d.ts +63 -0
- package/dist/src/generated/types/PolicyPayload.js +37 -0
- package/dist/src/generated/types/PolicyState.d.ts +63 -0
- package/dist/src/generated/types/PolicyState.js +37 -0
- package/dist/src/generated/types/ProgramConfigSetAuthorityArgs.d.ts +16 -0
- package/dist/src/generated/types/ProgramConfigSetAuthorityArgs.js +13 -0
- package/dist/src/generated/types/ProgramConfigSetSmartAccountCreationFeeArgs.d.ts +15 -0
- package/dist/src/generated/types/ProgramConfigSetSmartAccountCreationFeeArgs.js +12 -0
- package/dist/src/generated/types/ProgramConfigSetTreasuryArgs.d.ts +16 -0
- package/dist/src/generated/types/ProgramConfigSetTreasuryArgs.js +13 -0
- package/dist/src/generated/types/ProgramInteractionPayload.d.ts +17 -0
- package/dist/src/generated/types/ProgramInteractionPayload.js +16 -0
- package/dist/src/generated/types/ProgramInteractionPolicy.d.ts +22 -0
- package/dist/src/generated/types/ProgramInteractionPolicy.js +21 -0
- package/dist/src/generated/types/ProgramInteractionPolicyCreationPayload.d.ts +22 -0
- package/dist/src/generated/types/ProgramInteractionPolicyCreationPayload.js +21 -0
- package/dist/src/generated/types/ProgramInteractionTransactionPayload.d.ts +49 -0
- package/dist/src/generated/types/ProgramInteractionTransactionPayload.js +25 -0
- package/dist/src/generated/types/ProposalEventType.d.ts +24 -0
- package/dist/src/generated/types/ProposalEventType.js +25 -0
- package/dist/src/generated/types/ProposalStatus.d.ts +75 -0
- package/dist/src/generated/types/ProposalStatus.js +45 -0
- package/dist/src/generated/types/QuantityConstraints.d.ts +17 -0
- package/dist/src/generated/types/QuantityConstraints.js +16 -0
- package/dist/src/generated/types/RemoveSignerArgs.d.ts +17 -0
- package/dist/src/generated/types/RemoveSignerArgs.js +16 -0
- package/dist/src/generated/types/RemoveSpendingLimitArgs.d.ts +15 -0
- package/dist/src/generated/types/RemoveSpendingLimitArgs.js +12 -0
- package/dist/src/generated/types/SetArchivalAuthorityArgs.d.ts +17 -0
- package/dist/src/generated/types/SetArchivalAuthorityArgs.js +16 -0
- package/dist/src/generated/types/SetNewSettingsAuthorityArgs.d.ts +17 -0
- package/dist/src/generated/types/SetNewSettingsAuthorityArgs.js +16 -0
- package/dist/src/generated/types/SetTimeLockArgs.d.ts +16 -0
- package/dist/src/generated/types/SetTimeLockArgs.js +15 -0
- package/dist/src/generated/types/SettingsAction.d.ts +118 -0
- package/dist/src/generated/types/SettingsAction.js +92 -0
- package/dist/src/generated/types/SettingsChangePayload.d.ts +17 -0
- package/dist/src/generated/types/SettingsChangePayload.js +16 -0
- package/dist/src/generated/types/SettingsChangePolicy.d.ts +16 -0
- package/dist/src/generated/types/SettingsChangePolicy.js +13 -0
- package/dist/src/generated/types/SettingsChangePolicyCreationPayload.d.ts +16 -0
- package/dist/src/generated/types/SettingsChangePolicyCreationPayload.js +13 -0
- package/dist/src/generated/types/SmartAccountCompiledInstruction.d.ts +17 -0
- package/dist/src/generated/types/SmartAccountCompiledInstruction.js +16 -0
- package/dist/src/generated/types/SmartAccountMessageAddressTableLookup.d.ts +18 -0
- package/dist/src/generated/types/SmartAccountMessageAddressTableLookup.js +17 -0
- package/dist/src/generated/types/SmartAccountSigner.d.ts +18 -0
- package/dist/src/generated/types/SmartAccountSigner.js +17 -0
- package/dist/src/generated/types/SmartAccountTransactionMessage.d.ts +23 -0
- package/dist/src/generated/types/SmartAccountTransactionMessage.js +25 -0
- package/dist/src/generated/types/SpendingLimitPayload.d.ts +18 -0
- package/dist/src/generated/types/SpendingLimitPayload.js +17 -0
- package/dist/src/generated/types/SpendingLimitPolicy.d.ts +19 -0
- package/dist/src/generated/types/SpendingLimitPolicy.js +18 -0
- package/dist/src/generated/types/SpendingLimitPolicyCreationPayload.d.ts +24 -0
- package/dist/src/generated/types/SpendingLimitPolicyCreationPayload.js +23 -0
- package/dist/src/generated/types/SpendingLimitV2.d.ts +22 -0
- package/dist/src/generated/types/SpendingLimitV2.js +21 -0
- package/dist/src/generated/types/SyncPayload.d.ts +48 -0
- package/dist/src/generated/types/SyncPayload.js +24 -0
- package/dist/src/generated/types/SyncSettingsTransactionArgs.d.ts +18 -0
- package/dist/src/generated/types/SyncSettingsTransactionArgs.js +17 -0
- package/dist/src/generated/types/SyncTransactionArgs.d.ts +18 -0
- package/dist/src/generated/types/SyncTransactionArgs.js +17 -0
- package/dist/src/generated/types/SyncTransactionPayloadDetails.d.ts +16 -0
- package/dist/src/generated/types/SyncTransactionPayloadDetails.js +15 -0
- package/dist/src/generated/types/SynchronousTransactionEventPayload.d.ts +50 -0
- package/dist/src/generated/types/SynchronousTransactionEventPayload.js +28 -0
- package/dist/src/generated/types/TimeConstraints.d.ts +19 -0
- package/dist/src/generated/types/TimeConstraints.js +18 -0
- package/dist/src/generated/types/TransactionEventType.d.ts +21 -0
- package/dist/src/generated/types/TransactionEventType.js +22 -0
- package/dist/src/generated/types/TransactionPayload.d.ts +18 -0
- package/dist/src/generated/types/TransactionPayload.js +17 -0
- package/dist/src/generated/types/TransactionPayloadDetails.d.ts +18 -0
- package/dist/src/generated/types/TransactionPayloadDetails.js +17 -0
- package/dist/src/generated/types/UsageState.d.ts +16 -0
- package/dist/src/generated/types/UsageState.js +15 -0
- package/dist/src/generated/types/UseSpendingLimitArgs.d.ts +17 -0
- package/dist/src/generated/types/UseSpendingLimitArgs.js +16 -0
- package/dist/src/generated/types/Vote.d.ts +21 -0
- package/dist/src/generated/types/Vote.js +22 -0
- package/dist/src/generated/types/VoteOnProposalArgs.d.ts +15 -0
- package/dist/src/generated/types/VoteOnProposalArgs.js +12 -0
- package/dist/src/generated/types/index.d.ts +83 -0
- package/dist/src/generated/types/index.js +83 -0
- package/dist/src/index.d.ts +15 -0
- package/dist/src/index.js +15 -0
- package/dist/src/internal/generated.d.ts +1 -0
- package/dist/src/internal/generated.js +1 -0
- package/dist/src/internal/index.d.ts +2 -0
- package/dist/src/internal/index.js +2 -0
- package/dist/src/internal/instructions/activateProposal.d.ts +7 -0
- package/dist/src/internal/instructions/activateProposal.js +14 -0
- package/dist/src/internal/instructions/addSignerAsAuthority.d.ts +10 -0
- package/dist/src/internal/instructions/addSignerAsAuthority.js +11 -0
- package/dist/src/internal/instructions/addSpendingLimitAsAuthority.d.ts +18 -0
- package/dist/src/internal/instructions/addSpendingLimitAsAuthority.js +27 -0
- package/dist/src/internal/instructions/addTransactionToBatch.d.ts +18 -0
- package/dist/src/internal/instructions/addTransactionToBatch.js +44 -0
- package/dist/src/internal/instructions/approveProposal.d.ts +8 -0
- package/dist/src/internal/instructions/approveProposal.js +10 -0
- package/dist/src/internal/instructions/cancelProposal.d.ts +8 -0
- package/dist/src/internal/instructions/cancelProposal.js +11 -0
- package/dist/src/internal/instructions/changeThresholdAsAuthority.d.ts +9 -0
- package/dist/src/internal/instructions/changeThresholdAsAuthority.js +14 -0
- package/dist/src/internal/instructions/closeBatch.d.ts +15 -0
- package/dist/src/internal/instructions/closeBatch.js +29 -0
- package/dist/src/internal/instructions/closeBatchTransaction.d.ts +15 -0
- package/dist/src/internal/instructions/closeBatchTransaction.js +34 -0
- package/dist/src/internal/instructions/closeEmptyPolicyTransaction.d.ts +8 -0
- package/dist/src/internal/instructions/closeEmptyPolicyTransaction.js +26 -0
- package/dist/src/internal/instructions/closeSettingsTransaction.d.ts +8 -0
- package/dist/src/internal/instructions/closeSettingsTransaction.js +22 -0
- package/dist/src/internal/instructions/closeTransaction.d.ts +8 -0
- package/dist/src/internal/instructions/closeTransaction.js +22 -0
- package/dist/src/internal/instructions/closeTransactionBuffer.d.ts +8 -0
- package/dist/src/internal/instructions/closeTransactionBuffer.js +15 -0
- package/dist/src/internal/instructions/createBatch.d.ts +12 -0
- package/dist/src/internal/instructions/createBatch.js +15 -0
- package/dist/src/internal/instructions/createPolicyTransaction.d.ts +11 -0
- package/dist/src/internal/instructions/createPolicyTransaction.js +21 -0
- package/dist/src/internal/instructions/createProposal.d.ts +11 -0
- package/dist/src/internal/instructions/createProposal.js +19 -0
- package/dist/src/internal/instructions/createSettingsTransaction.d.ts +14 -0
- package/dist/src/internal/instructions/createSettingsTransaction.js +17 -0
- package/dist/src/internal/instructions/createSmartAccount.d.ts +15 -0
- package/dist/src/internal/instructions/createSmartAccount.js +30 -0
- package/dist/src/internal/instructions/createTransaction.d.ts +16 -0
- package/dist/src/internal/instructions/createTransaction.js +39 -0
- package/dist/src/internal/instructions/createTransactionBuffer.d.ts +13 -0
- package/dist/src/internal/instructions/createTransactionBuffer.js +24 -0
- package/dist/src/internal/instructions/createTransactionFromBuffer.d.ts +13 -0
- package/dist/src/internal/instructions/createTransactionFromBuffer.js +39 -0
- package/dist/src/internal/instructions/executeBatchTransaction.d.ts +13 -0
- package/dist/src/internal/instructions/executeBatchTransaction.js +47 -0
- package/dist/src/internal/instructions/executePolicyPayloadSync.d.ts +15 -0
- package/dist/src/internal/instructions/executePolicyPayloadSync.js +18 -0
- package/dist/src/internal/instructions/executePolicyTransaction.d.ts +9 -0
- package/dist/src/internal/instructions/executePolicyTransaction.js +22 -0
- package/dist/src/internal/instructions/executeSettingsTransaction.d.ts +12 -0
- package/dist/src/internal/instructions/executeSettingsTransaction.js +37 -0
- package/dist/src/internal/instructions/executeSettingsTransactionSync.d.ts +11 -0
- package/dist/src/internal/instructions/executeSettingsTransactionSync.js +26 -0
- package/dist/src/internal/instructions/executeTransaction.d.ts +12 -0
- package/dist/src/internal/instructions/executeTransaction.js +49 -0
- package/dist/src/internal/instructions/executeTransactionSync.d.ts +14 -0
- package/dist/src/internal/instructions/executeTransactionSync.js +15 -0
- package/dist/src/internal/instructions/executeTransactionSyncV2.d.ts +14 -0
- package/dist/src/internal/instructions/executeTransactionSyncV2.js +18 -0
- package/dist/src/internal/instructions/extendTransactionBuffer.d.ts +9 -0
- package/dist/src/internal/instructions/extendTransactionBuffer.js +19 -0
- package/dist/src/internal/instructions/index.d.ts +42 -0
- package/dist/src/internal/instructions/index.js +42 -0
- package/dist/src/internal/instructions/initializeProgramConfig.d.ts +9 -0
- package/dist/src/internal/instructions/initializeProgramConfig.js +16 -0
- package/dist/src/internal/instructions/logEvent.d.ts +6 -0
- package/dist/src/internal/instructions/logEvent.js +10 -0
- package/dist/src/internal/instructions/rejectProposal.d.ts +8 -0
- package/dist/src/internal/instructions/rejectProposal.js +15 -0
- package/dist/src/internal/instructions/removeSignerAsAuthority.d.ts +8 -0
- package/dist/src/internal/instructions/removeSignerAsAuthority.js +10 -0
- package/dist/src/internal/instructions/removeSpendingLimitAsAuthority.d.ts +9 -0
- package/dist/src/internal/instructions/removeSpendingLimitAsAuthority.js +14 -0
- package/dist/src/internal/instructions/setArchivalAuthorityAsAuthority.d.ts +8 -0
- package/dist/src/internal/instructions/setArchivalAuthorityAsAuthority.js +15 -0
- package/dist/src/internal/instructions/setNewSettingsAuthorityAsAuthority.d.ts +8 -0
- package/dist/src/internal/instructions/setNewSettingsAuthorityAsAuthority.js +13 -0
- package/dist/src/internal/instructions/setProgramConfigAuthority.d.ts +6 -0
- package/dist/src/internal/instructions/setProgramConfigAuthority.js +13 -0
- package/dist/src/internal/instructions/setProgramConfigSmartAccountCreationFee.d.ts +7 -0
- package/dist/src/internal/instructions/setProgramConfigSmartAccountCreationFee.js +14 -0
- package/dist/src/internal/instructions/setProgramConfigTreasury.d.ts +6 -0
- package/dist/src/internal/instructions/setProgramConfigTreasury.js +13 -0
- package/dist/src/internal/instructions/setTimeLockAsAuthority.d.ts +8 -0
- package/dist/src/internal/instructions/setTimeLockAsAuthority.js +13 -0
- package/dist/src/internal/instructions/useSpendingLimit.d.ts +15 -0
- package/dist/src/internal/instructions/useSpendingLimit.js +24 -0
- package/dist/src/internal/pda.d.ts +1 -0
- package/dist/src/internal/pda.js +1 -0
- package/dist/src/internal/utils.d.ts +1 -0
- package/dist/src/internal/utils.js +1 -0
- package/dist/src/loyal.d.ts +18 -0
- package/dist/src/loyal.js +56 -0
- package/dist/src/pda.d.ts +1 -0
- package/dist/src/pda.js +1 -0
- package/dist/src/spec/features.d.ts +15 -0
- package/dist/src/spec/features.js +69 -0
- package/dist/src/spec/idl.d.ts +3 -0
- package/dist/src/spec/idl.js +75 -0
- package/dist/src/spec/index.d.ts +4 -0
- package/dist/src/spec/index.js +4 -0
- package/dist/src/spec/operation-registry.d.ts +385 -0
- package/dist/src/spec/operation-registry.js +390 -0
- package/dist/src/spec/pda-registry.d.ts +32 -0
- package/dist/src/spec/pda-registry.js +71 -0
- package/dist/src/transport.d.ts +1 -0
- package/dist/src/transport.js +1 -0
- package/dist/src/types.d.ts +69 -0
- package/dist/src/types.js +129 -0
- package/dist/src/utils/compileToSynchronousMessage.d.ts +9 -0
- package/dist/src/utils/compileToSynchronousMessage.js +87 -0
- package/dist/src/utils/compileToSynchronousMessageV2.d.ts +19 -0
- package/dist/src/utils/compileToSynchronousMessageV2.js +154 -0
- package/dist/src/utils/compileToWrappedMessageV0.d.ts +7 -0
- package/dist/src/utils/compileToWrappedMessageV0.js +30 -0
- package/dist/src/utils/compiled-keys.d.ts +31 -0
- package/dist/src/utils/compiled-keys.js +144 -0
- package/dist/src/utils.d.ts +61 -0
- package/dist/src/utils.js +217 -0
- package/package.json +71 -0
- package/upstream/manifest.json +14 -0
- package/upstream/normalized/squads_smart_account_program.json +6020 -0
- package/upstream/raw/squads_smart_account_program.json +6020 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import * as beet from "@metaplex-foundation/beet";
|
|
2
|
+
import * as beetSolana from "@metaplex-foundation/beet-solana";
|
|
3
|
+
import invariant from "invariant";
|
|
4
|
+
export { isProposalStatusActive, isProposalStatusApproved, isProposalStatusRejected, isProposalStatusCancelled, isProposalStatusExecuted, isSettingsActionAddSigner, isSettingsActionRemoveSigner, isSettingsActionChangeThreshold, isSettingsActionAddSpendingLimit, isSettingsActionRemoveSpendingLimit, isSettingsActionSetTimeLock, } from "./generated";
|
|
5
|
+
export const Permission = {
|
|
6
|
+
Initiate: 0b0000_0001,
|
|
7
|
+
Vote: 0b0000_0010,
|
|
8
|
+
Execute: 0b0000_0100,
|
|
9
|
+
};
|
|
10
|
+
export class Permissions {
|
|
11
|
+
mask;
|
|
12
|
+
constructor(mask) {
|
|
13
|
+
this.mask = mask;
|
|
14
|
+
}
|
|
15
|
+
static fromPermissions(permissions) {
|
|
16
|
+
return new Permissions(permissions.reduce((mask, permission) => mask | permission, 0));
|
|
17
|
+
}
|
|
18
|
+
static all() {
|
|
19
|
+
return new Permissions(Object.values(Permission).reduce((mask, permission) => mask | permission, 0));
|
|
20
|
+
}
|
|
21
|
+
static has(permissions, permission) {
|
|
22
|
+
return (permissions.mask & permission) === permission;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* De/Serializes a small array with configurable length prefix and a specific number of elements of type {@link T}
|
|
27
|
+
* which do not all have the same size.
|
|
28
|
+
*
|
|
29
|
+
* @template T type of elements held in the array
|
|
30
|
+
*
|
|
31
|
+
* @param lengthBeet the De/Serializer for the array length prefix
|
|
32
|
+
* @param elements the De/Serializers for the element types
|
|
33
|
+
* @param elementsByteSize size of all elements in the array combined
|
|
34
|
+
*
|
|
35
|
+
* The implementation is minor modification of `fixedSizeArray` where the length is encoded as `lengthBeet.byteSize` bytes:
|
|
36
|
+
* https://github.dev/metaplex-foundation/beet/blob/e053b7b5b0c46ce7f6906ecd38be9fd85d6e5254/beet/src/beets/collections.ts#L84
|
|
37
|
+
*/
|
|
38
|
+
export function fixedSizeSmallArray(lengthBeet, elements, elementsByteSize) {
|
|
39
|
+
const len = elements.length;
|
|
40
|
+
const firstElement = len === 0 ? "<EMPTY>" : elements[0].description;
|
|
41
|
+
return {
|
|
42
|
+
write: function (buf, offset, value) {
|
|
43
|
+
invariant(value.length === len, `array length ${value.length} should match len ${len}`);
|
|
44
|
+
lengthBeet.write(buf, offset, len);
|
|
45
|
+
let cursor = offset + lengthBeet.byteSize;
|
|
46
|
+
for (let i = 0; i < len; i++) {
|
|
47
|
+
const element = elements[i];
|
|
48
|
+
element.write(buf, cursor, value[i]);
|
|
49
|
+
cursor += element.byteSize;
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
read: function (buf, offset) {
|
|
53
|
+
const size = lengthBeet.read(buf, offset);
|
|
54
|
+
invariant(size === len, "invalid byte size");
|
|
55
|
+
let cursor = offset + lengthBeet.byteSize;
|
|
56
|
+
const arr = new Array(len);
|
|
57
|
+
for (let i = 0; i < len; i++) {
|
|
58
|
+
const element = elements[i];
|
|
59
|
+
arr[i] = element.read(buf, cursor);
|
|
60
|
+
cursor += element.byteSize;
|
|
61
|
+
}
|
|
62
|
+
return arr;
|
|
63
|
+
},
|
|
64
|
+
byteSize: lengthBeet.byteSize + elementsByteSize,
|
|
65
|
+
length: len,
|
|
66
|
+
description: `Array<${firstElement}>(${len})[ ${lengthBeet.byteSize} + ${elementsByteSize} ]`,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Wraps a small array De/Serializer with configurable length prefix and elements of type {@link T}
|
|
71
|
+
* which do not all have the same size.
|
|
72
|
+
*
|
|
73
|
+
* @template T type of elements held in the array
|
|
74
|
+
*
|
|
75
|
+
* @param lengthBeet the De/Serializer for the array length prefix
|
|
76
|
+
* @param element the De/Serializer for the element types
|
|
77
|
+
*
|
|
78
|
+
* The implementation is minor modification of `array` where the length is encoded as `lengthBeet.byteSize` bytes:
|
|
79
|
+
* https://github.dev/metaplex-foundation/beet/blob/e053b7b5b0c46ce7f6906ecd38be9fd85d6e5254/beet/src/beets/collections.ts#L137
|
|
80
|
+
*/
|
|
81
|
+
export function smallArray(lengthBeet, element) {
|
|
82
|
+
return {
|
|
83
|
+
toFixedFromData(buf, offset) {
|
|
84
|
+
const len = lengthBeet.read(buf, offset);
|
|
85
|
+
const cursorStart = offset + lengthBeet.byteSize;
|
|
86
|
+
let cursor = cursorStart;
|
|
87
|
+
const fixedElements = new Array(len);
|
|
88
|
+
for (let i = 0; i < len; i++) {
|
|
89
|
+
const fixedElement = beet.fixBeetFromData(element, buf, cursor);
|
|
90
|
+
fixedElements[i] = fixedElement;
|
|
91
|
+
cursor += fixedElement.byteSize;
|
|
92
|
+
}
|
|
93
|
+
return fixedSizeSmallArray(lengthBeet, fixedElements, cursor - cursorStart);
|
|
94
|
+
},
|
|
95
|
+
toFixedFromValue(vals) {
|
|
96
|
+
invariant(Array.isArray(vals), `${vals} should be an array`);
|
|
97
|
+
let elementsSize = 0;
|
|
98
|
+
const fixedElements = new Array(vals.length);
|
|
99
|
+
for (let i = 0; i < vals.length; i++) {
|
|
100
|
+
const fixedElement = beet.fixBeetFromValue(element, vals[i]);
|
|
101
|
+
fixedElements[i] = fixedElement;
|
|
102
|
+
elementsSize += fixedElement.byteSize;
|
|
103
|
+
}
|
|
104
|
+
return fixedSizeSmallArray(lengthBeet, fixedElements, elementsSize);
|
|
105
|
+
},
|
|
106
|
+
description: `smallArray`,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export const compiledMsInstructionBeet = new beet.FixableBeetArgsStruct([
|
|
110
|
+
["programIdIndex", beet.u8],
|
|
111
|
+
["accountIndexes", smallArray(beet.u8, beet.u8)],
|
|
112
|
+
["data", smallArray(beet.u16, beet.u8)],
|
|
113
|
+
], "CompiledMsInstruction");
|
|
114
|
+
export const messageAddressTableLookupBeet = new beet.FixableBeetArgsStruct([
|
|
115
|
+
["accountKey", beetSolana.publicKey],
|
|
116
|
+
["writableIndexes", smallArray(beet.u8, beet.u8)],
|
|
117
|
+
["readonlyIndexes", smallArray(beet.u8, beet.u8)],
|
|
118
|
+
], "MessageAddressTableLookup");
|
|
119
|
+
export const transactionMessageBeet = new beet.FixableBeetArgsStruct([
|
|
120
|
+
["numSigners", beet.u8],
|
|
121
|
+
["numWritableSigners", beet.u8],
|
|
122
|
+
["numWritableNonSigners", beet.u8],
|
|
123
|
+
["accountKeys", smallArray(beet.u8, beetSolana.publicKey)],
|
|
124
|
+
["instructions", smallArray(beet.u8, compiledMsInstructionBeet)],
|
|
125
|
+
[
|
|
126
|
+
"addressTableLookups",
|
|
127
|
+
smallArray(beet.u8, messageAddressTableLookupBeet),
|
|
128
|
+
],
|
|
129
|
+
], "TransactionMessage");
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AccountMeta, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
|
+
export declare function compileToSynchronousMessageAndAccounts({ vaultPda, members, instructions, }: {
|
|
3
|
+
vaultPda: PublicKey;
|
|
4
|
+
members: PublicKey[];
|
|
5
|
+
instructions: TransactionInstruction[];
|
|
6
|
+
}): {
|
|
7
|
+
instructions: Uint8Array;
|
|
8
|
+
accounts: AccountMeta[];
|
|
9
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { CompiledKeys } from "./compiled-keys";
|
|
2
|
+
export function compileToSynchronousMessageAndAccounts({ vaultPda, members, instructions, }) {
|
|
3
|
+
// Compile instructions to get account mapping
|
|
4
|
+
const compiledKeys = CompiledKeys.compileWithoutPayer(instructions);
|
|
5
|
+
// Get message components
|
|
6
|
+
const [header, staticAccountKeys] = compiledKeys.getMessageComponents();
|
|
7
|
+
// Mark the vault as non-signer if it exists
|
|
8
|
+
// Create remaining accounts array starting with vault
|
|
9
|
+
const remainingAccounts = [];
|
|
10
|
+
// Add the members as signers
|
|
11
|
+
members.forEach((member) => {
|
|
12
|
+
remainingAccounts.unshift({
|
|
13
|
+
pubkey: member,
|
|
14
|
+
isSigner: true,
|
|
15
|
+
isWritable: false,
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
// Add all other accounts
|
|
19
|
+
staticAccountKeys.forEach((key, index) => {
|
|
20
|
+
remainingAccounts.push({
|
|
21
|
+
pubkey: key,
|
|
22
|
+
isSigner: index < header.numRequiredSignatures,
|
|
23
|
+
isWritable: index <
|
|
24
|
+
header.numRequiredSignatures - header.numReadonlySignedAccounts ||
|
|
25
|
+
(index >= header.numRequiredSignatures &&
|
|
26
|
+
index <
|
|
27
|
+
staticAccountKeys.length - header.numReadonlyUnsignedAccounts),
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
// Mark the vault as non-signer if it exists
|
|
31
|
+
if (remainingAccounts.find((acc) => acc.pubkey.equals(vaultPda))) {
|
|
32
|
+
remainingAccounts.find((acc) => acc.pubkey.equals(vaultPda)).isSigner =
|
|
33
|
+
false;
|
|
34
|
+
}
|
|
35
|
+
// Compile instructions with updated indices
|
|
36
|
+
let args_buffer = Buffer.alloc(0);
|
|
37
|
+
// Insert instruction length as u8 as first byte
|
|
38
|
+
args_buffer = Buffer.concat([Buffer.from([instructions.length])]);
|
|
39
|
+
// Serialize each instruction
|
|
40
|
+
instructions.forEach((ix) => {
|
|
41
|
+
const accounts = ix.keys.map((key) => {
|
|
42
|
+
const index = remainingAccounts.findIndex((acc) => acc.pubkey.equals(key.pubkey));
|
|
43
|
+
if (index === -1) {
|
|
44
|
+
throw new Error(`Account ${key.pubkey.toBase58()} not found in remaining accounts`);
|
|
45
|
+
}
|
|
46
|
+
return index;
|
|
47
|
+
});
|
|
48
|
+
const programIdIndex = remainingAccounts.findIndex((id) => id.pubkey.equals(ix.programId));
|
|
49
|
+
if (programIdIndex === -1) {
|
|
50
|
+
throw new Error(`ProgramId ${ix.programId.toBase58()} not found in remaining accounts`);
|
|
51
|
+
}
|
|
52
|
+
const serialized_ix = serializeCompiledInstruction({
|
|
53
|
+
programIdIndex,
|
|
54
|
+
accountIndexes: accounts,
|
|
55
|
+
data: ix.data,
|
|
56
|
+
});
|
|
57
|
+
// Concatenate the serialized instruction to the buffer
|
|
58
|
+
args_buffer = Buffer.concat([args_buffer, serialized_ix]);
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
instructions: args_buffer,
|
|
62
|
+
accounts: remainingAccounts,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function serializeCompiledInstruction(ix) {
|
|
66
|
+
// Create a buffer to hold the serialized instruction
|
|
67
|
+
let buffer = Buffer.alloc(0);
|
|
68
|
+
// Add program id index (u8)
|
|
69
|
+
buffer = Buffer.concat([buffer, Buffer.from([ix.programIdIndex])]);
|
|
70
|
+
// SmallVec<u8, u8> for account indexes
|
|
71
|
+
buffer = Buffer.concat([
|
|
72
|
+
buffer,
|
|
73
|
+
// Length prefix as u8
|
|
74
|
+
Buffer.from([ix.accountIndexes.length]),
|
|
75
|
+
// The account indexes
|
|
76
|
+
Buffer.from(ix.accountIndexes),
|
|
77
|
+
]);
|
|
78
|
+
// SmallVec<u16, u8> for data
|
|
79
|
+
buffer = Buffer.concat([
|
|
80
|
+
buffer,
|
|
81
|
+
// Length prefix as u16 (little endian)
|
|
82
|
+
Buffer.from(new Uint16Array([ix.data.length]).buffer),
|
|
83
|
+
// The actual data bytes
|
|
84
|
+
ix.data,
|
|
85
|
+
]);
|
|
86
|
+
return Uint8Array.from(buffer);
|
|
87
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AccountMeta, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
|
+
export declare function compileToSynchronousMessageAndAccountsV2({ vaultPda, members, instructions, }: {
|
|
3
|
+
vaultPda: PublicKey;
|
|
4
|
+
members: PublicKey[];
|
|
5
|
+
instructions: TransactionInstruction[];
|
|
6
|
+
}): {
|
|
7
|
+
instructions: Uint8Array;
|
|
8
|
+
accounts: AccountMeta[];
|
|
9
|
+
};
|
|
10
|
+
export declare function compileToSynchronousMessageAndAccountsV2WithHooks({ vaultPda, members, preHookAccounts, postHookAccounts, instructions, }: {
|
|
11
|
+
vaultPda: PublicKey;
|
|
12
|
+
members: PublicKey[];
|
|
13
|
+
preHookAccounts: AccountMeta[];
|
|
14
|
+
postHookAccounts: AccountMeta[];
|
|
15
|
+
instructions: TransactionInstruction[];
|
|
16
|
+
}): {
|
|
17
|
+
instructions: Uint8Array;
|
|
18
|
+
accounts: AccountMeta[];
|
|
19
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { CompiledKeys } from "./compiled-keys";
|
|
2
|
+
export function compileToSynchronousMessageAndAccountsV2({ vaultPda, members, instructions, }) {
|
|
3
|
+
// Compile instructions to get account mapping
|
|
4
|
+
const compiledKeys = CompiledKeys.compileWithoutPayer(instructions);
|
|
5
|
+
// Get message components
|
|
6
|
+
const [header, staticAccountKeys] = compiledKeys.getMessageComponents();
|
|
7
|
+
// Mark the vault as non-signer if it exists
|
|
8
|
+
// Create remaining accounts array starting with vault
|
|
9
|
+
const remainingAccounts = [];
|
|
10
|
+
// Add all other accounts
|
|
11
|
+
staticAccountKeys.forEach((key, index) => {
|
|
12
|
+
remainingAccounts.push({
|
|
13
|
+
pubkey: key,
|
|
14
|
+
isSigner: index < header.numRequiredSignatures,
|
|
15
|
+
isWritable: index <
|
|
16
|
+
header.numRequiredSignatures - header.numReadonlySignedAccounts ||
|
|
17
|
+
(index >= header.numRequiredSignatures &&
|
|
18
|
+
index <
|
|
19
|
+
staticAccountKeys.length - header.numReadonlyUnsignedAccounts),
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
// Mark the vault as non-signer if it exists
|
|
23
|
+
if (remainingAccounts.find((acc) => acc.pubkey.equals(vaultPda))) {
|
|
24
|
+
remainingAccounts.find((acc) => acc.pubkey.equals(vaultPda)).isSigner =
|
|
25
|
+
false;
|
|
26
|
+
}
|
|
27
|
+
// Compile instructions with updated indices
|
|
28
|
+
let args_buffer = Buffer.alloc(0);
|
|
29
|
+
// Insert instruction length as u8 as first byte
|
|
30
|
+
args_buffer = Buffer.concat([Buffer.from([instructions.length])]);
|
|
31
|
+
// Serialize each instruction
|
|
32
|
+
instructions.forEach((ix) => {
|
|
33
|
+
const accounts = ix.keys.map((key) => {
|
|
34
|
+
const index = remainingAccounts.findIndex((acc) => acc.pubkey.equals(key.pubkey));
|
|
35
|
+
if (index === -1) {
|
|
36
|
+
throw new Error(`Account ${key.pubkey.toBase58()} not found in remaining accounts`);
|
|
37
|
+
}
|
|
38
|
+
return index;
|
|
39
|
+
});
|
|
40
|
+
const programIdIndex = remainingAccounts.findIndex((id) => id.pubkey.equals(ix.programId));
|
|
41
|
+
if (programIdIndex === -1) {
|
|
42
|
+
throw new Error(`ProgramId ${ix.programId.toBase58()} not found in remaining accounts`);
|
|
43
|
+
}
|
|
44
|
+
const serialized_ix = serializeCompiledInstruction({
|
|
45
|
+
programIdIndex,
|
|
46
|
+
accountIndexes: accounts,
|
|
47
|
+
data: ix.data,
|
|
48
|
+
});
|
|
49
|
+
// Concatenate the serialized instruction to the buffer
|
|
50
|
+
args_buffer = Buffer.concat([args_buffer, serialized_ix]);
|
|
51
|
+
// Add the members as signers
|
|
52
|
+
members.forEach((member) => {
|
|
53
|
+
remainingAccounts.unshift({
|
|
54
|
+
pubkey: member,
|
|
55
|
+
isSigner: true,
|
|
56
|
+
isWritable: false,
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
return {
|
|
61
|
+
instructions: args_buffer,
|
|
62
|
+
accounts: remainingAccounts,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export function compileToSynchronousMessageAndAccountsV2WithHooks({ vaultPda, members, preHookAccounts, postHookAccounts, instructions, }) {
|
|
66
|
+
// Compile instructions to get account mapping
|
|
67
|
+
const compiledKeys = CompiledKeys.compileWithoutPayer(instructions);
|
|
68
|
+
// Get message components
|
|
69
|
+
const [header, staticAccountKeys] = compiledKeys.getMessageComponents();
|
|
70
|
+
// Mark the vault as non-signer if it exists
|
|
71
|
+
// Create remaining accounts array starting with vault
|
|
72
|
+
const remainingAccounts = [];
|
|
73
|
+
// Add all other accounts
|
|
74
|
+
staticAccountKeys.forEach((key, index) => {
|
|
75
|
+
remainingAccounts.push({
|
|
76
|
+
pubkey: key,
|
|
77
|
+
isSigner: index < header.numRequiredSignatures,
|
|
78
|
+
isWritable: index <
|
|
79
|
+
header.numRequiredSignatures - header.numReadonlySignedAccounts ||
|
|
80
|
+
(index >= header.numRequiredSignatures &&
|
|
81
|
+
index <
|
|
82
|
+
staticAccountKeys.length - header.numReadonlyUnsignedAccounts),
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
// Mark the vault as non-signer if it exists
|
|
86
|
+
if (remainingAccounts.find((acc) => acc.pubkey.equals(vaultPda))) {
|
|
87
|
+
remainingAccounts.find((acc) => acc.pubkey.equals(vaultPda)).isSigner =
|
|
88
|
+
false;
|
|
89
|
+
}
|
|
90
|
+
// Compile instructions with updated indices
|
|
91
|
+
let args_buffer = Buffer.alloc(0);
|
|
92
|
+
// Insert instruction length as u8 as first byte
|
|
93
|
+
args_buffer = Buffer.concat([Buffer.from([instructions.length])]);
|
|
94
|
+
// Serialize each instruction
|
|
95
|
+
instructions.forEach((ix) => {
|
|
96
|
+
const accounts = ix.keys.map((key) => {
|
|
97
|
+
const index = remainingAccounts.findIndex((acc) => acc.pubkey.equals(key.pubkey));
|
|
98
|
+
if (index === -1) {
|
|
99
|
+
throw new Error(`Account ${key.pubkey.toBase58()} not found in remaining accounts`);
|
|
100
|
+
}
|
|
101
|
+
return index;
|
|
102
|
+
});
|
|
103
|
+
const programIdIndex = remainingAccounts.findIndex((id) => id.pubkey.equals(ix.programId));
|
|
104
|
+
if (programIdIndex === -1) {
|
|
105
|
+
throw new Error(`ProgramId ${ix.programId.toBase58()} not found in remaining accounts`);
|
|
106
|
+
}
|
|
107
|
+
const serialized_ix = serializeCompiledInstruction({
|
|
108
|
+
programIdIndex,
|
|
109
|
+
accountIndexes: accounts,
|
|
110
|
+
data: ix.data,
|
|
111
|
+
});
|
|
112
|
+
// Concatenate the serialized instruction to the buffer
|
|
113
|
+
args_buffer = Buffer.concat([args_buffer, serialized_ix]);
|
|
114
|
+
// Add the members as signers
|
|
115
|
+
members.forEach((member) => {
|
|
116
|
+
remainingAccounts.unshift({
|
|
117
|
+
pubkey: member,
|
|
118
|
+
isSigner: true,
|
|
119
|
+
isWritable: false,
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
// Add the pre hook accounts after the members
|
|
123
|
+
remainingAccounts.splice(members.length, 0, ...preHookAccounts);
|
|
124
|
+
// Add the post hook accounts after the pre hook accounts
|
|
125
|
+
remainingAccounts.splice(members.length + preHookAccounts.length, 0, ...postHookAccounts);
|
|
126
|
+
});
|
|
127
|
+
return {
|
|
128
|
+
instructions: args_buffer,
|
|
129
|
+
accounts: remainingAccounts,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function serializeCompiledInstruction(ix) {
|
|
133
|
+
// Create a buffer to hold the serialized instruction
|
|
134
|
+
let buffer = Buffer.alloc(0);
|
|
135
|
+
// Add program id index (u8)
|
|
136
|
+
buffer = Buffer.concat([buffer, Buffer.from([ix.programIdIndex])]);
|
|
137
|
+
// SmallVec<u8, u8> for account indexes
|
|
138
|
+
buffer = Buffer.concat([
|
|
139
|
+
buffer,
|
|
140
|
+
// Length prefix as u8
|
|
141
|
+
Buffer.from([ix.accountIndexes.length]),
|
|
142
|
+
// The account indexes
|
|
143
|
+
Buffer.from(ix.accountIndexes),
|
|
144
|
+
]);
|
|
145
|
+
// SmallVec<u16, u8> for data
|
|
146
|
+
buffer = Buffer.concat([
|
|
147
|
+
buffer,
|
|
148
|
+
// Length prefix as u16 (little endian)
|
|
149
|
+
Buffer.from(new Uint16Array([ix.data.length]).buffer),
|
|
150
|
+
// The actual data bytes
|
|
151
|
+
ix.data,
|
|
152
|
+
]);
|
|
153
|
+
return Uint8Array.from(buffer);
|
|
154
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AddressLookupTableAccount, MessageV0, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
|
+
export declare function compileToWrappedMessageV0({ payerKey, recentBlockhash, instructions, addressLookupTableAccounts, }: {
|
|
3
|
+
payerKey: PublicKey;
|
|
4
|
+
recentBlockhash: string;
|
|
5
|
+
instructions: TransactionInstruction[];
|
|
6
|
+
addressLookupTableAccounts?: AddressLookupTableAccount[];
|
|
7
|
+
}): MessageV0;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MessageAccountKeys, MessageV0, } from "@solana/web3.js";
|
|
2
|
+
import { CompiledKeys } from "./compiled-keys";
|
|
3
|
+
export function compileToWrappedMessageV0({ payerKey, recentBlockhash, instructions, addressLookupTableAccounts, }) {
|
|
4
|
+
const compiledKeys = CompiledKeys.compile(instructions, payerKey);
|
|
5
|
+
const addressTableLookups = new Array();
|
|
6
|
+
const accountKeysFromLookups = {
|
|
7
|
+
writable: [],
|
|
8
|
+
readonly: [],
|
|
9
|
+
};
|
|
10
|
+
const lookupTableAccounts = addressLookupTableAccounts || [];
|
|
11
|
+
for (const lookupTable of lookupTableAccounts) {
|
|
12
|
+
const extractResult = compiledKeys.extractTableLookup(lookupTable);
|
|
13
|
+
if (extractResult !== undefined) {
|
|
14
|
+
const [addressTableLookup, { writable, readonly }] = extractResult;
|
|
15
|
+
addressTableLookups.push(addressTableLookup);
|
|
16
|
+
accountKeysFromLookups.writable.push(...writable);
|
|
17
|
+
accountKeysFromLookups.readonly.push(...readonly);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const [header, staticAccountKeys] = compiledKeys.getMessageComponents();
|
|
21
|
+
const accountKeys = new MessageAccountKeys(staticAccountKeys, accountKeysFromLookups);
|
|
22
|
+
const compiledInstructions = accountKeys.compileInstructions(instructions);
|
|
23
|
+
return new MessageV0({
|
|
24
|
+
header,
|
|
25
|
+
staticAccountKeys,
|
|
26
|
+
recentBlockhash,
|
|
27
|
+
compiledInstructions,
|
|
28
|
+
addressTableLookups,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AccountKeysFromLookups, AddressLookupTableAccount, MessageAddressTableLookup, MessageHeader, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
|
+
export type CompiledKeyMeta = {
|
|
3
|
+
isSigner: boolean;
|
|
4
|
+
isWritable: boolean;
|
|
5
|
+
isInvoked: boolean;
|
|
6
|
+
};
|
|
7
|
+
type KeyMetaMap = Map<string, CompiledKeyMeta>;
|
|
8
|
+
/**
|
|
9
|
+
* This is almost completely copy-pasted from solana-web3.js and slightly adapted to work with "wrapped" transaction messaged such as in VaultTransaction.
|
|
10
|
+
* @see https://github.com/solana-labs/solana-web3.js/blob/87d33ac68e2453b8a01cf8c425aa7623888434e8/packages/library-legacy/src/message/compiled-keys.ts
|
|
11
|
+
*/
|
|
12
|
+
export declare class CompiledKeys {
|
|
13
|
+
payer?: PublicKey;
|
|
14
|
+
keyMetaMap: KeyMetaMap;
|
|
15
|
+
constructor(payer: PublicKey | undefined, keyMetaMap: KeyMetaMap);
|
|
16
|
+
/**
|
|
17
|
+
* The only difference between this and the original is that we don't mark the instruction programIds as invoked.
|
|
18
|
+
* It makes sense to do because the instructions will be called via CPI, so the programIds can come from Address Lookup Tables.
|
|
19
|
+
* This allows to compress the message size and avoid hitting the tx size limit during vault_transaction_create instruction calls.
|
|
20
|
+
*/
|
|
21
|
+
static compile(instructions: Array<TransactionInstruction>, payer: PublicKey): CompiledKeys;
|
|
22
|
+
/**
|
|
23
|
+
* Compiles instructions without a payer.
|
|
24
|
+
*/
|
|
25
|
+
static compileWithoutPayer(instructions: Array<TransactionInstruction>): CompiledKeys;
|
|
26
|
+
getMessageComponents(): [MessageHeader, Array<PublicKey>];
|
|
27
|
+
extractTableLookup(lookupTable: AddressLookupTableAccount): [MessageAddressTableLookup, AccountKeysFromLookups] | undefined;
|
|
28
|
+
/** @internal */
|
|
29
|
+
private drainKeysFoundInLookupTable;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { PublicKey, } from "@solana/web3.js";
|
|
2
|
+
import assert from "assert";
|
|
3
|
+
/**
|
|
4
|
+
* This is almost completely copy-pasted from solana-web3.js and slightly adapted to work with "wrapped" transaction messaged such as in VaultTransaction.
|
|
5
|
+
* @see https://github.com/solana-labs/solana-web3.js/blob/87d33ac68e2453b8a01cf8c425aa7623888434e8/packages/library-legacy/src/message/compiled-keys.ts
|
|
6
|
+
*/
|
|
7
|
+
export class CompiledKeys {
|
|
8
|
+
payer;
|
|
9
|
+
keyMetaMap;
|
|
10
|
+
constructor(payer, keyMetaMap) {
|
|
11
|
+
this.payer = payer;
|
|
12
|
+
this.keyMetaMap = keyMetaMap;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The only difference between this and the original is that we don't mark the instruction programIds as invoked.
|
|
16
|
+
* It makes sense to do because the instructions will be called via CPI, so the programIds can come from Address Lookup Tables.
|
|
17
|
+
* This allows to compress the message size and avoid hitting the tx size limit during vault_transaction_create instruction calls.
|
|
18
|
+
*/
|
|
19
|
+
static compile(instructions, payer) {
|
|
20
|
+
const keyMetaMap = new Map();
|
|
21
|
+
const getOrInsertDefault = (pubkey) => {
|
|
22
|
+
const address = pubkey.toBase58();
|
|
23
|
+
let keyMeta = keyMetaMap.get(address);
|
|
24
|
+
if (keyMeta === undefined) {
|
|
25
|
+
keyMeta = {
|
|
26
|
+
isSigner: false,
|
|
27
|
+
isWritable: false,
|
|
28
|
+
isInvoked: false,
|
|
29
|
+
};
|
|
30
|
+
keyMetaMap.set(address, keyMeta);
|
|
31
|
+
}
|
|
32
|
+
return keyMeta;
|
|
33
|
+
};
|
|
34
|
+
const payerKeyMeta = getOrInsertDefault(payer);
|
|
35
|
+
payerKeyMeta.isSigner = true;
|
|
36
|
+
payerKeyMeta.isWritable = true;
|
|
37
|
+
for (const ix of instructions) {
|
|
38
|
+
// This is the only difference from the original.
|
|
39
|
+
// getOrInsertDefault(ix.programId).isInvoked = true;
|
|
40
|
+
getOrInsertDefault(ix.programId).isInvoked = false;
|
|
41
|
+
for (const accountMeta of ix.keys) {
|
|
42
|
+
const keyMeta = getOrInsertDefault(accountMeta.pubkey);
|
|
43
|
+
keyMeta.isSigner ||= accountMeta.isSigner;
|
|
44
|
+
keyMeta.isWritable ||= accountMeta.isWritable;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return new CompiledKeys(payer, keyMetaMap);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Compiles instructions without a payer.
|
|
51
|
+
*/
|
|
52
|
+
static compileWithoutPayer(instructions) {
|
|
53
|
+
const keyMetaMap = new Map();
|
|
54
|
+
const getOrInsertDefault = (pubkey) => {
|
|
55
|
+
const address = pubkey.toBase58();
|
|
56
|
+
let keyMeta = keyMetaMap.get(address);
|
|
57
|
+
if (keyMeta === undefined) {
|
|
58
|
+
keyMeta = {
|
|
59
|
+
isSigner: false,
|
|
60
|
+
isWritable: false,
|
|
61
|
+
isInvoked: false,
|
|
62
|
+
};
|
|
63
|
+
keyMetaMap.set(address, keyMeta);
|
|
64
|
+
}
|
|
65
|
+
return keyMeta;
|
|
66
|
+
};
|
|
67
|
+
for (const ix of instructions) {
|
|
68
|
+
// This is the only difference from the original.
|
|
69
|
+
// getOrInsertDefault(ix.programId).isInvoked = true;
|
|
70
|
+
getOrInsertDefault(ix.programId).isInvoked = false;
|
|
71
|
+
for (const accountMeta of ix.keys) {
|
|
72
|
+
const keyMeta = getOrInsertDefault(accountMeta.pubkey);
|
|
73
|
+
keyMeta.isSigner ||= accountMeta.isSigner;
|
|
74
|
+
keyMeta.isWritable ||= accountMeta.isWritable;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return new CompiledKeys(undefined, keyMetaMap);
|
|
78
|
+
}
|
|
79
|
+
getMessageComponents() {
|
|
80
|
+
const mapEntries = [...this.keyMetaMap.entries()];
|
|
81
|
+
assert(mapEntries.length <= 256, "Max static account keys length exceeded");
|
|
82
|
+
const writableSigners = mapEntries.filter(([, meta]) => meta.isSigner && meta.isWritable);
|
|
83
|
+
const readonlySigners = mapEntries.filter(([, meta]) => meta.isSigner && !meta.isWritable);
|
|
84
|
+
const writableNonSigners = mapEntries.filter(([, meta]) => !meta.isSigner && meta.isWritable);
|
|
85
|
+
const readonlyNonSigners = mapEntries.filter(([, meta]) => !meta.isSigner && !meta.isWritable);
|
|
86
|
+
const header = {
|
|
87
|
+
numRequiredSignatures: writableSigners.length + readonlySigners.length,
|
|
88
|
+
numReadonlySignedAccounts: readonlySigners.length,
|
|
89
|
+
numReadonlyUnsignedAccounts: readonlyNonSigners.length,
|
|
90
|
+
};
|
|
91
|
+
// sanity checks
|
|
92
|
+
{
|
|
93
|
+
assert(writableSigners.length > 0, "Expected at least one writable signer key");
|
|
94
|
+
const [payerAddress] = writableSigners[0];
|
|
95
|
+
if (this.payer) {
|
|
96
|
+
assert(payerAddress === this.payer.toBase58(), "Expected first writable signer key to be the fee payer");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const staticAccountKeys = [
|
|
100
|
+
...writableSigners.map(([address]) => new PublicKey(address)),
|
|
101
|
+
...readonlySigners.map(([address]) => new PublicKey(address)),
|
|
102
|
+
...writableNonSigners.map(([address]) => new PublicKey(address)),
|
|
103
|
+
...readonlyNonSigners.map(([address]) => new PublicKey(address)),
|
|
104
|
+
];
|
|
105
|
+
return [header, staticAccountKeys];
|
|
106
|
+
}
|
|
107
|
+
extractTableLookup(lookupTable) {
|
|
108
|
+
const [writableIndexes, drainedWritableKeys] = this.drainKeysFoundInLookupTable(lookupTable.state.addresses, (keyMeta) => !keyMeta.isSigner && !keyMeta.isInvoked && keyMeta.isWritable);
|
|
109
|
+
const [readonlyIndexes, drainedReadonlyKeys] = this.drainKeysFoundInLookupTable(lookupTable.state.addresses, (keyMeta) => !keyMeta.isSigner && !keyMeta.isInvoked && !keyMeta.isWritable);
|
|
110
|
+
// Don't extract lookup if no keys were found
|
|
111
|
+
if (writableIndexes.length === 0 && readonlyIndexes.length === 0) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
return [
|
|
115
|
+
{
|
|
116
|
+
accountKey: lookupTable.key,
|
|
117
|
+
writableIndexes,
|
|
118
|
+
readonlyIndexes,
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
writable: drainedWritableKeys,
|
|
122
|
+
readonly: drainedReadonlyKeys,
|
|
123
|
+
},
|
|
124
|
+
];
|
|
125
|
+
}
|
|
126
|
+
/** @internal */
|
|
127
|
+
drainKeysFoundInLookupTable(lookupTableEntries, keyMetaFilter) {
|
|
128
|
+
const lookupTableIndexes = new Array();
|
|
129
|
+
const drainedKeys = new Array();
|
|
130
|
+
for (const [address, keyMeta] of this.keyMetaMap.entries()) {
|
|
131
|
+
if (keyMetaFilter(keyMeta)) {
|
|
132
|
+
const key = new PublicKey(address);
|
|
133
|
+
const lookupTableIndex = lookupTableEntries.findIndex((entry) => entry.equals(key));
|
|
134
|
+
if (lookupTableIndex >= 0) {
|
|
135
|
+
assert(lookupTableIndex < 256, "Max lookup table index exceeded");
|
|
136
|
+
lookupTableIndexes.push(lookupTableIndex);
|
|
137
|
+
drainedKeys.push(key);
|
|
138
|
+
this.keyMetaMap.delete(address);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return [lookupTableIndexes, drainedKeys];
|
|
143
|
+
}
|
|
144
|
+
}
|