@oobe-protocol-labs/synapse-client-sdk 2.0.2 → 2.0.5
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 +54 -0
- package/README.md +2 -2
- package/dist/cjs/ai/index.d.ts +1 -1
- package/dist/cjs/ai/index.d.ts.map +1 -1
- package/dist/cjs/ai/index.js +12 -28
- package/dist/cjs/ai/index.js.map +1 -1
- package/dist/cjs/ai/sap/client.d.ts +197 -0
- package/dist/cjs/ai/sap/client.d.ts.map +1 -0
- package/dist/cjs/ai/sap/client.js +334 -0
- package/dist/cjs/ai/sap/client.js.map +1 -0
- package/dist/cjs/ai/sap/index.d.ts +69 -52
- package/dist/cjs/ai/sap/index.d.ts.map +1 -1
- package/dist/cjs/ai/sap/index.js +73 -77
- package/dist/cjs/ai/sap/index.js.map +1 -1
- package/dist/cjs/ai/sap/provider.d.ts +180 -0
- package/dist/cjs/ai/sap/provider.d.ts.map +1 -0
- package/dist/cjs/ai/sap/provider.js +219 -0
- package/dist/cjs/ai/sap/provider.js.map +1 -0
- package/dist/cjs/ai/sap/types.d.ts +120 -384
- package/dist/cjs/ai/sap/types.d.ts.map +1 -1
- package/dist/cjs/ai/sap/types.js +20 -200
- package/dist/cjs/ai/sap/types.js.map +1 -1
- package/dist/docs/classes/AccountReader.html +18 -18
- package/dist/docs/classes/AccountsClient.html +10 -10
- package/dist/docs/classes/AsyncProviderError.html +4 -4
- package/dist/docs/classes/CircularDependencyError.html +4 -4
- 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/InstructionWriter.html +11 -11
- package/dist/docs/classes/MemoryGuard.html +9 -9
- package/dist/docs/classes/NetworkError.html +5 -5
- package/dist/docs/classes/RefRegistry.html +11 -11
- package/dist/docs/classes/RefReleasedError.html +4 -4
- package/dist/docs/classes/RpcMethodNotFoundError.html +4 -4
- package/dist/docs/classes/ServiceNotFoundError.html +4 -4
- package/dist/docs/classes/ServiceRef.html +13 -13
- package/dist/docs/classes/SolanaRpc.html +55 -55
- package/dist/docs/classes/SynapseClient.html +15 -15
- package/dist/docs/classes/SynapseContext.html +27 -27
- 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/WeakServiceRef.html +4 -4
- 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 +2 -2
- 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/autoWire.html +1 -1
- package/dist/docs/functions/base58Encode.html +1 -1
- package/dist/docs/functions/base64ToBytes.html +1 -1
- package/dist/docs/functions/bigIntReplacer.html +1 -1
- 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/createBareContext.html +1 -1
- package/dist/docs/functions/createBinding.html +1 -1
- package/dist/docs/functions/createBoundHook.html +1 -1
- package/dist/docs/functions/createReactAdapter.html +1 -1
- package/dist/docs/functions/createRefHook.html +1 -1
- package/dist/docs/functions/createServerMiddleware.html +1 -1
- package/dist/docs/functions/createServiceHook.html +1 -1
- package/dist/docs/functions/createSingleton.html +1 -1
- package/dist/docs/functions/createSynapse.html +1 -1
- package/dist/docs/functions/createSynapseContext.html +1 -1
- package/dist/docs/functions/createToken.html +1 -1
- package/dist/docs/functions/decodeBase58.html +1 -1
- package/dist/docs/functions/decodeLookupTable.html +1 -1
- package/dist/docs/functions/decodeMint.html +1 -1
- package/dist/docs/functions/decodeMultisig.html +1 -1
- package/dist/docs/functions/decodeNonceAccount.html +1 -1
- package/dist/docs/functions/decodeStakeAccount.html +1 -1
- package/dist/docs/functions/decodeToken2022Account.html +1 -1
- package/dist/docs/functions/decodeToken2022Mint.html +1 -1
- package/dist/docs/functions/decodeTokenAccount.html +1 -1
- package/dist/docs/functions/encodeBase58.html +1 -1
- package/dist/docs/functions/fetchLookupTable.html +1 -1
- package/dist/docs/functions/fetchMint.html +1 -1
- package/dist/docs/functions/fetchNonceAccount.html +1 -1
- package/dist/docs/functions/fetchStakeAccount.html +1 -1
- package/dist/docs/functions/fetchTokenAccount.html +1 -1
- package/dist/docs/functions/fetchTokenAccountsByOwner.html +1 -1
- 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/getContext.html +1 -1
- package/dist/docs/functions/getDecodedAccount.html +1 -1
- package/dist/docs/functions/getDecodedAccounts.html +1 -1
- 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/isDisposable.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/readonly.html +1 -1
- package/dist/docs/functions/readonlySigner.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/setGlobalContext.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/toJsonSafe.html +1 -1
- package/dist/docs/functions/toKitAddress.html +1 -1
- package/dist/docs/functions/toKitInstruction.html +1 -1
- package/dist/docs/functions/toKitLamports.html +1 -1
- package/dist/docs/functions/toKitSignatureString.html +1 -1
- package/dist/docs/functions/tryGetContext.html +1 -1
- package/dist/docs/functions/tryUseService.html +1 -1
- package/dist/docs/functions/useBoundServices.html +1 -1
- package/dist/docs/functions/useService.html +1 -1
- package/dist/docs/functions/useSharedRef.html +1 -1
- package/dist/docs/functions/withRef.html +1 -1
- package/dist/docs/functions/withRefAsync.html +1 -1
- package/dist/docs/functions/writable.html +1 -1
- package/dist/docs/functions/writableSigner.html +1 -1
- package/dist/docs/index.html +2 -2
- package/dist/docs/interfaces/AccountInfo.html +7 -7
- package/dist/docs/interfaces/AccountMeta.html +4 -4
- package/dist/docs/interfaces/AccountNotification.html +2 -2
- package/dist/docs/interfaces/AccountSubParams.html +2 -2
- package/dist/docs/interfaces/AddMemoParams.html +5 -5
- package/dist/docs/interfaces/AdvanceNonceParams.html +3 -3
- package/dist/docs/interfaces/AliasProvider.html +2 -2
- package/dist/docs/interfaces/AllocateParams.html +3 -3
- package/dist/docs/interfaces/ApproveCheckedParams.html +9 -9
- package/dist/docs/interfaces/ApproveParams.html +7 -7
- package/dist/docs/interfaces/AssetSignatureInfo.html +2 -2
- package/dist/docs/interfaces/AssetSignaturesPage.html +2 -2
- package/dist/docs/interfaces/AssignParams.html +3 -3
- package/dist/docs/interfaces/AsyncFactoryProvider.html +2 -2
- package/dist/docs/interfaces/AuthorizeNonceParams.html +4 -4
- 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/BurnCheckedParams.html +8 -8
- package/dist/docs/interfaces/BurnParams.html +7 -7
- package/dist/docs/interfaces/CallOptions.html +6 -6
- package/dist/docs/interfaces/ClassProvider.html +2 -2
- package/dist/docs/interfaces/CloseAccountParams.html +6 -6
- package/dist/docs/interfaces/ConfirmedTransaction.html +6 -6
- package/dist/docs/interfaces/ContactInfo.html +2 -2
- package/dist/docs/interfaces/ContextAdapter.html +5 -5
- package/dist/docs/interfaces/ContextEvents.html +6 -6
- package/dist/docs/interfaces/ContextModule.html +3 -3
- package/dist/docs/interfaces/CreateATAParams.html +6 -6
- package/dist/docs/interfaces/CreateAccountParams.html +6 -6
- package/dist/docs/interfaces/CreateAccountWithSeedParams.html +8 -8
- package/dist/docs/interfaces/CreateSynapseContextOpts.html +4 -4
- 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 +4 -4
- package/dist/docs/interfaces/DecodedLookupTable.html +8 -8
- package/dist/docs/interfaces/DecodedMint.html +6 -6
- package/dist/docs/interfaces/DecodedMultisig.html +5 -5
- package/dist/docs/interfaces/DecodedNonceAccount.html +6 -6
- package/dist/docs/interfaces/DecodedStakeAccount.html +2 -2
- package/dist/docs/interfaces/DecodedToken2022Account.html +9 -9
- package/dist/docs/interfaces/DecodedToken2022Mint.html +6 -6
- package/dist/docs/interfaces/DecodedTokenAccount.html +9 -9
- package/dist/docs/interfaces/DefaultAccountStateExt.html +2 -2
- package/dist/docs/interfaces/Disposable.html +2 -2
- 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/FactoryProvider.html +2 -2
- package/dist/docs/interfaces/FetchedMint.html +6 -6
- package/dist/docs/interfaces/FetchedTokenAccount.html +6 -6
- package/dist/docs/interfaces/FreezeThawParams.html +6 -6
- 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 +2 -2
- 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/InitializeAccountParams.html +5 -5
- package/dist/docs/interfaces/InitializeMintParams.html +6 -6
- package/dist/docs/interfaces/InitializeNonceParams.html +3 -3
- package/dist/docs/interfaces/InterestBearingConfigExt.html +2 -2
- package/dist/docs/interfaces/LatencyProbeResult.html +2 -2
- package/dist/docs/interfaces/LeakReport.html +5 -5
- package/dist/docs/interfaces/LogsNotification.html +2 -2
- package/dist/docs/interfaces/LogsSubParams.html +2 -2
- package/dist/docs/interfaces/MemoTransferExt.html +2 -2
- package/dist/docs/interfaces/MemoryGuardConfig.html +4 -4
- package/dist/docs/interfaces/MetadataPointerExt.html +2 -2
- package/dist/docs/interfaces/MintCloseAuthorityExt.html +2 -2
- package/dist/docs/interfaces/MintToCheckedParams.html +8 -8
- package/dist/docs/interfaces/MintToParams.html +7 -7
- package/dist/docs/interfaces/NonTransferableExt.html +2 -2
- 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 +2 -2
- 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/ProgramsBundle.html +33 -33
- 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/ReactAdapterConfig.html +2 -2
- package/dist/docs/interfaces/RecoverNestedParams.html +7 -7
- package/dist/docs/interfaces/RefRegistryConfig.html +2 -2
- package/dist/docs/interfaces/RefStats.html +7 -7
- package/dist/docs/interfaces/RequestHeapFrameParams.html +2 -2
- package/dist/docs/interfaces/ResolveMiddleware.html +1 -1
- package/dist/docs/interfaces/RevokeParams.html +5 -5
- 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 +3 -3
- package/dist/docs/interfaces/RpcResponse.html +2 -2
- package/dist/docs/interfaces/SendTransactionOpts.html +6 -6
- package/dist/docs/interfaces/ServerAdapterConfig.html +3 -3
- package/dist/docs/interfaces/ServiceBinding.html +6 -6
- package/dist/docs/interfaces/ServiceRegistration.html +3 -3
- package/dist/docs/interfaces/ServiceResolver.html +6 -6
- package/dist/docs/interfaces/ServiceToken.html +4 -4
- package/dist/docs/interfaces/SetComputeUnitLimitParams.html +2 -2
- package/dist/docs/interfaces/SetComputeUnitPriceParams.html +2 -2
- package/dist/docs/interfaces/SetLoadedAccountsDataSizeLimitParams.html +2 -2
- 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/SingletonOptions.html +2 -2
- 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 +2 -2
- package/dist/docs/interfaces/StakeDelegation.html +3 -3
- package/dist/docs/interfaces/StakeLockup.html +4 -4
- package/dist/docs/interfaces/StakeMeta.html +2 -2
- package/dist/docs/interfaces/Supply.html +5 -5
- package/dist/docs/interfaces/SynapseClientConfig.html +9 -9
- package/dist/docs/interfaces/SynapseClientLike.html +2 -2
- package/dist/docs/interfaces/SynapseEndpoint.html +7 -7
- package/dist/docs/interfaces/SyncNativeParams.html +3 -3
- package/dist/docs/interfaces/SystemTransferParams.html +4 -4
- 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/TokenTransferParams.html +7 -7
- package/dist/docs/interfaces/TransactionInstruction.html +4 -4
- package/dist/docs/interfaces/TransactionMeta.html +11 -11
- package/dist/docs/interfaces/TransferCheckedParams.html +9 -9
- package/dist/docs/interfaces/TransferFeeAmount.html +2 -2
- package/dist/docs/interfaces/TransferFeeConfig.html +2 -2
- package/dist/docs/interfaces/TransportConfig.html +7 -7
- package/dist/docs/interfaces/UnknownExtension.html +2 -2
- package/dist/docs/interfaces/ValueProvider.html +2 -2
- package/dist/docs/interfaces/VoteAccount.html +9 -9
- package/dist/docs/interfaces/VoteAccountsResult.html +3 -3
- package/dist/docs/interfaces/WithdrawNonceParams.html +5 -5
- package/dist/docs/interfaces/WsConfig.html +6 -6
- package/dist/docs/media/CHANGELOG.md +54 -0
- package/dist/docs/types/AccountFetchOpts.html +1 -1
- 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 +1 -1
- 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 +1 -1
- 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/ServiceLifecycle.html +1 -1
- package/dist/docs/types/ServiceProvider.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 +1 -1
- package/dist/docs/types/SubscriptionId.html +1 -1
- package/dist/docs/types/TokenAccountState.html +1 -1
- 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/ASSOCIATED_TOKEN_PROGRAM.html +1 -1
- package/dist/docs/variables/AssociatedToken.html +4 -4
- package/dist/docs/variables/COMPUTE_BUDGET_PROGRAM.html +1 -1
- package/dist/docs/variables/ComputeBudget.html +5 -5
- 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 +1 -1
- package/dist/docs/variables/LOOKUP_TABLE_PROGRAM_ID.html +1 -1
- package/dist/docs/variables/MARINADE_PROGRAMS.html +1 -1
- package/dist/docs/variables/MAX_MULTISIG_SIGNERS.html +1 -1
- package/dist/docs/variables/MEMO_PROGRAM_V1.html +1 -1
- package/dist/docs/variables/MEMO_PROGRAM_V2.html +1 -1
- 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 +1 -1
- package/dist/docs/variables/MULTISIG_SIZE.html +1 -1
- package/dist/docs/variables/Memo.html +2 -2
- package/dist/docs/variables/NONCE_ACCOUNT_SIZE.html +1 -1
- 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 +1 -1
- 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_PROGRAM.html +1 -1
- package/dist/docs/variables/SYSTEM_PROGRAMS.html +1 -1
- package/dist/docs/variables/SYSTEM_PROGRAM_ID.html +1 -1
- package/dist/docs/variables/SplToken.html +16 -16
- package/dist/docs/variables/SystemProgram.html +10 -10
- package/dist/docs/variables/TOKEN_2022_PROGRAM.html +1 -1
- package/dist/docs/variables/TOKEN_2022_PROGRAM_ID.html +1 -1
- package/dist/docs/variables/TOKEN_ACCOUNT_SIZE.html +1 -1
- package/dist/docs/variables/TOKEN_PROGRAM.html +1 -1
- package/dist/docs/variables/TOKEN_PROGRAM_ID.html +1 -1
- package/dist/docs/variables/Tokens.html +1 -1
- package/dist/esm/ai/index.d.ts +1 -1
- package/dist/esm/ai/index.d.ts.map +1 -1
- package/dist/esm/ai/index.js +9 -11
- package/dist/esm/ai/index.js.map +1 -1
- package/dist/esm/ai/sap/client.d.ts +197 -0
- package/dist/esm/ai/sap/client.d.ts.map +1 -0
- package/dist/esm/ai/sap/client.js +330 -0
- package/dist/esm/ai/sap/client.js.map +1 -0
- package/dist/esm/ai/sap/index.d.ts +69 -52
- package/dist/esm/ai/sap/index.d.ts.map +1 -1
- package/dist/esm/ai/sap/index.js +68 -49
- package/dist/esm/ai/sap/index.js.map +1 -1
- package/dist/esm/ai/sap/provider.d.ts +180 -0
- package/dist/esm/ai/sap/provider.d.ts.map +1 -0
- package/dist/esm/ai/sap/provider.js +215 -0
- package/dist/esm/ai/sap/provider.js.map +1 -0
- package/dist/esm/ai/sap/types.d.ts +120 -384
- package/dist/esm/ai/sap/types.d.ts.map +1 -1
- package/dist/esm/ai/sap/types.js +18 -195
- package/dist/esm/ai/sap/types.js.map +1 -1
- package/package.json +31 -20
- package/dist/cjs/ai/sap/adapter.d.ts +0 -140
- package/dist/cjs/ai/sap/adapter.d.ts.map +0 -1
- package/dist/cjs/ai/sap/adapter.js +0 -181
- package/dist/cjs/ai/sap/adapter.js.map +0 -1
- package/dist/cjs/ai/sap/discovery.d.ts +0 -165
- package/dist/cjs/ai/sap/discovery.d.ts.map +0 -1
- package/dist/cjs/ai/sap/discovery.js +0 -316
- package/dist/cjs/ai/sap/discovery.js.map +0 -1
- package/dist/cjs/ai/sap/pda.d.ts +0 -205
- package/dist/cjs/ai/sap/pda.d.ts.map +0 -1
- package/dist/cjs/ai/sap/pda.js +0 -547
- package/dist/cjs/ai/sap/pda.js.map +0 -1
- package/dist/cjs/ai/sap/program.d.ts +0 -153
- package/dist/cjs/ai/sap/program.d.ts.map +0 -1
- package/dist/cjs/ai/sap/program.js +0 -227
- package/dist/cjs/ai/sap/program.js.map +0 -1
- package/dist/cjs/ai/sap/registry.d.ts +0 -218
- package/dist/cjs/ai/sap/registry.d.ts.map +0 -1
- package/dist/cjs/ai/sap/registry.js +0 -519
- package/dist/cjs/ai/sap/registry.js.map +0 -1
- package/dist/cjs/ai/sap/scoring.d.ts +0 -138
- package/dist/cjs/ai/sap/scoring.d.ts.map +0 -1
- package/dist/cjs/ai/sap/scoring.js +0 -266
- package/dist/cjs/ai/sap/scoring.js.map +0 -1
- package/dist/cjs/ai/sap/subnetwork.d.ts +0 -201
- package/dist/cjs/ai/sap/subnetwork.d.ts.map +0 -1
- package/dist/cjs/ai/sap/subnetwork.js +0 -365
- package/dist/cjs/ai/sap/subnetwork.js.map +0 -1
- package/dist/cjs/ai/sap/validator.d.ts +0 -160
- package/dist/cjs/ai/sap/validator.d.ts.map +0 -1
- package/dist/cjs/ai/sap/validator.js +0 -619
- package/dist/cjs/ai/sap/validator.js.map +0 -1
- package/dist/esm/ai/sap/adapter.d.ts +0 -140
- package/dist/esm/ai/sap/adapter.d.ts.map +0 -1
- package/dist/esm/ai/sap/adapter.js +0 -177
- package/dist/esm/ai/sap/adapter.js.map +0 -1
- package/dist/esm/ai/sap/discovery.d.ts +0 -165
- package/dist/esm/ai/sap/discovery.d.ts.map +0 -1
- package/dist/esm/ai/sap/discovery.js +0 -311
- package/dist/esm/ai/sap/discovery.js.map +0 -1
- package/dist/esm/ai/sap/pda.d.ts +0 -205
- package/dist/esm/ai/sap/pda.d.ts.map +0 -1
- package/dist/esm/ai/sap/pda.js +0 -535
- package/dist/esm/ai/sap/pda.js.map +0 -1
- package/dist/esm/ai/sap/program.d.ts +0 -153
- package/dist/esm/ai/sap/program.d.ts.map +0 -1
- package/dist/esm/ai/sap/program.js +0 -222
- package/dist/esm/ai/sap/program.js.map +0 -1
- package/dist/esm/ai/sap/registry.d.ts +0 -218
- package/dist/esm/ai/sap/registry.d.ts.map +0 -1
- package/dist/esm/ai/sap/registry.js +0 -515
- package/dist/esm/ai/sap/registry.js.map +0 -1
- package/dist/esm/ai/sap/scoring.d.ts +0 -138
- package/dist/esm/ai/sap/scoring.d.ts.map +0 -1
- package/dist/esm/ai/sap/scoring.js +0 -262
- package/dist/esm/ai/sap/scoring.js.map +0 -1
- package/dist/esm/ai/sap/subnetwork.d.ts +0 -201
- package/dist/esm/ai/sap/subnetwork.d.ts.map +0 -1
- package/dist/esm/ai/sap/subnetwork.js +0 -361
- package/dist/esm/ai/sap/subnetwork.js.map +0 -1
- package/dist/esm/ai/sap/validator.d.ts +0 -160
- package/dist/esm/ai/sap/validator.d.ts.map +0 -1
- package/dist/esm/ai/sap/validator.js +0 -614
- package/dist/esm/ai/sap/validator.js.map +0 -1
package/dist/esm/ai/sap/types.js
CHANGED
|
@@ -1,210 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module ai/sap/types
|
|
3
|
-
* @description
|
|
3
|
+
* @description Integration types for the SAP bridge layer.
|
|
4
4
|
*
|
|
5
|
-
* Defines the
|
|
6
|
-
*
|
|
5
|
+
* Defines the configuration, wallet interface, and context shapes
|
|
6
|
+
* used by {@link SynapseAnchorSap} to connect the Synapse Client SDK
|
|
7
|
+
* with the standalone SAP SDK (`@oobe-protocol-labs/synapse-sap-sdk`).
|
|
7
8
|
*
|
|
8
|
-
*
|
|
9
|
-
* ```
|
|
10
|
-
* [0..8] u8[8] Anchor discriminator
|
|
11
|
-
* [8] u8 version (1)
|
|
12
|
-
* [9] u8 is_active (0 | 1)
|
|
13
|
-
* [10..42] u8[32] wallet pubkey (raw bytes)
|
|
14
|
-
* [42..50] i64 created_at (unix ms)
|
|
15
|
-
* [50..58] i64 updated_at (unix ms)
|
|
16
|
-
* [58..66] u64 total_calls_served
|
|
17
|
-
* [66..70] u32 avg_latency_ms
|
|
18
|
-
* [70] u8 uptime_percent (0-100)
|
|
19
|
-
* [71..] Borsh name (string), description (string),
|
|
20
|
-
* capabilities (Vec<string>),
|
|
21
|
-
* pricing tiers (Vec<AgentPricingOnChain>),
|
|
22
|
-
* x402_endpoint (Option<string>)
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @since 1.3.0
|
|
9
|
+
* @since 2.1.0
|
|
26
10
|
*/
|
|
27
11
|
/* ═══════════════════════════════════════════════════════════════
|
|
28
|
-
*
|
|
12
|
+
* Constants
|
|
29
13
|
* ═══════════════════════════════════════════════════════════════ */
|
|
30
14
|
/**
|
|
31
|
-
*
|
|
32
|
-
* This is a placeholder — deploy the SAP Anchor program and set your ID.
|
|
33
|
-
* @since 1.3.0
|
|
34
|
-
*/
|
|
35
|
-
export const SAP_DEFAULT_PROGRAM_ID = 'SAPAgnt1111111111111111111111111111111111111';
|
|
36
|
-
/**
|
|
37
|
-
* @description PDA seed prefix used for all agent PDAs.
|
|
38
|
-
* Seeds: `["synapse_agent", wallet_pubkey_bytes]`
|
|
39
|
-
* @since 1.3.0
|
|
40
|
-
*/
|
|
41
|
-
export const SAP_SEED_PREFIX = 'synapse_agent';
|
|
42
|
-
/**
|
|
43
|
-
* @description Anchor discriminator for the AgentAccount type.
|
|
44
|
-
* Computed as: `sha256("account:AgentAccount")[0..8]`
|
|
45
|
-
* @since 1.3.0
|
|
46
|
-
*/
|
|
47
|
-
export const SAP_ACCOUNT_DISCRIMINATOR = new Uint8Array([
|
|
48
|
-
0x9b, 0x56, 0x1c, 0xa4, 0x7f, 0x3e, 0x21, 0xd8,
|
|
49
|
-
]);
|
|
50
|
-
/**
|
|
51
|
-
* @description Instruction discriminators for SAP program methods.
|
|
52
|
-
* Computed as: `sha256("global:<method_name>")[0..8]`
|
|
53
|
-
* @since 1.3.0
|
|
54
|
-
*/
|
|
55
|
-
export const SAP_INSTRUCTION_DISCRIMINATORS = {
|
|
56
|
-
register: new Uint8Array([0x18, 0xac, 0x2e, 0x6b, 0x01, 0xf9, 0x7c, 0xd4]),
|
|
57
|
-
update: new Uint8Array([0x27, 0x5d, 0x4b, 0x8e, 0x03, 0xa1, 0x6f, 0xb2]),
|
|
58
|
-
deactivate: new Uint8Array([0x34, 0x6e, 0x5a, 0x9f, 0x02, 0xb3, 0x5d, 0xc1]),
|
|
59
|
-
updateReputation: new Uint8Array([0x41, 0x7f, 0x6b, 0xa0, 0x04, 0xc2, 0x4e, 0xd3]),
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* @description Conversion helpers to bridge SAP types to gateway types.
|
|
63
|
-
* @since 1.3.0
|
|
64
|
-
*/
|
|
65
|
-
export function pdaToIdentity(pda) {
|
|
66
|
-
return {
|
|
67
|
-
id: (pda.agentId ?? `did:sap:${pda.walletPubkey}`),
|
|
68
|
-
name: pda.name,
|
|
69
|
-
walletPubkey: pda.walletPubkey,
|
|
70
|
-
description: pda.description,
|
|
71
|
-
tags: pda.capabilities.map(c => c.id),
|
|
72
|
-
createdAt: pda.createdAt,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* @description Convert on-chain pricing to gateway PricingTier.
|
|
77
|
-
* @param {AgentPricingOnChain} p - On-chain pricing entry
|
|
78
|
-
* @returns {PricingTier} Gateway-compatible pricing tier
|
|
79
|
-
* @since 1.3.0
|
|
80
|
-
*/
|
|
81
|
-
export function pricingToTier(p) {
|
|
82
|
-
const token = p.tokenType === 'SOL' ? { type: 'SOL' } :
|
|
83
|
-
p.tokenType === 'USDC' ? { type: 'USDC' } :
|
|
84
|
-
{ type: 'SPL', mint: p.tokenMint ?? '', decimals: p.tokenDecimals ?? 6 };
|
|
85
|
-
return {
|
|
86
|
-
id: p.tierId,
|
|
87
|
-
label: p.tierId,
|
|
88
|
-
pricePerCall: p.pricePerCall,
|
|
89
|
-
maxCallsPerSession: p.maxCallsPerSession,
|
|
90
|
-
rateLimit: p.rateLimit,
|
|
91
|
-
token,
|
|
92
|
-
includesAttestation: true,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* @description Compute the cost of a specific call number using volume curve pricing.
|
|
97
|
-
*
|
|
98
|
-
* Evaluates the agent's volume curve to determine the price for the Nth call.
|
|
99
|
-
* This implements ERC-8004-style metered billing natively on Solana.
|
|
100
|
-
*
|
|
101
|
-
* @param {AgentPricingOnChain} pricing - The pricing tier
|
|
102
|
-
* @param {number} callNumber - The call number (1-indexed, cumulative across sessions)
|
|
103
|
-
* @returns {bigint} Cost of this specific call in smallest token unit
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* ```ts
|
|
107
|
-
* const pricing = {
|
|
108
|
-
* tierId: 'base',
|
|
109
|
-
* pricePerCall: 1000n, // 0.001 USDC base price
|
|
110
|
-
* volumeCurve: [
|
|
111
|
-
* { afterCalls: 100, pricePerCall: 800n }, // 20% off after 100 calls
|
|
112
|
-
* { afterCalls: 1000, pricePerCall: 500n }, // 50% off after 1000 calls
|
|
113
|
-
* ],
|
|
114
|
-
* // ...
|
|
115
|
-
* };
|
|
15
|
+
* Canonical SAP program ID (mainnet deployment).
|
|
116
16
|
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* computeCallCost(pricing, 1001); // → 500n (second discount tier)
|
|
120
|
-
* ```
|
|
121
|
-
*
|
|
122
|
-
* @since 1.4.0
|
|
17
|
+
* This is the default used when no `programId` is specified.
|
|
18
|
+
* It matches `SAP_PROGRAM_ID` from `@oobe-protocol-labs/synapse-sap-sdk`.
|
|
123
19
|
*/
|
|
124
|
-
export
|
|
125
|
-
let price = pricing.pricePerCall;
|
|
126
|
-
if (pricing.volumeCurve && pricing.volumeCurve.length > 0) {
|
|
127
|
-
// Sort breakpoints by afterCalls ascending
|
|
128
|
-
const sorted = [...pricing.volumeCurve].sort((a, b) => a.afterCalls - b.afterCalls);
|
|
129
|
-
for (const bp of sorted) {
|
|
130
|
-
if (callNumber > bp.afterCalls) {
|
|
131
|
-
price = bp.pricePerCall;
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
// Enforce floor/ceiling
|
|
139
|
-
if (pricing.minPricePerCall !== undefined && price < pricing.minPricePerCall) {
|
|
140
|
-
price = pricing.minPricePerCall;
|
|
141
|
-
}
|
|
142
|
-
if (pricing.maxPricePerCall !== undefined && price > pricing.maxPricePerCall) {
|
|
143
|
-
price = pricing.maxPricePerCall;
|
|
144
|
-
}
|
|
145
|
-
return price;
|
|
146
|
-
}
|
|
20
|
+
export const SAP_PROGRAM_ID = 'SAPTU7aUXk2AaAdktexae1iuxXpokxzNDBAYYhaVyQL';
|
|
147
21
|
/**
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* @param {AgentPricingOnChain} pricing - The pricing tier
|
|
151
|
-
* @param {number} totalCalls - Total number of calls
|
|
152
|
-
* @param {number} [startingFrom=1] - Starting call number (for continuing sessions)
|
|
153
|
-
* @returns {{ totalCost: bigint; avgPricePerCall: bigint; breakdown: Array<{ from: number; to: number; pricePerCall: bigint; subtotal: bigint }> }}
|
|
154
|
-
*
|
|
155
|
-
* @example
|
|
156
|
-
* ```ts
|
|
157
|
-
* const estimate = estimateTotalCost(pricing, 1500);
|
|
158
|
-
* // estimate.totalCost → 850_000n
|
|
159
|
-
* // estimate.avgPricePerCall → 566n
|
|
160
|
-
* // estimate.breakdown → [
|
|
161
|
-
* // { from: 1, to: 100, pricePerCall: 1000n, subtotal: 100_000n },
|
|
162
|
-
* // { from: 101, to: 1000, pricePerCall: 800n, subtotal: 720_000n },
|
|
163
|
-
* // { from: 1001, to: 1500, pricePerCall: 500n, subtotal: 250_000n },
|
|
164
|
-
* // ]
|
|
165
|
-
* ```
|
|
166
|
-
*
|
|
167
|
-
* @since 1.4.0
|
|
22
|
+
* Error thrown when a required peer dependency is missing.
|
|
168
23
|
*/
|
|
169
|
-
export
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
// Build segments: [0, bp1, bp2, ...] with corresponding prices
|
|
177
|
-
const segments = [
|
|
178
|
-
{ afterCalls: 0, pricePerCall: pricing.pricePerCall },
|
|
179
|
-
...curve,
|
|
180
|
-
];
|
|
181
|
-
const endCall = startingFrom + totalCalls - 1;
|
|
182
|
-
const breakdown = [];
|
|
183
|
-
let totalCost = 0n;
|
|
184
|
-
for (let i = 0; i < segments.length; i++) {
|
|
185
|
-
const segStart = segments[i].afterCalls + 1;
|
|
186
|
-
const segEnd = i + 1 < segments.length ? segments[i + 1].afterCalls : Infinity;
|
|
187
|
-
let price = segments[i].pricePerCall;
|
|
188
|
-
// Enforce floor/ceiling
|
|
189
|
-
if (pricing.minPricePerCall !== undefined && price < pricing.minPricePerCall)
|
|
190
|
-
price = pricing.minPricePerCall;
|
|
191
|
-
if (pricing.maxPricePerCall !== undefined && price > pricing.maxPricePerCall)
|
|
192
|
-
price = pricing.maxPricePerCall;
|
|
193
|
-
const rangeStart = Math.max(segStart, startingFrom);
|
|
194
|
-
const rangeEnd = Math.min(segEnd, endCall);
|
|
195
|
-
if (rangeStart > rangeEnd)
|
|
196
|
-
continue;
|
|
197
|
-
const count = rangeEnd - rangeStart + 1;
|
|
198
|
-
const subtotal = price * BigInt(count);
|
|
199
|
-
totalCost += subtotal;
|
|
200
|
-
breakdown.push({
|
|
201
|
-
from: rangeStart,
|
|
202
|
-
to: rangeEnd,
|
|
203
|
-
pricePerCall: price,
|
|
204
|
-
subtotal,
|
|
205
|
-
});
|
|
24
|
+
export class SapDependencyError extends Error {
|
|
25
|
+
name = 'SapDependencyError';
|
|
26
|
+
packageName;
|
|
27
|
+
constructor(packageName) {
|
|
28
|
+
super(`Missing peer dependency: ${packageName} is required for SAP integration. ` +
|
|
29
|
+
`Install it: pnpm add ${packageName}`);
|
|
30
|
+
this.packageName = packageName;
|
|
206
31
|
}
|
|
207
|
-
const avgPricePerCall = totalCalls > 0 ? totalCost / BigInt(totalCalls) : 0n;
|
|
208
|
-
return { totalCost, avgPricePerCall, breakdown };
|
|
209
32
|
}
|
|
210
33
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/ai/sap/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/ai/sap/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH;;qEAEqE;AAErE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,6CAA6C,CAAC;AAsJ5E;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IACzB,IAAI,GAAG,oBAAoB,CAAC;IACrC,WAAW,CAAS;IAE7B,YAAY,WAAmB;QAC7B,KAAK,CACH,4BAA4B,WAAW,oCAAoC;YAC3E,wBAAwB,WAAW,EAAE,CACtC,CAAC;QACF,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oobe-protocol-labs/synapse-client-sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"description": "Synapse Client SDK -- Typed Solana RPC gateway with @solana/kit native types, 53 JSON-RPC methods, DAS, WebSocket, gRPC/Geyser parser, 110+ plugin-based AI tools (Token, NFT, DeFi, Misc, Blinks), MCP server & client, and x402 payments | Powered by oobeprotocol.ai (OOBE)",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -251,23 +251,6 @@
|
|
|
251
251
|
]
|
|
252
252
|
}
|
|
253
253
|
},
|
|
254
|
-
"scripts": {
|
|
255
|
-
"build": "rm -rf dist && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && node scripts/fix-esm-imports.mjs && pnpm run -s build:docs",
|
|
256
|
-
"build:docs": "typedoc --out dist/docs src/index.ts && cp -r dist/docs docs && touch docs/.nojekyll",
|
|
257
|
-
"docs": "typedoc --out docs src/index.ts",
|
|
258
|
-
"win-build": "rimraf dist && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && pnpm run -s win-build:docs",
|
|
259
|
-
"win-build:docs": "typedoc --out dist/docs src/index.ts || echo 'typedoc not found, skipping docs build'",
|
|
260
|
-
"dev": "tsc --watch",
|
|
261
|
-
"lint": "eslint src/**/*.ts --fix",
|
|
262
|
-
"lint:check": "eslint src/**/*.ts",
|
|
263
|
-
"typecheck": "tsc --noEmit",
|
|
264
|
-
"prepublishOnly": "pnpm build",
|
|
265
|
-
"test": "vitest run",
|
|
266
|
-
"test:watch": "vitest",
|
|
267
|
-
"test:coverage": "vitest run --coverage",
|
|
268
|
-
"benchmark": "node benchmark/performance.mjs",
|
|
269
|
-
"stress-test": "node benchmark/stress-test.mjs"
|
|
270
|
-
},
|
|
271
254
|
"keywords": [
|
|
272
255
|
"solana",
|
|
273
256
|
"solana-kit",
|
|
@@ -320,7 +303,10 @@
|
|
|
320
303
|
"typescript": ">=5.0.0",
|
|
321
304
|
"zod": ">=3.23.0 || >=4.0.0",
|
|
322
305
|
"ioredis": ">=5.0.0",
|
|
323
|
-
"pg": ">=8.0.0"
|
|
306
|
+
"pg": ">=8.0.0",
|
|
307
|
+
"@oobe-protocol-labs/synapse-sap-sdk": ">=0.1.0",
|
|
308
|
+
"@coral-xyz/anchor": ">=0.30.0",
|
|
309
|
+
"@solana/web3.js": ">=1.90.0"
|
|
324
310
|
},
|
|
325
311
|
"peerDependenciesMeta": {
|
|
326
312
|
"zod": {
|
|
@@ -334,6 +320,15 @@
|
|
|
334
320
|
},
|
|
335
321
|
"pg": {
|
|
336
322
|
"optional": true
|
|
323
|
+
},
|
|
324
|
+
"@oobe-protocol-labs/synapse-sap-sdk": {
|
|
325
|
+
"optional": true
|
|
326
|
+
},
|
|
327
|
+
"@coral-xyz/anchor": {
|
|
328
|
+
"optional": true
|
|
329
|
+
},
|
|
330
|
+
"@solana/web3.js": {
|
|
331
|
+
"optional": true
|
|
337
332
|
}
|
|
338
333
|
},
|
|
339
334
|
"engines": {
|
|
@@ -346,5 +341,21 @@
|
|
|
346
341
|
"publishConfig": {
|
|
347
342
|
"access": "public",
|
|
348
343
|
"registry": "https://registry.npmjs.org/"
|
|
344
|
+
},
|
|
345
|
+
"scripts": {
|
|
346
|
+
"build": "rm -rf dist && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && node scripts/fix-esm-imports.mjs && pnpm run -s build:docs",
|
|
347
|
+
"build:docs": "typedoc --out dist/docs src/index.ts && cp -r dist/docs docs && touch docs/.nojekyll",
|
|
348
|
+
"docs": "typedoc --out docs src/index.ts",
|
|
349
|
+
"win-build": "rimraf dist && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && pnpm run -s win-build:docs",
|
|
350
|
+
"win-build:docs": "typedoc --out dist/docs src/index.ts || echo 'typedoc not found, skipping docs build'",
|
|
351
|
+
"dev": "tsc --watch",
|
|
352
|
+
"lint": "eslint src/**/*.ts --fix",
|
|
353
|
+
"lint:check": "eslint src/**/*.ts",
|
|
354
|
+
"typecheck": "tsc --noEmit",
|
|
355
|
+
"test": "vitest run",
|
|
356
|
+
"test:watch": "vitest",
|
|
357
|
+
"test:coverage": "vitest run --coverage",
|
|
358
|
+
"benchmark": "node benchmark/performance.mjs",
|
|
359
|
+
"stress-test": "node benchmark/stress-test.mjs"
|
|
349
360
|
}
|
|
350
|
-
}
|
|
361
|
+
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module ai/sap/adapter
|
|
3
|
-
* @description SAP — On-chain persistence adapter for {@link AgentRegistry}.
|
|
4
|
-
*
|
|
5
|
-
* Implements the {@link PersistenceAdapter} interface using SAP on-chain
|
|
6
|
-
* data, enabling the `AgentRegistry` to persist and discover agents
|
|
7
|
-
* directly on the Solana blockchain.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* import { AgentRegistry, OnChainPersistenceAdapter } from '@oobe-protocol-labs/synapse-client-sdk/ai';
|
|
12
|
-
*
|
|
13
|
-
* const adapter = new OnChainPersistenceAdapter(client, { programId: 'SAPAgnt1...' });
|
|
14
|
-
* const registry = new AgentRegistry({ adapter });
|
|
15
|
-
*
|
|
16
|
-
* // Agents registered via the registry are now backed by on-chain data
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @since 1.3.0
|
|
20
|
-
*/
|
|
21
|
-
import type { SAPConfig } from './types';
|
|
22
|
-
import { SAPDiscovery } from './discovery';
|
|
23
|
-
/**
|
|
24
|
-
* @description Persistence adapter interface (matches gateway/registry).
|
|
25
|
-
* @since 1.3.0
|
|
26
|
-
*/
|
|
27
|
-
interface PersistenceAdapterLike {
|
|
28
|
-
save(id: string, data: unknown): Promise<void>;
|
|
29
|
-
load(id: string): Promise<unknown | null>;
|
|
30
|
-
loadAll(): Promise<Array<{
|
|
31
|
-
id: string;
|
|
32
|
-
data: unknown;
|
|
33
|
-
}>>;
|
|
34
|
-
remove(id: string): Promise<void>;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* @description Minimal RPC client interface.
|
|
38
|
-
* @since 1.3.0
|
|
39
|
-
*/
|
|
40
|
-
interface RpcClient {
|
|
41
|
-
transport: {
|
|
42
|
-
request<T = unknown>(method: string, params: unknown[]): Promise<T>;
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* @description Persistence adapter backed by SAP on-chain data.
|
|
47
|
-
*
|
|
48
|
-
* **Read operations** (`load`, `loadAll`) query the blockchain via
|
|
49
|
-
* {@link SAPDiscovery}. **Write operations** (`save`, `remove`) are
|
|
50
|
-
* cached locally — the actual on-chain write must be done by the user
|
|
51
|
-
* via {@link SAPInstructionBuilder} + transaction signing.
|
|
52
|
-
*
|
|
53
|
-
* This design separates read (automatic) from write (user-driven)
|
|
54
|
-
* because on-chain writes require a signature from the agent's wallet.
|
|
55
|
-
*
|
|
56
|
-
* @implements {PersistenceAdapterLike}
|
|
57
|
-
* @since 1.3.0
|
|
58
|
-
*/
|
|
59
|
-
export declare class OnChainPersistenceAdapter implements PersistenceAdapterLike {
|
|
60
|
-
private readonly discovery;
|
|
61
|
-
private readonly pendingWrites;
|
|
62
|
-
private readonly removed;
|
|
63
|
-
/**
|
|
64
|
-
* @param {RpcClient} client - Client providing RPC transport
|
|
65
|
-
* @param {Partial<SAPConfig>} [config] - SAP configuration
|
|
66
|
-
*/
|
|
67
|
-
constructor(client: RpcClient, config?: Partial<SAPConfig>);
|
|
68
|
-
/**
|
|
69
|
-
* @description Get the underlying discovery instance for direct queries.
|
|
70
|
-
* @returns {SAPDiscovery} Discovery engine
|
|
71
|
-
* @since 1.3.0
|
|
72
|
-
*/
|
|
73
|
-
getDiscovery(): SAPDiscovery;
|
|
74
|
-
/**
|
|
75
|
-
* @description Stage agent data for persistence.
|
|
76
|
-
*
|
|
77
|
-
* This caches the data locally. To actually write on-chain, build and
|
|
78
|
-
* send a transaction using {@link SAPInstructionBuilder}.
|
|
79
|
-
*
|
|
80
|
-
* @param {string} id - Agent wallet pubkey or DID
|
|
81
|
-
* @param {unknown} data - Agent data to persist
|
|
82
|
-
* @returns {Promise<void>}
|
|
83
|
-
* @since 1.3.0
|
|
84
|
-
*/
|
|
85
|
-
save(id: string, data: unknown): Promise<void>;
|
|
86
|
-
/**
|
|
87
|
-
* @description Load agent data from on-chain PDA.
|
|
88
|
-
*
|
|
89
|
-
* First checks pending writes (local cache), then queries the blockchain.
|
|
90
|
-
*
|
|
91
|
-
* @param {string} id - Agent wallet pubkey
|
|
92
|
-
* @returns {Promise<AgentPDAAccount | unknown | null>} Agent data or null
|
|
93
|
-
* @since 1.3.0
|
|
94
|
-
*/
|
|
95
|
-
load(id: string): Promise<unknown | null>;
|
|
96
|
-
/**
|
|
97
|
-
* @description Load all agents from the blockchain.
|
|
98
|
-
*
|
|
99
|
-
* Merges on-chain data with pending local writes, excluding removed entries.
|
|
100
|
-
*
|
|
101
|
-
* @returns {Promise<Array<{ id: string; data: unknown }>>} All agent records
|
|
102
|
-
* @since 1.3.0
|
|
103
|
-
*/
|
|
104
|
-
loadAll(): Promise<Array<{
|
|
105
|
-
id: string;
|
|
106
|
-
data: unknown;
|
|
107
|
-
}>>;
|
|
108
|
-
/**
|
|
109
|
-
* @description Mark an agent for removal (locally cached).
|
|
110
|
-
*
|
|
111
|
-
* On-chain removal requires sending a `deactivate` instruction
|
|
112
|
-
* via {@link SAPInstructionBuilder}.
|
|
113
|
-
*
|
|
114
|
-
* @param {string} id - Agent wallet pubkey
|
|
115
|
-
* @returns {Promise<void>}
|
|
116
|
-
* @since 1.3.0
|
|
117
|
-
*/
|
|
118
|
-
remove(id: string): Promise<void>;
|
|
119
|
-
/**
|
|
120
|
-
* @description Get pending writes that need to be committed on-chain.
|
|
121
|
-
* @returns {Map<string, unknown>} Map of agent ID → staged data
|
|
122
|
-
* @since 1.3.0
|
|
123
|
-
*/
|
|
124
|
-
getPendingWrites(): ReadonlyMap<string, unknown>;
|
|
125
|
-
/**
|
|
126
|
-
* @description Get IDs of agents marked for removal.
|
|
127
|
-
* @returns {ReadonlySet<string>} Set of removed agent IDs
|
|
128
|
-
* @since 1.3.0
|
|
129
|
-
*/
|
|
130
|
-
getRemovedIds(): ReadonlySet<string>;
|
|
131
|
-
/**
|
|
132
|
-
* @description Clear all pending local writes and removals.
|
|
133
|
-
* Call after successfully committing transactions on-chain.
|
|
134
|
-
* @returns {void}
|
|
135
|
-
* @since 1.3.0
|
|
136
|
-
*/
|
|
137
|
-
clearPending(): void;
|
|
138
|
-
}
|
|
139
|
-
export {};
|
|
140
|
-
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/ai/sap/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,SAAS,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAS3C;;;GAGG;AACH,UAAU,sBAAsB;IAC9B,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAC1C,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC,CAAC;IACzD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC;AAED;;;GAGG;AACH,UAAU,SAAS;IACjB,SAAS,EAAE;QACT,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;KACrE,CAAC;CACH;AAMD;;;;;;;;;;;;;GAaG;AACH,qBAAa,yBAA0B,YAAW,sBAAsB;IACtE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IACzC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAmC;IACjE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0B;IAElD;;;OAGG;gBACS,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC;IAQ1D;;;;OAIG;IACH,YAAY,IAAI,YAAY;IAI5B;;;;;;;;;;OAUG;IACG,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpD;;;;;;;;OAQG;IACG,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAa/C;;;;;;;OAOG;IACG,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IA+B9D;;;;;;;;;OASG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKvC;;;;OAIG;IACH,gBAAgB,IAAI,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC;IAIhD;;;;OAIG;IACH,aAAa,IAAI,WAAW,CAAC,MAAM,CAAC;IAIpC;;;;;OAKG;IACH,YAAY,IAAI,IAAI;CAIrB"}
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @module ai/sap/adapter
|
|
4
|
-
* @description SAP — On-chain persistence adapter for {@link AgentRegistry}.
|
|
5
|
-
*
|
|
6
|
-
* Implements the {@link PersistenceAdapter} interface using SAP on-chain
|
|
7
|
-
* data, enabling the `AgentRegistry` to persist and discover agents
|
|
8
|
-
* directly on the Solana blockchain.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* import { AgentRegistry, OnChainPersistenceAdapter } from '@oobe-protocol-labs/synapse-client-sdk/ai';
|
|
13
|
-
*
|
|
14
|
-
* const adapter = new OnChainPersistenceAdapter(client, { programId: 'SAPAgnt1...' });
|
|
15
|
-
* const registry = new AgentRegistry({ adapter });
|
|
16
|
-
*
|
|
17
|
-
* // Agents registered via the registry are now backed by on-chain data
|
|
18
|
-
* ```
|
|
19
|
-
*
|
|
20
|
-
* @since 1.3.0
|
|
21
|
-
*/
|
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.OnChainPersistenceAdapter = void 0;
|
|
24
|
-
const types_1 = require("./types");
|
|
25
|
-
const discovery_1 = require("./discovery");
|
|
26
|
-
/* ═══════════════════════════════════════════════════════════════
|
|
27
|
-
* OnChainPersistenceAdapter
|
|
28
|
-
* ═══════════════════════════════════════════════════════════════ */
|
|
29
|
-
/**
|
|
30
|
-
* @description Persistence adapter backed by SAP on-chain data.
|
|
31
|
-
*
|
|
32
|
-
* **Read operations** (`load`, `loadAll`) query the blockchain via
|
|
33
|
-
* {@link SAPDiscovery}. **Write operations** (`save`, `remove`) are
|
|
34
|
-
* cached locally — the actual on-chain write must be done by the user
|
|
35
|
-
* via {@link SAPInstructionBuilder} + transaction signing.
|
|
36
|
-
*
|
|
37
|
-
* This design separates read (automatic) from write (user-driven)
|
|
38
|
-
* because on-chain writes require a signature from the agent's wallet.
|
|
39
|
-
*
|
|
40
|
-
* @implements {PersistenceAdapterLike}
|
|
41
|
-
* @since 1.3.0
|
|
42
|
-
*/
|
|
43
|
-
class OnChainPersistenceAdapter {
|
|
44
|
-
discovery;
|
|
45
|
-
pendingWrites = new Map();
|
|
46
|
-
removed = new Set();
|
|
47
|
-
/**
|
|
48
|
-
* @param {RpcClient} client - Client providing RPC transport
|
|
49
|
-
* @param {Partial<SAPConfig>} [config] - SAP configuration
|
|
50
|
-
*/
|
|
51
|
-
constructor(client, config) {
|
|
52
|
-
this.discovery = new discovery_1.SAPDiscovery(client, {
|
|
53
|
-
programId: config?.programId ?? types_1.SAP_DEFAULT_PROGRAM_ID,
|
|
54
|
-
commitment: config?.commitment ?? 'confirmed',
|
|
55
|
-
maxAccounts: config?.maxAccounts ?? 100,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* @description Get the underlying discovery instance for direct queries.
|
|
60
|
-
* @returns {SAPDiscovery} Discovery engine
|
|
61
|
-
* @since 1.3.0
|
|
62
|
-
*/
|
|
63
|
-
getDiscovery() {
|
|
64
|
-
return this.discovery;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* @description Stage agent data for persistence.
|
|
68
|
-
*
|
|
69
|
-
* This caches the data locally. To actually write on-chain, build and
|
|
70
|
-
* send a transaction using {@link SAPInstructionBuilder}.
|
|
71
|
-
*
|
|
72
|
-
* @param {string} id - Agent wallet pubkey or DID
|
|
73
|
-
* @param {unknown} data - Agent data to persist
|
|
74
|
-
* @returns {Promise<void>}
|
|
75
|
-
* @since 1.3.0
|
|
76
|
-
*/
|
|
77
|
-
async save(id, data) {
|
|
78
|
-
this.removed.delete(id);
|
|
79
|
-
this.pendingWrites.set(id, data);
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* @description Load agent data from on-chain PDA.
|
|
83
|
-
*
|
|
84
|
-
* First checks pending writes (local cache), then queries the blockchain.
|
|
85
|
-
*
|
|
86
|
-
* @param {string} id - Agent wallet pubkey
|
|
87
|
-
* @returns {Promise<AgentPDAAccount | unknown | null>} Agent data or null
|
|
88
|
-
* @since 1.3.0
|
|
89
|
-
*/
|
|
90
|
-
async load(id) {
|
|
91
|
-
if (this.removed.has(id))
|
|
92
|
-
return null;
|
|
93
|
-
if (this.pendingWrites.has(id))
|
|
94
|
-
return this.pendingWrites.get(id);
|
|
95
|
-
const agent = await this.discovery.findAgent(id);
|
|
96
|
-
if (!agent)
|
|
97
|
-
return null;
|
|
98
|
-
return {
|
|
99
|
-
identity: (0, types_1.pdaToIdentity)(agent),
|
|
100
|
-
pda: agent,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* @description Load all agents from the blockchain.
|
|
105
|
-
*
|
|
106
|
-
* Merges on-chain data with pending local writes, excluding removed entries.
|
|
107
|
-
*
|
|
108
|
-
* @returns {Promise<Array<{ id: string; data: unknown }>>} All agent records
|
|
109
|
-
* @since 1.3.0
|
|
110
|
-
*/
|
|
111
|
-
async loadAll() {
|
|
112
|
-
const onChain = await this.discovery.findActive();
|
|
113
|
-
const results = [];
|
|
114
|
-
const seen = new Set();
|
|
115
|
-
// On-chain agents
|
|
116
|
-
for (const agent of onChain) {
|
|
117
|
-
if (this.removed.has(agent.walletPubkey))
|
|
118
|
-
continue;
|
|
119
|
-
seen.add(agent.walletPubkey);
|
|
120
|
-
// Prefer pending write if available
|
|
121
|
-
if (this.pendingWrites.has(agent.walletPubkey)) {
|
|
122
|
-
results.push({ id: agent.walletPubkey, data: this.pendingWrites.get(agent.walletPubkey) });
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
results.push({
|
|
126
|
-
id: agent.walletPubkey,
|
|
127
|
-
data: { identity: (0, types_1.pdaToIdentity)(agent), pda: agent },
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
// Pending writes not yet on-chain
|
|
132
|
-
for (const [id, data] of this.pendingWrites) {
|
|
133
|
-
if (!seen.has(id) && !this.removed.has(id)) {
|
|
134
|
-
results.push({ id, data });
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return results;
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* @description Mark an agent for removal (locally cached).
|
|
141
|
-
*
|
|
142
|
-
* On-chain removal requires sending a `deactivate` instruction
|
|
143
|
-
* via {@link SAPInstructionBuilder}.
|
|
144
|
-
*
|
|
145
|
-
* @param {string} id - Agent wallet pubkey
|
|
146
|
-
* @returns {Promise<void>}
|
|
147
|
-
* @since 1.3.0
|
|
148
|
-
*/
|
|
149
|
-
async remove(id) {
|
|
150
|
-
this.pendingWrites.delete(id);
|
|
151
|
-
this.removed.add(id);
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* @description Get pending writes that need to be committed on-chain.
|
|
155
|
-
* @returns {Map<string, unknown>} Map of agent ID → staged data
|
|
156
|
-
* @since 1.3.0
|
|
157
|
-
*/
|
|
158
|
-
getPendingWrites() {
|
|
159
|
-
return this.pendingWrites;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* @description Get IDs of agents marked for removal.
|
|
163
|
-
* @returns {ReadonlySet<string>} Set of removed agent IDs
|
|
164
|
-
* @since 1.3.0
|
|
165
|
-
*/
|
|
166
|
-
getRemovedIds() {
|
|
167
|
-
return this.removed;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* @description Clear all pending local writes and removals.
|
|
171
|
-
* Call after successfully committing transactions on-chain.
|
|
172
|
-
* @returns {void}
|
|
173
|
-
* @since 1.3.0
|
|
174
|
-
*/
|
|
175
|
-
clearPending() {
|
|
176
|
-
this.pendingWrites.clear();
|
|
177
|
-
this.removed.clear();
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
exports.OnChainPersistenceAdapter = OnChainPersistenceAdapter;
|
|
181
|
-
//# sourceMappingURL=adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../../src/ai/sap/adapter.ts"],"names":[],"mappings":"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"}
|