@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
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/internal/index.js";
|
package/dist/internal.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/internal/index.js";
|
package/dist/loyal.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/loyal.js";
|
package/dist/loyal.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/loyal.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./generated/accounts/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./generated/accounts/index.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export * from "./utils.js";
|
|
3
|
+
export * from "./utils/compileToSynchronousMessage.js";
|
|
4
|
+
export * from "./utils/compileToSynchronousMessageV2.js";
|
|
5
|
+
export * from "./utils/compileToWrappedMessageV0.js";
|
|
6
|
+
export * from "./utils/compiled-keys.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export * from "./utils.js";
|
|
3
|
+
export * from "./utils/compileToSynchronousMessage.js";
|
|
4
|
+
export * from "./utils/compileToSynchronousMessageV2.js";
|
|
5
|
+
export * from "./utils/compileToWrappedMessageV0.js";
|
|
6
|
+
export * from "./utils/compiled-keys.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "../../types.js";
|
|
2
|
+
export * from "../../utils.js";
|
|
3
|
+
export * from "../../utils/compileToSynchronousMessage.js";
|
|
4
|
+
export * from "../../utils/compileToSynchronousMessageV2.js";
|
|
5
|
+
export * from "../../utils/compileToWrappedMessageV0.js";
|
|
6
|
+
export * from "../../utils/compiled-keys.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "../../types.js";
|
|
2
|
+
export * from "../../utils.js";
|
|
3
|
+
export * from "../../utils/compileToSynchronousMessage.js";
|
|
4
|
+
export * from "../../utils/compileToSynchronousMessageV2.js";
|
|
5
|
+
export * from "../../utils/compileToWrappedMessageV0.js";
|
|
6
|
+
export * from "../../utils/compiled-keys.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type bignum } from "@metaplex-foundation/beet";
|
|
2
|
+
export declare function toUtfBytes(str: string): Uint8Array;
|
|
3
|
+
export declare function toU8Bytes(num: number): Uint8Array;
|
|
4
|
+
export declare function toU32Bytes(num: number): Uint8Array;
|
|
5
|
+
export declare function toU64Bytes(num: bigint): Uint8Array;
|
|
6
|
+
export declare function toU128Bytes(num: bigint): Uint8Array;
|
|
7
|
+
export declare function toBigInt(number: bignum): bigint;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { u32, u64, u8, u128 } from "@metaplex-foundation/beet";
|
|
2
|
+
import { Buffer } from "buffer";
|
|
3
|
+
export function toUtfBytes(str) {
|
|
4
|
+
return new TextEncoder().encode(str);
|
|
5
|
+
}
|
|
6
|
+
export function toU8Bytes(num) {
|
|
7
|
+
const bytes = Buffer.alloc(1);
|
|
8
|
+
u8.write(bytes, 0, num);
|
|
9
|
+
return bytes;
|
|
10
|
+
}
|
|
11
|
+
export function toU32Bytes(num) {
|
|
12
|
+
const bytes = Buffer.alloc(4);
|
|
13
|
+
u32.write(bytes, 0, num);
|
|
14
|
+
return bytes;
|
|
15
|
+
}
|
|
16
|
+
export function toU64Bytes(num) {
|
|
17
|
+
const bytes = Buffer.alloc(8);
|
|
18
|
+
u64.write(bytes, 0, num);
|
|
19
|
+
return bytes;
|
|
20
|
+
}
|
|
21
|
+
export function toU128Bytes(num) {
|
|
22
|
+
const bytes = Buffer.alloc(16);
|
|
23
|
+
u128.write(bytes, 0, num);
|
|
24
|
+
return bytes;
|
|
25
|
+
}
|
|
26
|
+
export function toBigInt(number) {
|
|
27
|
+
return BigInt(number.toString());
|
|
28
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ErrorWithLogs } from "@metaplex-foundation/cusper";
|
|
2
|
+
export * from "../../generated/errors/index.js";
|
|
3
|
+
export declare class LoyalSmartAccountsError extends Error {
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
6
|
+
export declare class MissingOperationConnectionError extends LoyalSmartAccountsError {
|
|
7
|
+
constructor(operation: string);
|
|
8
|
+
}
|
|
9
|
+
export declare class MissingRequiredSignerError extends LoyalSmartAccountsError {
|
|
10
|
+
constructor(operation: string, role: string);
|
|
11
|
+
}
|
|
12
|
+
export declare class InvalidRoleResolutionError extends LoyalSmartAccountsError {
|
|
13
|
+
constructor(operation: string, role: string);
|
|
14
|
+
}
|
|
15
|
+
export declare class InvalidPayloadError extends LoyalSmartAccountsError {
|
|
16
|
+
constructor(message: string);
|
|
17
|
+
}
|
|
18
|
+
export declare class MissingLookupTableAccountError extends LoyalSmartAccountsError {
|
|
19
|
+
constructor(address: string, detail?: string);
|
|
20
|
+
}
|
|
21
|
+
export declare class OperationRegistryCoverageError extends LoyalSmartAccountsError {
|
|
22
|
+
constructor(message: string);
|
|
23
|
+
}
|
|
24
|
+
export declare class SolanaTransactionLogError extends LoyalSmartAccountsError {
|
|
25
|
+
readonly logs: string[];
|
|
26
|
+
constructor(message: string, logs: string[]);
|
|
27
|
+
}
|
|
28
|
+
export declare function translateAndThrowAnchorError(err: unknown): never;
|
|
29
|
+
export declare const isErrorWithLogs: (err: unknown) => err is ErrorWithLogs;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { initCusper } from "@metaplex-foundation/cusper";
|
|
2
|
+
export * from "../../generated/errors/index.js";
|
|
3
|
+
import { errorFromCode } from "../../generated/index.js";
|
|
4
|
+
export class LoyalSmartAccountsError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "LoyalSmartAccountsError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export class MissingOperationConnectionError extends LoyalSmartAccountsError {
|
|
11
|
+
constructor(operation) {
|
|
12
|
+
super(`Operation "${operation}" requires a Solana connection during prepare, but no connection was provided.`);
|
|
13
|
+
this.name = "MissingOperationConnectionError";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export class MissingRequiredSignerError extends LoyalSmartAccountsError {
|
|
17
|
+
constructor(operation, role) {
|
|
18
|
+
super(`Operation "${operation}" requires a signer for role "${role}" when sending through the bound client.`);
|
|
19
|
+
this.name = "MissingRequiredSignerError";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export class InvalidRoleResolutionError extends LoyalSmartAccountsError {
|
|
23
|
+
constructor(operation, role) {
|
|
24
|
+
super(`Operation "${operation}" could not resolve a PublicKey for required role "${role}".`);
|
|
25
|
+
this.name = "InvalidRoleResolutionError";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export class InvalidPayloadError extends LoyalSmartAccountsError {
|
|
29
|
+
constructor(message) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.name = "InvalidPayloadError";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export class MissingLookupTableAccountError extends LoyalSmartAccountsError {
|
|
35
|
+
constructor(address, detail) {
|
|
36
|
+
super(detail
|
|
37
|
+
? `Address lookup table account ${address} ${detail}`
|
|
38
|
+
: `Address lookup table account ${address} not found.`);
|
|
39
|
+
this.name = "MissingLookupTableAccountError";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export class OperationRegistryCoverageError extends LoyalSmartAccountsError {
|
|
43
|
+
constructor(message) {
|
|
44
|
+
super(message);
|
|
45
|
+
this.name = "OperationRegistryCoverageError";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class SolanaTransactionLogError extends LoyalSmartAccountsError {
|
|
49
|
+
logs;
|
|
50
|
+
constructor(message, logs) {
|
|
51
|
+
super(message);
|
|
52
|
+
this.name = "SolanaTransactionLogError";
|
|
53
|
+
this.logs = logs;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const cusper = initCusper(errorFromCode);
|
|
57
|
+
const SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
58
|
+
const LAMPORTS_PER_SOL = 1000000000n;
|
|
59
|
+
function formatLamports(lamports) {
|
|
60
|
+
const whole = lamports / LAMPORTS_PER_SOL;
|
|
61
|
+
const fraction = lamports % LAMPORTS_PER_SOL;
|
|
62
|
+
if (fraction === 0n) {
|
|
63
|
+
return `${whole.toString()} SOL`;
|
|
64
|
+
}
|
|
65
|
+
const fractionText = fraction.toString().padStart(9, "0").replace(/0+$/, "");
|
|
66
|
+
return `${whole.toString()}.${fractionText} SOL`;
|
|
67
|
+
}
|
|
68
|
+
function getInsufficientLamportsError(logs) {
|
|
69
|
+
for (const log of logs) {
|
|
70
|
+
const match = log.match(/Transfer: insufficient lamports (\d+), need (\d+)/);
|
|
71
|
+
if (!match) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const availableLamports = BigInt(match[1]);
|
|
75
|
+
const neededLamports = BigInt(match[2]);
|
|
76
|
+
const shortfallLamports = neededLamports - availableLamports;
|
|
77
|
+
return new SolanaTransactionLogError(`Insufficient SOL to pay transaction rent or fees at the failing instruction. ` +
|
|
78
|
+
`Available: ${formatLamports(availableLamports)} (${availableLamports.toString()} lamports). ` +
|
|
79
|
+
`Needed: ${formatLamports(neededLamports)} (${neededLamports.toString()} lamports). ` +
|
|
80
|
+
`Top up at least ${formatLamports(shortfallLamports)} plus network fees and retry.`, logs);
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
function getAccountAlreadyInUseError(logs) {
|
|
85
|
+
const alreadyInUseLog = logs.find((log) => /\balready in use\b|\balready initialized\b/i.test(log));
|
|
86
|
+
if (!alreadyInUseLog) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
return new SolanaTransactionLogError(`Account initialization failed because the target account is already in use. ` +
|
|
90
|
+
`This create flow is one-shot; refresh the on-chain transaction index and retry with the next PDA, ` +
|
|
91
|
+
`or close the existing account first if the program permits it. Runtime log: ${alreadyInUseLog}`, logs);
|
|
92
|
+
}
|
|
93
|
+
function getSystemProgramError(logs) {
|
|
94
|
+
const systemProgramFailure = logs.find((log) => log.startsWith(`Program ${SYSTEM_PROGRAM_ADDRESS} failed:`));
|
|
95
|
+
if (!systemProgramFailure) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const reason = systemProgramFailure
|
|
99
|
+
.replace(`Program ${SYSTEM_PROGRAM_ADDRESS} failed:`, "")
|
|
100
|
+
.trim();
|
|
101
|
+
return new SolanaTransactionLogError(`System Program failed while processing the transaction: ${reason}. ` +
|
|
102
|
+
`Check the preceding simulation logs for the operation that failed.`, logs);
|
|
103
|
+
}
|
|
104
|
+
function getHumanReadableRuntimeError(logs) {
|
|
105
|
+
return (getInsufficientLamportsError(logs) ??
|
|
106
|
+
getAccountAlreadyInUseError(logs) ??
|
|
107
|
+
getSystemProgramError(logs));
|
|
108
|
+
}
|
|
109
|
+
export function translateAndThrowAnchorError(err) {
|
|
110
|
+
if (!isErrorWithLogs(err)) {
|
|
111
|
+
throw err;
|
|
112
|
+
}
|
|
113
|
+
const translatedError = getHumanReadableRuntimeError(err.logs) ??
|
|
114
|
+
cusper.errorFromProgramLogs(err.logs) ??
|
|
115
|
+
err;
|
|
116
|
+
if (typeof Error.captureStackTrace === "function") {
|
|
117
|
+
Error.captureStackTrace(translatedError, translateAndThrowAnchorError);
|
|
118
|
+
}
|
|
119
|
+
translatedError.logs = err.logs;
|
|
120
|
+
throw translatedError;
|
|
121
|
+
}
|
|
122
|
+
export const isErrorWithLogs = (err) => {
|
|
123
|
+
return Boolean(err && typeof err === "object" && "logs" in err && Array.isArray(err.logs));
|
|
124
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../generated/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../generated/index.js";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { PDA_REGISTRY } from "../spec/pda-registry.js";
|
|
3
|
+
type ProgramIdParam = {
|
|
4
|
+
programId?: PublicKey;
|
|
5
|
+
};
|
|
6
|
+
export declare function getProgramConfigPda({ programId, }: ProgramIdParam): [PublicKey, number];
|
|
7
|
+
export declare function getSettingsPda({ accountIndex, programId, }: ProgramIdParam & {
|
|
8
|
+
accountIndex: bigint;
|
|
9
|
+
}): [PublicKey, number];
|
|
10
|
+
export declare function getSmartAccountPda({ settingsPda, accountIndex, programId, }: ProgramIdParam & {
|
|
11
|
+
settingsPda: PublicKey;
|
|
12
|
+
accountIndex: number;
|
|
13
|
+
}): [PublicKey, number];
|
|
14
|
+
export declare function getEphemeralSignerPda({ transactionPda, ephemeralSignerIndex, programId, }: ProgramIdParam & {
|
|
15
|
+
transactionPda: PublicKey;
|
|
16
|
+
ephemeralSignerIndex: number;
|
|
17
|
+
}): [PublicKey, number];
|
|
18
|
+
export declare function getTransactionPda({ settingsPda, transactionIndex, programId, }: ProgramIdParam & {
|
|
19
|
+
settingsPda: PublicKey;
|
|
20
|
+
transactionIndex: bigint;
|
|
21
|
+
}): [PublicKey, number];
|
|
22
|
+
export declare function getProposalPda({ settingsPda, transactionIndex, programId, }: ProgramIdParam & {
|
|
23
|
+
settingsPda: PublicKey;
|
|
24
|
+
transactionIndex: bigint;
|
|
25
|
+
}): [PublicKey, number];
|
|
26
|
+
export declare function getBatchTransactionPda({ settingsPda, batchIndex, transactionIndex, programId, }: ProgramIdParam & {
|
|
27
|
+
settingsPda: PublicKey;
|
|
28
|
+
batchIndex: bigint;
|
|
29
|
+
transactionIndex: number;
|
|
30
|
+
}): [PublicKey, number];
|
|
31
|
+
export declare function getSpendingLimitPda({ settingsPda, seed, programId, }: ProgramIdParam & {
|
|
32
|
+
settingsPda: PublicKey;
|
|
33
|
+
seed: PublicKey;
|
|
34
|
+
}): [PublicKey, number];
|
|
35
|
+
export declare function getTransactionBufferPda({ consensusPda, creator, bufferIndex, programId, }: ProgramIdParam & {
|
|
36
|
+
consensusPda: PublicKey;
|
|
37
|
+
creator: PublicKey;
|
|
38
|
+
bufferIndex: number;
|
|
39
|
+
}): [PublicKey, number];
|
|
40
|
+
export declare function getPolicyPda({ settingsPda, policySeed, programId, }: ProgramIdParam & {
|
|
41
|
+
settingsPda: PublicKey;
|
|
42
|
+
policySeed: number;
|
|
43
|
+
}): [PublicKey, number];
|
|
44
|
+
export { PDA_REGISTRY };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import invariant from "invariant";
|
|
3
|
+
import { PROGRAM_ID } from "../generated/index.js";
|
|
4
|
+
import { PDA_REGISTRY } from "../spec/pda-registry.js";
|
|
5
|
+
import { toU128Bytes, toU32Bytes, toU64Bytes, toU8Bytes, toUtfBytes, } from "../codecs/primitives.js";
|
|
6
|
+
const STATIC_SEED_CACHE = new Map();
|
|
7
|
+
function getStaticSeed(value) {
|
|
8
|
+
const cached = STATIC_SEED_CACHE.get(value);
|
|
9
|
+
if (cached) {
|
|
10
|
+
return cached;
|
|
11
|
+
}
|
|
12
|
+
const seed = toUtfBytes(value);
|
|
13
|
+
STATIC_SEED_CACHE.set(value, seed);
|
|
14
|
+
return seed;
|
|
15
|
+
}
|
|
16
|
+
function derivePda(seeds, programId) {
|
|
17
|
+
return PublicKey.findProgramAddressSync(seeds, programId);
|
|
18
|
+
}
|
|
19
|
+
function toSeedBytes(token, args) {
|
|
20
|
+
if (!token.includes(":")) {
|
|
21
|
+
return getStaticSeed(token);
|
|
22
|
+
}
|
|
23
|
+
const [field, encoding] = token.split(":");
|
|
24
|
+
const value = args[field];
|
|
25
|
+
invariant(value != null, `Missing PDA seed value for "${field}"`);
|
|
26
|
+
switch (encoding) {
|
|
27
|
+
case "pubkey":
|
|
28
|
+
invariant(value instanceof PublicKey, `PDA seed "${field}" must be a PublicKey`);
|
|
29
|
+
return value.toBytes();
|
|
30
|
+
case "u8":
|
|
31
|
+
invariant(typeof value === "number", `PDA seed "${field}" must be a number`);
|
|
32
|
+
return toU8Bytes(value);
|
|
33
|
+
case "u32":
|
|
34
|
+
invariant(typeof value === "number", `PDA seed "${field}" must be a number`);
|
|
35
|
+
return toU32Bytes(value);
|
|
36
|
+
case "u64":
|
|
37
|
+
invariant(typeof value === "bigint" || typeof value === "number", `PDA seed "${field}" must be a bigint or number`);
|
|
38
|
+
return toU64Bytes(typeof value === "bigint" ? value : BigInt(value));
|
|
39
|
+
case "u128":
|
|
40
|
+
invariant(typeof value === "bigint" || typeof value === "number", `PDA seed "${field}" must be a bigint or number`);
|
|
41
|
+
return toU128Bytes(typeof value === "bigint" ? value : BigInt(value));
|
|
42
|
+
default:
|
|
43
|
+
invariant(false, `Unsupported PDA seed encoding "${encoding}"`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function derivePdaFromRegistry(key, args, programId) {
|
|
47
|
+
return derivePda(PDA_REGISTRY[key].seeds.map((seed) => toSeedBytes(seed, args)), programId);
|
|
48
|
+
}
|
|
49
|
+
export function getProgramConfigPda({ programId = PROGRAM_ID, }) {
|
|
50
|
+
return derivePdaFromRegistry("programConfig", {}, programId);
|
|
51
|
+
}
|
|
52
|
+
export function getSettingsPda({ accountIndex, programId = PROGRAM_ID, }) {
|
|
53
|
+
return derivePdaFromRegistry("settings", { accountIndex }, programId);
|
|
54
|
+
}
|
|
55
|
+
export function getSmartAccountPda({ settingsPda, accountIndex, programId = PROGRAM_ID, }) {
|
|
56
|
+
invariant(accountIndex >= 0 && accountIndex < 256, "Invalid vault index");
|
|
57
|
+
return derivePdaFromRegistry("smartAccount", { settingsPda, accountIndex }, programId);
|
|
58
|
+
}
|
|
59
|
+
export function getEphemeralSignerPda({ transactionPda, ephemeralSignerIndex, programId = PROGRAM_ID, }) {
|
|
60
|
+
return derivePdaFromRegistry("ephemeralSigner", { transactionPda, ephemeralSignerIndex }, programId);
|
|
61
|
+
}
|
|
62
|
+
export function getTransactionPda({ settingsPda, transactionIndex, programId = PROGRAM_ID, }) {
|
|
63
|
+
return derivePdaFromRegistry("transaction", { settingsPda, transactionIndex }, programId);
|
|
64
|
+
}
|
|
65
|
+
export function getProposalPda({ settingsPda, transactionIndex, programId = PROGRAM_ID, }) {
|
|
66
|
+
return derivePdaFromRegistry("proposal", { settingsPda, transactionIndex }, programId);
|
|
67
|
+
}
|
|
68
|
+
export function getBatchTransactionPda({ settingsPda, batchIndex, transactionIndex, programId = PROGRAM_ID, }) {
|
|
69
|
+
return derivePdaFromRegistry("batchTransaction", { settingsPda, batchIndex, transactionIndex }, programId);
|
|
70
|
+
}
|
|
71
|
+
export function getSpendingLimitPda({ settingsPda, seed, programId = PROGRAM_ID, }) {
|
|
72
|
+
return derivePdaFromRegistry("spendingLimit", { settingsPda, seed }, programId);
|
|
73
|
+
}
|
|
74
|
+
export function getTransactionBufferPda({ consensusPda, creator, bufferIndex, programId = PROGRAM_ID, }) {
|
|
75
|
+
return derivePdaFromRegistry("transactionBuffer", { consensusPda, creator, bufferIndex }, programId);
|
|
76
|
+
}
|
|
77
|
+
export function getPolicyPda({ settingsPda, policySeed, programId = PROGRAM_ID, }) {
|
|
78
|
+
return derivePdaFromRegistry("policy", { settingsPda, policySeed }, programId);
|
|
79
|
+
}
|
|
80
|
+
export { PDA_REGISTRY };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../spec/features.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../spec/features.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../spec/idl.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../spec/idl.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../spec/pda-registry.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../spec/pda-registry.js";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { VersionedTransaction } from "@solana/web3.js";
|
|
2
|
+
import type { AddressLookupTableAccount, Commitment, Connection, PublicKey, SendOptions, Signer, TransactionInstruction } from "@solana/web3.js";
|
|
3
|
+
export type PreparedLoyalSmartAccountsOperation<Name extends string = string> = Readonly<{
|
|
4
|
+
operation: Name;
|
|
5
|
+
payer: PublicKey;
|
|
6
|
+
programId: PublicKey;
|
|
7
|
+
requiresConfirmation: boolean;
|
|
8
|
+
instructions: readonly TransactionInstruction[];
|
|
9
|
+
lookupTableAccounts: readonly AddressLookupTableAccount[];
|
|
10
|
+
}>;
|
|
11
|
+
export type LoyalSmartAccountsConfirmationContext = {
|
|
12
|
+
prepared: PreparedLoyalSmartAccountsOperation<string>;
|
|
13
|
+
blockhash: string;
|
|
14
|
+
lastValidBlockHeight: number;
|
|
15
|
+
commitment?: Commitment;
|
|
16
|
+
};
|
|
17
|
+
export type LoyalSmartAccountsSendPreparedContext = {
|
|
18
|
+
blockhash: string;
|
|
19
|
+
lastValidBlockHeight: number;
|
|
20
|
+
commitment?: Commitment;
|
|
21
|
+
sendOptions?: SendOptions;
|
|
22
|
+
compileUnsignedTransaction: () => VersionedTransaction;
|
|
23
|
+
};
|
|
24
|
+
export type LoyalSmartAccountsSendPreparedFn = (prepared: PreparedLoyalSmartAccountsOperation<string>, signers: readonly Signer[], context: LoyalSmartAccountsSendPreparedContext) => Promise<string>;
|
|
25
|
+
export type LoyalSmartAccountsConfirmFn = (signature: string, context: LoyalSmartAccountsConfirmationContext) => Promise<void>;
|
|
26
|
+
export type LoyalSmartAccountsClientConfig = {
|
|
27
|
+
connection: Connection;
|
|
28
|
+
programId?: PublicKey;
|
|
29
|
+
defaultCommitment?: Commitment;
|
|
30
|
+
sendPrepared?: LoyalSmartAccountsSendPreparedFn;
|
|
31
|
+
confirm?: LoyalSmartAccountsConfirmFn;
|
|
32
|
+
};
|
|
33
|
+
export type LoyalSmartAccountsTransport = {
|
|
34
|
+
connection: Connection;
|
|
35
|
+
programId: PublicKey;
|
|
36
|
+
defaultCommitment?: Commitment;
|
|
37
|
+
sendPrepared?: LoyalSmartAccountsSendPreparedFn;
|
|
38
|
+
confirm?: LoyalSmartAccountsConfirmFn;
|
|
39
|
+
};
|
|
40
|
+
export type LoyalSmartAccountsSendOptions = SendOptions;
|
|
41
|
+
export type LoyalSmartAccountsConfirmBehavior = true | false | "if-required";
|
|
42
|
+
export declare function createTransport(config: LoyalSmartAccountsClientConfig): LoyalSmartAccountsTransport;
|
|
43
|
+
export declare function freezePreparedOperation<Name extends string>(operation: PreparedLoyalSmartAccountsOperation<Name>): PreparedLoyalSmartAccountsOperation<Name>;
|
|
44
|
+
export declare function compilePreparedOperation(args: {
|
|
45
|
+
prepared: PreparedLoyalSmartAccountsOperation<string>;
|
|
46
|
+
blockhash: string;
|
|
47
|
+
}): VersionedTransaction;
|
|
48
|
+
export declare function sendPreparedOperation(args: {
|
|
49
|
+
transport: LoyalSmartAccountsTransport;
|
|
50
|
+
prepared: PreparedLoyalSmartAccountsOperation<string>;
|
|
51
|
+
signers: Signer[];
|
|
52
|
+
sendOptions?: LoyalSmartAccountsSendOptions;
|
|
53
|
+
confirm?: LoyalSmartAccountsConfirmBehavior;
|
|
54
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { TransactionMessage, VersionedTransaction } from "@solana/web3.js";
|
|
2
|
+
import { PROGRAM_ID } from "../generated/index.js";
|
|
3
|
+
import { translateAndThrowAnchorError } from "../errors/index.js";
|
|
4
|
+
export function createTransport(config) {
|
|
5
|
+
return {
|
|
6
|
+
connection: config.connection,
|
|
7
|
+
programId: config.programId ?? PROGRAM_ID,
|
|
8
|
+
defaultCommitment: config.defaultCommitment,
|
|
9
|
+
sendPrepared: config.sendPrepared,
|
|
10
|
+
confirm: config.confirm,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function freezePreparedOperation(operation) {
|
|
14
|
+
return Object.freeze({
|
|
15
|
+
...operation,
|
|
16
|
+
instructions: Object.freeze([...operation.instructions]),
|
|
17
|
+
lookupTableAccounts: Object.freeze([
|
|
18
|
+
...(operation.lookupTableAccounts ?? []),
|
|
19
|
+
]),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function dedupeSigners(signers) {
|
|
23
|
+
const unique = new Map();
|
|
24
|
+
for (const signer of signers) {
|
|
25
|
+
unique.set(signer.publicKey.toBase58(), signer);
|
|
26
|
+
}
|
|
27
|
+
return [...unique.values()];
|
|
28
|
+
}
|
|
29
|
+
async function confirmPreparedOperation(args) {
|
|
30
|
+
const context = {
|
|
31
|
+
prepared: args.prepared,
|
|
32
|
+
blockhash: args.blockhash,
|
|
33
|
+
lastValidBlockHeight: args.lastValidBlockHeight,
|
|
34
|
+
commitment: args.transport.defaultCommitment,
|
|
35
|
+
};
|
|
36
|
+
if (args.transport.confirm) {
|
|
37
|
+
await args.transport.confirm(args.signature, context);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const confirmation = await args.transport.connection.confirmTransaction({
|
|
41
|
+
signature: args.signature,
|
|
42
|
+
blockhash: args.blockhash,
|
|
43
|
+
lastValidBlockHeight: args.lastValidBlockHeight,
|
|
44
|
+
}, args.transport.defaultCommitment);
|
|
45
|
+
if (confirmation.value.err) {
|
|
46
|
+
throw new Error(`Transaction ${args.signature} failed to confirm: ${JSON.stringify(confirmation.value.err)}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function compilePreparedOperation(args) {
|
|
50
|
+
const message = new TransactionMessage({
|
|
51
|
+
payerKey: args.prepared.payer,
|
|
52
|
+
recentBlockhash: args.blockhash,
|
|
53
|
+
instructions: [...args.prepared.instructions],
|
|
54
|
+
}).compileToV0Message([...args.prepared.lookupTableAccounts]);
|
|
55
|
+
return new VersionedTransaction(message);
|
|
56
|
+
}
|
|
57
|
+
export async function sendPreparedOperation(args) {
|
|
58
|
+
const { transport, prepared, sendOptions } = args;
|
|
59
|
+
const signers = dedupeSigners(args.signers);
|
|
60
|
+
const latestBlockhash = await transport.connection.getLatestBlockhash(transport.defaultCommitment);
|
|
61
|
+
try {
|
|
62
|
+
const compileUnsignedTransaction = () => compilePreparedOperation({
|
|
63
|
+
prepared,
|
|
64
|
+
blockhash: latestBlockhash.blockhash,
|
|
65
|
+
});
|
|
66
|
+
const signature = transport.sendPrepared
|
|
67
|
+
? await transport.sendPrepared(prepared, signers, {
|
|
68
|
+
blockhash: latestBlockhash.blockhash,
|
|
69
|
+
lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
|
|
70
|
+
commitment: transport.defaultCommitment,
|
|
71
|
+
sendOptions,
|
|
72
|
+
compileUnsignedTransaction,
|
|
73
|
+
})
|
|
74
|
+
: await (async () => {
|
|
75
|
+
const transaction = compileUnsignedTransaction();
|
|
76
|
+
transaction.sign(signers);
|
|
77
|
+
return transport.connection.sendTransaction(transaction, sendOptions);
|
|
78
|
+
})();
|
|
79
|
+
const shouldConfirm = args.confirm === true ||
|
|
80
|
+
(args.confirm !== false && prepared.requiresConfirmation);
|
|
81
|
+
if (shouldConfirm) {
|
|
82
|
+
await confirmPreparedOperation({
|
|
83
|
+
transport,
|
|
84
|
+
prepared,
|
|
85
|
+
signature,
|
|
86
|
+
blockhash: latestBlockhash.blockhash,
|
|
87
|
+
lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return signature;
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
translateAndThrowAnchorError(error);
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core/errors/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core/errors/index.js";
|