@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,260 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SapErrorCode = exports.SapValidationError = exports.SapError = void 0;
|
|
4
|
+
exports.decodeSapError = decodeSapError;
|
|
5
|
+
exports.isRetryableError = isRetryableError;
|
|
6
|
+
exports.isClientValidationFailure = isClientValidationFailure;
|
|
7
|
+
/** Generic SDK error */
|
|
8
|
+
class SapError extends Error {
|
|
9
|
+
constructor(message) { super(message); this.name = "SapError"; }
|
|
10
|
+
}
|
|
11
|
+
exports.SapError = SapError;
|
|
12
|
+
/** Validation-specific SDK error */
|
|
13
|
+
class SapValidationError extends Error {
|
|
14
|
+
constructor(message) { super(message); this.name = "SapValidationError"; }
|
|
15
|
+
}
|
|
16
|
+
exports.SapValidationError = SapValidationError;
|
|
17
|
+
// ================================================================
|
|
18
|
+
// synapse-sap-sdk / src/errors.ts
|
|
19
|
+
// On-chain error codes ↔ human-readable messages + recovery actions
|
|
20
|
+
// ================================================================
|
|
21
|
+
/** All v0.13 SapError variants with recovery hints */
|
|
22
|
+
var SapErrorCode;
|
|
23
|
+
(function (SapErrorCode) {
|
|
24
|
+
// ── Agent ──
|
|
25
|
+
SapErrorCode[SapErrorCode["NameTooLong"] = 6000] = "NameTooLong";
|
|
26
|
+
SapErrorCode[SapErrorCode["NameTooShort"] = 6001] = "NameTooShort";
|
|
27
|
+
SapErrorCode[SapErrorCode["InvalidEndpoint"] = 6002] = "InvalidEndpoint";
|
|
28
|
+
SapErrorCode[SapErrorCode["EndpointTooLong"] = 6003] = "EndpointTooLong";
|
|
29
|
+
SapErrorCode[SapErrorCode["InvalidDIDHash"] = 6004] = "InvalidDIDHash";
|
|
30
|
+
SapErrorCode[SapErrorCode["AgentNotInitialized"] = 6005] = "AgentNotInitialized";
|
|
31
|
+
SapErrorCode[SapErrorCode["AgentAlreadyInitialized"] = 6006] = "AgentAlreadyInitialized";
|
|
32
|
+
SapErrorCode[SapErrorCode["AgentClosed"] = 6007] = "AgentClosed";
|
|
33
|
+
// ── Tool / Registry ──
|
|
34
|
+
SapErrorCode[SapErrorCode["NameEmpty"] = 6010] = "NameEmpty";
|
|
35
|
+
SapErrorCode[SapErrorCode["NameWhitespace"] = 6011] = "NameWhitespace";
|
|
36
|
+
SapErrorCode[SapErrorCode["DescriptionTooLong"] = 6012] = "DescriptionTooLong";
|
|
37
|
+
SapErrorCode[SapErrorCode["CategoryOutOfRange"] = 6013] = "CategoryOutOfRange";
|
|
38
|
+
SapErrorCode[SapErrorCode["ToolNameExists"] = 6014] = "ToolNameExists";
|
|
39
|
+
SapErrorCode[SapErrorCode["ToolNotFound"] = 6015] = "ToolNotFound";
|
|
40
|
+
SapErrorCode[SapErrorCode["CallerNotAgentOwner"] = 6016] = "CallerNotAgentOwner";
|
|
41
|
+
SapErrorCode[SapErrorCode["CallerNotToolOwner"] = 6017] = "CallerNotToolOwner";
|
|
42
|
+
SapErrorCode[SapErrorCode["ToolCategoryMismatch"] = 6018] = "ToolCategoryMismatch";
|
|
43
|
+
// ── Stake ──
|
|
44
|
+
SapErrorCode[SapErrorCode["StakeBelowMinimum"] = 6020] = "StakeBelowMinimum";
|
|
45
|
+
SapErrorCode[SapErrorCode["NotStaked"] = 6021] = "NotStaked";
|
|
46
|
+
SapErrorCode[SapErrorCode["UnstakeTooSoon"] = 6022] = "UnstakeTooSoon";
|
|
47
|
+
SapErrorCode[SapErrorCode["UnstakeExceedsStake"] = 6023] = "UnstakeExceedsStake";
|
|
48
|
+
SapErrorCode[SapErrorCode["AlreadyStaked"] = 6024] = "AlreadyStaked";
|
|
49
|
+
SapErrorCode[SapErrorCode["UnstakeWindowNotOpen"] = 6025] = "UnstakeWindowNotOpen";
|
|
50
|
+
SapErrorCode[SapErrorCode["UnstakeAlreadyPending"] = 6026] = "UnstakeAlreadyPending";
|
|
51
|
+
SapErrorCode[SapErrorCode["CannotCloseAgentWithActiveEscrows"] = 6027] = "CannotCloseAgentWithActiveEscrows";
|
|
52
|
+
SapErrorCode[SapErrorCode["StakeNotFound"] = 6028] = "StakeNotFound";
|
|
53
|
+
SapErrorCode[SapErrorCode["AgentStatsNotFound"] = 6029] = "AgentStatsNotFound";
|
|
54
|
+
SapErrorCode[SapErrorCode["InsufficientStake"] = 6030] = "InsufficientStake";
|
|
55
|
+
// ── Escrow ──
|
|
56
|
+
SapErrorCode[SapErrorCode["InsufficientEscrowBalance"] = 6032] = "InsufficientEscrowBalance";
|
|
57
|
+
SapErrorCode[SapErrorCode["EscrowNotFound"] = 6033] = "EscrowNotFound";
|
|
58
|
+
SapErrorCode[SapErrorCode["EscrowNotForAgent"] = 6034] = "EscrowNotForAgent";
|
|
59
|
+
SapErrorCode[SapErrorCode["EscrowNotForDepositor"] = 6035] = "EscrowNotForDepositor";
|
|
60
|
+
SapErrorCode[SapErrorCode["AmountMustBePositive"] = 6036] = "AmountMustBePositive";
|
|
61
|
+
SapErrorCode[SapErrorCode["PricePerCallMustBePositive"] = 6037] = "PricePerCallMustBePositive";
|
|
62
|
+
SapErrorCode[SapErrorCode["InvalidEscrowNonce"] = 6038] = "InvalidEscrowNonce";
|
|
63
|
+
SapErrorCode[SapErrorCode["InvalidVolumeCurve"] = 6039] = "InvalidVolumeCurve";
|
|
64
|
+
SapErrorCode[SapErrorCode["VolumeCurveNotDescending"] = 6040] = "VolumeCurveNotDescending";
|
|
65
|
+
SapErrorCode[SapErrorCode["TooManyVolumeCurvePoints"] = 6041] = "TooManyVolumeCurvePoints";
|
|
66
|
+
SapErrorCode[SapErrorCode["SettlementNotPending"] = 6042] = "SettlementNotPending";
|
|
67
|
+
SapErrorCode[SapErrorCode["SettlementAlreadyFinalized"] = 6043] = "SettlementAlreadyFinalized";
|
|
68
|
+
SapErrorCode[SapErrorCode["DisputeWindowNotExpired"] = 6044] = "DisputeWindowNotExpired";
|
|
69
|
+
SapErrorCode[SapErrorCode["DisputeWindowExpired"] = 6045] = "DisputeWindowExpired";
|
|
70
|
+
SapErrorCode[SapErrorCode["NotDepositor"] = 6046] = "NotDepositor";
|
|
71
|
+
SapErrorCode[SapErrorCode["DisputeAlreadyFiled"] = 6047] = "DisputeAlreadyFiled";
|
|
72
|
+
SapErrorCode[SapErrorCode["DisputeStillOpen"] = 6048] = "DisputeStillOpen";
|
|
73
|
+
SapErrorCode[SapErrorCode["NotArbiter"] = 6049] = "NotArbiter";
|
|
74
|
+
SapErrorCode[SapErrorCode["InvalidArbiter"] = 6050] = "InvalidArbiter";
|
|
75
|
+
SapErrorCode[SapErrorCode["ArbiterRequired"] = 6051] = "ArbiterRequired";
|
|
76
|
+
SapErrorCode[SapErrorCode["CoSignerRequired"] = 6052] = "CoSignerRequired";
|
|
77
|
+
SapErrorCode[SapErrorCode["InvalidCoSigner"] = 6053] = "InvalidCoSigner";
|
|
78
|
+
SapErrorCode[SapErrorCode["InvalidDisputeOutcome"] = 6054] = "InvalidDisputeOutcome";
|
|
79
|
+
SapErrorCode[SapErrorCode["EscrowEmpty"] = 6055] = "EscrowEmpty";
|
|
80
|
+
SapErrorCode[SapErrorCode["EscrowAlreadyExpired"] = 6056] = "EscrowAlreadyExpired";
|
|
81
|
+
SapErrorCode[SapErrorCode["EscrowExpired"] = 6057] = "EscrowExpired";
|
|
82
|
+
SapErrorCode[SapErrorCode["EscrowNonceReused"] = 6058] = "EscrowNonceReused";
|
|
83
|
+
// ── Receipt ──
|
|
84
|
+
SapErrorCode[SapErrorCode["ReceiptBatchNotFound"] = 6060] = "ReceiptBatchNotFound";
|
|
85
|
+
SapErrorCode[SapErrorCode["ReceiptTreeEmpty"] = 6061] = "ReceiptTreeEmpty";
|
|
86
|
+
SapErrorCode[SapErrorCode["ReceiptNotFound"] = 6062] = "ReceiptNotFound";
|
|
87
|
+
SapErrorCode[SapErrorCode["ReceiptAlreadyDisputed"] = 6063] = "ReceiptAlreadyDisputed";
|
|
88
|
+
SapErrorCode[SapErrorCode["ReceiptNotInWindow"] = 6064] = "ReceiptNotInWindow";
|
|
89
|
+
SapErrorCode[SapErrorCode["InvalidReceiptProof"] = 6065] = "InvalidReceiptProof";
|
|
90
|
+
SapErrorCode[SapErrorCode["InvalidMerkleProof"] = 6066] = "InvalidMerkleProof";
|
|
91
|
+
SapErrorCode[SapErrorCode["NotAgentOwner"] = 6067] = "NotAgentOwner";
|
|
92
|
+
// ── Subscription ──
|
|
93
|
+
SapErrorCode[SapErrorCode["SubscriptionNotFound"] = 6070] = "SubscriptionNotFound";
|
|
94
|
+
SapErrorCode[SapErrorCode["NotSubscriber"] = 6071] = "NotSubscriber";
|
|
95
|
+
SapErrorCode[SapErrorCode["SubscriptionInsufficientBalance"] = 6072] = "SubscriptionInsufficientBalance";
|
|
96
|
+
SapErrorCode[SapErrorCode["SubscriptionIntervalOverflow"] = 6073] = "SubscriptionIntervalOverflow";
|
|
97
|
+
SapErrorCode[SapErrorCode["SubscriptionDurationTooLong"] = 6074] = "SubscriptionDurationTooLong";
|
|
98
|
+
// ── Dispute / Security (v0.13) ──
|
|
99
|
+
SapErrorCode[SapErrorCode["PendingAmountMismatch"] = 6080] = "PendingAmountMismatch";
|
|
100
|
+
SapErrorCode[SapErrorCode["MaxCallsPerSettlementExceeded"] = 6081] = "MaxCallsPerSettlementExceeded";
|
|
101
|
+
SapErrorCode[SapErrorCode["InvalidVolumeCurvePrice"] = 6082] = "InvalidVolumeCurvePrice";
|
|
102
|
+
SapErrorCode[SapErrorCode["EscrowCoverageExceeded"] = 6083] = "EscrowCoverageExceeded";
|
|
103
|
+
SapErrorCode[SapErrorCode["CoSignerIsAgentWallet"] = 6084] = "CoSignerIsAgentWallet";
|
|
104
|
+
SapErrorCode[SapErrorCode["PendingSettlementExists"] = 6085] = "PendingSettlementExists";
|
|
105
|
+
SapErrorCode[SapErrorCode["TokenAccountOwnerMismatch"] = 6086] = "TokenAccountOwnerMismatch";
|
|
106
|
+
SapErrorCode[SapErrorCode["MaxReceiptProofExceeded"] = 6087] = "MaxReceiptProofExceeded";
|
|
107
|
+
SapErrorCode[SapErrorCode["MaxMerkleDepthExceeded"] = 6088] = "MaxMerkleDepthExceeded";
|
|
108
|
+
SapErrorCode[SapErrorCode["StakeSlashLocksUnstake"] = 6089] = "StakeSlashLocksUnstake";
|
|
109
|
+
// ── Math ──
|
|
110
|
+
SapErrorCode[SapErrorCode["ArithmeticOverflow"] = 6300] = "ArithmeticOverflow";
|
|
111
|
+
// ── Vault ──
|
|
112
|
+
SapErrorCode[SapErrorCode["VaultNotFound"] = 6350] = "VaultNotFound";
|
|
113
|
+
SapErrorCode[SapErrorCode["VaultAlreadyInitialized"] = 6351] = "VaultAlreadyInitialized";
|
|
114
|
+
SapErrorCode[SapErrorCode["VaultNotInitialized"] = 6352] = "VaultNotInitialized";
|
|
115
|
+
SapErrorCode[SapErrorCode["NotVaultOwner"] = 6353] = "NotVaultOwner";
|
|
116
|
+
SapErrorCode[SapErrorCode["NotDelegate"] = 6354] = "NotDelegate";
|
|
117
|
+
SapErrorCode[SapErrorCode["DelegateExpired"] = 6355] = "DelegateExpired";
|
|
118
|
+
SapErrorCode[SapErrorCode["InvalidPermissions"] = 6356] = "InvalidPermissions";
|
|
119
|
+
SapErrorCode[SapErrorCode["SessionNotFound"] = 6357] = "SessionNotFound";
|
|
120
|
+
SapErrorCode[SapErrorCode["EpochNotFound"] = 6358] = "EpochNotFound";
|
|
121
|
+
SapErrorCode[SapErrorCode["VaultAlreadyOpen"] = 6359] = "VaultAlreadyOpen";
|
|
122
|
+
SapErrorCode[SapErrorCode["InvalidSequence"] = 6360] = "InvalidSequence";
|
|
123
|
+
SapErrorCode[SapErrorCode["FragmentTooLarge"] = 6361] = "FragmentTooLarge";
|
|
124
|
+
SapErrorCode[SapErrorCode["VaultClosed"] = 6362] = "VaultClosed";
|
|
125
|
+
SapErrorCode[SapErrorCode["InsufficientVaultBalance"] = 6363] = "InsufficientVaultBalance";
|
|
126
|
+
})(SapErrorCode || (exports.SapErrorCode = SapErrorCode = {}));
|
|
127
|
+
const ERROR_MAP = {
|
|
128
|
+
[SapErrorCode.NameTooLong]: { code: SapErrorCode.NameTooLong, name: "NameTooLong", message: "Agent name exceeds 64 characters.", recovery: "Shorten the agent name to ≤64 chars." },
|
|
129
|
+
[SapErrorCode.NameTooShort]: { code: SapErrorCode.NameTooShort, name: "NameTooShort", message: "Agent name is too short.", recovery: "Use at least 3 characters for the agent name." },
|
|
130
|
+
[SapErrorCode.InvalidEndpoint]: { code: SapErrorCode.InvalidEndpoint, name: "InvalidEndpoint", message: "Endpoint URI must start with http:// or https://.", recovery: "Provide a valid HTTP or HTTPS URL." },
|
|
131
|
+
[SapErrorCode.EndpointTooLong]: { code: SapErrorCode.EndpointTooLong, name: "EndpointTooLong", message: "Endpoint URI exceeds 256 characters.", recovery: "Shorten the endpoint URL." },
|
|
132
|
+
[SapErrorCode.AgentClosed]: { code: SapErrorCode.AgentClosed, name: "AgentClosed", message: "Agent has been closed.", recovery: "Re-register the agent or use a different wallet." },
|
|
133
|
+
[SapErrorCode.CallerNotAgentOwner]: { code: SapErrorCode.CallerNotAgentOwner, name: "CallerNotAgentOwner", message: "Signer is not the agent owner.", recovery: "Sign with the wallet that owns the agent." },
|
|
134
|
+
[SapErrorCode.StakeBelowMinimum]: { code: SapErrorCode.StakeBelowMinimum, name: "StakeBelowMinimum", message: `Stake is below minimum (${1} SOL).`, recovery: "Increase the stake amount to at least 1 SOL." },
|
|
135
|
+
[SapErrorCode.NotStaked]: { code: SapErrorCode.NotStaked, name: "NotStaked", message: "Wallet has no stake account.", recovery: "Call stake() first to create a stake account." },
|
|
136
|
+
[SapErrorCode.UnstakeTooSoon]: { code: SapErrorCode.UnstakeTooSoon, name: "UnstakeTooSoon", message: "Cannot unstake yet — wait for the cooldown period.", recovery: "Wait 14 days after requesting unstake before completing." },
|
|
137
|
+
[SapErrorCode.UnstakeExceedsStake]: { code: SapErrorCode.UnstakeExceedsStake, name: "UnstakeExceedsStake", message: "Unstake amount exceeds staked amount.", recovery: "Reduce unstake amount to ≤ staked amount." },
|
|
138
|
+
[SapErrorCode.CannotCloseAgentWithActiveEscrows]: { code: SapErrorCode.CannotCloseAgentWithActiveEscrows, name: "CannotCloseAgentWithActiveEscrows", message: "Agent has active escrows.", recovery: "Close all escrows or wait for expiry before closing agent." },
|
|
139
|
+
[SapErrorCode.InsufficientEscrowBalance]: { code: SapErrorCode.InsufficientEscrowBalance, name: "InsufficientEscrowBalance", message: "Escrow has insufficient balance for the operation.", recovery: "Deposit more funds or reduce the settlement/withdraw amount." },
|
|
140
|
+
[SapErrorCode.EscrowNotFound]: { code: SapErrorCode.EscrowNotFound, name: "EscrowNotFound", message: "Escrow account does not exist.", recovery: "Verify the PDA seeds or create the escrow first." },
|
|
141
|
+
[SapErrorCode.AmountMustBePositive]: { code: SapErrorCode.AmountMustBePositive, name: "AmountMustBePositive", message: "Amount must be > 0.", recovery: "Provide a positive amount." },
|
|
142
|
+
[SapErrorCode.PricePerCallMustBePositive]: { code: SapErrorCode.PricePerCallMustBePositive, name: "PricePerCallMustBePositive", message: "price_per_call must be > 0.", recovery: "Set price_per_call to a positive value." },
|
|
143
|
+
[SapErrorCode.InvalidVolumeCurve]: { code: SapErrorCode.InvalidVolumeCurve, name: "InvalidVolumeCurve", message: "Volume curve breakpoints are not strictly increasing.", recovery: "Ensure each breakpoint's after_calls > the previous." },
|
|
144
|
+
[SapErrorCode.VolumeCurveNotDescending]: { code: SapErrorCode.VolumeCurveNotDescending, name: "VolumeCurveNotDescending", message: "Volume curve prices are not non-increasing.", recovery: "Ensure each breakpoint's price ≤ previous." },
|
|
145
|
+
[SapErrorCode.TooManyVolumeCurvePoints]: { code: SapErrorCode.TooManyVolumeCurvePoints, name: "TooManyVolumeCurvePoints", message: "Volume curve exceeds max 10 points.", recovery: "Reduce volume curve to ≤10 breakpoints." },
|
|
146
|
+
[SapErrorCode.SettlementNotPending]: { code: SapErrorCode.SettlementNotPending, name: "SettlementNotPending", message: "Settlement is not in pending state.", recovery: "Verify the settlement index or file a dispute." },
|
|
147
|
+
[SapErrorCode.SettlementAlreadyFinalized]: { code: SapErrorCode.SettlementAlreadyFinalized, name: "SettlementAlreadyFinalized", message: "Settlement already finalized.", recovery: "Nothing to do — settlement is complete." },
|
|
148
|
+
[SapErrorCode.DisputeWindowNotExpired]: { code: SapErrorCode.DisputeWindowNotExpired, name: "DisputeWindowNotExpired", message: "Dispute window has not expired yet.", recovery: "Wait for the dispute window to close." },
|
|
149
|
+
[SapErrorCode.DisputeWindowExpired]: { code: SapErrorCode.DisputeWindowExpired, name: "DisputeWindowExpired", message: "Dispute window has expired.", recovery: "The deadline for filing a dispute has passed." },
|
|
150
|
+
[SapErrorCode.NotDepositor]: { code: SapErrorCode.NotDepositor, name: "NotDepositor", message: "Signer is not the depositor.", recovery: "Sign with the wallet that deposited into the escrow." },
|
|
151
|
+
[SapErrorCode.DisputeAlreadyFiled]: { code: SapErrorCode.DisputeAlreadyFiled, name: "DisputeAlreadyFiled", message: "A dispute has already been filed for this settlement.", recovery: "Wait for the dispute to resolve or file on a different settlement." },
|
|
152
|
+
[SapErrorCode.DisputeStillOpen]: { code: SapErrorCode.DisputeStillOpen, name: "DisputeStillOpen", message: "Dispute is still open.", recovery: "Wait for the dispute to reach a final outcome." },
|
|
153
|
+
[SapErrorCode.NotArbiter]: { code: SapErrorCode.NotArbiter, name: "NotArbiter", message: "Signer is not the designated arbiter.", recovery: "Sign with the arbiter wallet or wait for auto-resolution." },
|
|
154
|
+
[SapErrorCode.ArbiterRequired]: { code: SapErrorCode.ArbiterRequired, name: "ArbiterRequired", message: "Arbiter must be set for DisputeWindow mode.", recovery: "Provide a valid arbiter public key when creating the escrow." },
|
|
155
|
+
[SapErrorCode.CoSignerRequired]: { code: SapErrorCode.CoSignerRequired, name: "CoSignerRequired", message: "CoSigner must be set for CoSigned mode.", recovery: "Provide a valid co-signer public key when creating the escrow." },
|
|
156
|
+
[SapErrorCode.InvalidCoSigner]: { code: SapErrorCode.InvalidCoSigner, name: "InvalidCoSigner", message: "Invalid co-signer public key.", recovery: "Provide a valid public key for the co-signer." },
|
|
157
|
+
[SapErrorCode.InvalidDisputeOutcome]: { code: SapErrorCode.InvalidDisputeOutcome, name: "InvalidDisputeOutcome", message: "Invalid dispute outcome.", recovery: "Outcome must be DepositorWins (1), AgentWins (2), or Refunded (3)." },
|
|
158
|
+
[SapErrorCode.EscrowEmpty]: { code: SapErrorCode.EscrowEmpty, name: "EscrowEmpty", message: "Escrow balance is zero.", recovery: "Deposit funds before withdrawing or settling." },
|
|
159
|
+
[SapErrorCode.EscrowAlreadyExpired]: { code: SapErrorCode.EscrowAlreadyExpired, name: "EscrowAlreadyExpired", message: "Escrow has already expired at the time of creation.", recovery: "Set expires_at to a future timestamp or 0 (never)." },
|
|
160
|
+
[SapErrorCode.EscrowExpired]: { code: SapErrorCode.EscrowExpired, name: "EscrowExpired", message: "Escrow has expired.", recovery: "Create a new escrow or withdraw remaining balance." },
|
|
161
|
+
[SapErrorCode.ReceiptBatchNotFound]: { code: SapErrorCode.ReceiptBatchNotFound, name: "ReceiptBatchNotFound", message: "Receipt batch not found.", recovery: "Create a receipt batch first." },
|
|
162
|
+
[SapErrorCode.InvalidReceiptProof]: { code: SapErrorCode.InvalidReceiptProof, name: "InvalidReceiptProof", message: "Receipt proof does not verify.", recovery: "Verify the receipt hash and merkle proof are correct." },
|
|
163
|
+
[SapErrorCode.InvalidMerkleProof]: { code: SapErrorCode.InvalidMerkleProof, name: "InvalidMerkleProof", message: "Merkle proof structure is invalid.", recovery: "Check merkle proof depth (≤16) and sibling hashes." },
|
|
164
|
+
[SapErrorCode.SubscriptionNotFound]: { code: SapErrorCode.SubscriptionNotFound, name: "SubscriptionNotFound", message: "Subscription account does not exist.", recovery: "Create a subscription first." },
|
|
165
|
+
[SapErrorCode.NotSubscriber]: { code: SapErrorCode.NotSubscriber, name: "NotSubscriber", message: "Signer is not the subscriber.", recovery: "Sign with the wallet that created the subscription." },
|
|
166
|
+
[SapErrorCode.SubscriptionInsufficientBalance]: { code: SapErrorCode.SubscriptionInsufficientBalance, name: "SubscriptionInsufficientBalance", message: "Subscription has insufficient balance.", recovery: "Fund the subscription before claiming." },
|
|
167
|
+
[SapErrorCode.SubscriptionIntervalOverflow]: { code: SapErrorCode.SubscriptionIntervalOverflow, name: "SubscriptionIntervalOverflow", message: "Claimable intervals exceed u32 range.", recovery: "Claim in smaller batches." },
|
|
168
|
+
[SapErrorCode.SubscriptionDurationTooLong]: { code: SapErrorCode.SubscriptionDurationTooLong, name: "SubscriptionDurationTooLong", message: "Subscription duration exceeds 10 years.", recovery: "Reduce the subscription duration." },
|
|
169
|
+
[SapErrorCode.ArithmeticOverflow]: { code: SapErrorCode.ArithmeticOverflow, name: "ArithmeticOverflow", message: "Arithmetic operation overflow.", recovery: "Reduce amounts to stay within u64 range." },
|
|
170
|
+
[SapErrorCode.VaultNotFound]: { code: SapErrorCode.VaultNotFound, name: "VaultNotFound", message: "Vault account does not exist.", recovery: "Create a vault first." },
|
|
171
|
+
[SapErrorCode.VaultAlreadyInitialized]: { code: SapErrorCode.VaultAlreadyInitialized, name: "VaultAlreadyInitialized", message: "Vault is already initialized.", recovery: "Use the existing vault or close it first." },
|
|
172
|
+
[SapErrorCode.NotVaultOwner]: { code: SapErrorCode.NotVaultOwner, name: "NotVaultOwner", message: "Signer is not the vault owner.", recovery: "Sign with the agent wallet that owns the vault." },
|
|
173
|
+
[SapErrorCode.NotDelegate]: { code: SapErrorCode.NotDelegate, name: "NotDelegate", message: "Signer is not a vault delegate.", recovery: "Add the signer as a vault delegate first." },
|
|
174
|
+
[SapErrorCode.DelegateExpired]: { code: SapErrorCode.DelegateExpired, name: "DelegateExpired", message: "Vault delegate has expired.", recovery: "Renew the delegate or use the owner wallet." },
|
|
175
|
+
[SapErrorCode.InvalidPermissions]: { code: SapErrorCode.InvalidPermissions, name: "InvalidPermissions", message: "Invalid vault delegate permissions.", recovery: "Use a valid permission bitmask (1=inscribe, 2=close, 4=open)." },
|
|
176
|
+
[SapErrorCode.SessionNotFound]: { code: SapErrorCode.SessionNotFound, name: "SessionNotFound", message: "Session ledger does not exist.", recovery: "Create a session first." },
|
|
177
|
+
[SapErrorCode.EpochNotFound]: { code: SapErrorCode.EpochNotFound, name: "EpochNotFound", message: "Epoch page does not exist.", recovery: "Create an epoch first." },
|
|
178
|
+
[SapErrorCode.VaultAlreadyOpen]: { code: SapErrorCode.VaultAlreadyOpen, name: "VaultAlreadyOpen", message: "Vault is already open.", recovery: "Vault is already initialized — proceed with inscription." },
|
|
179
|
+
[SapErrorCode.InvalidSequence]: { code: SapErrorCode.InvalidSequence, name: "InvalidSequence", message: "Inscription sequence is invalid.", recovery: "Use the next expected sequence number." },
|
|
180
|
+
[SapErrorCode.FragmentTooLarge]: { code: SapErrorCode.FragmentTooLarge, name: "FragmentTooLarge", message: "Inscription fragment exceeds max size.", recovery: "Split the inscription into smaller fragments." },
|
|
181
|
+
[SapErrorCode.VaultClosed]: { code: SapErrorCode.VaultClosed, name: "VaultClosed", message: "Vault has been closed.", recovery: "Re-open the vault or create a new one." },
|
|
182
|
+
[SapErrorCode.InsufficientVaultBalance]: { code: SapErrorCode.InsufficientVaultBalance, name: "InsufficientVaultBalance", message: "Vault has insufficient balance.", recovery: "Deposit more funds into the vault." },
|
|
183
|
+
// ── v0.13 Hardening Errors ──
|
|
184
|
+
[SapErrorCode.PendingAmountMismatch]: { code: SapErrorCode.PendingAmountMismatch, name: "PendingAmountMismatch", message: "Pending settlement amount does not match escrow.", recovery: "This is a protocol bug — escalate immediately." },
|
|
185
|
+
[SapErrorCode.MaxCallsPerSettlementExceeded]: { code: SapErrorCode.MaxCallsPerSettlementExceeded, name: "MaxCallsPerSettlementExceeded", message: "Calls per settlement exceeds 10,000.", recovery: "Split settlement into multiple batches of ≤10,000 calls." },
|
|
186
|
+
[SapErrorCode.InvalidVolumeCurvePrice]: { code: SapErrorCode.InvalidVolumeCurvePrice, name: "InvalidVolumeCurvePrice", message: "Volume curve breakpoint price must be > 0.", recovery: "Set price_per_call > 0 for all breakpoints." },
|
|
187
|
+
[SapErrorCode.EscrowCoverageExceeded]: { code: SapErrorCode.EscrowCoverageExceeded, name: "EscrowCoverageExceeded", message: "Escrow deposit would exceed agent staked coverage.", recovery: "Increase agent stake or reduce deposit amount." },
|
|
188
|
+
[SapErrorCode.CoSignerIsAgentWallet]: { code: SapErrorCode.CoSignerIsAgentWallet, name: "CoSignerIsAgentWallet", message: "Co-signer cannot be the agent's own wallet.", recovery: "Use a different wallet for the co-signer." },
|
|
189
|
+
[SapErrorCode.PendingSettlementExists]: { code: SapErrorCode.PendingSettlementExists, name: "PendingSettlementExists", message: "Escrow has an unresolved pending settlement.", recovery: "Finalize or dispute the pending settlement before closing." },
|
|
190
|
+
[SapErrorCode.TokenAccountOwnerMismatch]: { code: SapErrorCode.TokenAccountOwnerMismatch, name: "TokenAccountOwnerMismatch", message: "SPL token account owner mismatch.", recovery: "Verify the destination token account belongs to the depositor." },
|
|
191
|
+
[SapErrorCode.MaxReceiptProofExceeded]: { code: SapErrorCode.MaxReceiptProofExceeded, name: "MaxReceiptProofExceeded", message: "Receipt proof exceeds 128 receipts.", recovery: "Submit proof in chunks of ≤128 receipts." },
|
|
192
|
+
[SapErrorCode.MaxMerkleDepthExceeded]: { code: SapErrorCode.MaxMerkleDepthExceeded, name: "MaxMerkleDepthExceeded", message: "Merkle proof depth exceeds 16.", recovery: "Verify merkle tree depth (≤16)." },
|
|
193
|
+
[SapErrorCode.StakeSlashLocksUnstake]: { code: SapErrorCode.StakeSlashLocksUnstake, name: "StakeSlashLocksUnstake", message: "Stake slash would lock unstake request.", recovery: "The unstake was reduced proportionally — retry." },
|
|
194
|
+
};
|
|
195
|
+
/** Decode an Anchor transaction error into structured info */
|
|
196
|
+
function decodeSapError(err) {
|
|
197
|
+
// Anchor custom error format: { error: { errorCode: { code: number, number: number, ... }, ... } }
|
|
198
|
+
const anyErr = err;
|
|
199
|
+
let code;
|
|
200
|
+
// Anchor 0.30 format
|
|
201
|
+
if (anyErr.error?.errorCode?.code != null) {
|
|
202
|
+
code = anyErr.error.errorCode.code;
|
|
203
|
+
}
|
|
204
|
+
else if (anyErr.error?.errorCode?.number != null) {
|
|
205
|
+
code = anyErr.error.errorCode.number;
|
|
206
|
+
}
|
|
207
|
+
else if (anyErr.error?.instructionError?.[1]?.Custom != null) {
|
|
208
|
+
code = anyErr.error.instructionError[1].Custom;
|
|
209
|
+
}
|
|
210
|
+
if (code != null && ERROR_MAP[code]) {
|
|
211
|
+
return ERROR_MAP[code];
|
|
212
|
+
}
|
|
213
|
+
// Attempt log-based detection
|
|
214
|
+
if (anyErr.logs) {
|
|
215
|
+
for (const log of anyErr.logs) {
|
|
216
|
+
const match = log.match(/Error Code:\s*(\d+)/);
|
|
217
|
+
if (match) {
|
|
218
|
+
const logCode = parseInt(match[1], 10);
|
|
219
|
+
if (ERROR_MAP[logCode])
|
|
220
|
+
return ERROR_MAP[logCode];
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return {
|
|
225
|
+
code: (code ?? -9999),
|
|
226
|
+
name: "UnknownError",
|
|
227
|
+
message: err?.message ?? "Unknown transaction error",
|
|
228
|
+
recovery: "Check transaction logs or retry with a different configuration.",
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
/** Is this error retryable? */
|
|
232
|
+
function isRetryableError(err) {
|
|
233
|
+
const retryable = [
|
|
234
|
+
SapErrorCode.DisputeWindowNotExpired,
|
|
235
|
+
SapErrorCode.UnstakeTooSoon,
|
|
236
|
+
SapErrorCode.EscrowExpired, // can retry with new escrow
|
|
237
|
+
];
|
|
238
|
+
return retryable.includes(err.code);
|
|
239
|
+
}
|
|
240
|
+
/** Is this a client-side validation error that should have been caught before sending?
|
|
241
|
+
* If true, the SDK's validate functions have a bug.
|
|
242
|
+
*/
|
|
243
|
+
function isClientValidationFailure(err) {
|
|
244
|
+
const client = [
|
|
245
|
+
SapErrorCode.AmountMustBePositive,
|
|
246
|
+
SapErrorCode.PricePerCallMustBePositive,
|
|
247
|
+
SapErrorCode.InvalidVolumeCurve,
|
|
248
|
+
SapErrorCode.VolumeCurveNotDescending,
|
|
249
|
+
SapErrorCode.TooManyVolumeCurvePoints,
|
|
250
|
+
SapErrorCode.MaxCallsPerSettlementExceeded,
|
|
251
|
+
SapErrorCode.InvalidVolumeCurvePrice,
|
|
252
|
+
SapErrorCode.EscrowAlreadyExpired,
|
|
253
|
+
SapErrorCode.CoSignerIsAgentWallet,
|
|
254
|
+
SapErrorCode.MaxReceiptProofExceeded,
|
|
255
|
+
SapErrorCode.MaxMerkleDepthExceeded,
|
|
256
|
+
SapErrorCode.SubscriptionDurationTooLong,
|
|
257
|
+
];
|
|
258
|
+
return client.includes(err.code);
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAiNA,wCAmCC;AAGD,4CAOC;AAKD,8DAgBC;AAnRD,wBAAwB;AACxB,MAAa,QAAS,SAAQ,KAAK;IACjC,YAAY,OAAe,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC;CACzE;AAFD,4BAEC;AAED,oCAAoC;AACpC,MAAa,kBAAmB,SAAQ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AE,iEAAiE;KAC5E,CAAC;AACJ,CAAC;AAED,+BAA+B;AAC/B,SAAgB,gBAAgB,CAAC,GAAiB;IAChD,MAAM,SAAS,GAAG;QAChB,YAAY,CAAC,uBAAuB;QACpC,YAAY,CAAC,cAAc;QAC3B,YAAY,CAAC,aAAa,EAAE,4BAA4B;KACzD,CAAC;IACF,OAAO,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,SAAgB,yBAAyB,CAAC,GAAiB;IACzD,MAAM,MAAM,GAAG;QACb,YAAY,CAAC,oBAAoB;QACjC,YAAY,CAAC,0BAA0B;QACvC,YAAY,CAAC,kBAAkB;QAC/B,YAAY,CAAC,wBAAwB;QACrC,YAAY,CAAC,wBAAwB;QACrC,YAAY,CAAC,6BAA6B;QAC1C,YAAY,CAAC,uBAAuB;QACpC,YAAY,CAAC,oBAAoB;QACjC,YAAY,CAAC,qBAAqB;QAClC,YAAY,CAAC,uBAAuB;QACpC,YAAY,CAAC,sBAAsB;QACnC,YAAY,CAAC,2BAA2B;KACzC,CAAC;IACF,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC"}
|
package/dist/cjs/events/index.js
CHANGED
|
@@ -1,136 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* Uses Anchor's event parser under the hood. Provides a
|
|
7
|
-
* strongly-typed, filterable event stream.
|
|
8
|
-
*
|
|
9
|
-
* @category Events
|
|
10
|
-
* @since v0.1.0
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* import { EventParser } from "@synapse-sap/sdk/events";
|
|
15
|
-
*
|
|
16
|
-
* const events = client.events.parseLogs(txLogs);
|
|
17
|
-
* for (const event of events) {
|
|
18
|
-
* if (event.name === "PaymentSettledEvent") {
|
|
19
|
-
* console.log(event.data);
|
|
20
|
-
* }
|
|
21
|
-
* }
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
2
|
+
// ================================================================
|
|
3
|
+
// synapse-sap-sdk / src/events/index.ts
|
|
4
|
+
// All program event parsers
|
|
5
|
+
// ================================================================
|
|
24
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.EventParser =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// Event Name Literals
|
|
29
|
-
// ═══════════════════════════════════════════════════════════════════
|
|
30
|
-
/**
|
|
31
|
-
* Exhaustive list of all SAP v2 event name strings.
|
|
32
|
-
*
|
|
33
|
-
* @name SAP_EVENT_NAMES
|
|
34
|
-
* @description Frozen array of every event discriminant emitted by the program.
|
|
35
|
-
* Useful for log filtering and exhaustive switch checks.
|
|
36
|
-
* @category Events
|
|
37
|
-
* @since v0.1.0
|
|
38
|
-
* @see {@link SapEventName}
|
|
39
|
-
*/
|
|
40
|
-
exports.SAP_EVENT_NAMES = [
|
|
41
|
-
"RegisteredEvent",
|
|
42
|
-
"UpdatedEvent",
|
|
43
|
-
"DeactivatedEvent",
|
|
44
|
-
"ReactivatedEvent",
|
|
45
|
-
"ClosedEvent",
|
|
46
|
-
"FeedbackEvent",
|
|
47
|
-
"FeedbackUpdatedEvent",
|
|
48
|
-
"FeedbackRevokedEvent",
|
|
49
|
-
"ReputationUpdatedEvent",
|
|
50
|
-
"CallsReportedEvent",
|
|
51
|
-
"VaultInitializedEvent",
|
|
52
|
-
"SessionOpenedEvent",
|
|
53
|
-
"MemoryInscribedEvent",
|
|
54
|
-
"EpochOpenedEvent",
|
|
55
|
-
"SessionClosedEvent",
|
|
56
|
-
"VaultClosedEvent",
|
|
57
|
-
"SessionPdaClosedEvent",
|
|
58
|
-
"EpochPageClosedEvent",
|
|
59
|
-
"VaultNonceRotatedEvent",
|
|
60
|
-
"DelegateAddedEvent",
|
|
61
|
-
"DelegateRevokedEvent",
|
|
62
|
-
"ToolPublishedEvent",
|
|
63
|
-
"ToolSchemaInscribedEvent",
|
|
64
|
-
"ToolUpdatedEvent",
|
|
65
|
-
"ToolDeactivatedEvent",
|
|
66
|
-
"ToolReactivatedEvent",
|
|
67
|
-
"ToolClosedEvent",
|
|
68
|
-
"ToolInvocationReportedEvent",
|
|
69
|
-
"CheckpointCreatedEvent",
|
|
70
|
-
"EscrowCreatedEvent",
|
|
71
|
-
"EscrowDepositedEvent",
|
|
72
|
-
"PaymentSettledEvent",
|
|
73
|
-
"EscrowWithdrawnEvent",
|
|
74
|
-
"BatchSettledEvent",
|
|
75
|
-
"AttestationCreatedEvent",
|
|
76
|
-
"AttestationRevokedEvent",
|
|
77
|
-
"LedgerEntryEvent",
|
|
78
|
-
"LedgerSealedEvent",
|
|
79
|
-
];
|
|
80
|
-
/**
|
|
81
|
-
* Typed wrapper around Anchor’s `EventParser` for SAP v2 programs.
|
|
82
|
-
*
|
|
83
|
-
* Extracts strongly-typed {@link ParsedEvent} objects from raw
|
|
84
|
-
* transaction log lines.
|
|
85
|
-
*
|
|
86
|
-
* @name EventParser
|
|
87
|
-
* @description Instantiate with an Anchor `Program` and call {@link EventParser.parseLogs}
|
|
88
|
-
* to decode events, or {@link EventParser.filterByName} to narrow results.
|
|
89
|
-
* @category Events
|
|
90
|
-
* @since v0.1.0
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
93
|
-
* ```ts
|
|
94
|
-
* const parser = new EventParser(program);
|
|
95
|
-
* const events = parser.parseLogs(txLogs);
|
|
96
|
-
* const settled = parser.filterByName(events, "PaymentSettledEvent");
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
7
|
+
exports.EventParser = void 0;
|
|
8
|
+
exports.parseEventsFromLogs = parseEventsFromLogs;
|
|
9
|
+
exports.fetchTransactionEvents = fetchTransactionEvents;
|
|
99
10
|
class EventParser {
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Create a new `EventParser`.
|
|
103
|
-
*
|
|
104
|
-
* @param program - An Anchor `Program` instance whose IDL defines the events to decode.
|
|
105
|
-
*/
|
|
106
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
program;
|
|
107
12
|
constructor(program) {
|
|
108
|
-
this.
|
|
13
|
+
this.program = program;
|
|
109
14
|
}
|
|
110
|
-
/**
|
|
111
|
-
* Parse raw transaction log lines into typed events.
|
|
112
|
-
*
|
|
113
|
-
* @param logs - Array of log strings from a confirmed transaction.
|
|
114
|
-
* @returns {ParsedEvent[]} Decoded events found in the logs.
|
|
115
|
-
*/
|
|
116
15
|
parseLogs(logs) {
|
|
117
16
|
const events = [];
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
17
|
+
for (const log of logs) {
|
|
18
|
+
if (!log.includes("Program log:"))
|
|
19
|
+
continue;
|
|
20
|
+
const payload = log.replace(/^Program log:\s*/, "");
|
|
21
|
+
for (const name of [
|
|
22
|
+
"EscrowCreated",
|
|
23
|
+
"SettlementFiled",
|
|
24
|
+
"SettlementFinalized",
|
|
25
|
+
"DisputeFiled",
|
|
26
|
+
"DisputeResolved",
|
|
27
|
+
"StakeEvent",
|
|
28
|
+
"SubscriptionEvent",
|
|
29
|
+
]) {
|
|
30
|
+
if (payload.startsWith(`Event ${name} `)) {
|
|
31
|
+
const b64 = payload.slice(`Event ${name} `.length);
|
|
32
|
+
events.push({ name, data: { raw: b64 }, signature: "", slot: 0 });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
121
35
|
}
|
|
122
36
|
return events;
|
|
123
37
|
}
|
|
124
|
-
/**
|
|
125
|
-
* Filter a list of parsed events by event name.
|
|
126
|
-
*
|
|
127
|
-
* @param events - The full array of {@link ParsedEvent} objects to filter.
|
|
128
|
-
* @param name - The {@link SapEventName} to match against.
|
|
129
|
-
* @returns {ParsedEvent[]} Only events whose `name` matches.
|
|
130
|
-
*/
|
|
131
|
-
filterByName(events, name) {
|
|
132
|
-
return events.filter((e) => e.name === name);
|
|
133
|
-
}
|
|
134
38
|
}
|
|
135
39
|
exports.EventParser = EventParser;
|
|
40
|
+
function parseEventsFromLogs(logs, signature) {
|
|
41
|
+
const parser = new EventParser({});
|
|
42
|
+
return parser.parseLogs(logs).map((e) => ({ ...e, signature }));
|
|
43
|
+
}
|
|
44
|
+
async function fetchTransactionEvents(connection, signature) {
|
|
45
|
+
const tx = await connection.getTransaction(signature, { commitment: "confirmed" });
|
|
46
|
+
if (!tx || !tx.meta?.logMessages)
|
|
47
|
+
return [];
|
|
48
|
+
return parseEventsFromLogs(tx.meta.logMessages, signature);
|
|
49
|
+
}
|
|
136
50
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/events/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/events/index.ts"],"names":[],"mappings":";AAAA,mEAAmE;AACnE,yCAAyC;AACzC,6BAA6B;AAC7B,mEAAmE;;;AAgDnE,kDAMC;AAED,wDAOC;AA1CD,MAAa,WAAW;IACF;IAApB,YAAoB,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;IAAG,CAAC;IAExC,SAAS,CAAC,IAAc;QACtB,MAAM,MAAM,GAAkB,EAAE,CAAC;QACjC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC;gBAAE,SAAS;YAC5C,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;YACpD,KAAK,MAAM,IAAI,IAAI;gBACjB,eAAe;gBACf,iBAAiB;gBACjB,qBAAqB;gBACrB,cAAc;gBACd,iBAAiB;gBACjB,YAAY;gBACZ,mBAAmB;aACF,EAAE,CAAC;gBACpB,IAAI,OAAO,CAAC,UAAU,CAAC,SAAS,IAAI,GAAG,CAAC,EAAE,CAAC;oBACzC,MAAM,GAAG,G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