@oobe-protocol-labs/synapse-sap-sdk 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/accounts/index.js +286 -0
- package/dist/cjs/accounts/index.js.map +1 -0
- package/dist/cjs/client.js +125 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/constants/seeds.js +9 -9
- package/dist/cjs/constants/seeds.js.map +1 -1
- package/dist/cjs/constants.js +66 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/errors.js +260 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/events/index.js +37 -123
- package/dist/cjs/events/index.js.map +1 -1
- package/dist/cjs/idlTypes.js +4 -0
- package/dist/cjs/idlTypes.js.map +1 -0
- package/dist/cjs/index.js +75 -241
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/instructions/agent.js +90 -0
- package/dist/cjs/instructions/agent.js.map +1 -0
- package/dist/cjs/instructions/attestation.js +113 -0
- package/dist/cjs/instructions/attestation.js.map +1 -0
- package/dist/cjs/instructions/digest.js +29 -0
- package/dist/cjs/instructions/digest.js.map +1 -0
- package/dist/cjs/instructions/dispute.js +117 -0
- package/dist/cjs/instructions/dispute.js.map +1 -0
- package/dist/cjs/instructions/escrow.js +102 -0
- package/dist/cjs/instructions/escrow.js.map +1 -0
- package/dist/cjs/instructions/global.js +29 -0
- package/dist/cjs/instructions/global.js.map +1 -0
- package/dist/cjs/instructions/index.js +31 -0
- package/dist/cjs/instructions/index.js.map +1 -0
- package/dist/cjs/instructions/indexing.js +222 -0
- package/dist/cjs/instructions/indexing.js.map +1 -0
- package/dist/cjs/instructions/misc.js +74 -0
- package/dist/cjs/instructions/misc.js.map +1 -0
- package/dist/cjs/instructions/session.js +90 -0
- package/dist/cjs/instructions/session.js.map +1 -0
- package/dist/cjs/instructions/staking.js +133 -0
- package/dist/cjs/instructions/staking.js.map +1 -0
- package/dist/cjs/instructions/subscription.js +81 -0
- package/dist/cjs/instructions/subscription.js.map +1 -0
- package/dist/cjs/instructions/tools.js +110 -0
- package/dist/cjs/instructions/tools.js.map +1 -0
- package/dist/cjs/instructions/vault.js +107 -0
- package/dist/cjs/instructions/vault.js.map +1 -0
- package/dist/cjs/pdas/index.js +120 -0
- package/dist/cjs/pdas/index.js.map +1 -0
- package/dist/cjs/registries/fairscale.js +1 -1
- package/dist/cjs/registries/fairscale.js.map +1 -1
- package/dist/cjs/registries/metaplex-bridge.js +1 -1
- package/dist/cjs/registries/metaplex-bridge.js.map +1 -1
- package/dist/cjs/types.js +45 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils/escrow-validation.js +1 -1
- package/dist/cjs/utils/escrow-validation.js.map +1 -1
- package/dist/cjs/utils/index.js +32 -83
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/merchant-validator.js +5 -5
- package/dist/cjs/utils/merchant-validator.js.map +1 -1
- package/dist/cjs/utils/validate.js +236 -0
- package/dist/cjs/utils/validate.js.map +1 -0
- package/dist/cjs/utils/volume-curve.js +1 -1
- package/dist/cjs/utils/volume-curve.js.map +1 -1
- package/dist/esm/accounts/index.d.ts +11 -0
- package/dist/esm/accounts/index.d.ts.map +1 -0
- package/dist/esm/accounts/index.js +273 -0
- package/dist/esm/accounts/index.js.map +1 -0
- package/dist/esm/client.d.ts +55 -0
- package/dist/esm/client.d.ts.map +1 -0
- package/dist/esm/client.js +87 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/constants/addresses.d.ts +117 -0
- package/dist/esm/constants/addresses.d.ts.map +1 -0
- package/dist/esm/constants/index.d.ts +31 -0
- package/dist/esm/constants/index.d.ts.map +1 -0
- package/dist/esm/constants/limits.d.ts +149 -0
- package/dist/esm/constants/limits.d.ts.map +1 -0
- package/{src/constants/network.ts → dist/esm/constants/network.d.ts} +23 -31
- package/dist/esm/constants/network.d.ts.map +1 -0
- package/{src/constants/payments.ts → dist/esm/constants/payments.d.ts} +11 -35
- package/dist/esm/constants/payments.d.ts.map +1 -0
- package/{src/constants/programs.ts → dist/esm/constants/programs.d.ts} +6 -20
- package/dist/esm/constants/programs.d.ts.map +1 -0
- package/dist/esm/constants/seeds.d.ts +80 -0
- package/dist/esm/constants/seeds.d.ts.map +1 -0
- package/dist/esm/constants/seeds.js +9 -9
- package/dist/esm/constants/seeds.js.map +1 -1
- package/dist/esm/constants.d.ts +39 -0
- package/dist/esm/constants.d.ts.map +1 -0
- package/dist/esm/constants.js +41 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/core/client.d.ts +452 -0
- package/dist/esm/core/client.d.ts.map +1 -0
- package/dist/esm/core/connection.d.ts +305 -0
- package/dist/esm/core/connection.d.ts.map +1 -0
- package/{src/core/index.ts → dist/esm/core/index.d.ts} +1 -1
- package/dist/esm/core/index.d.ts.map +1 -0
- package/dist/esm/errors/index.d.ts +276 -0
- package/dist/esm/errors/index.d.ts.map +1 -0
- package/dist/esm/errors.d.ts +119 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js +252 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/events/geyser.d.ts +150 -0
- package/dist/esm/events/geyser.d.ts.map +1 -0
- package/dist/esm/events/index.d.ts +17 -0
- package/dist/esm/events/index.d.ts.map +1 -0
- package/dist/esm/events/index.js +34 -122
- package/dist/esm/events/index.js.map +1 -1
- package/{src/idl/index.ts → dist/esm/idl/index.d.ts} +9 -15
- package/dist/esm/idl/index.d.ts.map +1 -0
- package/dist/esm/idlTypes.d.ts +925 -0
- package/dist/esm/idlTypes.d.ts.map +1 -0
- package/dist/esm/idlTypes.js +3 -0
- package/dist/esm/idlTypes.js.map +1 -0
- package/dist/esm/index.d.ts +12 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +15 -88
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/instructions/agent.d.ts +71 -0
- package/dist/esm/instructions/agent.d.ts.map +1 -0
- package/dist/esm/instructions/agent.js +86 -0
- package/dist/esm/instructions/agent.js.map +1 -0
- package/dist/esm/instructions/attestation.d.ts +76 -0
- package/dist/esm/instructions/attestation.d.ts.map +1 -0
- package/dist/esm/instructions/attestation.js +109 -0
- package/dist/esm/instructions/attestation.js.map +1 -0
- package/dist/esm/instructions/digest.d.ts +20 -0
- package/dist/esm/instructions/digest.d.ts.map +1 -0
- package/dist/esm/instructions/digest.js +25 -0
- package/dist/esm/instructions/digest.js.map +1 -0
- package/dist/esm/instructions/dispute.d.ts +81 -0
- package/dist/esm/instructions/dispute.d.ts.map +1 -0
- package/dist/esm/instructions/dispute.js +113 -0
- package/dist/esm/instructions/dispute.js.map +1 -0
- package/dist/esm/instructions/escrow.d.ts +79 -0
- package/dist/esm/instructions/escrow.d.ts.map +1 -0
- package/dist/esm/instructions/escrow.js +98 -0
- package/dist/esm/instructions/escrow.js.map +1 -0
- package/dist/esm/instructions/global.d.ts +14 -0
- package/dist/esm/instructions/global.d.ts.map +1 -0
- package/dist/esm/instructions/global.js +25 -0
- package/dist/esm/instructions/global.js.map +1 -0
- package/dist/esm/instructions/index.d.ts +14 -0
- package/dist/esm/instructions/index.d.ts.map +1 -0
- package/dist/esm/instructions/index.js +15 -0
- package/dist/esm/instructions/index.js.map +1 -0
- package/dist/esm/instructions/indexing.d.ts +150 -0
- package/dist/esm/instructions/indexing.d.ts.map +1 -0
- package/dist/esm/instructions/indexing.js +218 -0
- package/dist/esm/instructions/indexing.js.map +1 -0
- package/dist/esm/instructions/memory.d.ts +8 -0
- package/dist/esm/instructions/memory.d.ts.map +1 -0
- package/dist/esm/instructions/memory.js +234 -0
- package/dist/esm/instructions/memory.js.map +1 -0
- package/dist/esm/instructions/misc.d.ts +50 -0
- package/dist/esm/instructions/misc.d.ts.map +1 -0
- package/dist/esm/instructions/misc.js +70 -0
- package/dist/esm/instructions/misc.js.map +1 -0
- package/dist/esm/instructions/session.d.ts +57 -0
- package/dist/esm/instructions/session.d.ts.map +1 -0
- package/dist/esm/instructions/session.js +86 -0
- package/dist/esm/instructions/session.js.map +1 -0
- package/dist/esm/instructions/staking.d.ts +85 -0
- package/dist/esm/instructions/staking.d.ts.map +1 -0
- package/dist/esm/instructions/staking.js +129 -0
- package/dist/esm/instructions/staking.js.map +1 -0
- package/dist/esm/instructions/subscription.d.ts +50 -0
- package/dist/esm/instructions/subscription.d.ts.map +1 -0
- package/dist/esm/instructions/subscription.js +77 -0
- package/dist/esm/instructions/subscription.js.map +1 -0
- package/dist/esm/instructions/tools.d.ts +88 -0
- package/dist/esm/instructions/tools.d.ts.map +1 -0
- package/dist/esm/instructions/tools.js +106 -0
- package/dist/esm/instructions/tools.js.map +1 -0
- package/dist/esm/instructions/vault.d.ts +84 -0
- package/dist/esm/instructions/vault.d.ts.map +1 -0
- package/dist/esm/instructions/vault.js +103 -0
- package/dist/esm/instructions/vault.js.map +1 -0
- package/dist/esm/modules/agent.d.ts +166 -0
- package/dist/esm/modules/agent.d.ts.map +1 -0
- package/dist/esm/modules/attestation.d.ts +96 -0
- package/dist/esm/modules/attestation.d.ts.map +1 -0
- package/dist/esm/modules/base.d.ts +161 -0
- package/dist/esm/modules/base.d.ts.map +1 -0
- package/dist/esm/modules/escrow-v2.d.ts +169 -0
- package/dist/esm/modules/escrow-v2.d.ts.map +1 -0
- package/dist/esm/modules/feedback.d.ts +105 -0
- package/dist/esm/modules/feedback.d.ts.map +1 -0
- package/{src/modules/index.ts → dist/esm/modules/index.d.ts} +1 -1
- package/dist/esm/modules/index.d.ts.map +1 -0
- package/dist/esm/modules/indexing.d.ts +200 -0
- package/dist/esm/modules/indexing.d.ts.map +1 -0
- package/dist/esm/modules/ledger.d.ts +150 -0
- package/dist/esm/modules/ledger.d.ts.map +1 -0
- package/dist/esm/modules/receipt.d.ts +77 -0
- package/dist/esm/modules/receipt.d.ts.map +1 -0
- package/dist/esm/modules/staking.d.ts +51 -0
- package/dist/esm/modules/staking.d.ts.map +1 -0
- package/dist/esm/modules/subscription.d.ts +33 -0
- package/dist/esm/modules/subscription.d.ts.map +1 -0
- package/dist/esm/modules/tools.d.ts +182 -0
- package/dist/esm/modules/tools.d.ts.map +1 -0
- package/dist/esm/modules/vault.d.ts +240 -0
- package/dist/esm/modules/vault.d.ts.map +1 -0
- package/dist/esm/parser/client.d.ts +123 -0
- package/dist/esm/parser/client.d.ts.map +1 -0
- package/dist/esm/parser/complete.d.ts +90 -0
- package/dist/esm/parser/complete.d.ts.map +1 -0
- package/{src/parser/index.ts → dist/esm/parser/index.d.ts} +6 -37
- package/dist/esm/parser/index.d.ts.map +1 -0
- package/dist/esm/parser/inner.d.ts +114 -0
- package/dist/esm/parser/inner.d.ts.map +1 -0
- package/{src/parser/instructions.ts → dist/esm/parser/instructions.d.ts} +4 -63
- package/dist/esm/parser/instructions.d.ts.map +1 -0
- package/dist/esm/parser/transaction.d.ts +77 -0
- package/dist/esm/parser/transaction.d.ts.map +1 -0
- package/dist/esm/parser/types.d.ts +154 -0
- package/dist/esm/parser/types.d.ts.map +1 -0
- package/{src/pda/index.ts → dist/esm/pda/index.d.ts} +33 -442
- package/dist/esm/pda/index.d.ts.map +1 -0
- package/dist/esm/pdas/index.d.ts +37 -0
- package/dist/esm/pdas/index.d.ts.map +1 -0
- package/dist/esm/pdas/index.js +101 -0
- package/dist/esm/pdas/index.js.map +1 -0
- package/dist/esm/plugin/index.d.ts +171 -0
- package/dist/esm/plugin/index.d.ts.map +1 -0
- package/dist/esm/plugin/protocols.d.ts +152 -0
- package/dist/esm/plugin/protocols.d.ts.map +1 -0
- package/dist/esm/plugin/schemas.d.ts +829 -0
- package/dist/esm/plugin/schemas.d.ts.map +1 -0
- package/dist/esm/postgres/adapter.d.ts +355 -0
- package/dist/esm/postgres/adapter.d.ts.map +1 -0
- package/dist/esm/postgres/index.d.ts +24 -0
- package/dist/esm/postgres/index.d.ts.map +1 -0
- package/dist/esm/postgres/serializers.d.ts +30 -0
- package/dist/esm/postgres/serializers.d.ts.map +1 -0
- package/dist/esm/postgres/sync.d.ts +156 -0
- package/dist/esm/postgres/sync.d.ts.map +1 -0
- package/dist/esm/postgres/types.d.ts +167 -0
- package/dist/esm/postgres/types.d.ts.map +1 -0
- package/dist/esm/registries/builder.d.ts +340 -0
- package/dist/esm/registries/builder.d.ts.map +1 -0
- package/dist/esm/registries/discovery.d.ts +333 -0
- package/dist/esm/registries/discovery.d.ts.map +1 -0
- package/dist/esm/registries/fairscale.d.ts +680 -0
- package/dist/esm/registries/fairscale.d.ts.map +1 -0
- package/dist/esm/registries/fairscale.js +1 -1
- package/dist/esm/registries/fairscale.js.map +1 -1
- package/dist/esm/registries/index.d.ts +52 -0
- package/dist/esm/registries/index.d.ts.map +1 -0
- package/dist/esm/registries/metaplex-bridge.d.ts +489 -0
- package/dist/esm/registries/metaplex-bridge.d.ts.map +1 -0
- package/dist/esm/registries/metaplex-bridge.js +1 -1
- package/dist/esm/registries/metaplex-bridge.js.map +1 -1
- package/dist/esm/registries/session.d.ts +323 -0
- package/dist/esm/registries/session.d.ts.map +1 -0
- package/dist/esm/registries/x402.d.ts +530 -0
- package/dist/esm/registries/x402.d.ts.map +1 -0
- package/dist/esm/types/accounts.d.ts +765 -0
- package/dist/esm/types/accounts.d.ts.map +1 -0
- package/dist/esm/types/common.d.ts +166 -0
- package/dist/esm/types/common.d.ts.map +1 -0
- package/dist/esm/types/endpoint.d.ts +161 -0
- package/dist/esm/types/endpoint.d.ts.map +1 -0
- package/dist/esm/types/enums.d.ts +353 -0
- package/dist/esm/types/enums.d.ts.map +1 -0
- package/dist/esm/types/index.d.ts +29 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/types/instructions.d.ts +400 -0
- package/dist/esm/types/instructions.d.ts.map +1 -0
- package/dist/esm/types.d.ts +236 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +40 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/anchor-errors.d.ts +61 -0
- package/dist/esm/utils/anchor-errors.d.ts.map +1 -0
- package/dist/esm/utils/endpoint-validator.d.ts +110 -0
- package/dist/esm/utils/endpoint-validator.d.ts.map +1 -0
- package/dist/esm/utils/escrow-validation.d.ts +145 -0
- package/dist/esm/utils/escrow-validation.d.ts.map +1 -0
- package/dist/esm/utils/escrow-validation.js +1 -1
- package/dist/esm/utils/escrow-validation.js.map +1 -1
- package/{src/utils/hash.ts → dist/esm/utils/hash.d.ts} +4 -42
- package/dist/esm/utils/hash.d.ts.map +1 -0
- package/dist/esm/utils/index.d.ts +6 -0
- package/dist/esm/utils/index.d.ts.map +1 -0
- package/dist/esm/utils/index.js +16 -33
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/merchant-validator.d.ts +176 -0
- package/dist/esm/utils/merchant-validator.d.ts.map +1 -0
- package/dist/esm/utils/merchant-validator.js +1 -1
- package/dist/esm/utils/merchant-validator.js.map +1 -1
- package/dist/esm/utils/network-normalizer.d.ts +120 -0
- package/dist/esm/utils/network-normalizer.d.ts.map +1 -0
- package/dist/esm/utils/priority-fee.d.ts +205 -0
- package/dist/esm/utils/priority-fee.d.ts.map +1 -0
- package/dist/esm/utils/rpc-strategy.d.ts +172 -0
- package/dist/esm/utils/rpc-strategy.d.ts.map +1 -0
- package/dist/esm/utils/schemas.d.ts +351 -0
- package/dist/esm/utils/schemas.d.ts.map +1 -0
- package/{src/utils/serialization.ts → dist/esm/utils/serialization.d.ts} +3 -32
- package/dist/esm/utils/serialization.d.ts.map +1 -0
- package/dist/esm/utils/validate.d.ts +66 -0
- package/dist/esm/utils/validate.d.ts.map +1 -0
- package/dist/esm/utils/validate.js +221 -0
- package/dist/esm/utils/validate.js.map +1 -0
- package/{src/utils/validation.ts → dist/esm/utils/validation.d.ts} +2 -9
- package/dist/esm/utils/validation.d.ts.map +1 -0
- package/{src/utils/volume-curve.ts → dist/esm/utils/volume-curve.d.ts} +2 -73
- package/dist/esm/utils/volume-curve.d.ts.map +1 -0
- package/dist/esm/utils/volume-curve.js +1 -1
- package/dist/esm/utils/volume-curve.js.map +1 -1
- package/dist/esm/utils/x402-direct.d.ts +114 -0
- package/dist/esm/utils/x402-direct.d.ts.map +1 -0
- package/dist/types/constants/seeds.d.ts +2 -0
- package/dist/types/constants/seeds.d.ts.map +1 -1
- package/dist/types/core/client.d.ts +21 -6
- package/dist/types/core/client.d.ts.map +1 -1
- package/dist/types/errors/index.d.ts +59 -0
- package/dist/types/errors/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/agent.d.ts +9 -19
- package/dist/types/modules/agent.d.ts.map +1 -1
- package/dist/types/modules/attestation.d.ts.map +1 -1
- package/dist/types/modules/base.d.ts +54 -0
- package/dist/types/modules/base.d.ts.map +1 -1
- package/dist/types/modules/escrow-v2.d.ts +117 -1
- package/dist/types/modules/escrow-v2.d.ts.map +1 -1
- package/dist/types/modules/index.d.ts +1 -2
- package/dist/types/modules/index.d.ts.map +1 -1
- package/dist/types/modules/receipt.d.ts +14 -0
- package/dist/types/modules/receipt.d.ts.map +1 -1
- package/dist/types/modules/subscription.d.ts.map +1 -1
- package/dist/types/modules/tools.d.ts +0 -10
- package/dist/types/modules/tools.d.ts.map +1 -1
- package/dist/types/modules/vault.d.ts.map +1 -1
- package/dist/types/pda/index.d.ts +17 -0
- package/dist/types/pda/index.d.ts.map +1 -1
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/registries/builder.d.ts +2 -9
- package/dist/types/registries/builder.d.ts.map +1 -1
- package/dist/types/registries/metaplex-bridge.d.ts.map +1 -1
- package/dist/types/registries/session.d.ts +3 -9
- package/dist/types/registries/session.d.ts.map +1 -1
- package/dist/types/registries/x402.d.ts +2 -9
- package/dist/types/registries/x402.d.ts.map +1 -1
- package/dist/types/types/accounts.d.ts +52 -0
- package/dist/types/types/accounts.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/utils/rpc-strategy.d.ts +7 -0
- package/dist/types/utils/rpc-strategy.d.ts.map +1 -1
- package/package.json +59 -183
- package/src/constants/addresses.ts +0 -162
- package/src/constants/index.ts +0 -69
- package/src/constants/limits.ts +0 -165
- package/src/constants/seeds.ts +0 -85
- package/src/core/client.ts +0 -583
- package/src/core/connection.ts +0 -461
- package/src/errors/index.ts +0 -346
- package/src/events/geyser.ts +0 -384
- package/src/events/index.ts +0 -335
- package/src/events/yellowstone.d.ts +0 -7
- package/src/idl/synapse_agent_sap.json +0 -14595
- package/src/index.ts +0 -421
- package/src/modules/agent.ts +0 -319
- package/src/modules/attestation.ts +0 -168
- package/src/modules/base.ts +0 -247
- package/src/modules/escrow-v2.ts +0 -871
- package/src/modules/escrow.ts +0 -439
- package/src/modules/feedback.ts +0 -186
- package/src/modules/indexing.ts +0 -444
- package/src/modules/ledger.ts +0 -262
- package/src/modules/receipt.ts +0 -212
- package/src/modules/staking.ts +0 -223
- package/src/modules/subscription.ts +0 -147
- package/src/modules/tools.ts +0 -454
- package/src/modules/vault.ts +0 -558
- package/src/parser/client.ts +0 -211
- package/src/parser/complete.ts +0 -232
- package/src/parser/inner.ts +0 -255
- package/src/parser/transaction.ts +0 -200
- package/src/parser/types.ts +0 -182
- package/src/plugin/index.ts +0 -1224
- package/src/plugin/protocols.ts +0 -404
- package/src/plugin/schemas.ts +0 -941
- package/src/postgres/adapter.ts +0 -904
- package/src/postgres/index.ts +0 -59
- package/src/postgres/schema.sql +0 -683
- package/src/postgres/serializers.ts +0 -485
- package/src/postgres/sync.ts +0 -340
- package/src/postgres/types.ts +0 -245
- package/src/registries/builder.ts +0 -607
- package/src/registries/discovery.ts +0 -572
- package/src/registries/fairscale.ts +0 -1278
- package/src/registries/index.ts +0 -143
- package/src/registries/metaplex-bridge.ts +0 -1199
- package/src/registries/session.ts +0 -613
- package/src/registries/x402.ts +0 -1048
- package/src/types/accounts.ts +0 -858
- package/src/types/common.ts +0 -187
- package/src/types/endpoint.ts +0 -181
- package/src/types/enums.ts +0 -333
- package/src/types/index.ts +0 -121
- package/src/types/instructions.ts +0 -453
- package/src/utils/anchor-errors.ts +0 -461
- package/src/utils/endpoint-validator.ts +0 -300
- package/src/utils/escrow-validation.ts +0 -301
- package/src/utils/index.ts +0 -118
- package/src/utils/merchant-validator.ts +0 -359
- package/src/utils/network-normalizer.ts +0 -240
- package/src/utils/priority-fee.ts +0 -325
- package/src/utils/rpc-strategy.ts +0 -322
- package/src/utils/schemas.ts +0 -359
- package/src/utils/x402-direct.ts +0 -370
- /package/dist/{types → esm}/modules/escrow.d.ts +0 -0
- /package/dist/{types → esm}/modules/escrow.d.ts.map +0 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module tools
|
|
3
|
+
* @description Tool schema registry and session checkpoints for the
|
|
4
|
+
* Synapse Agent Protocol.
|
|
5
|
+
*
|
|
6
|
+
* Covers: publish, inscribe schema, update, deactivate/reactivate,
|
|
7
|
+
* close, report invocations, and session checkpoint management.
|
|
8
|
+
*
|
|
9
|
+
* @category Modules
|
|
10
|
+
* @since v0.1.0
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import { type PublicKey, type TransactionSignature } from "@solana/web3.js";
|
|
14
|
+
import { BaseModule } from "./base";
|
|
15
|
+
import type { ToolDescriptorData, SessionCheckpointData, PublishToolArgs, UpdateToolArgs, InscribeToolSchemaArgs } from "../types";
|
|
16
|
+
/**
|
|
17
|
+
* @name ToolsModule
|
|
18
|
+
* @description Manages tool descriptors and session checkpoints for the
|
|
19
|
+
* Synapse Agent Protocol. Provides methods to publish, update, deactivate,
|
|
20
|
+
* reactivate, close, and fetch tool descriptors, as well as inscribe
|
|
21
|
+
* JSON schemas into TX logs and manage session checkpoints.
|
|
22
|
+
*
|
|
23
|
+
* @category Modules
|
|
24
|
+
* @since v0.1.0
|
|
25
|
+
* @extends BaseModule
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const sap = new SapClient(provider);
|
|
30
|
+
* // Publish a tool by name (auto-hashes)
|
|
31
|
+
* const sig = await sap.tools.publishByName(
|
|
32
|
+
* "getWeather", "mcp-v1", "Fetch weather",
|
|
33
|
+
* '{"type":"object"}', '{"type":"object"}',
|
|
34
|
+
* 0, 1, 2, 1, false,
|
|
35
|
+
* );
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare class ToolsModule extends BaseModule {
|
|
39
|
+
/**
|
|
40
|
+
* @name deriveTool
|
|
41
|
+
* @description Derive the `ToolDescriptor` PDA for a given agent and tool name.
|
|
42
|
+
* The tool name is SHA-256 hashed internally.
|
|
43
|
+
* @param agentPda - The agent account PDA.
|
|
44
|
+
* @param toolName - The human-readable tool name.
|
|
45
|
+
* @returns A tuple of `[PublicKey, bump]` for the tool PDA.
|
|
46
|
+
* @see {@link deriveTool} from `pda/` module for the underlying derivation.
|
|
47
|
+
* @since v0.1.0
|
|
48
|
+
*/
|
|
49
|
+
deriveTool(agentPda: PublicKey, toolName: string): readonly [PublicKey, number];
|
|
50
|
+
/**
|
|
51
|
+
* @name publish
|
|
52
|
+
* @description Publish a new tool descriptor for an agent using pre-computed
|
|
53
|
+
* hashes. For auto-hashing, prefer {@link publishByName}.
|
|
54
|
+
* @param args - Tool publication parameters (name, hashes, HTTP method, category, params, etc.).
|
|
55
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
56
|
+
* @since v0.1.0
|
|
57
|
+
*/
|
|
58
|
+
publish(args: PublishToolArgs): Promise<TransactionSignature>;
|
|
59
|
+
/**
|
|
60
|
+
* @name publishByName
|
|
61
|
+
* @description Convenience method to publish a tool using string names.
|
|
62
|
+
* All string arguments are automatically SHA-256 hashed.
|
|
63
|
+
* @param toolName - Human-readable tool name.
|
|
64
|
+
* @param protocolId - Protocol identifier (e.g. `"mcp-v1"`).
|
|
65
|
+
* @param description - Tool description text.
|
|
66
|
+
* @param inputSchema - JSON schema string for input validation.
|
|
67
|
+
* @param outputSchema - JSON schema string for output validation.
|
|
68
|
+
* @param httpMethod - Numeric HTTP method enum value.
|
|
69
|
+
* @param category - Numeric tool category enum value.
|
|
70
|
+
* @param paramsCount - Total number of parameters.
|
|
71
|
+
* @param requiredParams - Number of required parameters.
|
|
72
|
+
* @param isCompound - Whether the tool is a compound (multi-step) tool.
|
|
73
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
74
|
+
* @since v0.1.0
|
|
75
|
+
*/
|
|
76
|
+
publishByName(toolName: string, protocolId: string, description: string, inputSchema: string, outputSchema: string, httpMethod: number, category: number, paramsCount: number, requiredParams: number, isCompound: boolean): Promise<TransactionSignature>;
|
|
77
|
+
/**
|
|
78
|
+
* @name inscribeSchema
|
|
79
|
+
* @description Inscribe a full JSON schema into the transaction log (zero rent).
|
|
80
|
+
* The schema is stored as TX log data, not as PDA account data.
|
|
81
|
+
* @param toolName - The human-readable tool name.
|
|
82
|
+
* @param args - Schema inscription parameters (type, data, hash, compression).
|
|
83
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
84
|
+
* @since v0.1.0
|
|
85
|
+
*/
|
|
86
|
+
inscribeSchema(toolName: string, args: InscribeToolSchemaArgs): Promise<TransactionSignature>;
|
|
87
|
+
/**
|
|
88
|
+
* @name update
|
|
89
|
+
* @description Update a tool’s schema hashes and bump its version.
|
|
90
|
+
* All fields are optional — only non-null values are written.
|
|
91
|
+
* @param toolName - The human-readable tool name.
|
|
92
|
+
* @param args - Partial update parameters (hashes, method, category, params).
|
|
93
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
94
|
+
* @since v0.1.0
|
|
95
|
+
*/
|
|
96
|
+
update(toolName: string, args: UpdateToolArgs): Promise<TransactionSignature>;
|
|
97
|
+
/**
|
|
98
|
+
* @name deactivate
|
|
99
|
+
* @description Deactivate a tool. The tool remains discoverable but is
|
|
100
|
+
* marked as unavailable.
|
|
101
|
+
* @param toolName - The human-readable tool name.
|
|
102
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
103
|
+
* @since v0.1.0
|
|
104
|
+
*/
|
|
105
|
+
deactivate(toolName: string): Promise<TransactionSignature>;
|
|
106
|
+
/**
|
|
107
|
+
* @name reactivate
|
|
108
|
+
* @description Reactivate a previously deactivated tool.
|
|
109
|
+
* @param toolName - The human-readable tool name.
|
|
110
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
111
|
+
* @since v0.1.0
|
|
112
|
+
*/
|
|
113
|
+
reactivate(toolName: string): Promise<TransactionSignature>;
|
|
114
|
+
/**
|
|
115
|
+
* @name close
|
|
116
|
+
* @description Close a tool PDA and reclaim rent to the owner wallet.
|
|
117
|
+
* @param toolName - The human-readable tool name.
|
|
118
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
119
|
+
* @since v0.1.0
|
|
120
|
+
*/
|
|
121
|
+
close(toolName: string): Promise<TransactionSignature>;
|
|
122
|
+
/**
|
|
123
|
+
* @name reportInvocations
|
|
124
|
+
* @description Report tool invocation count. Updates the on-chain counter
|
|
125
|
+
* for analytics and discovery ranking.
|
|
126
|
+
* @param toolName - The human-readable tool name.
|
|
127
|
+
* @param invocations - The number of invocations to report.
|
|
128
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
129
|
+
* @since v0.1.0
|
|
130
|
+
*/
|
|
131
|
+
reportInvocations(toolName: string, invocations: number | bigint): Promise<TransactionSignature>;
|
|
132
|
+
/**
|
|
133
|
+
* @name createCheckpoint
|
|
134
|
+
* @description Create a checkpoint snapshot of the current session state.
|
|
135
|
+
* Checkpoints are indexed by session PDA and checkpoint index.
|
|
136
|
+
* @param sessionPda - The session ledger PDA.
|
|
137
|
+
* @param checkpointIndex - The zero-based checkpoint index.
|
|
138
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
139
|
+
* @since v0.1.0
|
|
140
|
+
*/
|
|
141
|
+
createCheckpoint(sessionPda: PublicKey, checkpointIndex: number): Promise<TransactionSignature>;
|
|
142
|
+
/**
|
|
143
|
+
* @name closeCheckpoint
|
|
144
|
+
* @description Close a checkpoint PDA and reclaim rent.
|
|
145
|
+
* @param sessionPda - The session ledger PDA.
|
|
146
|
+
* @param checkpointIndex - The zero-based checkpoint index.
|
|
147
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
148
|
+
* @since v0.1.0
|
|
149
|
+
*/
|
|
150
|
+
closeCheckpoint(sessionPda: PublicKey, checkpointIndex: number): Promise<TransactionSignature>;
|
|
151
|
+
/**
|
|
152
|
+
* @name fetch
|
|
153
|
+
* @description Fetch a deserialized `ToolDescriptor` account.
|
|
154
|
+
* @param agentPda - The agent account PDA.
|
|
155
|
+
* @param toolName - The human-readable tool name.
|
|
156
|
+
* @returns {Promise<ToolDescriptorData>} The tool descriptor data.
|
|
157
|
+
* @throws Will throw if the tool descriptor does not exist.
|
|
158
|
+
* @since v0.1.0
|
|
159
|
+
*/
|
|
160
|
+
fetch(agentPda: PublicKey, toolName: string): Promise<ToolDescriptorData>;
|
|
161
|
+
/**
|
|
162
|
+
* @name fetchNullable
|
|
163
|
+
* @description Fetch a deserialized `ToolDescriptor` account, or `null`
|
|
164
|
+
* if it does not exist on-chain.
|
|
165
|
+
* @param agentPda - The agent account PDA.
|
|
166
|
+
* @param toolName - The human-readable tool name.
|
|
167
|
+
* @returns {Promise<ToolDescriptorData | null>} The tool data or `null`.
|
|
168
|
+
* @since v0.1.0
|
|
169
|
+
*/
|
|
170
|
+
fetchNullable(agentPda: PublicKey, toolName: string): Promise<ToolDescriptorData | null>;
|
|
171
|
+
/**
|
|
172
|
+
* @name fetchCheckpoint
|
|
173
|
+
* @description Fetch a deserialized `SessionCheckpoint` account by session PDA and index.
|
|
174
|
+
* @param sessionPda - The session ledger PDA.
|
|
175
|
+
* @param checkpointIndex - The zero-based checkpoint index.
|
|
176
|
+
* @returns {Promise<SessionCheckpointData>} The checkpoint data.
|
|
177
|
+
* @throws Will throw if the checkpoint does not exist.
|
|
178
|
+
* @since v0.1.0
|
|
179
|
+
*/
|
|
180
|
+
fetchCheckpoint(sessionPda: PublicKey, checkpointIndex: number): Promise<SessionCheckpointData>;
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/modules/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAiB,KAAK,SAAS,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAOpC,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,sBAAsB,EACvB,MAAM,UAAU,CAAC;AAIlB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,WAAY,SAAQ,UAAU;IAGzC;;;;;;;;;OASG;IACH,UAAU,CACR,QAAQ,EAAE,SAAS,EACnB,QAAQ,EAAE,MAAM,GACf,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAM/B;;;;;;;OAOG;IACG,OAAO,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAyDnE;;;;;;;;;;;;;;;;OAgBG;IACG,aAAa,CACjB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,OAAO,GAClB,OAAO,CAAC,oBAAoB,CAAC;IA8BhC;;;;;;;;OAQG;IACG,cAAc,CAClB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,oBAAoB,CAAC;IAmBhC;;;;;;;;OAQG;IACG,MAAM,CACV,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,oBAAoB,CAAC;IAsBhC;;;;;;;OAOG;IACG,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAcjE;;;;;;OAMG;IACG,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAcjE;;;;;;OAMG;IACG,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAgB5D;;;;;;;;OAQG;IACG,iBAAiB,CACrB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,OAAO,CAAC,oBAAoB,CAAC;IAgBhC;;;;;;;;OAQG;IACG,gBAAgB,CACpB,UAAU,EAAE,SAAS,EACrB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,oBAAoB,CAAC;IAchC;;;;;;;OAOG;IACG,eAAe,CACnB,UAAU,EAAE,SAAS,EACrB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,oBAAoB,CAAC;IAehC;;;;;;;;OAQG;IACG,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAK/E;;;;;;;;OAQG;IACG,aAAa,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAK9F;;;;;;;;OAQG;IACG,eAAe,CACnB,UAAU,EAAE,SAAS,EACrB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,qBAAqB,CAAC;CAIlC"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module vault
|
|
3
|
+
* @description Encrypted memory vault — init, session management, inscribe,
|
|
4
|
+
* delegate access, nonce rotation, and close operations.
|
|
5
|
+
*
|
|
6
|
+
* Vaults provide encrypted, session-scoped memory storage for agents,
|
|
7
|
+
* with support for epoch-based pagination and hot-wallet delegation.
|
|
8
|
+
*
|
|
9
|
+
* @category Modules
|
|
10
|
+
* @since v0.1.0
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import { type PublicKey, type TransactionSignature } from "@solana/web3.js";
|
|
14
|
+
import { BaseModule } from "./base";
|
|
15
|
+
import type { MemoryVaultData, SessionLedgerData, EpochPageData, VaultDelegateData, InscribeMemoryArgs, CompactInscribeArgs } from "../types";
|
|
16
|
+
/**
|
|
17
|
+
* @name VaultModule
|
|
18
|
+
* @description Manages encrypted memory vaults for the Synapse Agent Protocol.
|
|
19
|
+
* Provides methods to initialise vaults, open/close sessions, inscribe
|
|
20
|
+
* encrypted data, manage delegates (hot wallets), rotate nonces, and
|
|
21
|
+
* fetch all related account types.
|
|
22
|
+
*
|
|
23
|
+
* @category Modules
|
|
24
|
+
* @since v0.1.0
|
|
25
|
+
* @extends BaseModule
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const sap = new SapClient(provider);
|
|
30
|
+
* // Initialize a vault
|
|
31
|
+
* await sap.vault.initVault([...nonce]);
|
|
32
|
+
* // Open a session and inscribe data
|
|
33
|
+
* await sap.vault.openSession([...sessionHash]);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare class VaultModule extends BaseModule {
|
|
37
|
+
/**
|
|
38
|
+
* @name deriveVault
|
|
39
|
+
* @description Derive the `MemoryVault` PDA for a given agent.
|
|
40
|
+
* @param agentPda - The agent account PDA.
|
|
41
|
+
* @returns A tuple of `[PublicKey, bump]` for the vault PDA.
|
|
42
|
+
* @see {@link deriveVault} from `pda/` module for the underlying derivation.
|
|
43
|
+
* @since v0.1.0
|
|
44
|
+
*/
|
|
45
|
+
deriveVault(agentPda: PublicKey): readonly [PublicKey, number];
|
|
46
|
+
/**
|
|
47
|
+
* @name deriveSession
|
|
48
|
+
* @description Derive the `SessionLedger` PDA for a given vault and session hash.
|
|
49
|
+
* @param vaultPda - The memory vault PDA.
|
|
50
|
+
* @param sessionHash - A unique session identifier (32 bytes).
|
|
51
|
+
* @returns A tuple of `[PublicKey, bump]` for the session PDA.
|
|
52
|
+
* @see {@link deriveSession} from `pda/` module for the underlying derivation.
|
|
53
|
+
* @since v0.1.0
|
|
54
|
+
*/
|
|
55
|
+
deriveSession(vaultPda: PublicKey, sessionHash: Uint8Array): readonly [PublicKey, number];
|
|
56
|
+
/**
|
|
57
|
+
* @name initVault
|
|
58
|
+
* @description Initialize an encrypted memory vault for the caller's agent.
|
|
59
|
+
* Creates the `MemoryVault` PDA and sets the initial encryption nonce.
|
|
60
|
+
* @param vaultNonce - The initial encryption nonce (byte array).
|
|
61
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
62
|
+
* @since v0.1.0
|
|
63
|
+
*/
|
|
64
|
+
initVault(vaultNonce: number[]): Promise<TransactionSignature>;
|
|
65
|
+
/**
|
|
66
|
+
* @name openSession
|
|
67
|
+
* @description Open a new session within a vault. Creates a `SessionLedger`
|
|
68
|
+
* PDA identified by the session hash.
|
|
69
|
+
* @param sessionHash - A unique session identifier (byte array).
|
|
70
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
71
|
+
* @since v0.1.0
|
|
72
|
+
*/
|
|
73
|
+
openSession(sessionHash: number[]): Promise<TransactionSignature>;
|
|
74
|
+
/**
|
|
75
|
+
* @name inscribe
|
|
76
|
+
* @description Inscribe encrypted data into the transaction log.
|
|
77
|
+
* Account resolution is handled by Anchor via remaining accounts.
|
|
78
|
+
* @param args - Inscription parameters (sequence, encrypted data, nonce, content hash, fragments, compression, epoch).
|
|
79
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
80
|
+
* @since v0.1.0
|
|
81
|
+
*/
|
|
82
|
+
inscribe(args: InscribeMemoryArgs): Promise<TransactionSignature>;
|
|
83
|
+
/**
|
|
84
|
+
* @name inscribeWithAccounts
|
|
85
|
+
* @description Full inscribe with explicit session and epoch page PDAs.
|
|
86
|
+
* Use this when you need manual control over account resolution.
|
|
87
|
+
* @param sessionPda - The session ledger PDA.
|
|
88
|
+
* @param epochPagePda - The epoch page PDA for the target epoch.
|
|
89
|
+
* @param vaultPda - The memory vault PDA.
|
|
90
|
+
* @param args - Inscription parameters.
|
|
91
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
92
|
+
* @since v0.1.0
|
|
93
|
+
*/
|
|
94
|
+
inscribeWithAccounts(sessionPda: PublicKey, epochPagePda: PublicKey, vaultPda: PublicKey, args: InscribeMemoryArgs): Promise<TransactionSignature>;
|
|
95
|
+
/**
|
|
96
|
+
* @name compactInscribe
|
|
97
|
+
* @description Simplified inscription (4 args vs 8) for single-fragment writes.
|
|
98
|
+
* @param sessionPda - The session ledger PDA.
|
|
99
|
+
* @param vaultPda - The memory vault PDA.
|
|
100
|
+
* @param args - Compact inscription parameters (sequence, encrypted data, nonce, content hash).
|
|
101
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
102
|
+
* @since v0.1.0
|
|
103
|
+
*/
|
|
104
|
+
compactInscribe(sessionPda: PublicKey, vaultPda: PublicKey, args: CompactInscribeArgs): Promise<TransactionSignature>;
|
|
105
|
+
/**
|
|
106
|
+
* @name closeSession
|
|
107
|
+
* @description Close a session — no more inscriptions will be allowed.
|
|
108
|
+
* @param vaultPda - The memory vault PDA.
|
|
109
|
+
* @param sessionPda - The session ledger PDA to close.
|
|
110
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
111
|
+
* @since v0.1.0
|
|
112
|
+
*/
|
|
113
|
+
closeSession(vaultPda: PublicKey, sessionPda: PublicKey): Promise<TransactionSignature>;
|
|
114
|
+
/**
|
|
115
|
+
* @name closeVault
|
|
116
|
+
* @description Close the `MemoryVault` PDA and reclaim rent to the owner wallet.
|
|
117
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
118
|
+
* @since v0.1.0
|
|
119
|
+
*/
|
|
120
|
+
closeVault(): Promise<TransactionSignature>;
|
|
121
|
+
/**
|
|
122
|
+
* @name closeSessionPda
|
|
123
|
+
* @description Close a `SessionLedger` PDA (session must be closed first).
|
|
124
|
+
* Reclaims rent to the owner wallet.
|
|
125
|
+
* @param vaultPda - The memory vault PDA.
|
|
126
|
+
* @param sessionPda - The session ledger PDA to close.
|
|
127
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
128
|
+
* @since v0.1.0
|
|
129
|
+
*/
|
|
130
|
+
closeSessionPda(vaultPda: PublicKey, sessionPda: PublicKey): Promise<TransactionSignature>;
|
|
131
|
+
/**
|
|
132
|
+
* @name closeEpochPage
|
|
133
|
+
* @description Close an `EpochPage` PDA and reclaim rent.
|
|
134
|
+
* @param sessionPda - The session ledger PDA that owns this epoch page.
|
|
135
|
+
* @param epochIndex - The zero-based epoch index.
|
|
136
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
137
|
+
* @since v0.1.0
|
|
138
|
+
*/
|
|
139
|
+
closeEpochPage(sessionPda: PublicKey, epochIndex: number): Promise<TransactionSignature>;
|
|
140
|
+
/**
|
|
141
|
+
* @name rotateNonce
|
|
142
|
+
* @description Rotate the vault encryption nonce. All future inscriptions
|
|
143
|
+
* will use the new nonce.
|
|
144
|
+
* @param newNonce - The replacement nonce (byte array).
|
|
145
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
146
|
+
* @since v0.1.0
|
|
147
|
+
*/
|
|
148
|
+
rotateNonce(newNonce: number[]): Promise<TransactionSignature>;
|
|
149
|
+
/**
|
|
150
|
+
* @name addDelegate
|
|
151
|
+
* @description Authorize a delegate (hot wallet) for vault operations.
|
|
152
|
+
* Creates a `VaultDelegate` PDA with the specified permissions and expiry.
|
|
153
|
+
* @param delegatePubkey - The public key of the delegate wallet to authorize.
|
|
154
|
+
* @param permissions - Bitmask of permitted operations.
|
|
155
|
+
* @param expiresAt - Unix timestamp when delegation expires.
|
|
156
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
157
|
+
* @since v0.1.0
|
|
158
|
+
*/
|
|
159
|
+
addDelegate(delegatePubkey: PublicKey, permissions: number, expiresAt: number | bigint): Promise<TransactionSignature>;
|
|
160
|
+
/**
|
|
161
|
+
* @name revokeDelegate
|
|
162
|
+
* @description Revoke a delegate’s authorization, closing their `VaultDelegate` PDA.
|
|
163
|
+
* @param delegatePubkey - The public key of the delegate wallet to revoke.
|
|
164
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
165
|
+
* @since v0.1.0
|
|
166
|
+
*/
|
|
167
|
+
revokeDelegate(delegatePubkey: PublicKey): Promise<TransactionSignature>;
|
|
168
|
+
/**
|
|
169
|
+
* @name inscribeDelegated
|
|
170
|
+
* @description Inscribe data via an authorized delegate (hot wallet).
|
|
171
|
+
* The transaction is signed by the delegate instead of the vault owner.
|
|
172
|
+
* @param delegateWallet - The delegate wallet public key.
|
|
173
|
+
* @param vaultPda - The memory vault PDA.
|
|
174
|
+
* @param sessionPda - The session ledger PDA.
|
|
175
|
+
* @param epochPagePda - The epoch page PDA.
|
|
176
|
+
* @param args - Inscription parameters.
|
|
177
|
+
* @returns {Promise<TransactionSignature>} The transaction signature.
|
|
178
|
+
* @since v0.1.0
|
|
179
|
+
*/
|
|
180
|
+
inscribeDelegated(delegateWallet: PublicKey, vaultPda: PublicKey, sessionPda: PublicKey, epochPagePda: PublicKey, args: InscribeMemoryArgs): Promise<TransactionSignature>;
|
|
181
|
+
/**
|
|
182
|
+
* @name fetchVault
|
|
183
|
+
* @description Fetch a deserialized `MemoryVault` account.
|
|
184
|
+
* @param agentPda - The agent account PDA.
|
|
185
|
+
* @returns {Promise<MemoryVaultData>} The vault account data.
|
|
186
|
+
* @throws Will throw if the vault account does not exist.
|
|
187
|
+
* @since v0.1.0
|
|
188
|
+
*/
|
|
189
|
+
fetchVault(agentPda: PublicKey): Promise<MemoryVaultData>;
|
|
190
|
+
/**
|
|
191
|
+
* @name fetchVaultNullable
|
|
192
|
+
* @description Fetch a deserialized `MemoryVault` account, or `null`
|
|
193
|
+
* if it does not exist on-chain.
|
|
194
|
+
* @param agentPda - The agent account PDA.
|
|
195
|
+
* @returns {Promise<MemoryVaultData | null>} The vault data or `null`.
|
|
196
|
+
* @since v0.1.0
|
|
197
|
+
*/
|
|
198
|
+
fetchVaultNullable(agentPda: PublicKey): Promise<MemoryVaultData | null>;
|
|
199
|
+
/**
|
|
200
|
+
* @name fetchSession
|
|
201
|
+
* @description Fetch a deserialized `SessionLedger` account by vault and session hash.
|
|
202
|
+
* @param vaultPda - The memory vault PDA.
|
|
203
|
+
* @param sessionHash - The session identifier used during creation.
|
|
204
|
+
* @returns {Promise<SessionLedgerData>} The session ledger data.
|
|
205
|
+
* @throws Will throw if the session does not exist.
|
|
206
|
+
* @since v0.1.0
|
|
207
|
+
*/
|
|
208
|
+
fetchSession(vaultPda: PublicKey, sessionHash: Uint8Array): Promise<SessionLedgerData>;
|
|
209
|
+
/**
|
|
210
|
+
* @name fetchSessionByPda
|
|
211
|
+
* @description Fetch a deserialized `SessionLedger` account by its PDA directly,
|
|
212
|
+
* bypassing PDA derivation.
|
|
213
|
+
* @param sessionPda - The session ledger PDA.
|
|
214
|
+
* @returns {Promise<SessionLedgerData>} The session ledger data.
|
|
215
|
+
* @throws Will throw if the session does not exist.
|
|
216
|
+
* @since v0.1.0
|
|
217
|
+
*/
|
|
218
|
+
fetchSessionByPda(sessionPda: PublicKey): Promise<SessionLedgerData>;
|
|
219
|
+
/**
|
|
220
|
+
* @name fetchEpochPage
|
|
221
|
+
* @description Fetch a deserialized `EpochPage` account.
|
|
222
|
+
* @param sessionPda - The session ledger PDA.
|
|
223
|
+
* @param epochIndex - The zero-based epoch index.
|
|
224
|
+
* @returns {Promise<EpochPageData>} The epoch page data.
|
|
225
|
+
* @throws Will throw if the epoch page does not exist.
|
|
226
|
+
* @since v0.1.0
|
|
227
|
+
*/
|
|
228
|
+
fetchEpochPage(sessionPda: PublicKey, epochIndex: number): Promise<EpochPageData>;
|
|
229
|
+
/**
|
|
230
|
+
* @name fetchDelegate
|
|
231
|
+
* @description Fetch a deserialized `VaultDelegate` account.
|
|
232
|
+
* @param vaultPda - The memory vault PDA.
|
|
233
|
+
* @param delegatePubkey - The delegate wallet public key.
|
|
234
|
+
* @returns {Promise<VaultDelegateData>} The delegate account data.
|
|
235
|
+
* @throws Will throw if the delegate does not exist.
|
|
236
|
+
* @since v0.1.0
|
|
237
|
+
*/
|
|
238
|
+
fetchDelegate(vaultPda: PublicKey, delegatePubkey: PublicKey): Promise<VaultDelegateData>;
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=vault.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vault.d.ts","sourceRoot":"","sources":["../../../src/modules/vault.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAiB,KAAK,SAAS,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AASpC,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAIlB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,WAAY,SAAQ,UAAU;IAGzC;;;;;;;OAOG;IACH,WAAW,CAAC,QAAQ,EAAE,SAAS,GAAG,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAI9D;;;;;;;;OAQG;IACH,aAAa,CACX,QAAQ,EAAE,SAAS,EACnB,WAAW,EAAE,UAAU,GACtB,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAM/B;;;;;;;OAOG;IACG,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAiBpE;;;;;;;OAOG;IACG,WAAW,CACf,WAAW,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC,oBAAoB,CAAC;IAgBhC;;;;;;;OAOG;IACG,QAAQ,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAkBvE;;;;;;;;;;OAUG;IACG,oBAAoB,CACxB,UAAU,EAAE,SAAS,EACrB,YAAY,EAAE,SAAS,EACvB,QAAQ,EAAE,SAAS,EACnB,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,oBAAoB,CAAC;IAsBhC;;;;;;;;OAQG;IACG,eAAe,CACnB,UAAU,EAAE,SAAS,EACrB,QAAQ,EAAE,SAAS,EACnB,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,oBAAoB,CAAC;IAgBhC;;;;;;;OAOG;IACG,YAAY,CAChB,QAAQ,EAAE,SAAS,EACnB,UAAU,EAAE,SAAS,GACpB,OAAO,CAAC,oBAAoB,CAAC;IAWhC;;;;;OAKG;IACG,UAAU,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAcjD;;;;;;;;OAQG;IACG,eAAe,CACnB,QAAQ,EAAE,SAAS,EACnB,UAAU,EAAE,SAAS,GACpB,OAAO,CAAC,oBAAoB,CAAC;IAWhC;;;;;;;OAOG;IACG,cAAc,CAClB,UAAU,EAAE,SAAS,EACrB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,oBAAoB,CAAC;IAahC;;;;;;;OAOG;IACG,WAAW,CACf,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,oBAAoB,CAAC;IAehC;;;;;;;;;OASG;IACG,WAAW,CACf,cAAc,EAAE,SAAS,EACzB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAAG,MAAM,GACzB,OAAO,CAAC,oBAAoB,CAAC;IAwChC;;;;;;OAMG;IACG,cAAc,CAClB,cAAc,EAAE,SAAS,GACxB,OAAO,CAAC,oBAAoB,CAAC;IAehC;;;;;;;;;;;OAWG;IACG,iBAAiB,CACrB,cAAc,EAAE,SAAS,EACzB,QAAQ,EAAE,SAAS,EACnB,UAAU,EAAE,SAAS,EACrB,YAAY,EAAE,SAAS,EACvB,IAAI,EAAE,kBAAkB,GACvB,OAAO,CAAC,oBAAoB,CAAC;IA2BhC;;;;;;;OAOG;IACG,UAAU,CAAC,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,eAAe,CAAC;IAK/D;;;;;;;OAOG;IACG,kBAAkB,CAAC,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAK9E;;;;;;;;OAQG;IACG,YAAY,CAChB,QAAQ,EAAE,SAAS,EACnB,WAAW,EAAE,UAAU,GACtB,OAAO,CAAC,iBAAiB,CAAC;IAK7B;;;;;;;;OAQG;IACG,iBAAiB,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAI1E;;;;;;;;OAQG;IACG,cAAc,CAClB,UAAU,EAAE,SAAS,EACrB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,aAAa,CAAC;IAKzB;;;;;;;;OAQG;IACG,aAAa,CACjB,QAAQ,EAAE,SAAS,EACnB,cAAc,EAAE,SAAS,GACxB,OAAO,CAAC,iBAAiB,CAAC;CAI9B"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module parser/client
|
|
3
|
+
* @description Object-oriented wrapper for transaction parsing.
|
|
4
|
+
*
|
|
5
|
+
* Binds the Anchor `Program` reference so callers do not need to
|
|
6
|
+
* pass it on every call. Designed as a lazy singleton accessible
|
|
7
|
+
* from {@link SapClient.parser}.
|
|
8
|
+
*
|
|
9
|
+
* @category Parser
|
|
10
|
+
* @since v0.5.0
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const client = SapClient.from(provider);
|
|
15
|
+
*
|
|
16
|
+
* // Parse a full transaction
|
|
17
|
+
* const parsed = client.parser.parseTransaction(txResponse);
|
|
18
|
+
*
|
|
19
|
+
* // Quick instruction names
|
|
20
|
+
* const names = client.parser.instructionNames(txResponse);
|
|
21
|
+
*
|
|
22
|
+
* // From pre-built instructions
|
|
23
|
+
* const decoded = client.parser.fromInstructions(ixList);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
import type { Program } from "@coral-xyz/anchor";
|
|
27
|
+
import type { TransactionInstruction, TransactionResponse, VersionedTransactionResponse } from "@solana/web3.js";
|
|
28
|
+
import { AddressLookupTableAccount } from "@solana/web3.js";
|
|
29
|
+
import type { DecodedSapInstruction, ParsedSapTransaction, ParseFilterOptions } from "./types";
|
|
30
|
+
import { type InnerInstructionGroup } from "./inner";
|
|
31
|
+
/**
|
|
32
|
+
* Stateful transaction parser bound to a specific Anchor `Program`.
|
|
33
|
+
*
|
|
34
|
+
* Stores the program reference, instruction coder, and program ID
|
|
35
|
+
* internally so that repeated parse calls require only the
|
|
36
|
+
* transaction data as input.
|
|
37
|
+
*
|
|
38
|
+
* @name TransactionParser
|
|
39
|
+
* @category Parser
|
|
40
|
+
* @since v0.5.0
|
|
41
|
+
*/
|
|
42
|
+
export declare class TransactionParser {
|
|
43
|
+
private readonly program;
|
|
44
|
+
private readonly coder;
|
|
45
|
+
private readonly programId;
|
|
46
|
+
/**
|
|
47
|
+
* Create a new TransactionParser.
|
|
48
|
+
*
|
|
49
|
+
* @param program - An Anchor `Program` built from the SAP IDL.
|
|
50
|
+
*/
|
|
51
|
+
constructor(program: Program<any>);
|
|
52
|
+
/**
|
|
53
|
+
* Full parse: instructions + inner calls + events.
|
|
54
|
+
*
|
|
55
|
+
* @param tx - Raw transaction response from `connection.getTransaction`.
|
|
56
|
+
* @param options - Optional filters for instructions, events, and inner calls.
|
|
57
|
+
* @param addressLookupTables - Resolved lookup tables for v0 transactions.
|
|
58
|
+
* @returns Complete parsed transaction, or `null` if the input is nullish.
|
|
59
|
+
*
|
|
60
|
+
* @since v0.5.0
|
|
61
|
+
*/
|
|
62
|
+
parseTransaction(tx: TransactionResponse | VersionedTransactionResponse | null | undefined, options?: ParseFilterOptions, addressLookupTables?: AddressLookupTableAccount[]): ParsedSapTransaction | null;
|
|
63
|
+
/**
|
|
64
|
+
* Parse a batch of transactions.
|
|
65
|
+
*
|
|
66
|
+
* @param txs - Array of transaction responses (may contain `null` entries).
|
|
67
|
+
* @param options - Optional parse filters.
|
|
68
|
+
* @param addressLookupTables - Resolved lookup tables for v0 transactions.
|
|
69
|
+
* @returns Non-null parsed transactions.
|
|
70
|
+
*
|
|
71
|
+
* @since v0.5.0
|
|
72
|
+
*/
|
|
73
|
+
parseBatch(txs: (TransactionResponse | VersionedTransactionResponse | null | undefined)[], options?: ParseFilterOptions, addressLookupTables?: AddressLookupTableAccount[]): ParsedSapTransaction[];
|
|
74
|
+
/**
|
|
75
|
+
* Decode top-level SAP instructions from a transaction response.
|
|
76
|
+
*
|
|
77
|
+
* @param tx - Raw transaction response.
|
|
78
|
+
* @param addressLookupTables - Resolved lookup tables for v0 transactions.
|
|
79
|
+
* @returns Decoded SAP instructions.
|
|
80
|
+
*
|
|
81
|
+
* @since v0.5.0
|
|
82
|
+
*/
|
|
83
|
+
instructionsFromTransaction(tx: TransactionResponse | VersionedTransactionResponse, addressLookupTables?: AddressLookupTableAccount[]): DecodedSapInstruction[];
|
|
84
|
+
/**
|
|
85
|
+
* Extract only the instruction names from a transaction response.
|
|
86
|
+
*
|
|
87
|
+
* @param tx - Raw transaction response.
|
|
88
|
+
* @param addressLookupTables - Resolved lookup tables for v0 transactions.
|
|
89
|
+
* @returns Instruction name strings.
|
|
90
|
+
*
|
|
91
|
+
* @since v0.5.0
|
|
92
|
+
*/
|
|
93
|
+
instructionNames(tx: TransactionResponse | VersionedTransactionResponse, addressLookupTables?: AddressLookupTableAccount[]): string[];
|
|
94
|
+
/**
|
|
95
|
+
* Decode SAP instructions from a pre-built instruction array.
|
|
96
|
+
*
|
|
97
|
+
* @param instructions - The instruction list to decode.
|
|
98
|
+
* @returns Decoded SAP instructions.
|
|
99
|
+
*
|
|
100
|
+
* @since v0.5.0
|
|
101
|
+
*/
|
|
102
|
+
fromInstructions(instructions: TransactionInstruction[]): DecodedSapInstruction[];
|
|
103
|
+
/**
|
|
104
|
+
* Check if any instruction in the list targets the SAP program.
|
|
105
|
+
*
|
|
106
|
+
* @param instructions - The instruction array to inspect.
|
|
107
|
+
* @returns `true` if at least one instruction targets SAP.
|
|
108
|
+
*
|
|
109
|
+
* @since v0.5.0
|
|
110
|
+
*/
|
|
111
|
+
isSapTransaction(instructions: TransactionInstruction[]): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Decode inner (CPI) instructions from transaction metadata.
|
|
114
|
+
*
|
|
115
|
+
* @param innerGroups - The `tx.meta.innerInstructions` array.
|
|
116
|
+
* @param tx - The transaction response (for account key resolution).
|
|
117
|
+
* @returns Decoded inner instructions.
|
|
118
|
+
*
|
|
119
|
+
* @since v0.5.0
|
|
120
|
+
*/
|
|
121
|
+
decodeInner(innerGroups: InnerInstructionGroup[], tx: TransactionResponse | VersionedTransactionResponse): import("./types").DecodedInnerInstruction[];
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/parser/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAEV,sBAAsB,EACtB,mBAAmB,EACnB,4BAA4B,EAC7B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAEnB,MAAM,SAAS,CAAC;AAIjB,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;GAUG;AACH,qBAAa,iBAAiB;IAUhB,OAAO,CAAC,QAAQ,CAAC,OAAO;IATpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsB;IAC5C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IAEtC;;;;OAIG;gBAE0B,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC;IAKlD;;;;;;;;;OASG;IACH,gBAAgB,CACd,EAAE,EAAE,mBAAmB,GAAG,4BAA4B,GAAG,IAAI,GAAG,SAAS,EACzE,OAAO,CAAC,EAAE,kBAAkB,EAC5B,mBAAmB,CAAC,EAAE,yBAAyB,EAAE,GAChD,oBAAoB,GAAG,IAAI;IAU9B;;;;;;;;;OASG;IACH,UAAU,CACR,GAAG,EAAE,CAAC,mBAAmB,GAAG,4BAA4B,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,EAC9E,OAAO,CAAC,EAAE,kBAAkB,EAC5B,mBAAmB,CAAC,EAAE,yBAAyB,EAAE,GAChD,oBAAoB,EAAE;IAUzB;;;;;;;;OAQG;IACH,2BAA2B,CACzB,EAAE,EAAE,mBAAmB,GAAG,4BAA4B,EACtD,mBAAmB,CAAC,EAAE,yBAAyB,EAAE,GAChD,qBAAqB,EAAE;IAS1B;;;;;;;;OAQG;IACH,gBAAgB,CACd,EAAE,EAAE,mBAAmB,GAAG,4BAA4B,EACtD,mBAAmB,CAAC,EAAE,yBAAyB,EAAE,GAChD,MAAM,EAAE;IAMX;;;;;;;OAOG;IACH,gBAAgB,CACd,YAAY,EAAE,sBAAsB,EAAE,GACrC,qBAAqB,EAAE;IAI1B;;;;;;;OAOG;IACH,gBAAgB,CAAC,YAAY,EAAE,sBAAsB,EAAE,GAAG,OAAO;IAIjE;;;;;;;;OAQG;IACH,WAAW,CACT,WAAW,EAAE,qBAAqB,EAAE,EACpC,EAAE,EAAE,mBAAmB,GAAG,4BAA4B;CAUzD"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module parser/complete
|
|
3
|
+
* @description Full SAP transaction parser: instructions + args + accounts + events.
|
|
4
|
+
*
|
|
5
|
+
* This is "Case 2 Complete": given a raw transaction response, produce a
|
|
6
|
+
* single {@link ParsedSapTransaction} containing every decoded instruction,
|
|
7
|
+
* all inner (CPI) calls, and all SAP events extracted from the logs.
|
|
8
|
+
*
|
|
9
|
+
* Designed for indexer pipelines where the decode step must be pure,
|
|
10
|
+
* deterministic, and fully testable without an RPC connection.
|
|
11
|
+
*
|
|
12
|
+
* @category Parser
|
|
13
|
+
* @since v0.5.0
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { parseSapTransactionComplete } from "@synapse-sap/sdk/parser";
|
|
18
|
+
* import { SAP_PROGRAM_ID, SAP_IDL } from "@synapse-sap/sdk";
|
|
19
|
+
* import { Program } from "\@coral-xyz/anchor";
|
|
20
|
+
*
|
|
21
|
+
* const program = new Program(SAP_IDL, provider);
|
|
22
|
+
* const tx = await connection.getTransaction(sig, {
|
|
23
|
+
* commitment: "confirmed",
|
|
24
|
+
* maxSupportedTransactionVersion: 0,
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* const parsed = parseSapTransactionComplete(tx, program, SAP_PROGRAM_ID);
|
|
28
|
+
* console.log(parsed.instructions.map(i => i.name));
|
|
29
|
+
* console.log(parsed.events.map(e => e.name));
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
import { AddressLookupTableAccount, type PublicKey, type TransactionResponse, type VersionedTransactionResponse } from "@solana/web3.js";
|
|
33
|
+
import type { Program } from "@coral-xyz/anchor";
|
|
34
|
+
import type { ParsedSapTransaction, ParseFilterOptions } from "./types";
|
|
35
|
+
/**
|
|
36
|
+
* Parse a complete SAP transaction into a unified result.
|
|
37
|
+
*
|
|
38
|
+
* Combines three stages:
|
|
39
|
+
* 1. **Instruction decode** - top-level SAP instructions with args and accounts
|
|
40
|
+
* 2. **Inner instruction decode** - CPI calls with full account reconstruction
|
|
41
|
+
* 3. **Event extraction** - SAP events decoded from the transaction logs
|
|
42
|
+
*
|
|
43
|
+
* All three stages are safe: malformed data produces `null` fields
|
|
44
|
+
* rather than exceptions. This makes the function suitable for
|
|
45
|
+
* batch-processing in indexer workers where a single bad transaction
|
|
46
|
+
* must not halt the pipeline.
|
|
47
|
+
*
|
|
48
|
+
* @param tx - The raw transaction response from `connection.getTransaction`.
|
|
49
|
+
* @param program - An Anchor `Program` instance built from the SAP IDL.
|
|
50
|
+
* The coder and program ID are extracted automatically.
|
|
51
|
+
* @param sapProgramId - The SAP program public key. Passed explicitly so
|
|
52
|
+
* callers can target devnet/localnet deployments independently.
|
|
53
|
+
* @param options - Optional filters for instructions, events, and inner calls.
|
|
54
|
+
* @param addressLookupTables - Resolved lookup table accounts for v0 transactions.
|
|
55
|
+
* @returns A fully parsed transaction, or `null` if the input is `null`/`undefined`.
|
|
56
|
+
*
|
|
57
|
+
* @category Parser
|
|
58
|
+
* @since v0.5.0
|
|
59
|
+
*/
|
|
60
|
+
export declare function parseSapTransactionComplete(tx: TransactionResponse | VersionedTransactionResponse | null | undefined, program: Program<any>, sapProgramId: PublicKey, options?: ParseFilterOptions, addressLookupTables?: AddressLookupTableAccount[]): ParsedSapTransaction | null;
|
|
61
|
+
/**
|
|
62
|
+
* Parse multiple transactions in batch.
|
|
63
|
+
*
|
|
64
|
+
* Convenience wrapper for indexer pipelines that process pages of
|
|
65
|
+
* transactions. Skips `null` entries and failed decodes silently.
|
|
66
|
+
*
|
|
67
|
+
* @param txs - Array of transaction responses (may contain `null` entries).
|
|
68
|
+
* @param program - The Anchor SAP program instance.
|
|
69
|
+
* @param sapProgramId - The SAP program public key.
|
|
70
|
+
* @param options - Optional parse filters applied to every transaction.
|
|
71
|
+
* @param addressLookupTables - Lookup tables for v0 transactions.
|
|
72
|
+
* @returns An array of non-null parsed transactions.
|
|
73
|
+
*
|
|
74
|
+
* @category Parser
|
|
75
|
+
* @since v0.5.0
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* const signatures = await connection.getSignaturesForAddress(agentPda);
|
|
80
|
+
* const txs = await Promise.all(
|
|
81
|
+
* signatures.map(s => connection.getTransaction(s.signature, { ... }))
|
|
82
|
+
* );
|
|
83
|
+
* const parsed = parseSapTransactionBatch(txs, program, SAP_PROGRAM_ID, {
|
|
84
|
+
* includeEvents: true,
|
|
85
|
+
* includeInner: true,
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare function parseSapTransactionBatch(txs: (TransactionResponse | VersionedTransactionResponse | null | undefined)[], program: Program<any>, sapProgramId: PublicKey, options?: ParseFilterOptions, addressLookupTables?: AddressLookupTableAccount[]): ParsedSapTransaction[];
|
|
90
|
+
//# sourceMappingURL=complete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complete.d.ts","sourceRoot":"","sources":["../../../src/parser/complete.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EACL,yBAAyB,EACzB,KAAK,SAAS,EACd,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EAClC,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAGnB,MAAM,SAAS,CAAC;AAcjB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,2BAA2B,CACzC,EAAE,EAAE,mBAAmB,GAAG,4BAA4B,GAAG,IAAI,GAAG,SAAS,EAEzE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,EACrB,YAAY,EAAE,SAAS,EACvB,OAAO,CAAC,EAAE,kBAAkB,EAC5B,mBAAmB,CAAC,EAAE,yBAAyB,EAAE,GAChD,oBAAoB,GAAG,IAAI,CAoE7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,CAAC,mBAAmB,GAAG,4BAA4B,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,EAE9E,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,EACrB,YAAY,EAAE,SAAS,EACvB,OAAO,CAAC,EAAE,kBAAkB,EAC5B,mBAAmB,CAAC,EAAE,yBAAyB,EAAE,GAChD,oBAAoB,EAAE,CAaxB"}
|