@oobe-protocol-labs/synapse-sap-sdk 0.13.0 → 0.14.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 +108 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/constants.js +59 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/errors.js +250 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/events/index.js +38 -130
- 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 +89 -0
- package/dist/cjs/instructions/agent.js.map +1 -0
- package/dist/cjs/instructions/attestation.js +112 -0
- package/dist/cjs/instructions/attestation.js.map +1 -0
- package/dist/cjs/instructions/digest.js +28 -0
- package/dist/cjs/instructions/digest.js.map +1 -0
- package/dist/cjs/instructions/dispute.js +116 -0
- package/dist/cjs/instructions/dispute.js.map +1 -0
- package/dist/cjs/instructions/escrow.js +101 -0
- package/dist/cjs/instructions/escrow.js.map +1 -0
- package/dist/cjs/instructions/global.js +28 -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 +221 -0
- package/dist/cjs/instructions/indexing.js.map +1 -0
- package/dist/cjs/instructions/misc.js +73 -0
- package/dist/cjs/instructions/misc.js.map +1 -0
- package/dist/cjs/instructions/session.js +89 -0
- package/dist/cjs/instructions/session.js.map +1 -0
- package/dist/cjs/instructions/staking.js +132 -0
- package/dist/cjs/instructions/staking.js.map +1 -0
- package/dist/cjs/instructions/subscription.js +80 -0
- package/dist/cjs/instructions/subscription.js.map +1 -0
- package/dist/cjs/instructions/tools.js +109 -0
- package/dist/cjs/instructions/tools.js.map +1 -0
- package/dist/cjs/instructions/vault.js +106 -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/types.js +42 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils/index.js +29 -86
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/validate.js +236 -0
- package/dist/cjs/utils/validate.js.map +1 -0
- 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 +70 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/constants.d.ts +52 -0
- package/dist/esm/constants.d.ts.map +1 -0
- package/dist/esm/constants.js +56 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/errors.d.ts +111 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js +244 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/events/index.d.ts +13 -0
- package/dist/esm/events/index.d.ts.map +1 -0
- package/dist/esm/events/index.js +36 -128
- package/dist/esm/events/index.js.map +1 -1
- 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 +85 -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 +108 -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 +24 -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 +112 -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 +97 -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 +24 -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 +217 -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 +69 -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 +85 -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 +128 -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 +76 -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 +105 -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 +102 -0
- package/dist/esm/instructions/vault.js.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/types.d.ts +208 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +39 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/index.d.ts +4 -0
- package/dist/esm/utils/index.d.ts.map +1 -0
- package/dist/esm/utils/index.js +13 -33
- package/dist/esm/utils/index.js.map +1 -1
- 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/package.json +59 -183
- package/LICENSE +0 -21
- package/README.md +0 -986
- package/dist/cjs/constants/addresses.js +0 -143
- package/dist/cjs/constants/addresses.js.map +0 -1
- package/dist/cjs/constants/index.js +0 -64
- package/dist/cjs/constants/index.js.map +0 -1
- package/dist/cjs/constants/limits.js +0 -161
- package/dist/cjs/constants/limits.js.map +0 -1
- package/dist/cjs/constants/network.js +0 -81
- package/dist/cjs/constants/network.js.map +0 -1
- package/dist/cjs/constants/payments.js +0 -137
- package/dist/cjs/constants/payments.js.map +0 -1
- package/dist/cjs/constants/programs.js +0 -78
- package/dist/cjs/constants/programs.js.map +0 -1
- package/dist/cjs/constants/seeds.js +0 -76
- package/dist/cjs/constants/seeds.js.map +0 -1
- package/dist/cjs/core/client.js +0 -546
- package/dist/cjs/core/client.js.map +0 -1
- package/dist/cjs/core/connection.js +0 -350
- package/dist/cjs/core/connection.js.map +0 -1
- package/dist/cjs/core/index.js +0 -25
- package/dist/cjs/core/index.js.map +0 -1
- package/dist/cjs/errors/index.js +0 -334
- package/dist/cjs/errors/index.js.map +0 -1
- package/dist/cjs/events/geyser.js +0 -295
- package/dist/cjs/events/geyser.js.map +0 -1
- package/dist/cjs/idl/index.js +0 -63
- package/dist/cjs/idl/index.js.map +0 -1
- package/dist/cjs/idl/synapse_agent_sap.json +0 -14595
- package/dist/cjs/modules/agent.js +0 -272
- package/dist/cjs/modules/agent.js.map +0 -1
- package/dist/cjs/modules/attestation.js +0 -147
- package/dist/cjs/modules/attestation.js.map +0 -1
- package/dist/cjs/modules/base.js +0 -189
- package/dist/cjs/modules/base.js.map +0 -1
- package/dist/cjs/modules/escrow-v2.js +0 -607
- package/dist/cjs/modules/escrow-v2.js.map +0 -1
- package/dist/cjs/modules/escrow.js +0 -336
- package/dist/cjs/modules/escrow.js.map +0 -1
- package/dist/cjs/modules/feedback.js +0 -166
- package/dist/cjs/modules/feedback.js.map +0 -1
- package/dist/cjs/modules/index.js +0 -43
- package/dist/cjs/modules/index.js.map +0 -1
- package/dist/cjs/modules/indexing.js +0 -375
- package/dist/cjs/modules/indexing.js.map +0 -1
- package/dist/cjs/modules/ledger.js +0 -234
- package/dist/cjs/modules/ledger.js.map +0 -1
- package/dist/cjs/modules/receipt.js +0 -148
- package/dist/cjs/modules/receipt.js.map +0 -1
- package/dist/cjs/modules/staking.js +0 -159
- package/dist/cjs/modules/staking.js.map +0 -1
- package/dist/cjs/modules/subscription.js +0 -96
- package/dist/cjs/modules/subscription.js.map +0 -1
- package/dist/cjs/modules/tools.js +0 -345
- package/dist/cjs/modules/tools.js.map +0 -1
- package/dist/cjs/modules/vault.js +0 -427
- package/dist/cjs/modules/vault.js.map +0 -1
- package/dist/cjs/parser/client.js +0 -146
- package/dist/cjs/parser/client.js.map +0 -1
- package/dist/cjs/parser/complete.js +0 -177
- package/dist/cjs/parser/complete.js.map +0 -1
- package/dist/cjs/parser/index.js +0 -57
- package/dist/cjs/parser/index.js.map +0 -1
- package/dist/cjs/parser/inner.js +0 -185
- package/dist/cjs/parser/inner.js.map +0 -1
- package/dist/cjs/parser/instructions.js +0 -114
- package/dist/cjs/parser/instructions.js.map +0 -1
- package/dist/cjs/parser/transaction.js +0 -153
- package/dist/cjs/parser/transaction.js.map +0 -1
- package/dist/cjs/parser/types.js +0 -14
- package/dist/cjs/parser/types.js.map +0 -1
- package/dist/cjs/pda/index.js +0 -672
- package/dist/cjs/pda/index.js.map +0 -1
- package/dist/cjs/plugin/index.js +0 -952
- package/dist/cjs/plugin/index.js.map +0 -1
- package/dist/cjs/plugin/protocols.js +0 -282
- package/dist/cjs/plugin/protocols.js.map +0 -1
- package/dist/cjs/plugin/schemas.js +0 -863
- package/dist/cjs/plugin/schemas.js.map +0 -1
- package/dist/cjs/postgres/adapter.js +0 -715
- package/dist/cjs/postgres/adapter.js.map +0 -1
- package/dist/cjs/postgres/index.js +0 -50
- package/dist/cjs/postgres/index.js.map +0 -1
- package/dist/cjs/postgres/serializers.js +0 -381
- package/dist/cjs/postgres/serializers.js.map +0 -1
- package/dist/cjs/postgres/sync.js +0 -289
- package/dist/cjs/postgres/sync.js.map +0 -1
- package/dist/cjs/postgres/types.js +0 -44
- package/dist/cjs/postgres/types.js.map +0 -1
- package/dist/cjs/registries/builder.js +0 -414
- package/dist/cjs/registries/builder.js.map +0 -1
- package/dist/cjs/registries/discovery.js +0 -362
- package/dist/cjs/registries/discovery.js.map +0 -1
- package/dist/cjs/registries/fairscale.js +0 -639
- package/dist/cjs/registries/fairscale.js.map +0 -1
- package/dist/cjs/registries/index.js +0 -58
- package/dist/cjs/registries/index.js.map +0 -1
- package/dist/cjs/registries/metaplex-bridge.js +0 -743
- package/dist/cjs/registries/metaplex-bridge.js.map +0 -1
- package/dist/cjs/registries/session.js +0 -433
- package/dist/cjs/registries/session.js.map +0 -1
- package/dist/cjs/registries/x402.js +0 -668
- package/dist/cjs/registries/x402.js.map +0 -1
- package/dist/cjs/types/accounts.js +0 -13
- package/dist/cjs/types/accounts.js.map +0 -1
- package/dist/cjs/types/common.js +0 -13
- package/dist/cjs/types/common.js.map +0 -1
- package/dist/cjs/types/endpoint.js +0 -15
- package/dist/cjs/types/endpoint.js.map +0 -1
- package/dist/cjs/types/enums.js +0 -269
- package/dist/cjs/types/enums.js.map +0 -1
- package/dist/cjs/types/index.js +0 -41
- package/dist/cjs/types/index.js.map +0 -1
- package/dist/cjs/types/instructions.js +0 -92
- package/dist/cjs/types/instructions.js.map +0 -1
- package/dist/cjs/utils/anchor-errors.js +0 -453
- package/dist/cjs/utils/anchor-errors.js.map +0 -1
- package/dist/cjs/utils/endpoint-validator.js +0 -232
- package/dist/cjs/utils/endpoint-validator.js.map +0 -1
- package/dist/cjs/utils/escrow-validation.js +0 -219
- package/dist/cjs/utils/escrow-validation.js.map +0 -1
- package/dist/cjs/utils/hash.js +0 -109
- package/dist/cjs/utils/hash.js.map +0 -1
- package/dist/cjs/utils/merchant-validator.js +0 -246
- package/dist/cjs/utils/merchant-validator.js.map +0 -1
- package/dist/cjs/utils/network-normalizer.js +0 -236
- package/dist/cjs/utils/network-normalizer.js.map +0 -1
- package/dist/cjs/utils/priority-fee.js +0 -215
- package/dist/cjs/utils/priority-fee.js.map +0 -1
- package/dist/cjs/utils/rpc-strategy.js +0 -239
- package/dist/cjs/utils/rpc-strategy.js.map +0 -1
- package/dist/cjs/utils/schemas.js +0 -331
- package/dist/cjs/utils/schemas.js.map +0 -1
- package/dist/cjs/utils/serialization.js +0 -105
- package/dist/cjs/utils/serialization.js.map +0 -1
- package/dist/cjs/utils/validation.js +0 -36
- package/dist/cjs/utils/validation.js.map +0 -1
- package/dist/cjs/utils/volume-curve.js +0 -117
- package/dist/cjs/utils/volume-curve.js.map +0 -1
- package/dist/cjs/utils/x402-direct.js +0 -231
- package/dist/cjs/utils/x402-direct.js.map +0 -1
- package/dist/esm/constants/addresses.js +0 -140
- package/dist/esm/constants/addresses.js.map +0 -1
- package/dist/esm/constants/index.js +0 -35
- package/dist/esm/constants/index.js.map +0 -1
- package/dist/esm/constants/limits.js +0 -158
- package/dist/esm/constants/limits.js.map +0 -1
- package/dist/esm/constants/network.js +0 -78
- package/dist/esm/constants/network.js.map +0 -1
- package/dist/esm/constants/payments.js +0 -131
- package/dist/esm/constants/payments.js.map +0 -1
- package/dist/esm/constants/programs.js +0 -75
- package/dist/esm/constants/programs.js.map +0 -1
- package/dist/esm/constants/seeds.js +0 -73
- package/dist/esm/constants/seeds.js.map +0 -1
- package/dist/esm/core/client.js +0 -539
- package/dist/esm/core/client.js.map +0 -1
- package/dist/esm/core/connection.js +0 -345
- package/dist/esm/core/connection.js.map +0 -1
- package/dist/esm/core/index.js +0 -19
- package/dist/esm/core/index.js.map +0 -1
- package/dist/esm/errors/index.js +0 -325
- package/dist/esm/errors/index.js.map +0 -1
- package/dist/esm/events/geyser.js +0 -258
- package/dist/esm/events/geyser.js.map +0 -1
- package/dist/esm/idl/index.js +0 -57
- package/dist/esm/idl/index.js.map +0 -1
- package/dist/esm/idl/synapse_agent_sap.json +0 -14595
- package/dist/esm/modules/agent.js +0 -268
- package/dist/esm/modules/agent.js.map +0 -1
- package/dist/esm/modules/attestation.js +0 -143
- package/dist/esm/modules/attestation.js.map +0 -1
- package/dist/esm/modules/base.js +0 -185
- package/dist/esm/modules/base.js.map +0 -1
- package/dist/esm/modules/escrow-v2.js +0 -603
- package/dist/esm/modules/escrow-v2.js.map +0 -1
- package/dist/esm/modules/escrow.js +0 -332
- package/dist/esm/modules/escrow.js.map +0 -1
- package/dist/esm/modules/feedback.js +0 -162
- package/dist/esm/modules/feedback.js.map +0 -1
- package/dist/esm/modules/index.js +0 -27
- package/dist/esm/modules/index.js.map +0 -1
- package/dist/esm/modules/indexing.js +0 -371
- package/dist/esm/modules/indexing.js.map +0 -1
- package/dist/esm/modules/ledger.js +0 -230
- package/dist/esm/modules/ledger.js.map +0 -1
- package/dist/esm/modules/receipt.js +0 -144
- package/dist/esm/modules/receipt.js.map +0 -1
- package/dist/esm/modules/staking.js +0 -155
- package/dist/esm/modules/staking.js.map +0 -1
- package/dist/esm/modules/subscription.js +0 -92
- package/dist/esm/modules/subscription.js.map +0 -1
- package/dist/esm/modules/tools.js +0 -341
- package/dist/esm/modules/tools.js.map +0 -1
- package/dist/esm/modules/vault.js +0 -423
- package/dist/esm/modules/vault.js.map +0 -1
- package/dist/esm/parser/client.js +0 -142
- package/dist/esm/parser/client.js.map +0 -1
- package/dist/esm/parser/complete.js +0 -173
- package/dist/esm/parser/complete.js.map +0 -1
- package/dist/esm/parser/index.js +0 -43
- package/dist/esm/parser/index.js.map +0 -1
- package/dist/esm/parser/inner.js +0 -180
- package/dist/esm/parser/inner.js.map +0 -1
- package/dist/esm/parser/instructions.js +0 -109
- package/dist/esm/parser/instructions.js.map +0 -1
- package/dist/esm/parser/transaction.js +0 -149
- package/dist/esm/parser/transaction.js.map +0 -1
- package/dist/esm/parser/types.js +0 -13
- package/dist/esm/parser/types.js.map +0 -1
- package/dist/esm/pda/index.js +0 -638
- package/dist/esm/pda/index.js.map +0 -1
- package/dist/esm/plugin/index.js +0 -945
- package/dist/esm/plugin/index.js.map +0 -1
- package/dist/esm/plugin/protocols.js +0 -279
- package/dist/esm/plugin/protocols.js.map +0 -1
- package/dist/esm/plugin/schemas.js +0 -860
- package/dist/esm/plugin/schemas.js.map +0 -1
- package/dist/esm/postgres/adapter.js +0 -678
- package/dist/esm/postgres/adapter.js.map +0 -1
- package/dist/esm/postgres/index.js +0 -27
- package/dist/esm/postgres/index.js.map +0 -1
- package/dist/esm/postgres/serializers.js +0 -362
- package/dist/esm/postgres/serializers.js.map +0 -1
- package/dist/esm/postgres/sync.js +0 -285
- package/dist/esm/postgres/sync.js.map +0 -1
- package/dist/esm/postgres/types.js +0 -41
- package/dist/esm/postgres/types.js.map +0 -1
- package/dist/esm/registries/builder.js +0 -410
- package/dist/esm/registries/builder.js.map +0 -1
- package/dist/esm/registries/discovery.js +0 -358
- package/dist/esm/registries/discovery.js.map +0 -1
- package/dist/esm/registries/fairscale.js +0 -633
- package/dist/esm/registries/fairscale.js.map +0 -1
- package/dist/esm/registries/index.js +0 -46
- package/dist/esm/registries/index.js.map +0 -1
- package/dist/esm/registries/metaplex-bridge.js +0 -706
- package/dist/esm/registries/metaplex-bridge.js.map +0 -1
- package/dist/esm/registries/session.js +0 -429
- package/dist/esm/registries/session.js.map +0 -1
- package/dist/esm/registries/x402.js +0 -664
- package/dist/esm/registries/x402.js.map +0 -1
- package/dist/esm/types/accounts.js +0 -12
- package/dist/esm/types/accounts.js.map +0 -1
- package/dist/esm/types/common.js +0 -12
- package/dist/esm/types/common.js.map +0 -1
- package/dist/esm/types/endpoint.js +0 -14
- package/dist/esm/types/endpoint.js.map +0 -1
- package/dist/esm/types/enums.js +0 -266
- package/dist/esm/types/enums.js.map +0 -1
- package/dist/esm/types/index.js +0 -25
- package/dist/esm/types/index.js.map +0 -1
- package/dist/esm/types/instructions.js +0 -89
- package/dist/esm/types/instructions.js.map +0 -1
- package/dist/esm/utils/anchor-errors.js +0 -447
- package/dist/esm/utils/anchor-errors.js.map +0 -1
- package/dist/esm/utils/endpoint-validator.js +0 -226
- package/dist/esm/utils/endpoint-validator.js.map +0 -1
- package/dist/esm/utils/escrow-validation.js +0 -212
- package/dist/esm/utils/escrow-validation.js.map +0 -1
- package/dist/esm/utils/hash.js +0 -103
- package/dist/esm/utils/hash.js.map +0 -1
- package/dist/esm/utils/merchant-validator.js +0 -241
- package/dist/esm/utils/merchant-validator.js.map +0 -1
- package/dist/esm/utils/network-normalizer.js +0 -229
- package/dist/esm/utils/network-normalizer.js.map +0 -1
- package/dist/esm/utils/priority-fee.js +0 -209
- package/dist/esm/utils/priority-fee.js.map +0 -1
- package/dist/esm/utils/rpc-strategy.js +0 -231
- package/dist/esm/utils/rpc-strategy.js.map +0 -1
- package/dist/esm/utils/schemas.js +0 -320
- package/dist/esm/utils/schemas.js.map +0 -1
- package/dist/esm/utils/serialization.js +0 -98
- package/dist/esm/utils/serialization.js.map +0 -1
- package/dist/esm/utils/validation.js +0 -33
- package/dist/esm/utils/validation.js.map +0 -1
- package/dist/esm/utils/volume-curve.js +0 -114
- package/dist/esm/utils/volume-curve.js.map +0 -1
- package/dist/esm/utils/x402-direct.js +0 -228
- package/dist/esm/utils/x402-direct.js.map +0 -1
- package/dist/types/constants/addresses.d.ts +0 -117
- package/dist/types/constants/addresses.d.ts.map +0 -1
- package/dist/types/constants/index.d.ts +0 -31
- package/dist/types/constants/index.d.ts.map +0 -1
- package/dist/types/constants/limits.d.ts +0 -149
- package/dist/types/constants/limits.d.ts.map +0 -1
- package/dist/types/constants/network.d.ts +0 -81
- package/dist/types/constants/network.d.ts.map +0 -1
- package/dist/types/constants/payments.d.ts +0 -121
- package/dist/types/constants/payments.d.ts.map +0 -1
- package/dist/types/constants/programs.d.ts +0 -69
- package/dist/types/constants/programs.d.ts.map +0 -1
- package/dist/types/constants/seeds.d.ts +0 -80
- package/dist/types/constants/seeds.d.ts.map +0 -1
- package/dist/types/core/client.d.ts +0 -452
- package/dist/types/core/client.d.ts.map +0 -1
- package/dist/types/core/connection.d.ts +0 -305
- package/dist/types/core/connection.d.ts.map +0 -1
- package/dist/types/core/index.d.ts +0 -20
- package/dist/types/core/index.d.ts.map +0 -1
- package/dist/types/errors/index.d.ts +0 -276
- package/dist/types/errors/index.d.ts.map +0 -1
- package/dist/types/events/geyser.d.ts +0 -150
- package/dist/types/events/geyser.d.ts.map +0 -1
- package/dist/types/events/index.d.ts +0 -248
- package/dist/types/events/index.d.ts.map +0 -1
- package/dist/types/idl/index.d.ts +0 -70
- package/dist/types/idl/index.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -85
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/modules/agent.d.ts +0 -166
- package/dist/types/modules/agent.d.ts.map +0 -1
- package/dist/types/modules/attestation.d.ts +0 -96
- package/dist/types/modules/attestation.d.ts.map +0 -1
- package/dist/types/modules/base.d.ts +0 -161
- package/dist/types/modules/base.d.ts.map +0 -1
- package/dist/types/modules/escrow-v2.d.ts +0 -169
- package/dist/types/modules/escrow-v2.d.ts.map +0 -1
- package/dist/types/modules/escrow.d.ts +0 -168
- package/dist/types/modules/escrow.d.ts.map +0 -1
- package/dist/types/modules/feedback.d.ts +0 -105
- package/dist/types/modules/feedback.d.ts.map +0 -1
- package/dist/types/modules/index.d.ts +0 -28
- package/dist/types/modules/index.d.ts.map +0 -1
- package/dist/types/modules/indexing.d.ts +0 -200
- package/dist/types/modules/indexing.d.ts.map +0 -1
- package/dist/types/modules/ledger.d.ts +0 -150
- package/dist/types/modules/ledger.d.ts.map +0 -1
- package/dist/types/modules/receipt.d.ts +0 -77
- package/dist/types/modules/receipt.d.ts.map +0 -1
- package/dist/types/modules/staking.d.ts +0 -51
- package/dist/types/modules/staking.d.ts.map +0 -1
- package/dist/types/modules/subscription.d.ts +0 -33
- package/dist/types/modules/subscription.d.ts.map +0 -1
- package/dist/types/modules/tools.d.ts +0 -182
- package/dist/types/modules/tools.d.ts.map +0 -1
- package/dist/types/modules/vault.d.ts +0 -240
- package/dist/types/modules/vault.d.ts.map +0 -1
- package/dist/types/parser/client.d.ts +0 -123
- package/dist/types/parser/client.d.ts.map +0 -1
- package/dist/types/parser/complete.d.ts +0 -90
- package/dist/types/parser/complete.d.ts.map +0 -1
- package/dist/types/parser/index.d.ts +0 -40
- package/dist/types/parser/index.d.ts.map +0 -1
- package/dist/types/parser/inner.d.ts +0 -114
- package/dist/types/parser/inner.d.ts.map +0 -1
- package/dist/types/parser/instructions.d.ts +0 -76
- package/dist/types/parser/instructions.d.ts.map +0 -1
- package/dist/types/parser/transaction.d.ts +0 -77
- package/dist/types/parser/transaction.d.ts.map +0 -1
- package/dist/types/parser/types.d.ts +0 -154
- package/dist/types/parser/types.d.ts.map +0 -1
- package/dist/types/pda/index.d.ts +0 -510
- package/dist/types/pda/index.d.ts.map +0 -1
- package/dist/types/plugin/index.d.ts +0 -171
- package/dist/types/plugin/index.d.ts.map +0 -1
- package/dist/types/plugin/protocols.d.ts +0 -152
- package/dist/types/plugin/protocols.d.ts.map +0 -1
- package/dist/types/plugin/schemas.d.ts +0 -829
- package/dist/types/plugin/schemas.d.ts.map +0 -1
- package/dist/types/postgres/adapter.d.ts +0 -355
- package/dist/types/postgres/adapter.d.ts.map +0 -1
- package/dist/types/postgres/index.d.ts +0 -24
- package/dist/types/postgres/index.d.ts.map +0 -1
- package/dist/types/postgres/serializers.d.ts +0 -30
- package/dist/types/postgres/serializers.d.ts.map +0 -1
- package/dist/types/postgres/sync.d.ts +0 -156
- package/dist/types/postgres/sync.d.ts.map +0 -1
- package/dist/types/postgres/types.d.ts +0 -167
- package/dist/types/postgres/types.d.ts.map +0 -1
- package/dist/types/registries/builder.d.ts +0 -340
- package/dist/types/registries/builder.d.ts.map +0 -1
- package/dist/types/registries/discovery.d.ts +0 -333
- package/dist/types/registries/discovery.d.ts.map +0 -1
- package/dist/types/registries/fairscale.d.ts +0 -680
- package/dist/types/registries/fairscale.d.ts.map +0 -1
- package/dist/types/registries/index.d.ts +0 -52
- package/dist/types/registries/index.d.ts.map +0 -1
- package/dist/types/registries/metaplex-bridge.d.ts +0 -488
- package/dist/types/registries/metaplex-bridge.d.ts.map +0 -1
- package/dist/types/registries/session.d.ts +0 -323
- package/dist/types/registries/session.d.ts.map +0 -1
- package/dist/types/registries/x402.d.ts +0 -530
- package/dist/types/registries/x402.d.ts.map +0 -1
- package/dist/types/types/accounts.d.ts +0 -765
- package/dist/types/types/accounts.d.ts.map +0 -1
- package/dist/types/types/common.d.ts +0 -166
- package/dist/types/types/common.d.ts.map +0 -1
- package/dist/types/types/endpoint.d.ts +0 -161
- package/dist/types/types/endpoint.d.ts.map +0 -1
- package/dist/types/types/enums.d.ts +0 -353
- package/dist/types/types/enums.d.ts.map +0 -1
- package/dist/types/types/index.d.ts +0 -29
- package/dist/types/types/index.d.ts.map +0 -1
- package/dist/types/types/instructions.d.ts +0 -400
- package/dist/types/types/instructions.d.ts.map +0 -1
- package/dist/types/utils/anchor-errors.d.ts +0 -61
- package/dist/types/utils/anchor-errors.d.ts.map +0 -1
- package/dist/types/utils/endpoint-validator.d.ts +0 -110
- package/dist/types/utils/endpoint-validator.d.ts.map +0 -1
- package/dist/types/utils/escrow-validation.d.ts +0 -145
- package/dist/types/utils/escrow-validation.d.ts.map +0 -1
- package/dist/types/utils/hash.d.ts +0 -75
- package/dist/types/utils/hash.d.ts.map +0 -1
- package/dist/types/utils/index.d.ts +0 -36
- package/dist/types/utils/index.d.ts.map +0 -1
- package/dist/types/utils/merchant-validator.d.ts +0 -176
- package/dist/types/utils/merchant-validator.d.ts.map +0 -1
- package/dist/types/utils/network-normalizer.d.ts +0 -120
- package/dist/types/utils/network-normalizer.d.ts.map +0 -1
- package/dist/types/utils/priority-fee.d.ts +0 -205
- package/dist/types/utils/priority-fee.d.ts.map +0 -1
- package/dist/types/utils/rpc-strategy.d.ts +0 -172
- package/dist/types/utils/rpc-strategy.d.ts.map +0 -1
- package/dist/types/utils/schemas.d.ts +0 -351
- package/dist/types/utils/schemas.d.ts.map +0 -1
- package/dist/types/utils/serialization.d.ts +0 -69
- package/dist/types/utils/serialization.d.ts.map +0 -1
- package/dist/types/utils/validation.d.ts +0 -29
- package/dist/types/utils/validation.d.ts.map +0 -1
- package/dist/types/utils/volume-curve.d.ts +0 -60
- package/dist/types/utils/volume-curve.d.ts.map +0 -1
- package/dist/types/utils/x402-direct.d.ts +0 -114
- package/dist/types/utils/x402-direct.d.ts.map +0 -1
- package/src/constants/addresses.ts +0 -162
- package/src/constants/index.ts +0 -69
- package/src/constants/limits.ts +0 -165
- package/src/constants/network.ts +0 -89
- package/src/constants/payments.ts +0 -145
- package/src/constants/programs.ts +0 -83
- package/src/constants/seeds.ts +0 -85
- package/src/core/client.ts +0 -583
- package/src/core/connection.ts +0 -461
- package/src/core/index.ts +0 -20
- 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/index.ts +0 -76
- 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/index.ts +0 -28
- 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/index.ts +0 -71
- package/src/parser/inner.ts +0 -255
- package/src/parser/instructions.ts +0 -135
- package/src/parser/transaction.ts +0 -200
- package/src/parser/types.ts +0 -182
- package/src/pda/index.ts +0 -919
- 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/hash.ts +0 -113
- 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/serialization.ts +0 -98
- package/src/utils/validation.ts +0 -36
- package/src/utils/volume-curve.ts +0 -131
- package/src/utils/x402-direct.ts +0 -370
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module utils/serialization
|
|
3
|
-
* @description JSON-safe serialization helpers for on-chain account data.
|
|
4
|
-
*
|
|
5
|
-
* On-chain Anchor account objects contain `PublicKey` and `BN` instances
|
|
6
|
-
* that are not JSON-serializable. These helpers convert them to plain
|
|
7
|
-
* strings (`base58` and decimal `string`) recursively.
|
|
8
|
-
*
|
|
9
|
-
* @category Utils
|
|
10
|
-
* @since v0.1.0
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* import { serializeAccount } from "@synapse-sap/sdk/utils";
|
|
15
|
-
*
|
|
16
|
-
* const raw = await program.account.agent.fetch(pda);
|
|
17
|
-
* const json = serializeAccount(raw);
|
|
18
|
-
* // { authority: "GBL...", totalCalls: "42", ... }
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
import { PublicKey } from "@solana/web3.js";
|
|
23
|
-
import BN from "bn.js";
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Recursively convert a single value for JSON serialization.
|
|
27
|
-
*
|
|
28
|
-
* - `PublicKey` → base58 string
|
|
29
|
-
* - `BN` → decimal string
|
|
30
|
-
* - `Uint8Array` / `Buffer` → hex string
|
|
31
|
-
* - `Array` → recursed
|
|
32
|
-
* - plain `object` → recursed via {@link serializeAccount}
|
|
33
|
-
* - primitives → identity
|
|
34
|
-
*
|
|
35
|
-
* @name serializeValue
|
|
36
|
-
* @description Transforms a single Anchor-typed value into its JSON-safe equivalent.
|
|
37
|
-
* @param value - The value to serialize.
|
|
38
|
-
* @returns The JSON-safe representation of `value`.
|
|
39
|
-
* @category Utils
|
|
40
|
-
* @since v0.1.0
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* import { serializeValue } from "@synapse-sap/sdk/utils";
|
|
44
|
-
*
|
|
45
|
-
* serializeValue(new PublicKey("11111111111111111111111111111111")); // "1111..."
|
|
46
|
-
* serializeValue(new BN(42)); // "42"
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
-
export function serializeValue(value: unknown): any {
|
|
51
|
-
if (value === null || value === undefined) return null;
|
|
52
|
-
if (value instanceof PublicKey) return value.toBase58();
|
|
53
|
-
if (BN.isBN(value)) return value.toString();
|
|
54
|
-
if (value instanceof Uint8Array || Buffer.isBuffer(value))
|
|
55
|
-
return Buffer.from(value).toString("hex");
|
|
56
|
-
if (Array.isArray(value)) return value.map(serializeValue);
|
|
57
|
-
if (typeof value === "object") {
|
|
58
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
59
|
-
return serializeAccount(value as Record<string, any>);
|
|
60
|
-
}
|
|
61
|
-
return value;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Serialize an entire on-chain account object to a JSON-safe shape.
|
|
66
|
-
*
|
|
67
|
-
* Iterates over each key and delegates to {@link serializeValue}.
|
|
68
|
-
* Handles `PublicKey` → base58, `BN` → string, and nested
|
|
69
|
-
* objects / arrays recursively.
|
|
70
|
-
*
|
|
71
|
-
* @name serializeAccount
|
|
72
|
-
* @description Converts all non-primitive fields in an Anchor account record to JSON-safe strings.
|
|
73
|
-
* @param obj - The raw account object returned by `program.account.<name>.fetch()`.
|
|
74
|
-
* @returns A new plain object with all values converted.
|
|
75
|
-
* @category Utils
|
|
76
|
-
* @since v0.1.0
|
|
77
|
-
* @example
|
|
78
|
-
* ```ts
|
|
79
|
-
* import { serializeAccount } from "@synapse-sap/sdk/utils";
|
|
80
|
-
*
|
|
81
|
-
* const raw = await program.account.agent.fetch(pda);
|
|
82
|
-
* const safe = serializeAccount(raw);
|
|
83
|
-
* console.log(JSON.stringify(safe));
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
87
|
-
export function serializeAccount(
|
|
88
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
|
-
obj: Record<string, any>,
|
|
90
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
|
-
): Record<string, any> {
|
|
92
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
93
|
-
const result: Record<string, any> = {};
|
|
94
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
95
|
-
result[key] = serializeValue(value);
|
|
96
|
-
}
|
|
97
|
-
return result;
|
|
98
|
-
}
|
package/src/utils/validation.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module utils/validation
|
|
3
|
-
* @description Runtime assertion helpers.
|
|
4
|
-
*
|
|
5
|
-
* @category Utils
|
|
6
|
-
* @since v0.1.0
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Assert that a condition holds, throwing a descriptive error otherwise.
|
|
11
|
-
*
|
|
12
|
-
* Uses TypeScript’s `asserts condition` return type so the compiler
|
|
13
|
-
* narrows the guarded value after the call.
|
|
14
|
-
*
|
|
15
|
-
* @name assert
|
|
16
|
-
* @description Runtime guard — throws `RangeError` with a `[SAP SDK]` prefix when the condition is falsy.
|
|
17
|
-
* @param condition - The boolean expression to verify.
|
|
18
|
-
* @param message - Human-readable message included in the thrown error.
|
|
19
|
-
* @throws {RangeError} When `condition` is `false`.
|
|
20
|
-
* @category Utils
|
|
21
|
-
* @since v0.1.0
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* import { assert } from "@synapse-sap/sdk/utils";
|
|
25
|
-
*
|
|
26
|
-
* assert(name.length <= 64, "Agent name exceeds MAX_NAME_LEN");
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export function assert(
|
|
30
|
-
condition: boolean,
|
|
31
|
-
message: string,
|
|
32
|
-
): asserts condition {
|
|
33
|
-
if (!condition) {
|
|
34
|
-
throw new RangeError(`[SAP SDK] ${message}`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module volume-curve
|
|
3
|
-
* @description Client-side mirror of the on-chain `calculate_settle_amount`
|
|
4
|
-
* function from `programs/synapse-agent-sap/src/instructions/escrow_v2.rs`.
|
|
5
|
-
*
|
|
6
|
-
* Used by {@link EscrowV2Module.settle} to pre-compute the settlement
|
|
7
|
-
* `amount` so it can chain `createPendingSettlement` in the same transaction
|
|
8
|
-
* as `settleCallsV2` (DisputeWindow flow). Keeping the math in one place
|
|
9
|
-
* here ensures the SDK stays byte-for-byte aligned with the program; if the
|
|
10
|
-
* on-chain curve algorithm ever changes, this file is the single source of
|
|
11
|
-
* truth on the client.
|
|
12
|
-
*
|
|
13
|
-
* @category Utilities
|
|
14
|
-
* @since v0.13.0
|
|
15
|
-
* @packageDocumentation
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import { BN } from "@coral-xyz/anchor";
|
|
19
|
-
import type { VolumeCurveBreakpoint } from "../types/common";
|
|
20
|
-
|
|
21
|
-
const U64_MAX = new BN("18446744073709551615");
|
|
22
|
-
|
|
23
|
-
function checkedMul(a: BN, b: BN): BN {
|
|
24
|
-
const r = a.mul(b);
|
|
25
|
-
if (r.gt(U64_MAX)) {
|
|
26
|
-
throw new Error(
|
|
27
|
-
`volume-curve: u64 overflow on multiply (${a.toString()} * ${b.toString()})`,
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
return r;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function checkedAdd(a: BN, b: BN): BN {
|
|
34
|
-
const r = a.add(b);
|
|
35
|
-
if (r.gt(U64_MAX)) {
|
|
36
|
-
throw new Error(
|
|
37
|
-
`volume-curve: u64 overflow on add (${a.toString()} + ${b.toString()})`,
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
return r;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @function calculateSettleAmount
|
|
45
|
-
* @description Compute the lamport (or token base-unit) amount the on-chain
|
|
46
|
-
* `settle_calls_v2` handler will charge for `calls` calls, given the escrow's
|
|
47
|
-
* `pricePerCall`, `volumeCurve`, and the current settled+pending counter.
|
|
48
|
-
*
|
|
49
|
-
* Mirrors the exact algorithm of `calculate_settle_amount` in
|
|
50
|
-
* `escrow_v2.rs` (v0.7+):
|
|
51
|
-
*
|
|
52
|
-
* ```rust
|
|
53
|
-
* if curve.is_empty() { calls * base_price } else { walk-the-curve }
|
|
54
|
-
* ```
|
|
55
|
-
*
|
|
56
|
-
* Walks the curve from `cursor = totalCallsBefore` and at each cursor
|
|
57
|
-
* position picks the breakpoint price whose `afterCalls` threshold the
|
|
58
|
-
* cursor has passed. Calls are charged at the active price up to the next
|
|
59
|
-
* threshold, then the cursor advances and the loop repeats until all
|
|
60
|
-
* `calls` are accounted for.
|
|
61
|
-
*
|
|
62
|
-
* @param basePrice - Escrow's `pricePerCall` (BN, u64 lamports/base-units).
|
|
63
|
-
* @param curve - The escrow's `volumeCurve` array (may be empty).
|
|
64
|
-
* @param totalCallsBefore - `escrow.totalCallsSettled + escrow.pendingCalls`
|
|
65
|
-
* AT THE MOMENT `settleCallsV2` runs on-chain.
|
|
66
|
-
* @param calls - Number of calls being settled in this batch.
|
|
67
|
-
* @returns The amount the on-chain handler will compute (BN, u64).
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```ts
|
|
71
|
-
* import { calculateSettleAmount } from "@oobe-protocol-labs/synapse-sap-sdk";
|
|
72
|
-
*
|
|
73
|
-
* const amount = calculateSettleAmount(
|
|
74
|
-
* escrow.pricePerCall,
|
|
75
|
-
* escrow.volumeCurve,
|
|
76
|
-
* escrow.totalCallsSettled.add(escrow.pendingCalls),
|
|
77
|
-
* new BN(5),
|
|
78
|
-
* );
|
|
79
|
-
* ```
|
|
80
|
-
*
|
|
81
|
-
* @since v0.13.0
|
|
82
|
-
*/
|
|
83
|
-
export function calculateSettleAmount(
|
|
84
|
-
basePrice: BN,
|
|
85
|
-
curve: VolumeCurveBreakpoint[],
|
|
86
|
-
totalCallsBefore: BN,
|
|
87
|
-
calls: BN,
|
|
88
|
-
): BN {
|
|
89
|
-
if (calls.isZero()) return new BN(0);
|
|
90
|
-
if (!curve || curve.length === 0) {
|
|
91
|
-
return checkedMul(calls, basePrice);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
let amount = new BN(0);
|
|
95
|
-
let remaining = calls.clone();
|
|
96
|
-
let cursor = totalCallsBefore.clone();
|
|
97
|
-
|
|
98
|
-
while (remaining.gtn(0)) {
|
|
99
|
-
let currentPrice = basePrice;
|
|
100
|
-
let nextThreshold: BN | null = null;
|
|
101
|
-
|
|
102
|
-
for (const bp of curve) {
|
|
103
|
-
const threshold = new BN(bp.afterCalls);
|
|
104
|
-
if (cursor.gte(threshold)) {
|
|
105
|
-
currentPrice = bp.pricePerCall;
|
|
106
|
-
} else {
|
|
107
|
-
nextThreshold = threshold;
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
let callsAtPrice: BN;
|
|
113
|
-
if (nextThreshold) {
|
|
114
|
-
const room = nextThreshold.sub(cursor);
|
|
115
|
-
callsAtPrice = BN.min(remaining, room.isNeg() ? new BN(0) : room);
|
|
116
|
-
if (callsAtPrice.isZero()) {
|
|
117
|
-
// Defensive: shouldn't happen because cursor < nextThreshold by
|
|
118
|
-
// the `else` branch above, but guard anyway.
|
|
119
|
-
callsAtPrice = remaining;
|
|
120
|
-
}
|
|
121
|
-
} else {
|
|
122
|
-
callsAtPrice = remaining;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
amount = checkedAdd(amount, checkedMul(callsAtPrice, currentPrice));
|
|
126
|
-
remaining = remaining.sub(callsAtPrice);
|
|
127
|
-
cursor = cursor.add(callsAtPrice);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return amount;
|
|
131
|
-
}
|
package/src/utils/x402-direct.ts
DELETED
|
@@ -1,370 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module utils/x402-direct
|
|
3
|
-
* @description Recognize x402 direct SPL token payments on an agent's ATA
|
|
4
|
-
* by scanning transaction history and filtering for x402 patterns.
|
|
5
|
-
*
|
|
6
|
-
* @category Utils
|
|
7
|
-
* @since v0.6.4
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
type Connection,
|
|
12
|
-
PublicKey,
|
|
13
|
-
type ParsedTransactionWithMeta,
|
|
14
|
-
type ConfirmedSignatureInfo,
|
|
15
|
-
} from "@solana/web3.js";
|
|
16
|
-
import { sha256 } from "../utils";
|
|
17
|
-
|
|
18
|
-
// ═══════════════════════════════════════════════════════════════════
|
|
19
|
-
// Types
|
|
20
|
-
// ═══════════════════════════════════════════════════════════════════
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @interface SettlementPayload
|
|
24
|
-
* @description Settlement metadata from the merchant's PAYMENT-RESPONSE.
|
|
25
|
-
* @category Utils
|
|
26
|
-
* @since v0.6.4
|
|
27
|
-
*/
|
|
28
|
-
export interface SettlementPayload {
|
|
29
|
-
/** SHA-256 service hash. */
|
|
30
|
-
readonly serviceHash: string;
|
|
31
|
-
/** Resource identifier. */
|
|
32
|
-
readonly resource: string;
|
|
33
|
-
/** Agent wallet (base58). */
|
|
34
|
-
readonly agentWallet: string;
|
|
35
|
-
/** Depositor wallet (base58). */
|
|
36
|
-
readonly depositorWallet: string;
|
|
37
|
-
/** Amount in smallest unit. */
|
|
38
|
-
readonly amount: string;
|
|
39
|
-
/** Service timestamp. */
|
|
40
|
-
readonly timestamp: number;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @interface X402DirectPayment
|
|
45
|
-
* @description A recognized x402 direct SPL transfer on an agent's ATA.
|
|
46
|
-
* @category Utils
|
|
47
|
-
* @since v0.6.4
|
|
48
|
-
*/
|
|
49
|
-
export interface X402DirectPayment {
|
|
50
|
-
/** Transaction signature. */
|
|
51
|
-
readonly signature: string;
|
|
52
|
-
/** Transfer amount (in smallest token unit). */
|
|
53
|
-
readonly amount: bigint;
|
|
54
|
-
/** Source ATA (payer). */
|
|
55
|
-
readonly payerAta: PublicKey;
|
|
56
|
-
/** Destination ATA (payTo / agent). */
|
|
57
|
-
readonly payeeAta: PublicKey;
|
|
58
|
-
/** Token mint used for transfer. */
|
|
59
|
-
readonly mint: PublicKey;
|
|
60
|
-
/** Memo data (if a Memo instruction was included). */
|
|
61
|
-
readonly memo: string | null;
|
|
62
|
-
/** Matched settlement payload (if server-side verification is available). */
|
|
63
|
-
readonly settlement: SettlementPayload | null;
|
|
64
|
-
/** Block time (unix seconds). */
|
|
65
|
-
readonly blockTime: number | null;
|
|
66
|
-
/** Slot number. */
|
|
67
|
-
readonly slot: number;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* @interface GetX402DirectOptions
|
|
72
|
-
* @description Options for {@link getX402DirectPayments}.
|
|
73
|
-
* @category Utils
|
|
74
|
-
* @since v0.6.4
|
|
75
|
-
*/
|
|
76
|
-
export interface GetX402DirectOptions {
|
|
77
|
-
/** Max signatures to scan (default: 100). */
|
|
78
|
-
readonly limit?: number;
|
|
79
|
-
/** Only return transfers from this specific payer. */
|
|
80
|
-
readonly filterPayer?: PublicKey;
|
|
81
|
-
/** Known settlements from server-side PAYMENT-RESPONSE logs.
|
|
82
|
-
* Used for deterministic hash matching. */
|
|
83
|
-
readonly knownSettlements?: SettlementPayload[];
|
|
84
|
-
/** Only include payments that match x402 memo prefix. Default: false. */
|
|
85
|
-
readonly requireMemo?: boolean;
|
|
86
|
-
/** Scan before this TX signature (pagination). */
|
|
87
|
-
readonly before?: string;
|
|
88
|
-
/** Scan after this TX signature (pagination). */
|
|
89
|
-
readonly until?: string;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// ═══════════════════════════════════════════════════════════════════
|
|
93
|
-
// Core
|
|
94
|
-
// ═══════════════════════════════════════════════════════════════════
|
|
95
|
-
|
|
96
|
-
/** Recognized x402 memo prefixes. */
|
|
97
|
-
const X402_MEMO_PREFIXES = ["x402:", "SAP-x402:", "x402-direct:"];
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* @name extractSplTransfer
|
|
101
|
-
* @description Extract SPL Token transfer details from a parsed transaction.
|
|
102
|
-
*
|
|
103
|
-
* Looks for `transfer` or `transferChecked` inner instructions on the
|
|
104
|
-
* Token Program and returns source/dest/amount/mint.
|
|
105
|
-
*
|
|
106
|
-
* @internal
|
|
107
|
-
*/
|
|
108
|
-
function extractSplTransfer(
|
|
109
|
-
tx: ParsedTransactionWithMeta,
|
|
110
|
-
payToAta: PublicKey,
|
|
111
|
-
): {
|
|
112
|
-
amount: bigint;
|
|
113
|
-
source: PublicKey;
|
|
114
|
-
destination: PublicKey;
|
|
115
|
-
mint: PublicKey;
|
|
116
|
-
} | null {
|
|
117
|
-
if (!tx.meta?.innerInstructions && !tx.transaction.message.instructions) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Check all instructions (outer + inner)
|
|
122
|
-
const allIxs = [
|
|
123
|
-
...tx.transaction.message.instructions,
|
|
124
|
-
...(tx.meta?.innerInstructions?.flatMap((g) => g.instructions) ?? []),
|
|
125
|
-
];
|
|
126
|
-
|
|
127
|
-
for (const ix of allIxs) {
|
|
128
|
-
// Only process parsed instructions with known program
|
|
129
|
-
if (!("parsed" in ix) || !("program" in ix)) continue;
|
|
130
|
-
const parsed = ix as { parsed: Record<string, unknown>; program: string };
|
|
131
|
-
|
|
132
|
-
if (parsed.program !== "spl-token") continue;
|
|
133
|
-
|
|
134
|
-
const info = parsed.parsed as {
|
|
135
|
-
type?: string;
|
|
136
|
-
info?: {
|
|
137
|
-
source?: string;
|
|
138
|
-
destination?: string;
|
|
139
|
-
amount?: string;
|
|
140
|
-
tokenAmount?: { amount?: string };
|
|
141
|
-
mint?: string;
|
|
142
|
-
authority?: string;
|
|
143
|
-
};
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
if (
|
|
147
|
-
info.type !== "transfer" &&
|
|
148
|
-
info.type !== "transferChecked"
|
|
149
|
-
) {
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const transferInfo = info.info;
|
|
154
|
-
if (!transferInfo?.source || !transferInfo?.destination) continue;
|
|
155
|
-
|
|
156
|
-
// Check destination matches our payTo ATA
|
|
157
|
-
const destPk = new PublicKey(transferInfo.destination);
|
|
158
|
-
if (!destPk.equals(payToAta)) continue;
|
|
159
|
-
|
|
160
|
-
const amountStr =
|
|
161
|
-
transferInfo.amount ?? transferInfo.tokenAmount?.amount ?? "0";
|
|
162
|
-
|
|
163
|
-
return {
|
|
164
|
-
amount: BigInt(amountStr),
|
|
165
|
-
source: new PublicKey(transferInfo.source),
|
|
166
|
-
destination: destPk,
|
|
167
|
-
mint: transferInfo.mint ? new PublicKey(transferInfo.mint) : destPk, // fallback
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return null;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* @name extractMemo
|
|
176
|
-
* @description Extract memo data from a parsed transaction.
|
|
177
|
-
* @internal
|
|
178
|
-
*/
|
|
179
|
-
function extractMemo(tx: ParsedTransactionWithMeta): string | null {
|
|
180
|
-
const allIxs = [
|
|
181
|
-
...tx.transaction.message.instructions,
|
|
182
|
-
...(tx.meta?.innerInstructions?.flatMap((g) => g.instructions) ?? []),
|
|
183
|
-
];
|
|
184
|
-
|
|
185
|
-
for (const ix of allIxs) {
|
|
186
|
-
if (!("parsed" in ix) || !("program" in ix)) continue;
|
|
187
|
-
const parsed = ix as { parsed: unknown; program: string };
|
|
188
|
-
if (parsed.program === "spl-memo" && typeof parsed.parsed === "string") {
|
|
189
|
-
return parsed.parsed;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// Also check log messages for memo
|
|
194
|
-
if (tx.meta?.logMessages) {
|
|
195
|
-
for (const log of tx.meta.logMessages) {
|
|
196
|
-
if (log.startsWith("Program log: Memo")) {
|
|
197
|
-
const memoMatch = log.match(/Memo \(len \d+\): "(.*?)"/);
|
|
198
|
-
if (memoMatch?.[1]) return memoMatch[1];
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return null;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* @name matchesX402Pattern
|
|
208
|
-
* @description Check if a transfer matches an x402 payment pattern.
|
|
209
|
-
*
|
|
210
|
-
* Matches if:
|
|
211
|
-
* - A memo with recognized x402 prefix is present, OR
|
|
212
|
-
* - The transfer matches a known settlement payload (deterministic hash), OR
|
|
213
|
-
* - `requireMemo` is false (any SPL transfer to the ATA is included)
|
|
214
|
-
*
|
|
215
|
-
* @internal
|
|
216
|
-
*/
|
|
217
|
-
function matchesX402Pattern(
|
|
218
|
-
transfer: { amount: bigint; source: PublicKey },
|
|
219
|
-
memo: string | null,
|
|
220
|
-
knownSettlements: SettlementPayload[],
|
|
221
|
-
requireMemo: boolean,
|
|
222
|
-
): SettlementPayload | true | false {
|
|
223
|
-
// 1. Check memo prefix
|
|
224
|
-
if (memo) {
|
|
225
|
-
for (const prefix of X402_MEMO_PREFIXES) {
|
|
226
|
-
if (memo.startsWith(prefix)) return true;
|
|
227
|
-
}
|
|
228
|
-
// Try base64 JSON parse for embedded x402 payload
|
|
229
|
-
try {
|
|
230
|
-
const decoded = Buffer.from(memo, "base64").toString("utf-8");
|
|
231
|
-
const parsed = JSON.parse(decoded);
|
|
232
|
-
if (parsed.protocol === "x402" || parsed.protocol === "SAP-x402") {
|
|
233
|
-
return true;
|
|
234
|
-
}
|
|
235
|
-
} catch {
|
|
236
|
-
// Not base64 JSON — ignore
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// 2. Match against known settlements (deterministic hash)
|
|
241
|
-
for (const settlement of knownSettlements) {
|
|
242
|
-
const expected = BigInt(settlement.amount);
|
|
243
|
-
if (transfer.amount !== expected) continue;
|
|
244
|
-
|
|
245
|
-
// Deterministic hash: sha256(agentWallet + depositor + amount + timestamp)
|
|
246
|
-
const hashInput =
|
|
247
|
-
settlement.agentWallet +
|
|
248
|
-
settlement.depositorWallet +
|
|
249
|
-
settlement.amount +
|
|
250
|
-
settlement.timestamp.toString();
|
|
251
|
-
const expectedHash = Buffer.from(sha256(hashInput)).toString("hex");
|
|
252
|
-
const serviceHash = settlement.serviceHash;
|
|
253
|
-
|
|
254
|
-
if (expectedHash === serviceHash) return settlement;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// 3. If requireMemo is false, accept any SPL transfer to the ATA
|
|
258
|
-
if (!requireMemo) return true;
|
|
259
|
-
|
|
260
|
-
return false;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* @name getX402DirectPayments
|
|
265
|
-
* @description Scan an agent's ATA for x402 direct payments.
|
|
266
|
-
*
|
|
267
|
-
* Fetches recent transaction signatures for the given `payTo` ATA,
|
|
268
|
-
* inspects each transaction for SPL token transfers, and filters
|
|
269
|
-
* for x402 payment patterns (memo prefix, settlement hash match, etc.).
|
|
270
|
-
*
|
|
271
|
-
* @param connection - Solana RPC connection.
|
|
272
|
-
* @param payToAta - The agent's receiving ATA (e.g. USDC ATA of Syra).
|
|
273
|
-
* @param opts - Filter and pagination options.
|
|
274
|
-
* @returns Array of recognized x402 direct payments, newest first.
|
|
275
|
-
*
|
|
276
|
-
* @category Utils
|
|
277
|
-
* @since v0.6.4
|
|
278
|
-
*
|
|
279
|
-
* @example
|
|
280
|
-
* ```ts
|
|
281
|
-
* import { getX402DirectPayments, findATA } from "@oobe-protocol-labs/synapse-sap-sdk";
|
|
282
|
-
*
|
|
283
|
-
* const USDC_MINT = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
|
|
284
|
-
* const payToAta = findATA(agentWallet, USDC_MINT);
|
|
285
|
-
*
|
|
286
|
-
* const payments = await getX402DirectPayments(connection, payToAta, {
|
|
287
|
-
* limit: 50,
|
|
288
|
-
* knownSettlements: savedSettlements, // from your API PAYMENT-RESPONSE logs
|
|
289
|
-
* });
|
|
290
|
-
*
|
|
291
|
-
* for (const p of payments) {
|
|
292
|
-
* console.log(`${p.signature}: ${p.amount} from ${p.payerAta.toBase58()}`);
|
|
293
|
-
* if (p.settlement) {
|
|
294
|
-
* console.log(` Matched settlement: ${p.settlement.serviceHash}`);
|
|
295
|
-
* }
|
|
296
|
-
* }
|
|
297
|
-
* ```
|
|
298
|
-
*/
|
|
299
|
-
export async function getX402DirectPayments(
|
|
300
|
-
connection: Connection,
|
|
301
|
-
payToAta: PublicKey,
|
|
302
|
-
opts?: GetX402DirectOptions,
|
|
303
|
-
): Promise<X402DirectPayment[]> {
|
|
304
|
-
const limit = opts?.limit ?? 100;
|
|
305
|
-
const knownSettlements = opts?.knownSettlements ?? [];
|
|
306
|
-
const requireMemo = opts?.requireMemo ?? false;
|
|
307
|
-
|
|
308
|
-
// 1. Fetch signatures
|
|
309
|
-
const sigOpts: {
|
|
310
|
-
limit: number;
|
|
311
|
-
before?: string;
|
|
312
|
-
until?: string;
|
|
313
|
-
} = { limit };
|
|
314
|
-
if (opts?.before) sigOpts.before = opts.before;
|
|
315
|
-
if (opts?.until) sigOpts.until = opts.until;
|
|
316
|
-
|
|
317
|
-
const sigs: ConfirmedSignatureInfo[] =
|
|
318
|
-
await connection.getSignaturesForAddress(payToAta, sigOpts);
|
|
319
|
-
|
|
320
|
-
if (sigs.length === 0) return [];
|
|
321
|
-
|
|
322
|
-
// 2. Fetch transactions (batch with getParsedTransactions if available)
|
|
323
|
-
const txs = await connection.getParsedTransactions(
|
|
324
|
-
sigs.map((s) => s.signature),
|
|
325
|
-
{ maxSupportedTransactionVersion: 0 },
|
|
326
|
-
);
|
|
327
|
-
|
|
328
|
-
// 3. Extract and filter
|
|
329
|
-
const results: X402DirectPayment[] = [];
|
|
330
|
-
|
|
331
|
-
for (let i = 0; i < txs.length; i++) {
|
|
332
|
-
const tx = txs[i];
|
|
333
|
-
if (!tx) continue;
|
|
334
|
-
|
|
335
|
-
// Extract SPL transfer to our ATA
|
|
336
|
-
const transfer = extractSplTransfer(tx, payToAta);
|
|
337
|
-
if (!transfer) continue;
|
|
338
|
-
|
|
339
|
-
// Filter by payer if specified
|
|
340
|
-
if (opts?.filterPayer && !transfer.source.equals(opts.filterPayer)) {
|
|
341
|
-
continue;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
// Extract memo
|
|
345
|
-
const memo = extractMemo(tx);
|
|
346
|
-
|
|
347
|
-
// Match x402 pattern
|
|
348
|
-
const match = matchesX402Pattern(
|
|
349
|
-
transfer,
|
|
350
|
-
memo,
|
|
351
|
-
knownSettlements,
|
|
352
|
-
requireMemo,
|
|
353
|
-
);
|
|
354
|
-
if (match === false) continue;
|
|
355
|
-
|
|
356
|
-
results.push({
|
|
357
|
-
signature: sigs[i]!.signature,
|
|
358
|
-
amount: transfer.amount,
|
|
359
|
-
payerAta: transfer.source,
|
|
360
|
-
payeeAta: transfer.destination,
|
|
361
|
-
mint: transfer.mint,
|
|
362
|
-
memo,
|
|
363
|
-
settlement: typeof match === "object" ? match : null,
|
|
364
|
-
blockTime: tx.blockTime ?? null,
|
|
365
|
-
slot: tx.slot,
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
return results;
|
|
370
|
-
}
|