@oobe-protocol-labs/synapse-client-sdk 1.0.2 → 1.0.3
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/CHANGELOG.md +32 -0
- package/dist/cjs/accounts/helpers.d.ts +88 -0
- package/dist/cjs/accounts/helpers.d.ts.map +1 -0
- package/dist/cjs/accounts/helpers.js +117 -0
- package/dist/cjs/accounts/helpers.js.map +1 -0
- package/dist/cjs/accounts/index.d.ts +105 -0
- package/dist/cjs/accounts/index.d.ts.map +1 -0
- package/dist/cjs/accounts/index.js +137 -0
- package/dist/cjs/accounts/index.js.map +1 -0
- package/dist/cjs/accounts/lookup.d.ts +30 -0
- package/dist/cjs/accounts/lookup.d.ts.map +1 -0
- package/dist/cjs/accounts/lookup.js +31 -0
- package/dist/cjs/accounts/lookup.js.map +1 -0
- package/dist/cjs/accounts/nonce.d.ts +30 -0
- package/dist/cjs/accounts/nonce.d.ts.map +1 -0
- package/dist/cjs/accounts/nonce.js +31 -0
- package/dist/cjs/accounts/nonce.js.map +1 -0
- package/dist/cjs/accounts/stake.d.ts +33 -0
- package/dist/cjs/accounts/stake.d.ts.map +1 -0
- package/dist/cjs/accounts/stake.js +34 -0
- package/dist/cjs/accounts/stake.js.map +1 -0
- package/dist/cjs/accounts/token.d.ts +98 -0
- package/dist/cjs/accounts/token.d.ts.map +1 -0
- package/dist/cjs/accounts/token.js +126 -0
- package/dist/cjs/accounts/token.js.map +1 -0
- package/dist/cjs/ai/tools/zod/index.d.ts +1 -1
- package/dist/cjs/ai/tools/zod/index.d.ts.map +1 -1
- package/dist/cjs/ai/tools/zod/index.js +2 -2
- package/dist/cjs/ai/tools/zod/index.js.map +1 -1
- package/dist/cjs/ai/tools/zod/types.d.ts +2 -0
- package/dist/cjs/ai/tools/zod/types.d.ts.map +1 -1
- package/dist/cjs/ai/tools/zod/types.js.map +1 -1
- package/dist/cjs/core/client.d.ts +25 -0
- package/dist/cjs/core/client.d.ts.map +1 -1
- package/dist/cjs/core/client.js +30 -0
- package/dist/cjs/core/client.js.map +1 -1
- package/dist/cjs/decoders/index.d.ts +36 -0
- package/dist/cjs/decoders/index.d.ts.map +1 -0
- package/dist/cjs/decoders/index.js +62 -0
- package/dist/cjs/decoders/index.js.map +1 -0
- package/dist/cjs/decoders/layout.d.ts +105 -0
- package/dist/cjs/decoders/layout.d.ts.map +1 -0
- package/dist/cjs/decoders/layout.js +188 -0
- package/dist/cjs/decoders/layout.js.map +1 -0
- package/dist/cjs/decoders/lookup-table.d.ts +60 -0
- package/dist/cjs/decoders/lookup-table.d.ts.map +1 -0
- package/dist/cjs/decoders/lookup-table.js +75 -0
- package/dist/cjs/decoders/lookup-table.js.map +1 -0
- package/dist/cjs/decoders/multisig.d.ts +49 -0
- package/dist/cjs/decoders/multisig.d.ts.map +1 -0
- package/dist/cjs/decoders/multisig.js +50 -0
- package/dist/cjs/decoders/multisig.js.map +1 -0
- package/dist/cjs/decoders/nonce.d.ts +54 -0
- package/dist/cjs/decoders/nonce.d.ts.map +1 -0
- package/dist/cjs/decoders/nonce.js +48 -0
- package/dist/cjs/decoders/nonce.js.map +1 -0
- package/dist/cjs/decoders/stake.d.ts +65 -0
- package/dist/cjs/decoders/stake.d.ts.map +1 -0
- package/dist/cjs/decoders/stake.js +86 -0
- package/dist/cjs/decoders/stake.js.map +1 -0
- package/dist/cjs/decoders/token-2022.d.ts +134 -0
- package/dist/cjs/decoders/token-2022.d.ts.map +1 -0
- package/dist/cjs/decoders/token-2022.js +160 -0
- package/dist/cjs/decoders/token-2022.js.map +1 -0
- package/dist/cjs/decoders/token.d.ts +87 -0
- package/dist/cjs/decoders/token.d.ts.map +1 -0
- package/dist/cjs/decoders/token.js +71 -0
- package/dist/cjs/decoders/token.js.map +1 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/docs/assets/navigation.js +1 -1
- package/dist/docs/assets/search.js +1 -1
- package/dist/docs/classes/AccountReader.html +61 -0
- package/dist/docs/classes/AccountsClient.html +43 -0
- package/dist/docs/classes/DasClient.html +13 -13
- package/dist/docs/classes/GeyserParser.html +17 -17
- package/dist/docs/classes/GrpcTransport.html +6 -6
- package/dist/docs/classes/HttpTransport.html +4 -4
- package/dist/docs/classes/NetworkError.html +5 -5
- package/dist/docs/classes/RpcMethodNotFoundError.html +4 -4
- package/dist/docs/classes/SolanaRpc.html +55 -55
- package/dist/docs/classes/SynapseClient.html +35 -25
- package/dist/docs/classes/SynapseError.html +4 -4
- package/dist/docs/classes/TimeoutError.html +4 -4
- package/dist/docs/classes/UpstreamError.html +6 -6
- package/dist/docs/classes/WsClient.html +10 -10
- package/dist/docs/enums/SynapseNetwork.html +2 -2
- package/dist/docs/enums/SynapseRegion.html +2 -2
- package/dist/docs/enums/TokenExtensionType.html +23 -0
- package/dist/docs/functions/Epoch-1.html +1 -1
- package/dist/docs/functions/Lamports-2.html +1 -1
- package/dist/docs/functions/Pubkey-1.html +1 -1
- package/dist/docs/functions/Sig.html +1 -1
- package/dist/docs/functions/Slot-1.html +1 -1
- package/dist/docs/functions/UnixTs.html +1 -1
- package/dist/docs/functions/autoSelectRegion.html +1 -1
- package/dist/docs/functions/base58Encode.html +1 -1
- package/dist/docs/functions/base64ToBytes.html +7 -0
- package/dist/docs/functions/chunk.html +1 -1
- package/dist/docs/functions/computeBalanceChanges.html +1 -1
- package/dist/docs/functions/computeTokenBalanceChanges.html +1 -1
- package/dist/docs/functions/createSynapse.html +1 -1
- package/dist/docs/functions/decodeLookupTable.html +17 -0
- package/dist/docs/functions/decodeMint.html +6 -0
- package/dist/docs/functions/decodeMultisig.html +13 -0
- package/dist/docs/functions/decodeNonceAccount.html +14 -0
- package/dist/docs/functions/decodeStakeAccount.html +12 -0
- package/dist/docs/functions/decodeToken2022Account.html +5 -0
- package/dist/docs/functions/decodeToken2022Mint.html +5 -0
- package/dist/docs/functions/decodeTokenAccount.html +6 -0
- package/dist/docs/functions/encodeBase58.html +7 -0
- package/dist/docs/functions/fetchLookupTable.html +10 -0
- package/dist/docs/functions/fetchMint.html +11 -0
- package/dist/docs/functions/fetchNonceAccount.html +10 -0
- package/dist/docs/functions/fetchStakeAccount.html +10 -0
- package/dist/docs/functions/fetchTokenAccount.html +12 -0
- package/dist/docs/functions/fetchTokenAccountsByOwner.html +11 -0
- package/dist/docs/functions/fromKitAddress.html +1 -1
- package/dist/docs/functions/getAccountInfo.html +1 -1
- package/dist/docs/functions/getAsset.html +1 -1
- package/dist/docs/functions/getAssetBatch.html +1 -1
- package/dist/docs/functions/getAssetProof.html +1 -1
- package/dist/docs/functions/getAssetProofBatch.html +1 -1
- package/dist/docs/functions/getAssetsByAuthority.html +1 -1
- package/dist/docs/functions/getAssetsByCreator.html +1 -1
- package/dist/docs/functions/getAssetsByGroup.html +1 -1
- package/dist/docs/functions/getAssetsByOwner.html +1 -1
- package/dist/docs/functions/getBalance.html +1 -1
- package/dist/docs/functions/getBlock.html +1 -1
- package/dist/docs/functions/getBlockCommitment.html +1 -1
- package/dist/docs/functions/getBlockHeight.html +1 -1
- package/dist/docs/functions/getBlockProduction.html +1 -1
- package/dist/docs/functions/getBlockTime.html +1 -1
- package/dist/docs/functions/getBlocks.html +1 -1
- package/dist/docs/functions/getBlocksWithLimit.html +1 -1
- package/dist/docs/functions/getClusterNodes.html +1 -1
- package/dist/docs/functions/getDecodedAccount.html +14 -0
- package/dist/docs/functions/getDecodedAccounts.html +9 -0
- package/dist/docs/functions/getEnvironment.html +1 -1
- package/dist/docs/functions/getEpochInfo.html +1 -1
- package/dist/docs/functions/getEpochSchedule.html +1 -1
- package/dist/docs/functions/getFeeForMessage.html +1 -1
- package/dist/docs/functions/getFirstAvailableBlock.html +1 -1
- package/dist/docs/functions/getGenesisHash.html +1 -1
- package/dist/docs/functions/getHealth.html +1 -1
- package/dist/docs/functions/getHighestSnapshotSlot.html +1 -1
- package/dist/docs/functions/getIdentity.html +1 -1
- package/dist/docs/functions/getInflationGovernor.html +1 -1
- package/dist/docs/functions/getInflationRate.html +1 -1
- package/dist/docs/functions/getInflationReward.html +1 -1
- package/dist/docs/functions/getLargestAccounts.html +1 -1
- package/dist/docs/functions/getLatestBlockhash.html +1 -1
- package/dist/docs/functions/getLeaderSchedule.html +1 -1
- package/dist/docs/functions/getMaxRetransmitSlot.html +1 -1
- package/dist/docs/functions/getMaxShredInsertSlot.html +1 -1
- package/dist/docs/functions/getMinimumBalanceForRentExemption.html +1 -1
- package/dist/docs/functions/getMultipleAccounts.html +1 -1
- package/dist/docs/functions/getProgramAccounts.html +1 -1
- package/dist/docs/functions/getProgramCategory.html +1 -1
- package/dist/docs/functions/getRecentPerformanceSamples.html +1 -1
- package/dist/docs/functions/getRecentPrioritizationFees.html +1 -1
- package/dist/docs/functions/getSignatureStatuses.html +1 -1
- package/dist/docs/functions/getSignaturesForAddress.html +1 -1
- package/dist/docs/functions/getSignaturesForAsset.html +1 -1
- package/dist/docs/functions/getSlot.html +1 -1
- package/dist/docs/functions/getSlotLeader.html +1 -1
- package/dist/docs/functions/getSlotLeaders.html +1 -1
- package/dist/docs/functions/getStakeActivation.html +1 -1
- package/dist/docs/functions/getStakeMinimumDelegation.html +1 -1
- package/dist/docs/functions/getSupply.html +1 -1
- package/dist/docs/functions/getTokenAccountBalance.html +1 -1
- package/dist/docs/functions/getTokenAccounts.html +1 -1
- package/dist/docs/functions/getTokenAccountsByDelegate.html +1 -1
- package/dist/docs/functions/getTokenAccountsByOwner.html +1 -1
- package/dist/docs/functions/getTokenLargestAccounts.html +1 -1
- package/dist/docs/functions/getTokenSupply.html +1 -1
- package/dist/docs/functions/getTransaction.html +1 -1
- package/dist/docs/functions/getTransactionCount.html +1 -1
- package/dist/docs/functions/getVersion.html +1 -1
- package/dist/docs/functions/getVoteAccounts.html +1 -1
- package/dist/docs/functions/isBlockhashValid.html +1 -1
- package/dist/docs/functions/isBrowser.html +1 -1
- package/dist/docs/functions/isProgramInCategory.html +1 -1
- package/dist/docs/functions/isServer.html +1 -1
- package/dist/docs/functions/isValidPubkey.html +1 -1
- package/dist/docs/functions/isValidSignature.html +1 -1
- package/dist/docs/functions/lamportsToSol.html +1 -1
- package/dist/docs/functions/listEndpoints.html +1 -1
- package/dist/docs/functions/listNetworks.html +1 -1
- package/dist/docs/functions/listRegions.html +1 -1
- package/dist/docs/functions/minimumLedgerSlot.html +1 -1
- package/dist/docs/functions/parseAccountUpdate.html +1 -1
- package/dist/docs/functions/parseBlockMeta.html +1 -1
- package/dist/docs/functions/parseEntry.html +1 -1
- package/dist/docs/functions/parseGeyserUpdate.html +1 -1
- package/dist/docs/functions/parseSlotUpdate.html +1 -1
- package/dist/docs/functions/parseTimestamp.html +1 -1
- package/dist/docs/functions/parseTransaction.html +1 -1
- package/dist/docs/functions/probeLatency.html +1 -1
- package/dist/docs/functions/rawBufferToBase58.html +1 -1
- package/dist/docs/functions/rawBufferToBase64.html +1 -1
- package/dist/docs/functions/rawBufferToBytes.html +1 -1
- package/dist/docs/functions/rawBufferToHex.html +1 -1
- package/dist/docs/functions/requestAirdrop.html +1 -1
- package/dist/docs/functions/resolveEndpoint.html +1 -1
- package/dist/docs/functions/resolveProgram.html +1 -1
- package/dist/docs/functions/resolveProgramBatch.html +1 -1
- package/dist/docs/functions/retry.html +1 -1
- package/dist/docs/functions/searchAssets.html +1 -1
- package/dist/docs/functions/sendTransaction.html +1 -1
- package/dist/docs/functions/simulateTransaction.html +1 -1
- package/dist/docs/functions/sleep.html +1 -1
- package/dist/docs/functions/solToLamports.html +1 -1
- package/dist/docs/functions/toClientConfig.html +1 -1
- package/dist/docs/functions/toKitAddress.html +1 -1
- package/dist/docs/functions/toKitLamports.html +1 -1
- package/dist/docs/functions/toKitSignatureString.html +1 -1
- package/dist/docs/hierarchy.html +1 -1
- package/dist/docs/interfaces/AccountInfo.html +7 -7
- package/dist/docs/interfaces/AccountNotification.html +2 -2
- package/dist/docs/interfaces/AccountSubParams.html +2 -2
- package/dist/docs/interfaces/AssetSignatureInfo.html +2 -2
- package/dist/docs/interfaces/AssetSignaturesPage.html +2 -2
- package/dist/docs/interfaces/BalanceChange.html +6 -6
- package/dist/docs/interfaces/BlockProduction.html +3 -3
- package/dist/docs/interfaces/BlockResult.html +2 -2
- package/dist/docs/interfaces/BlockReward.html +2 -2
- package/dist/docs/interfaces/BlockhashResult.html +2 -2
- package/dist/docs/interfaces/CallOptions.html +6 -6
- package/dist/docs/interfaces/ConfirmedTransaction.html +6 -6
- package/dist/docs/interfaces/ContactInfo.html +2 -2
- package/dist/docs/interfaces/DasAsset.html +2 -2
- package/dist/docs/interfaces/DasAssetProof.html +2 -2
- package/dist/docs/interfaces/DasAuthority.html +2 -2
- package/dist/docs/interfaces/DasCompression.html +2 -2
- package/dist/docs/interfaces/DasContent.html +2 -2
- package/dist/docs/interfaces/DasCreator.html +2 -2
- package/dist/docs/interfaces/DasFile.html +2 -2
- package/dist/docs/interfaces/DasGrouping.html +2 -2
- package/dist/docs/interfaces/DasOpts.html +2 -2
- package/dist/docs/interfaces/DasOwnership.html +2 -2
- package/dist/docs/interfaces/DasPage.html +2 -2
- package/dist/docs/interfaces/DasRoyalty.html +2 -2
- package/dist/docs/interfaces/DasSearchParams.html +2 -2
- package/dist/docs/interfaces/DasSupply.html +2 -2
- package/dist/docs/interfaces/DataSlice.html +3 -3
- package/dist/docs/interfaces/DecodedAccountResult.html +10 -0
- package/dist/docs/interfaces/DecodedLookupTable.html +20 -0
- package/dist/docs/interfaces/DecodedMint.html +16 -0
- package/dist/docs/interfaces/DecodedMultisig.html +14 -0
- package/dist/docs/interfaces/DecodedNonceAccount.html +16 -0
- package/dist/docs/interfaces/DecodedStakeAccount.html +7 -0
- package/dist/docs/interfaces/DecodedToken2022Account.html +20 -0
- package/dist/docs/interfaces/DecodedToken2022Mint.html +14 -0
- package/dist/docs/interfaces/DecodedTokenAccount.html +22 -0
- package/dist/docs/interfaces/DefaultAccountStateExt.html +5 -0
- package/dist/docs/interfaces/EndpointConnectConfig.html +5 -5
- package/dist/docs/interfaces/EpochInfo.html +7 -7
- package/dist/docs/interfaces/EpochSchedule.html +2 -2
- package/dist/docs/interfaces/FetchedMint.html +13 -0
- package/dist/docs/interfaces/FetchedTokenAccount.html +13 -0
- package/dist/docs/interfaces/GetAccountInfoOpts.html +6 -6
- package/dist/docs/interfaces/GetAssetsByAuthorityParams.html +2 -2
- package/dist/docs/interfaces/GetAssetsByCreatorParams.html +2 -2
- package/dist/docs/interfaces/GetAssetsByGroupParams.html +2 -2
- package/dist/docs/interfaces/GetAssetsByOwnerParams.html +2 -2
- package/dist/docs/interfaces/GetBlockOpts.html +6 -6
- package/dist/docs/interfaces/GetBlockProductionOpts.html +6 -6
- package/dist/docs/interfaces/GetMultipleAccountsOpts.html +6 -6
- package/dist/docs/interfaces/GetProgramAccountsOpts.html +6 -6
- package/dist/docs/interfaces/GetSignatureStatusesOpts.html +6 -6
- package/dist/docs/interfaces/GetSignaturesOpts.html +7 -7
- package/dist/docs/interfaces/GetTokenAccountsParams.html +2 -2
- package/dist/docs/interfaces/GetTransactionOpts.html +6 -6
- package/dist/docs/interfaces/GeyserParserConfig.html +6 -6
- package/dist/docs/interfaces/GeyserParserEvents.html +9 -9
- package/dist/docs/interfaces/GeyserParserStats.html +2 -2
- package/dist/docs/interfaces/GrpcCallOptions.html +2 -2
- package/dist/docs/interfaces/GrpcTransportConfig.html +6 -6
- package/dist/docs/interfaces/ImmutableOwnerExt.html +4 -0
- package/dist/docs/interfaces/InflationGovernor.html +2 -2
- package/dist/docs/interfaces/InflationRate.html +2 -2
- package/dist/docs/interfaces/InflationReward.html +2 -2
- package/dist/docs/interfaces/InterestBearingConfigExt.html +9 -0
- package/dist/docs/interfaces/LatencyProbeResult.html +2 -2
- package/dist/docs/interfaces/LogsNotification.html +2 -2
- package/dist/docs/interfaces/LogsSubParams.html +2 -2
- package/dist/docs/interfaces/MemoTransferExt.html +5 -0
- package/dist/docs/interfaces/MetadataPointerExt.html +6 -0
- package/dist/docs/interfaces/MintCloseAuthorityExt.html +5 -0
- package/dist/docs/interfaces/NonTransferableExt.html +4 -0
- package/dist/docs/interfaces/PaginationOpts.html +2 -2
- package/dist/docs/interfaces/ParsedAccountUpdate.html +16 -16
- package/dist/docs/interfaces/ParsedBlockMeta.html +2 -2
- package/dist/docs/interfaces/ParsedEntry.html +2 -2
- package/dist/docs/interfaces/ParsedInstruction.html +9 -9
- package/dist/docs/interfaces/ParsedSlotUpdate.html +3 -3
- package/dist/docs/interfaces/ParsedTransaction.html +19 -19
- package/dist/docs/interfaces/PerfSample.html +2 -2
- package/dist/docs/interfaces/PermanentDelegateExt.html +5 -0
- package/dist/docs/interfaces/ProgramAccount.html +2 -2
- package/dist/docs/interfaces/ProgramNotification.html +2 -2
- package/dist/docs/interfaces/ProgramSubParams.html +2 -2
- package/dist/docs/interfaces/RawAccountInfo.html +2 -2
- package/dist/docs/interfaces/RawBlockMeta.html +2 -2
- package/dist/docs/interfaces/RawBuffer.html +2 -2
- package/dist/docs/interfaces/RawCompiledInstruction.html +2 -2
- package/dist/docs/interfaces/RawEntry.html +2 -2
- package/dist/docs/interfaces/RawGeyserUpdate.html +2 -2
- package/dist/docs/interfaces/RawInnerInstruction.html +2 -2
- package/dist/docs/interfaces/RawSlotInfo.html +2 -2
- package/dist/docs/interfaces/RawTimestamp.html +2 -2
- package/dist/docs/interfaces/RawTokenBalance.html +2 -2
- package/dist/docs/interfaces/RawTransactionInfo.html +2 -2
- package/dist/docs/interfaces/RootNotification.html +2 -2
- package/dist/docs/interfaces/RootSubParams.html +1 -1
- package/dist/docs/interfaces/RpcContext.html +2 -2
- package/dist/docs/interfaces/RpcError.html +4 -4
- package/dist/docs/interfaces/RpcRequest.html +2 -2
- package/dist/docs/interfaces/RpcResponse.html +2 -2
- package/dist/docs/interfaces/SendTransactionOpts.html +6 -6
- package/dist/docs/interfaces/SignatureInfo.html +7 -7
- package/dist/docs/interfaces/SignatureNotification.html +2 -2
- package/dist/docs/interfaces/SignatureStatus.html +5 -5
- package/dist/docs/interfaces/SignatureSubParams.html +2 -2
- package/dist/docs/interfaces/SignaturesForAssetParams.html +2 -2
- package/dist/docs/interfaces/SimulateResult.html +2 -2
- package/dist/docs/interfaces/SimulateTransactionOpts.html +7 -7
- package/dist/docs/interfaces/SlotNotification.html +2 -2
- package/dist/docs/interfaces/SlotSubParams.html +1 -1
- package/dist/docs/interfaces/SortOpts.html +2 -2
- package/dist/docs/interfaces/StakeAuthorized.html +5 -0
- package/dist/docs/interfaces/StakeDelegation.html +9 -0
- package/dist/docs/interfaces/StakeLockup.html +9 -0
- package/dist/docs/interfaces/StakeMeta.html +6 -0
- package/dist/docs/interfaces/Supply.html +5 -5
- package/dist/docs/interfaces/SynapseClientConfig.html +9 -9
- package/dist/docs/interfaces/SynapseEndpoint.html +7 -7
- package/dist/docs/interfaces/TokenAccount.html +3 -3
- package/dist/docs/interfaces/TokenAccountsByOwnerResult.html +2 -2
- package/dist/docs/interfaces/TokenAmount.html +5 -5
- package/dist/docs/interfaces/TokenBalanceChange.html +2 -2
- package/dist/docs/interfaces/TransactionMeta.html +11 -11
- package/dist/docs/interfaces/TransferFeeAmount.html +5 -0
- package/dist/docs/interfaces/TransferFeeConfig.html +9 -0
- package/dist/docs/interfaces/TransportConfig.html +7 -7
- package/dist/docs/interfaces/UnknownExtension.html +6 -0
- package/dist/docs/interfaces/VoteAccount.html +9 -9
- package/dist/docs/interfaces/VoteAccountsResult.html +3 -3
- package/dist/docs/interfaces/WsConfig.html +6 -6
- package/dist/docs/media/CHANGELOG.md +32 -0
- package/dist/docs/modules.html +65 -2
- package/dist/docs/types/AccountFetchOpts.html +3 -0
- package/dist/docs/types/AccountFilter.html +1 -1
- package/dist/docs/types/Base58.html +1 -1
- package/dist/docs/types/Brand.html +1 -1
- package/dist/docs/types/Commitment.html +1 -1
- package/dist/docs/types/DasSortBy.html +1 -1
- package/dist/docs/types/DasSortDirection.html +1 -1
- package/dist/docs/types/DataSizeFilter.html +1 -1
- package/dist/docs/types/DecodedExtension.html +3 -0
- package/dist/docs/types/Encoding.html +1 -1
- package/dist/docs/types/Epoch.html +1 -1
- package/dist/docs/types/Lamports.html +1 -1
- package/dist/docs/types/LogsFilter.html +1 -1
- package/dist/docs/types/MemcmpFilter.html +1 -1
- package/dist/docs/types/NonceState.html +3 -0
- package/dist/docs/types/ParsedGeyserUpdate.html +1 -1
- package/dist/docs/types/Pubkey.html +1 -1
- package/dist/docs/types/RuntimeEnv.html +1 -1
- package/dist/docs/types/Signature.html +1 -1
- package/dist/docs/types/Slot.html +1 -1
- package/dist/docs/types/StakeAccountType.html +3 -0
- package/dist/docs/types/SubscriptionId.html +1 -1
- package/dist/docs/types/TokenAccountState.html +3 -0
- package/dist/docs/types/TransactionDetail.html +1 -1
- package/dist/docs/types/UnaryMethod.html +1 -1
- package/dist/docs/types/UnixTimestamp.html +1 -1
- package/dist/docs/types/WsNotification.html +1 -1
- package/dist/docs/variables/JUPITER_PROGRAMS.html +1 -1
- package/dist/docs/variables/KNOWN_PROGRAMS.html +1 -1
- package/dist/docs/variables/KNOWN_PROGRAMS_COUNT.html +1 -1
- package/dist/docs/variables/LOOKUP_TABLE_HEADER_SIZE.html +3 -0
- package/dist/docs/variables/LOOKUP_TABLE_PROGRAM_ID.html +3 -0
- package/dist/docs/variables/MARINADE_PROGRAMS.html +1 -1
- package/dist/docs/variables/MAX_MULTISIG_SIGNERS.html +3 -0
- package/dist/docs/variables/METAPLEX_PROGRAMS.html +1 -1
- package/dist/docs/variables/METEORA_PROGRAMS.html +1 -1
- package/dist/docs/variables/MINT_SIZE.html +3 -0
- package/dist/docs/variables/MULTISIG_SIZE.html +3 -0
- package/dist/docs/variables/NONCE_ACCOUNT_SIZE.html +3 -0
- package/dist/docs/variables/ORCA_PROGRAMS.html +1 -1
- package/dist/docs/variables/OTHER_PROGRAMS.html +1 -1
- package/dist/docs/variables/RAYDIUM_PROGRAMS.html +1 -1
- package/dist/docs/variables/SDK_USER_AGENT.html +1 -1
- package/dist/docs/variables/SPL_PROGRAMS.html +1 -1
- package/dist/docs/variables/STAKE_PROGRAM_ID.html +3 -0
- package/dist/docs/variables/SYNAPSE_DEVNET_EU.html +1 -1
- package/dist/docs/variables/SYNAPSE_DEVNET_US.html +1 -1
- package/dist/docs/variables/SYNAPSE_ENDPOINTS.html +1 -1
- package/dist/docs/variables/SYNAPSE_MAINNET_EU.html +1 -1
- package/dist/docs/variables/SYNAPSE_MAINNET_US.html +1 -1
- package/dist/docs/variables/SYSTEM_PROGRAMS.html +1 -1
- package/dist/docs/variables/SYSTEM_PROGRAM_ID.html +3 -0
- package/dist/docs/variables/TOKEN_2022_PROGRAM_ID.html +3 -0
- package/dist/docs/variables/TOKEN_ACCOUNT_SIZE.html +3 -0
- package/dist/docs/variables/TOKEN_PROGRAM_ID.html +3 -0
- package/dist/esm/accounts/helpers.d.ts +88 -0
- package/dist/esm/accounts/helpers.d.ts.map +1 -0
- package/dist/esm/accounts/helpers.js +112 -0
- package/dist/esm/accounts/helpers.js.map +1 -0
- package/dist/esm/accounts/index.d.ts +105 -0
- package/dist/esm/accounts/index.d.ts.map +1 -0
- package/dist/esm/accounts/index.js +124 -0
- package/dist/esm/accounts/index.js.map +1 -0
- package/dist/esm/accounts/lookup.d.ts +30 -0
- package/dist/esm/accounts/lookup.d.ts.map +1 -0
- package/dist/esm/accounts/lookup.js +28 -0
- package/dist/esm/accounts/lookup.js.map +1 -0
- package/dist/esm/accounts/nonce.d.ts +30 -0
- package/dist/esm/accounts/nonce.d.ts.map +1 -0
- package/dist/esm/accounts/nonce.js +28 -0
- package/dist/esm/accounts/nonce.js.map +1 -0
- package/dist/esm/accounts/stake.d.ts +33 -0
- package/dist/esm/accounts/stake.d.ts.map +1 -0
- package/dist/esm/accounts/stake.js +31 -0
- package/dist/esm/accounts/stake.js.map +1 -0
- package/dist/esm/accounts/token.d.ts +98 -0
- package/dist/esm/accounts/token.d.ts.map +1 -0
- package/dist/esm/accounts/token.js +121 -0
- package/dist/esm/accounts/token.js.map +1 -0
- package/dist/esm/ai/tools/zod/index.d.ts +1 -1
- package/dist/esm/ai/tools/zod/index.d.ts.map +1 -1
- package/dist/esm/ai/tools/zod/index.js +2 -2
- package/dist/esm/ai/tools/zod/index.js.map +1 -1
- package/dist/esm/ai/tools/zod/types.d.ts +2 -0
- package/dist/esm/ai/tools/zod/types.d.ts.map +1 -1
- package/dist/esm/ai/tools/zod/types.js.map +1 -1
- package/dist/esm/core/client.d.ts +25 -0
- package/dist/esm/core/client.d.ts.map +1 -1
- package/dist/esm/core/client.js +30 -0
- package/dist/esm/core/client.js.map +1 -1
- package/dist/esm/decoders/index.d.ts +36 -0
- package/dist/esm/decoders/index.d.ts.map +1 -0
- package/dist/esm/decoders/index.js +37 -0
- package/dist/esm/decoders/index.js.map +1 -0
- package/dist/esm/decoders/layout.d.ts +105 -0
- package/dist/esm/decoders/layout.d.ts.map +1 -0
- package/dist/esm/decoders/layout.js +183 -0
- package/dist/esm/decoders/layout.js.map +1 -0
- package/dist/esm/decoders/lookup-table.d.ts +60 -0
- package/dist/esm/decoders/lookup-table.d.ts.map +1 -0
- package/dist/esm/decoders/lookup-table.js +71 -0
- package/dist/esm/decoders/lookup-table.js.map +1 -0
- package/dist/esm/decoders/multisig.d.ts +49 -0
- package/dist/esm/decoders/multisig.d.ts.map +1 -0
- package/dist/esm/decoders/multisig.js +46 -0
- package/dist/esm/decoders/multisig.js.map +1 -0
- package/dist/esm/decoders/nonce.d.ts +54 -0
- package/dist/esm/decoders/nonce.d.ts.map +1 -0
- package/dist/esm/decoders/nonce.js +44 -0
- package/dist/esm/decoders/nonce.js.map +1 -0
- package/dist/esm/decoders/stake.d.ts +65 -0
- package/dist/esm/decoders/stake.d.ts.map +1 -0
- package/dist/esm/decoders/stake.js +82 -0
- package/dist/esm/decoders/stake.js.map +1 -0
- package/dist/esm/decoders/token-2022.d.ts +134 -0
- package/dist/esm/decoders/token-2022.d.ts.map +1 -0
- package/dist/esm/decoders/token-2022.js +155 -0
- package/dist/esm/decoders/token-2022.js.map +1 -0
- package/dist/esm/decoders/token.d.ts +87 -0
- package/dist/esm/decoders/token.d.ts.map +1 -0
- package/dist/esm/decoders/token.js +66 -0
- package/dist/esm/decoders/token.js.map +1 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +11 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Native Solana account data decoders.
|
|
4
|
+
*
|
|
5
|
+
* Zero-dependency, DataView-based decoders for the most common Solana
|
|
6
|
+
* account types. Each decoder is a pure function that takes raw bytes
|
|
7
|
+
* and returns a fully typed object.
|
|
8
|
+
*
|
|
9
|
+
* @module decoders
|
|
10
|
+
* @since 1.1.0
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import {
|
|
15
|
+
* decodeTokenAccount, decodeMint, decodeStakeAccount,
|
|
16
|
+
* decodeNonceAccount, decodeLookupTable, decodeMultisig,
|
|
17
|
+
* } from '@oobe-protocol-labs/synapse-client-sdk/decoders';
|
|
18
|
+
*
|
|
19
|
+
* const tokenAcct = decodeTokenAccount(rawBytes);
|
|
20
|
+
* const mint = decodeMint(mintBytes);
|
|
21
|
+
* const stake = decodeStakeAccount(stakeBytes);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.MULTISIG_SIZE = exports.MAX_MULTISIG_SIGNERS = exports.decodeMultisig = exports.LOOKUP_TABLE_HEADER_SIZE = exports.LOOKUP_TABLE_PROGRAM_ID = exports.decodeLookupTable = exports.SYSTEM_PROGRAM_ID = exports.NONCE_ACCOUNT_SIZE = exports.decodeNonceAccount = exports.STAKE_PROGRAM_ID = exports.decodeStakeAccount = exports.TOKEN_2022_PROGRAM_ID = exports.TokenExtensionType = exports.decodeToken2022Mint = exports.decodeToken2022Account = exports.TOKEN_PROGRAM_ID = exports.MINT_SIZE = exports.TOKEN_ACCOUNT_SIZE = exports.decodeMint = exports.decodeTokenAccount = exports.encodeBase58 = exports.AccountReader = void 0;
|
|
26
|
+
// ── Core reader ────────────────────────────────────────────────
|
|
27
|
+
var layout_1 = require("./layout");
|
|
28
|
+
Object.defineProperty(exports, "AccountReader", { enumerable: true, get: function () { return layout_1.AccountReader; } });
|
|
29
|
+
Object.defineProperty(exports, "encodeBase58", { enumerable: true, get: function () { return layout_1.encodeBase58; } });
|
|
30
|
+
// ── SPL Token (v1) ─────────────────────────────────────────────
|
|
31
|
+
var token_1 = require("./token");
|
|
32
|
+
Object.defineProperty(exports, "decodeTokenAccount", { enumerable: true, get: function () { return token_1.decodeTokenAccount; } });
|
|
33
|
+
Object.defineProperty(exports, "decodeMint", { enumerable: true, get: function () { return token_1.decodeMint; } });
|
|
34
|
+
Object.defineProperty(exports, "TOKEN_ACCOUNT_SIZE", { enumerable: true, get: function () { return token_1.TOKEN_ACCOUNT_SIZE; } });
|
|
35
|
+
Object.defineProperty(exports, "MINT_SIZE", { enumerable: true, get: function () { return token_1.MINT_SIZE; } });
|
|
36
|
+
Object.defineProperty(exports, "TOKEN_PROGRAM_ID", { enumerable: true, get: function () { return token_1.TOKEN_PROGRAM_ID; } });
|
|
37
|
+
// ── SPL Token-2022 ─────────────────────────────────────────────
|
|
38
|
+
var token_2022_1 = require("./token-2022");
|
|
39
|
+
Object.defineProperty(exports, "decodeToken2022Account", { enumerable: true, get: function () { return token_2022_1.decodeToken2022Account; } });
|
|
40
|
+
Object.defineProperty(exports, "decodeToken2022Mint", { enumerable: true, get: function () { return token_2022_1.decodeToken2022Mint; } });
|
|
41
|
+
Object.defineProperty(exports, "TokenExtensionType", { enumerable: true, get: function () { return token_2022_1.TokenExtensionType; } });
|
|
42
|
+
Object.defineProperty(exports, "TOKEN_2022_PROGRAM_ID", { enumerable: true, get: function () { return token_2022_1.TOKEN_2022_PROGRAM_ID; } });
|
|
43
|
+
// ── Stake ──────────────────────────────────────────────────────
|
|
44
|
+
var stake_1 = require("./stake");
|
|
45
|
+
Object.defineProperty(exports, "decodeStakeAccount", { enumerable: true, get: function () { return stake_1.decodeStakeAccount; } });
|
|
46
|
+
Object.defineProperty(exports, "STAKE_PROGRAM_ID", { enumerable: true, get: function () { return stake_1.STAKE_PROGRAM_ID; } });
|
|
47
|
+
// ── Nonce ──────────────────────────────────────────────────────
|
|
48
|
+
var nonce_1 = require("./nonce");
|
|
49
|
+
Object.defineProperty(exports, "decodeNonceAccount", { enumerable: true, get: function () { return nonce_1.decodeNonceAccount; } });
|
|
50
|
+
Object.defineProperty(exports, "NONCE_ACCOUNT_SIZE", { enumerable: true, get: function () { return nonce_1.NONCE_ACCOUNT_SIZE; } });
|
|
51
|
+
Object.defineProperty(exports, "SYSTEM_PROGRAM_ID", { enumerable: true, get: function () { return nonce_1.SYSTEM_PROGRAM_ID; } });
|
|
52
|
+
// ── Address Lookup Table ───────────────────────────────────────
|
|
53
|
+
var lookup_table_1 = require("./lookup-table");
|
|
54
|
+
Object.defineProperty(exports, "decodeLookupTable", { enumerable: true, get: function () { return lookup_table_1.decodeLookupTable; } });
|
|
55
|
+
Object.defineProperty(exports, "LOOKUP_TABLE_PROGRAM_ID", { enumerable: true, get: function () { return lookup_table_1.LOOKUP_TABLE_PROGRAM_ID; } });
|
|
56
|
+
Object.defineProperty(exports, "LOOKUP_TABLE_HEADER_SIZE", { enumerable: true, get: function () { return lookup_table_1.LOOKUP_TABLE_HEADER_SIZE; } });
|
|
57
|
+
// ── Multisig ───────────────────────────────────────────────────
|
|
58
|
+
var multisig_1 = require("./multisig");
|
|
59
|
+
Object.defineProperty(exports, "decodeMultisig", { enumerable: true, get: function () { return multisig_1.decodeMultisig; } });
|
|
60
|
+
Object.defineProperty(exports, "MAX_MULTISIG_SIGNERS", { enumerable: true, get: function () { return multisig_1.MAX_MULTISIG_SIGNERS; } });
|
|
61
|
+
Object.defineProperty(exports, "MULTISIG_SIZE", { enumerable: true, get: function () { return multisig_1.MULTISIG_SIZE; } });
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decoders/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAEH,kEAAkE;AAClE,mCAAuD;AAA9C,uGAAA,aAAa,OAAA;AAAE,sGAAA,YAAY,OAAA;AAEpC,kEAAkE;AAClE,iCAMiB;AALf,2GAAA,kBAAkB,OAAA;AAClB,mGAAA,UAAU,OAAA;AACV,2GAAA,kBAAkB,OAAA;AAClB,kGAAA,SAAS,OAAA;AACT,yGAAA,gBAAgB,OAAA;AAQlB,kEAAkE;AAClE,2CAKsB;AAJpB,oHAAA,sBAAsB,OAAA;AACtB,iHAAA,mBAAmB,OAAA;AACnB,gHAAA,kBAAkB,OAAA;AAClB,mHAAA,qBAAqB,OAAA;AAmBvB,kEAAkE;AAClE,iCAGiB;AAFf,2GAAA,kBAAkB,OAAA;AAClB,yGAAA,gBAAgB,OAAA;AAWlB,kEAAkE;AAClE,iCAIiB;AAHf,2GAAA,kBAAkB,OAAA;AAClB,2GAAA,kBAAkB,OAAA;AAClB,0GAAA,iBAAiB,OAAA;AAOnB,kEAAkE;AAClE,+CAIwB;AAHtB,iHAAA,iBAAiB,OAAA;AACjB,uHAAA,uBAAuB,OAAA;AACvB,wHAAA,wBAAwB,OAAA;AAM1B,kEAAkE;AAClE,uCAIoB;AAHlB,0GAAA,cAAc,OAAA;AACd,gHAAA,oBAAoB,OAAA;AACpB,yGAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AccountReader — zero-dependency DataView-based binary reader for Solana account data.
|
|
3
|
+
*
|
|
4
|
+
* Provides typed reading primitives (u8, u16, u32, u64, i64, f64, pubkey, bool)
|
|
5
|
+
* with automatic offset tracking and little-endian byte order (Solana standard).
|
|
6
|
+
*
|
|
7
|
+
* @module decoders/layout
|
|
8
|
+
* @since 1.1.0
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { AccountReader } from '@oobe-protocol-labs/synapse-client-sdk/decoders';
|
|
13
|
+
*
|
|
14
|
+
* const reader = new AccountReader(rawBytes);
|
|
15
|
+
* const mint = reader.pubkey();
|
|
16
|
+
* const owner = reader.pubkey();
|
|
17
|
+
* const amount = reader.u64();
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
import { Pubkey } from '../core/types';
|
|
21
|
+
/**
|
|
22
|
+
* Encode a Uint8Array to a base58 string.
|
|
23
|
+
*
|
|
24
|
+
* Used internally for converting 32-byte pubkey buffers to base58.
|
|
25
|
+
* Self-contained — no external dependencies.
|
|
26
|
+
*
|
|
27
|
+
* @param bytes - Raw byte array to encode.
|
|
28
|
+
* @returns Base58-encoded string.
|
|
29
|
+
* @since 1.1.0
|
|
30
|
+
*/
|
|
31
|
+
export declare function encodeBase58(bytes: Uint8Array): string;
|
|
32
|
+
/**
|
|
33
|
+
* Zero-allocation binary reader for Solana account data.
|
|
34
|
+
*
|
|
35
|
+
* Reads little-endian integers, pubkeys, booleans, and COption fields
|
|
36
|
+
* from a Uint8Array with automatic offset tracking. All reads advance
|
|
37
|
+
* the internal cursor.
|
|
38
|
+
*
|
|
39
|
+
* @since 1.1.0
|
|
40
|
+
*/
|
|
41
|
+
export declare class AccountReader {
|
|
42
|
+
private offset;
|
|
43
|
+
private readonly view;
|
|
44
|
+
private readonly bytes;
|
|
45
|
+
constructor(data: Uint8Array);
|
|
46
|
+
/** Current read position. @since 1.1.0 */
|
|
47
|
+
get position(): number;
|
|
48
|
+
/** Total data length. @since 1.1.0 */
|
|
49
|
+
get length(): number;
|
|
50
|
+
/** Remaining bytes after current position. @since 1.1.0 */
|
|
51
|
+
get remaining(): number;
|
|
52
|
+
/** Read an unsigned 8-bit integer. @since 1.1.0 */
|
|
53
|
+
u8(): number;
|
|
54
|
+
/** Read an unsigned 16-bit integer (little-endian). @since 1.1.0 */
|
|
55
|
+
u16(): number;
|
|
56
|
+
/** Read an unsigned 32-bit integer (little-endian). @since 1.1.0 */
|
|
57
|
+
u32(): number;
|
|
58
|
+
/** Read an unsigned 64-bit integer (little-endian). @since 1.1.0 */
|
|
59
|
+
u64(): bigint;
|
|
60
|
+
/** Read a signed 64-bit integer (little-endian). @since 1.1.0 */
|
|
61
|
+
i64(): bigint;
|
|
62
|
+
/** Read a 64-bit float (little-endian). @since 1.1.0 */
|
|
63
|
+
f64(): number;
|
|
64
|
+
/** Read a boolean (1 byte, 0 = false, non-zero = true). @since 1.1.0 */
|
|
65
|
+
bool(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Read a 32-byte Solana public key and return as branded {@link Pubkey}.
|
|
68
|
+
* @since 1.1.0
|
|
69
|
+
*/
|
|
70
|
+
pubkey(): Pubkey;
|
|
71
|
+
/**
|
|
72
|
+
* Read a 32-byte hash and return as base58 string.
|
|
73
|
+
* @since 1.1.0
|
|
74
|
+
*/
|
|
75
|
+
hash(): string;
|
|
76
|
+
/**
|
|
77
|
+
* Read a raw byte slice of the given length.
|
|
78
|
+
* @since 1.1.0
|
|
79
|
+
*/
|
|
80
|
+
slice(length: number): Uint8Array;
|
|
81
|
+
/**
|
|
82
|
+
* Read a Solana COption — 4-byte discriminator (0 = None, 1 = Some)
|
|
83
|
+
* followed by the inner value.
|
|
84
|
+
*
|
|
85
|
+
* **Important:** The reader function is ALWAYS called to advance the
|
|
86
|
+
* offset past the fixed-size data region (C ABI: data is always present,
|
|
87
|
+
* only the tag indicates validity).
|
|
88
|
+
*
|
|
89
|
+
* @param reader - Function to read the inner value.
|
|
90
|
+
* @returns The inner value or `null` if tag is 0 (None).
|
|
91
|
+
* @since 1.1.0
|
|
92
|
+
*/
|
|
93
|
+
coption<T>(reader: () => T): T | null;
|
|
94
|
+
/**
|
|
95
|
+
* Skip N bytes without reading.
|
|
96
|
+
* @since 1.1.0
|
|
97
|
+
*/
|
|
98
|
+
skip(n: number): void;
|
|
99
|
+
/**
|
|
100
|
+
* Seek to an absolute offset.
|
|
101
|
+
* @since 1.1.0
|
|
102
|
+
*/
|
|
103
|
+
seek(offset: number): void;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/decoders/layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAMvC;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CA2BtD;AAID;;;;;;;;GAQG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAW;IAChC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;gBAEvB,IAAI,EAAE,UAAU;IAK5B,0CAA0C;IAC1C,IAAI,QAAQ,IAAI,MAAM,CAAwB;IAE9C,sCAAsC;IACtC,IAAI,MAAM,IAAI,MAAM,CAAkC;IAEtD,2DAA2D;IAC3D,IAAI,SAAS,IAAI,MAAM,CAAgD;IAEvE,mDAAmD;IACnD,EAAE,IAAI,MAAM;IAMZ,oEAAoE;IACpE,GAAG,IAAI,MAAM;IAMb,oEAAoE;IACpE,GAAG,IAAI,MAAM;IAMb,oEAAoE;IACpE,GAAG,IAAI,MAAM;IAMb,iEAAiE;IACjE,GAAG,IAAI,MAAM;IAMb,wDAAwD;IACxD,GAAG,IAAI,MAAM;IAMb,wEAAwE;IACxE,IAAI,IAAI,OAAO;IAIf;;;OAGG;IACH,MAAM,IAAI,MAAM;IAMhB;;;OAGG;IACH,IAAI,IAAI,MAAM;IAMd;;;OAGG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU;IAMjC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI;IAMrC;;;OAGG;IACH,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAIrB;;;OAGG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAG3B"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AccountReader — zero-dependency DataView-based binary reader for Solana account data.
|
|
4
|
+
*
|
|
5
|
+
* Provides typed reading primitives (u8, u16, u32, u64, i64, f64, pubkey, bool)
|
|
6
|
+
* with automatic offset tracking and little-endian byte order (Solana standard).
|
|
7
|
+
*
|
|
8
|
+
* @module decoders/layout
|
|
9
|
+
* @since 1.1.0
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { AccountReader } from '@oobe-protocol-labs/synapse-client-sdk/decoders';
|
|
14
|
+
*
|
|
15
|
+
* const reader = new AccountReader(rawBytes);
|
|
16
|
+
* const mint = reader.pubkey();
|
|
17
|
+
* const owner = reader.pubkey();
|
|
18
|
+
* const amount = reader.u64();
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.AccountReader = void 0;
|
|
23
|
+
exports.encodeBase58 = encodeBase58;
|
|
24
|
+
const types_1 = require("../core/types");
|
|
25
|
+
// ── Minimal base58 encoder (self-contained, no deps) ──────────
|
|
26
|
+
const B58_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
27
|
+
/**
|
|
28
|
+
* Encode a Uint8Array to a base58 string.
|
|
29
|
+
*
|
|
30
|
+
* Used internally for converting 32-byte pubkey buffers to base58.
|
|
31
|
+
* Self-contained — no external dependencies.
|
|
32
|
+
*
|
|
33
|
+
* @param bytes - Raw byte array to encode.
|
|
34
|
+
* @returns Base58-encoded string.
|
|
35
|
+
* @since 1.1.0
|
|
36
|
+
*/
|
|
37
|
+
function encodeBase58(bytes) {
|
|
38
|
+
if (bytes.length === 0)
|
|
39
|
+
return '';
|
|
40
|
+
let zeros = 0;
|
|
41
|
+
while (zeros < bytes.length && bytes[zeros] === 0)
|
|
42
|
+
zeros++;
|
|
43
|
+
const size = ((bytes.length - zeros) * 138 / 100 + 1) >>> 0;
|
|
44
|
+
const b58 = new Uint8Array(size);
|
|
45
|
+
let length = 0;
|
|
46
|
+
for (let i = zeros; i < bytes.length; i++) {
|
|
47
|
+
let carry = bytes[i];
|
|
48
|
+
let j = 0;
|
|
49
|
+
for (let k = size - 1; (carry !== 0 || j < length) && k >= 0; k--, j++) {
|
|
50
|
+
carry += 256 * b58[k];
|
|
51
|
+
b58[k] = carry % 58;
|
|
52
|
+
carry = (carry / 58) >>> 0;
|
|
53
|
+
}
|
|
54
|
+
length = j;
|
|
55
|
+
}
|
|
56
|
+
let idx = size - length;
|
|
57
|
+
while (idx < size && b58[idx] === 0)
|
|
58
|
+
idx++;
|
|
59
|
+
let str = '1'.repeat(zeros);
|
|
60
|
+
for (; idx < size; idx++)
|
|
61
|
+
str += B58_ALPHABET[b58[idx]];
|
|
62
|
+
return str;
|
|
63
|
+
}
|
|
64
|
+
// ── AccountReader ──────────────────────────────────────────────
|
|
65
|
+
/**
|
|
66
|
+
* Zero-allocation binary reader for Solana account data.
|
|
67
|
+
*
|
|
68
|
+
* Reads little-endian integers, pubkeys, booleans, and COption fields
|
|
69
|
+
* from a Uint8Array with automatic offset tracking. All reads advance
|
|
70
|
+
* the internal cursor.
|
|
71
|
+
*
|
|
72
|
+
* @since 1.1.0
|
|
73
|
+
*/
|
|
74
|
+
class AccountReader {
|
|
75
|
+
offset = 0;
|
|
76
|
+
view;
|
|
77
|
+
bytes;
|
|
78
|
+
constructor(data) {
|
|
79
|
+
this.bytes = data;
|
|
80
|
+
this.view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
81
|
+
}
|
|
82
|
+
/** Current read position. @since 1.1.0 */
|
|
83
|
+
get position() { return this.offset; }
|
|
84
|
+
/** Total data length. @since 1.1.0 */
|
|
85
|
+
get length() { return this.bytes.byteLength; }
|
|
86
|
+
/** Remaining bytes after current position. @since 1.1.0 */
|
|
87
|
+
get remaining() { return this.bytes.byteLength - this.offset; }
|
|
88
|
+
/** Read an unsigned 8-bit integer. @since 1.1.0 */
|
|
89
|
+
u8() {
|
|
90
|
+
const v = this.view.getUint8(this.offset);
|
|
91
|
+
this.offset += 1;
|
|
92
|
+
return v;
|
|
93
|
+
}
|
|
94
|
+
/** Read an unsigned 16-bit integer (little-endian). @since 1.1.0 */
|
|
95
|
+
u16() {
|
|
96
|
+
const v = this.view.getUint16(this.offset, true);
|
|
97
|
+
this.offset += 2;
|
|
98
|
+
return v;
|
|
99
|
+
}
|
|
100
|
+
/** Read an unsigned 32-bit integer (little-endian). @since 1.1.0 */
|
|
101
|
+
u32() {
|
|
102
|
+
const v = this.view.getUint32(this.offset, true);
|
|
103
|
+
this.offset += 4;
|
|
104
|
+
return v;
|
|
105
|
+
}
|
|
106
|
+
/** Read an unsigned 64-bit integer (little-endian). @since 1.1.0 */
|
|
107
|
+
u64() {
|
|
108
|
+
const v = this.view.getBigUint64(this.offset, true);
|
|
109
|
+
this.offset += 8;
|
|
110
|
+
return v;
|
|
111
|
+
}
|
|
112
|
+
/** Read a signed 64-bit integer (little-endian). @since 1.1.0 */
|
|
113
|
+
i64() {
|
|
114
|
+
const v = this.view.getBigInt64(this.offset, true);
|
|
115
|
+
this.offset += 8;
|
|
116
|
+
return v;
|
|
117
|
+
}
|
|
118
|
+
/** Read a 64-bit float (little-endian). @since 1.1.0 */
|
|
119
|
+
f64() {
|
|
120
|
+
const v = this.view.getFloat64(this.offset, true);
|
|
121
|
+
this.offset += 8;
|
|
122
|
+
return v;
|
|
123
|
+
}
|
|
124
|
+
/** Read a boolean (1 byte, 0 = false, non-zero = true). @since 1.1.0 */
|
|
125
|
+
bool() {
|
|
126
|
+
return this.u8() !== 0;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Read a 32-byte Solana public key and return as branded {@link Pubkey}.
|
|
130
|
+
* @since 1.1.0
|
|
131
|
+
*/
|
|
132
|
+
pubkey() {
|
|
133
|
+
const slice = this.bytes.slice(this.offset, this.offset + 32);
|
|
134
|
+
this.offset += 32;
|
|
135
|
+
return (0, types_1.Pubkey)(encodeBase58(slice));
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Read a 32-byte hash and return as base58 string.
|
|
139
|
+
* @since 1.1.0
|
|
140
|
+
*/
|
|
141
|
+
hash() {
|
|
142
|
+
const slice = this.bytes.slice(this.offset, this.offset + 32);
|
|
143
|
+
this.offset += 32;
|
|
144
|
+
return encodeBase58(slice);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Read a raw byte slice of the given length.
|
|
148
|
+
* @since 1.1.0
|
|
149
|
+
*/
|
|
150
|
+
slice(length) {
|
|
151
|
+
const s = this.bytes.slice(this.offset, this.offset + length);
|
|
152
|
+
this.offset += length;
|
|
153
|
+
return s;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Read a Solana COption — 4-byte discriminator (0 = None, 1 = Some)
|
|
157
|
+
* followed by the inner value.
|
|
158
|
+
*
|
|
159
|
+
* **Important:** The reader function is ALWAYS called to advance the
|
|
160
|
+
* offset past the fixed-size data region (C ABI: data is always present,
|
|
161
|
+
* only the tag indicates validity).
|
|
162
|
+
*
|
|
163
|
+
* @param reader - Function to read the inner value.
|
|
164
|
+
* @returns The inner value or `null` if tag is 0 (None).
|
|
165
|
+
* @since 1.1.0
|
|
166
|
+
*/
|
|
167
|
+
coption(reader) {
|
|
168
|
+
const tag = this.u32();
|
|
169
|
+
const value = reader(); // Always read to advance offset past fixed-size data
|
|
170
|
+
return tag === 0 ? null : value;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Skip N bytes without reading.
|
|
174
|
+
* @since 1.1.0
|
|
175
|
+
*/
|
|
176
|
+
skip(n) {
|
|
177
|
+
this.offset += n;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Seek to an absolute offset.
|
|
181
|
+
* @since 1.1.0
|
|
182
|
+
*/
|
|
183
|
+
seek(offset) {
|
|
184
|
+
this.offset = offset;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
exports.AccountReader = AccountReader;
|
|
188
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../../src/decoders/layout.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AAkBH,oCA2BC;AA3CD,yCAAuC;AAEvC,iEAAiE;AAEjE,MAAM,YAAY,GAAG,4DAA4D,CAAC;AAElF;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAAC,KAAiB;IAC5C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAElC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,OAAO,KAAK,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,KAAK,EAAE,CAAC;IAE3D,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IAC5D,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE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,CAAC,qDAAqD;QAC7E,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAClC,CAAC;IAED;;;OAGG;IACH,IAAI,CAAC,CAAS;QACZ,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;IACnB,CAAC;IAED;;;OAGG;IACH,IAAI,CAAC,MAAc;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAjID,sCAiIC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Address Lookup Table decoder.
|
|
3
|
+
*
|
|
4
|
+
* Decodes v0 transaction lookup table accounts used for compressing
|
|
5
|
+
* transaction address lists.
|
|
6
|
+
*
|
|
7
|
+
* @module decoders/lookup-table
|
|
8
|
+
* @since 1.1.0
|
|
9
|
+
*/
|
|
10
|
+
import type { Pubkey } from '../core/types';
|
|
11
|
+
/**
|
|
12
|
+
* Decoded Address Lookup Table account.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const lut = decodeLookupTable(rawBytes);
|
|
17
|
+
* console.log(`Addresses: ${lut.addresses.length}, Active: ${!lut.isDeactivated}`);
|
|
18
|
+
* ```
|
|
19
|
+
* @since 1.1.0
|
|
20
|
+
*/
|
|
21
|
+
export interface DecodedLookupTable {
|
|
22
|
+
/** Discriminator (always 1 for lookup tables). */
|
|
23
|
+
discriminator: number;
|
|
24
|
+
/** Slot at which deactivation was requested. `MAX_U64` if still active. */
|
|
25
|
+
deactivationSlot: bigint;
|
|
26
|
+
/** Last slot during which the table was extended. */
|
|
27
|
+
lastExtendedSlot: bigint;
|
|
28
|
+
/** Start index within the last extension batch. */
|
|
29
|
+
lastExtendedSlotStartIndex: number;
|
|
30
|
+
/** Authority that can extend/close the table. `null` if frozen. */
|
|
31
|
+
authority: Pubkey | null;
|
|
32
|
+
/** List of addresses stored in the table. */
|
|
33
|
+
addresses: Pubkey[];
|
|
34
|
+
/** Whether the table has been deactivated. */
|
|
35
|
+
isDeactivated: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** Address Lookup Table Program ID. @since 1.1.0 */
|
|
38
|
+
export declare const LOOKUP_TABLE_PROGRAM_ID = "AddressLookupTab1e1111111111111111111111111";
|
|
39
|
+
/** Header size of a lookup table account. @since 1.1.0 */
|
|
40
|
+
export declare const LOOKUP_TABLE_HEADER_SIZE = 56;
|
|
41
|
+
/**
|
|
42
|
+
* Decode an Address Lookup Table account from raw bytes.
|
|
43
|
+
*
|
|
44
|
+
* Layout:
|
|
45
|
+
* - [0..4] u32 — discriminator (always 1)
|
|
46
|
+
* - [4..12] u64 — deactivation slot (MAX_U64 = active)
|
|
47
|
+
* - [12..20] u64 — last extended slot
|
|
48
|
+
* - [20] u8 — last extended slot start index
|
|
49
|
+
* - [21] u8 — has authority (0 or 1)
|
|
50
|
+
* - [22..24] [u8;2] — padding
|
|
51
|
+
* - [24..56] [u8;32] — authority (meaningful only if has_authority=1)
|
|
52
|
+
* - [56..] [Pubkey] — addresses (32 bytes each)
|
|
53
|
+
*
|
|
54
|
+
* @param data - Raw account data (must be >= 56 bytes).
|
|
55
|
+
* @returns Decoded lookup table.
|
|
56
|
+
* @throws {Error} If data is too short.
|
|
57
|
+
* @since 1.1.0
|
|
58
|
+
*/
|
|
59
|
+
export declare function decodeLookupTable(data: Uint8Array): DecodedLookupTable;
|
|
60
|
+
//# sourceMappingURL=lookup-table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookup-table.d.ts","sourceRoot":"","sources":["../../../src/decoders/lookup-table.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAM5C;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB;IACjC,kDAAkD;IAClD,aAAa,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,gBAAgB,EAAE,MAAM,CAAC;IACzB,qDAAqD;IACrD,gBAAgB,EAAE,MAAM,CAAC;IACzB,mDAAmD;IACnD,0BAA0B,EAAE,MAAM,CAAC;IACnC,mEAAmE;IACnE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,6CAA6C;IAC7C,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,8CAA8C;IAC9C,aAAa,EAAE,OAAO,CAAC;CACxB;AAID,oDAAoD;AACpD,eAAO,MAAM,uBAAuB,gDAAgD,CAAC;AAErF,0DAA0D;AAC1D,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAO3C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,kBAAkB,CAwCtE"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Address Lookup Table decoder.
|
|
4
|
+
*
|
|
5
|
+
* Decodes v0 transaction lookup table accounts used for compressing
|
|
6
|
+
* transaction address lists.
|
|
7
|
+
*
|
|
8
|
+
* @module decoders/lookup-table
|
|
9
|
+
* @since 1.1.0
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.LOOKUP_TABLE_HEADER_SIZE = exports.LOOKUP_TABLE_PROGRAM_ID = void 0;
|
|
13
|
+
exports.decodeLookupTable = decodeLookupTable;
|
|
14
|
+
const types_1 = require("../core/types");
|
|
15
|
+
const layout_1 = require("./layout");
|
|
16
|
+
// ── Constants ──────────────────────────────────────────────────
|
|
17
|
+
/** Address Lookup Table Program ID. @since 1.1.0 */
|
|
18
|
+
exports.LOOKUP_TABLE_PROGRAM_ID = 'AddressLookupTab1e1111111111111111111111111';
|
|
19
|
+
/** Header size of a lookup table account. @since 1.1.0 */
|
|
20
|
+
exports.LOOKUP_TABLE_HEADER_SIZE = 56;
|
|
21
|
+
/** Sentinel value for "no deactivation scheduled". @since 1.1.0 */
|
|
22
|
+
const MAX_U64 = 0xffffffffffffffffn;
|
|
23
|
+
// ── Decoder ────────────────────────────────────────────────────
|
|
24
|
+
/**
|
|
25
|
+
* Decode an Address Lookup Table account from raw bytes.
|
|
26
|
+
*
|
|
27
|
+
* Layout:
|
|
28
|
+
* - [0..4] u32 — discriminator (always 1)
|
|
29
|
+
* - [4..12] u64 — deactivation slot (MAX_U64 = active)
|
|
30
|
+
* - [12..20] u64 — last extended slot
|
|
31
|
+
* - [20] u8 — last extended slot start index
|
|
32
|
+
* - [21] u8 — has authority (0 or 1)
|
|
33
|
+
* - [22..24] [u8;2] — padding
|
|
34
|
+
* - [24..56] [u8;32] — authority (meaningful only if has_authority=1)
|
|
35
|
+
* - [56..] [Pubkey] — addresses (32 bytes each)
|
|
36
|
+
*
|
|
37
|
+
* @param data - Raw account data (must be >= 56 bytes).
|
|
38
|
+
* @returns Decoded lookup table.
|
|
39
|
+
* @throws {Error} If data is too short.
|
|
40
|
+
* @since 1.1.0
|
|
41
|
+
*/
|
|
42
|
+
function decodeLookupTable(data) {
|
|
43
|
+
if (data.length < exports.LOOKUP_TABLE_HEADER_SIZE) {
|
|
44
|
+
throw new Error(`Lookup table data too short: expected >= ${exports.LOOKUP_TABLE_HEADER_SIZE} bytes, got ${data.length}`);
|
|
45
|
+
}
|
|
46
|
+
const r = new layout_1.AccountReader(data);
|
|
47
|
+
const discriminator = r.u32(); // [0..4]
|
|
48
|
+
const deactivationSlot = r.u64(); // [4..12]
|
|
49
|
+
const lastExtendedSlot = r.u64(); // [12..20]
|
|
50
|
+
const lastExtendedSlotStartIndex = r.u8(); // [20]
|
|
51
|
+
const hasAuthority = r.u8(); // [21]
|
|
52
|
+
r.skip(2); // [22..24] padding
|
|
53
|
+
const authorityPubkey = r.pubkey(); // [24..56]
|
|
54
|
+
const authority = hasAuthority === 1 ? authorityPubkey : null;
|
|
55
|
+
const isDeactivated = deactivationSlot !== MAX_U64;
|
|
56
|
+
// Parse addresses (remaining data, 32 bytes each)
|
|
57
|
+
const addressesData = data.slice(exports.LOOKUP_TABLE_HEADER_SIZE);
|
|
58
|
+
const numAddresses = Math.floor(addressesData.length / 32);
|
|
59
|
+
const addresses = [];
|
|
60
|
+
for (let i = 0; i < numAddresses; i++) {
|
|
61
|
+
const offset = i * 32;
|
|
62
|
+
const addrBytes = addressesData.slice(offset, offset + 32);
|
|
63
|
+
addresses.push((0, types_1.Pubkey)((0, layout_1.encodeBase58)(addrBytes)));
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
discriminator,
|
|
67
|
+
deactivationSlot,
|
|
68
|
+
lastExtendedSlot,
|
|
69
|
+
lastExtendedSlotStartIndex,
|
|
70
|
+
authority,
|
|
71
|
+
addresses,
|
|
72
|
+
isDeactivated,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=lookup-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookup-table.js","sourceRoot":"","sources":["../../../src/decoders/lookup-table.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAkEH,8CAwCC;AAvGD,yCAAmD;AACnD,qCAAuD;AA+BvD,kEAAkE;AAElE,oDAAoD;AACvC,QAAA,uBAAuB,GAAG,6CAA6C,CAAC;AAErF,0DAA0D;AAC7C,QAAA,wBAAwB,GAAG,EAAE,CAAC;AAE3C,mEAAmE;AACnE,MAAM,OAAO,GAAG,mBAAmB,CAAC;AAEpC,kEAAkE;AAElE;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,iBAAiB,CAAC,IAAgB;IAChD,IAAI,IAAI,CAAC,MAAM,GAAG,gCAAwB,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CACb,4CAA4C,gCAAwB,eAAe,IAAI,CAAC,MAAM,EAAE,CACjG,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,GAAG,IAAI,sBAAa,CAAC,IAAI,CAAC,CAAC;IAElC,MAAM,aAAa,GAA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SAAS;QACT,SAAS;QACT,aAAa;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SPL Token Multisig account decoder.
|
|
3
|
+
*
|
|
4
|
+
* Decodes the SPL Token multisig account layout (355 bytes).
|
|
5
|
+
*
|
|
6
|
+
* @module decoders/multisig
|
|
7
|
+
* @since 1.1.0
|
|
8
|
+
*/
|
|
9
|
+
import type { Pubkey } from '../core/types';
|
|
10
|
+
/**
|
|
11
|
+
* Decoded SPL Multisig account (355 bytes).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const ms = decodeMultisig(rawBytes);
|
|
16
|
+
* console.log(`Threshold: ${ms.m} of ${ms.n}, Signers: ${ms.signers.length}`);
|
|
17
|
+
* ```
|
|
18
|
+
* @since 1.1.0
|
|
19
|
+
*/
|
|
20
|
+
export interface DecodedMultisig {
|
|
21
|
+
/** Number of signers required (threshold). */
|
|
22
|
+
m: number;
|
|
23
|
+
/** Number of valid signers in the list. */
|
|
24
|
+
n: number;
|
|
25
|
+
/** Whether the multisig is initialized. */
|
|
26
|
+
isInitialized: boolean;
|
|
27
|
+
/** List of valid signer public keys (up to 11). */
|
|
28
|
+
signers: Pubkey[];
|
|
29
|
+
}
|
|
30
|
+
/** Maximum number of signers in a multisig. @since 1.1.0 */
|
|
31
|
+
export declare const MAX_MULTISIG_SIGNERS = 11;
|
|
32
|
+
/** SPL Multisig account size. @since 1.1.0 */
|
|
33
|
+
export declare const MULTISIG_SIZE = 355;
|
|
34
|
+
/**
|
|
35
|
+
* Decode an SPL Token Multisig account from raw bytes.
|
|
36
|
+
*
|
|
37
|
+
* Layout (355 bytes):
|
|
38
|
+
* - [0] u8 — m (threshold)
|
|
39
|
+
* - [1] u8 — n (total valid signers)
|
|
40
|
+
* - [2] u8 — is_initialized
|
|
41
|
+
* - [3..355] [Pubkey;11] — signer slots (32 bytes each, only first n are valid)
|
|
42
|
+
*
|
|
43
|
+
* @param data - Raw account data (must be >= 355 bytes).
|
|
44
|
+
* @returns Decoded multisig account.
|
|
45
|
+
* @throws {Error} If data is too short.
|
|
46
|
+
* @since 1.1.0
|
|
47
|
+
*/
|
|
48
|
+
export declare function decodeMultisig(data: Uint8Array): DecodedMultisig;
|
|
49
|
+
//# sourceMappingURL=multisig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multisig.d.ts","sourceRoot":"","sources":["../../../src/decoders/multisig.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAK5C;;;;;;;;;GASG;AACH,MAAM,WAAW,eAAe;IAC9B,8CAA8C;IAC9C,CAAC,EAAE,MAAM,CAAC;IACV,2CAA2C;IAC3C,CAAC,EAAE,MAAM,CAAC;IACV,2CAA2C;IAC3C,aAAa,EAAE,OAAO,CAAC;IACvB,mDAAmD;IACnD,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAID,4DAA4D;AAC5D,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,8CAA8C;AAC9C,eAAO,MAAM,aAAa,MAAM,CAAC;AAIjC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,eAAe,CAoBhE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SPL Token Multisig account decoder.
|
|
4
|
+
*
|
|
5
|
+
* Decodes the SPL Token multisig account layout (355 bytes).
|
|
6
|
+
*
|
|
7
|
+
* @module decoders/multisig
|
|
8
|
+
* @since 1.1.0
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.MULTISIG_SIZE = exports.MAX_MULTISIG_SIGNERS = void 0;
|
|
12
|
+
exports.decodeMultisig = decodeMultisig;
|
|
13
|
+
const layout_1 = require("./layout");
|
|
14
|
+
// ── Constants ──────────────────────────────────────────────────
|
|
15
|
+
/** Maximum number of signers in a multisig. @since 1.1.0 */
|
|
16
|
+
exports.MAX_MULTISIG_SIGNERS = 11;
|
|
17
|
+
/** SPL Multisig account size. @since 1.1.0 */
|
|
18
|
+
exports.MULTISIG_SIZE = 355;
|
|
19
|
+
// ── Decoder ────────────────────────────────────────────────────
|
|
20
|
+
/**
|
|
21
|
+
* Decode an SPL Token Multisig account from raw bytes.
|
|
22
|
+
*
|
|
23
|
+
* Layout (355 bytes):
|
|
24
|
+
* - [0] u8 — m (threshold)
|
|
25
|
+
* - [1] u8 — n (total valid signers)
|
|
26
|
+
* - [2] u8 — is_initialized
|
|
27
|
+
* - [3..355] [Pubkey;11] — signer slots (32 bytes each, only first n are valid)
|
|
28
|
+
*
|
|
29
|
+
* @param data - Raw account data (must be >= 355 bytes).
|
|
30
|
+
* @returns Decoded multisig account.
|
|
31
|
+
* @throws {Error} If data is too short.
|
|
32
|
+
* @since 1.1.0
|
|
33
|
+
*/
|
|
34
|
+
function decodeMultisig(data) {
|
|
35
|
+
if (data.length < exports.MULTISIG_SIZE) {
|
|
36
|
+
throw new Error(`Multisig data too short: expected >= ${exports.MULTISIG_SIZE} bytes, got ${data.length}`);
|
|
37
|
+
}
|
|
38
|
+
const r = new layout_1.AccountReader(data);
|
|
39
|
+
const m = r.u8(); // [0]
|
|
40
|
+
const n = r.u8(); // [1]
|
|
41
|
+
const isInitialized = r.bool(); // [2]
|
|
42
|
+
const signers = [];
|
|
43
|
+
for (let i = 0; i < exports.MAX_MULTISIG_SIGNERS; i++) {
|
|
44
|
+
const pk = r.pubkey();
|
|
45
|
+
if (i < n)
|
|
46
|
+
signers.push(pk);
|
|
47
|
+
}
|
|
48
|
+
return { m, n, isInitialized, signers };
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=multisig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multisig.js","sourceRoot":"","sources":["../../../src/decoders/multisig.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAoDH,wCAoBC;AArED,qCAAyC;AAyBzC,kEAAkE;AAElE,4DAA4D;AAC/C,QAAA,oBAAoB,GAAG,EAAE,CAAC;AAEvC,8CAA8C;AACjC,QAAA,aAAa,GAAG,GAAG,CAAC;AAEjC,kEAAkE;AAElE;;;;;;;;;;;;;GAaG;AACH,SAAgB,cAAc,CAAC,IAAgB;IAC7C,IAAI,IAAI,CAAC,MAAM,GAAG,qBAAa,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACb,wCAAwC,qBAAa,eAAe,IAAI,CAAC,MAAM,EAAE,CAClF,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,GAAG,IAAI,sBAAa,CAAC,IAAI,CAAC,CAAC;IAElC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAc,MAAM;IACrC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAc,MAAM;IACrC,MAAM,aAAa,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM;IAEtC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,4BAAoB,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;QACtB,IAAI,CAAC,GAAG,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;AAC1C,CAAC"}
|