@agirails/sdk 2.0.1-beta → 2.0.2
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/LICENSE +190 -0
- package/README.md +116 -108
- package/bin/actp +10 -0
- package/dist/ACTPClient.d.ts +456 -33
- package/dist/ACTPClient.d.ts.map +1 -1
- package/dist/ACTPClient.js +477 -93
- package/dist/ACTPClient.js.map +1 -1
- package/dist/abi/AgentRegistry.json +782 -0
- package/dist/abi/EscrowVault.json +106 -38
- package/dist/abi/IdentityRegistry.json +316 -0
- package/dist/adapters/BaseAdapter.d.ts +231 -0
- package/dist/adapters/BaseAdapter.d.ts.map +1 -0
- package/dist/adapters/BaseAdapter.js +393 -0
- package/dist/adapters/BaseAdapter.js.map +1 -0
- package/dist/adapters/BeginnerAdapter.d.ts +152 -0
- package/dist/adapters/BeginnerAdapter.d.ts.map +1 -0
- package/dist/adapters/BeginnerAdapter.js +168 -0
- package/dist/adapters/BeginnerAdapter.js.map +1 -0
- package/dist/adapters/IntermediateAdapter.d.ts +211 -0
- package/dist/adapters/IntermediateAdapter.d.ts.map +1 -0
- package/dist/adapters/IntermediateAdapter.js +260 -0
- package/dist/adapters/IntermediateAdapter.js.map +1 -0
- package/dist/adapters/index.d.ts +15 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +26 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/builders/DeliveryProofBuilder.d.ts +60 -1
- package/dist/builders/DeliveryProofBuilder.d.ts.map +1 -1
- package/dist/builders/DeliveryProofBuilder.js +81 -5
- package/dist/builders/DeliveryProofBuilder.js.map +1 -1
- package/dist/builders/QuoteBuilder.d.ts +101 -0
- package/dist/builders/QuoteBuilder.d.ts.map +1 -1
- package/dist/builders/QuoteBuilder.js +120 -3
- package/dist/builders/QuoteBuilder.js.map +1 -1
- package/dist/builders/index.d.ts +4 -0
- package/dist/builders/index.d.ts.map +1 -1
- package/dist/builders/index.js +4 -0
- package/dist/builders/index.js.map +1 -1
- package/dist/cli/commands/balance.d.ts +13 -0
- package/dist/cli/commands/balance.d.ts.map +1 -0
- package/dist/cli/commands/balance.js +89 -0
- package/dist/cli/commands/balance.js.map +1 -0
- package/dist/cli/commands/batch.d.ts +24 -0
- package/dist/cli/commands/batch.d.ts.map +1 -0
- package/dist/cli/commands/batch.js +424 -0
- package/dist/cli/commands/batch.js.map +1 -0
- package/dist/cli/commands/config.d.ts +13 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +192 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/init.d.ts +19 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +143 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/mint.d.ts +13 -0
- package/dist/cli/commands/mint.d.ts.map +1 -0
- package/dist/cli/commands/mint.js +91 -0
- package/dist/cli/commands/mint.js.map +1 -0
- package/dist/cli/commands/pay.d.ts +18 -0
- package/dist/cli/commands/pay.d.ts.map +1 -0
- package/dist/cli/commands/pay.js +87 -0
- package/dist/cli/commands/pay.js.map +1 -0
- package/dist/cli/commands/simulate.d.ts +32 -0
- package/dist/cli/commands/simulate.d.ts.map +1 -0
- package/dist/cli/commands/simulate.js +290 -0
- package/dist/cli/commands/simulate.js.map +1 -0
- package/dist/cli/commands/time.d.ts +29 -0
- package/dist/cli/commands/time.d.ts.map +1 -0
- package/dist/cli/commands/time.js +252 -0
- package/dist/cli/commands/time.js.map +1 -0
- package/dist/cli/commands/tx.d.ts +16 -0
- package/dist/cli/commands/tx.d.ts.map +1 -0
- package/dist/cli/commands/tx.js +379 -0
- package/dist/cli/commands/tx.js.map +1 -0
- package/dist/cli/commands/watch.d.ts +20 -0
- package/dist/cli/commands/watch.d.ts.map +1 -0
- package/dist/cli/commands/watch.js +160 -0
- package/dist/cli/commands/watch.js.map +1 -0
- package/dist/cli/index.d.ts +17 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +104 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/utils/client.d.ts +70 -0
- package/dist/cli/utils/client.d.ts.map +1 -0
- package/dist/cli/utils/client.js +240 -0
- package/dist/cli/utils/client.js.map +1 -0
- package/dist/cli/utils/config.d.ts +91 -0
- package/dist/cli/utils/config.d.ts.map +1 -0
- package/dist/cli/utils/config.js +240 -0
- package/dist/cli/utils/config.js.map +1 -0
- package/dist/cli/utils/output.d.ts +174 -0
- package/dist/cli/utils/output.d.ts.map +1 -0
- package/dist/cli/utils/output.js +380 -0
- package/dist/cli/utils/output.js.map +1 -0
- package/dist/config/networks.d.ts +28 -0
- package/dist/config/networks.d.ts.map +1 -1
- package/dist/config/networks.js +60 -12
- package/dist/config/networks.js.map +1 -1
- package/dist/errors/index.d.ts +165 -2
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +260 -2
- package/dist/errors/index.js.map +1 -1
- package/dist/index.d.ts +61 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +141 -36
- package/dist/index.js.map +1 -1
- package/dist/level0/Provider.d.ts +106 -0
- package/dist/level0/Provider.d.ts.map +1 -0
- package/dist/level0/Provider.js +10 -0
- package/dist/level0/Provider.js.map +1 -0
- package/dist/level0/ServiceDirectory.d.ts +74 -0
- package/dist/level0/ServiceDirectory.d.ts.map +1 -0
- package/dist/level0/ServiceDirectory.js +122 -0
- package/dist/level0/ServiceDirectory.js.map +1 -0
- package/dist/level0/index.d.ts +10 -0
- package/dist/level0/index.d.ts.map +1 -0
- package/dist/level0/index.js +15 -0
- package/dist/level0/index.js.map +1 -0
- package/dist/level0/provide.d.ts +51 -0
- package/dist/level0/provide.d.ts.map +1 -0
- package/dist/level0/provide.js +113 -0
- package/dist/level0/provide.js.map +1 -0
- package/dist/level0/request.d.ts +53 -0
- package/dist/level0/request.d.ts.map +1 -0
- package/dist/level0/request.js +462 -0
- package/dist/level0/request.js.map +1 -0
- package/dist/level1/Agent.d.ts +472 -0
- package/dist/level1/Agent.d.ts.map +1 -0
- package/dist/level1/Agent.js +1091 -0
- package/dist/level1/Agent.js.map +1 -0
- package/dist/level1/index.d.ts +10 -0
- package/dist/level1/index.d.ts.map +1 -0
- package/dist/level1/index.js +30 -0
- package/dist/level1/index.js.map +1 -0
- package/dist/level1/pricing/PriceCalculator.d.ts +62 -0
- package/dist/level1/pricing/PriceCalculator.d.ts.map +1 -0
- package/dist/level1/pricing/PriceCalculator.js +237 -0
- package/dist/level1/pricing/PriceCalculator.js.map +1 -0
- package/dist/level1/pricing/PricingStrategy.d.ts +179 -0
- package/dist/level1/pricing/PricingStrategy.d.ts.map +1 -0
- package/dist/level1/pricing/PricingStrategy.js +11 -0
- package/dist/level1/pricing/PricingStrategy.js.map +1 -0
- package/dist/level1/types/Job.d.ts +166 -0
- package/dist/level1/types/Job.d.ts.map +1 -0
- package/dist/level1/types/Job.js +11 -0
- package/dist/level1/types/Job.js.map +1 -0
- package/dist/level1/types/Options.d.ts +258 -0
- package/dist/level1/types/Options.d.ts.map +1 -0
- package/dist/level1/types/Options.js +8 -0
- package/dist/level1/types/Options.js.map +1 -0
- package/dist/level1/types/index.d.ts +8 -0
- package/dist/level1/types/index.d.ts.map +1 -0
- package/dist/level1/types/index.js +8 -0
- package/dist/level1/types/index.js.map +1 -0
- package/dist/protocol/ACTPKernel.d.ts +229 -2
- package/dist/protocol/ACTPKernel.d.ts.map +1 -1
- package/dist/protocol/ACTPKernel.js +367 -33
- package/dist/protocol/ACTPKernel.js.map +1 -1
- package/dist/protocol/AgentRegistry.d.ts +177 -0
- package/dist/protocol/AgentRegistry.d.ts.map +1 -0
- package/dist/protocol/AgentRegistry.js +449 -0
- package/dist/protocol/AgentRegistry.js.map +1 -0
- package/dist/protocol/DIDManager.d.ts +289 -0
- package/dist/protocol/DIDManager.d.ts.map +1 -0
- package/dist/protocol/DIDManager.js +481 -0
- package/dist/protocol/DIDManager.js.map +1 -0
- package/dist/protocol/DIDResolver.d.ts +236 -0
- package/dist/protocol/DIDResolver.d.ts.map +1 -0
- package/dist/protocol/DIDResolver.js +495 -0
- package/dist/protocol/DIDResolver.js.map +1 -0
- package/dist/protocol/EASHelper.d.ts +57 -2
- package/dist/protocol/EASHelper.d.ts.map +1 -1
- package/dist/protocol/EASHelper.js +230 -37
- package/dist/protocol/EASHelper.js.map +1 -1
- package/dist/protocol/EscrowVault.d.ts +93 -2
- package/dist/protocol/EscrowVault.d.ts.map +1 -1
- package/dist/protocol/EscrowVault.js +122 -33
- package/dist/protocol/EscrowVault.js.map +1 -1
- package/dist/protocol/EventMonitor.d.ts +45 -1
- package/dist/protocol/EventMonitor.d.ts.map +1 -1
- package/dist/protocol/EventMonitor.js +64 -8
- package/dist/protocol/EventMonitor.js.map +1 -1
- package/dist/protocol/MessageSigner.d.ts +116 -2
- package/dist/protocol/MessageSigner.d.ts.map +1 -1
- package/dist/protocol/MessageSigner.js +215 -9
- package/dist/protocol/MessageSigner.js.map +1 -1
- package/dist/protocol/ProofGenerator.d.ts +93 -0
- package/dist/protocol/ProofGenerator.d.ts.map +1 -1
- package/dist/protocol/ProofGenerator.js +194 -9
- package/dist/protocol/ProofGenerator.js.map +1 -1
- package/dist/protocol/QuoteBuilder.d.ts +8 -0
- package/dist/protocol/QuoteBuilder.d.ts.map +1 -1
- package/dist/protocol/QuoteBuilder.js +8 -0
- package/dist/protocol/QuoteBuilder.js.map +1 -1
- package/dist/runtime/BlockchainRuntime.d.ts +360 -0
- package/dist/runtime/BlockchainRuntime.d.ts.map +1 -0
- package/dist/runtime/BlockchainRuntime.js +767 -0
- package/dist/runtime/BlockchainRuntime.js.map +1 -0
- package/dist/runtime/IACTPRuntime.d.ts +271 -0
- package/dist/runtime/IACTPRuntime.d.ts.map +1 -0
- package/dist/runtime/IACTPRuntime.js +15 -0
- package/dist/runtime/IACTPRuntime.js.map +1 -0
- package/dist/runtime/MockRuntime.d.ts +445 -0
- package/dist/runtime/MockRuntime.d.ts.map +1 -0
- package/dist/runtime/MockRuntime.js +1065 -0
- package/dist/runtime/MockRuntime.js.map +1 -0
- package/dist/runtime/MockStateManager.d.ts +233 -0
- package/dist/runtime/MockStateManager.d.ts.map +1 -0
- package/dist/runtime/MockStateManager.js +533 -0
- package/dist/runtime/MockStateManager.js.map +1 -0
- package/dist/runtime/index.d.ts +14 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +42 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/types/MockState.d.ts +167 -0
- package/dist/runtime/types/MockState.d.ts.map +1 -0
- package/dist/runtime/types/MockState.js +43 -0
- package/dist/runtime/types/MockState.js.map +1 -0
- package/dist/types/agent.d.ts +76 -0
- package/dist/types/agent.d.ts.map +1 -0
- package/dist/types/agent.js +8 -0
- package/dist/types/agent.js.map +1 -0
- package/dist/types/did.d.ts +192 -0
- package/dist/types/did.d.ts.map +1 -0
- package/dist/types/did.js +38 -0
- package/dist/types/did.js.map +1 -0
- package/dist/types/eip712.d.ts +34 -0
- package/dist/types/eip712.d.ts.map +1 -1
- package/dist/types/eip712.js +31 -5
- package/dist/types/eip712.js.map +1 -1
- package/dist/types/escrow.d.ts +17 -10
- package/dist/types/escrow.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/message.d.ts +32 -0
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js +4 -0
- package/dist/types/message.js.map +1 -1
- package/dist/types/state.d.ts +28 -0
- package/dist/types/state.d.ts.map +1 -1
- package/dist/types/state.js +37 -6
- package/dist/types/state.js.map +1 -1
- package/dist/types/transaction.d.ts +17 -0
- package/dist/types/transaction.d.ts.map +1 -1
- package/dist/utils/ErrorRecoveryGuide.d.ts +125 -0
- package/dist/utils/ErrorRecoveryGuide.d.ts.map +1 -0
- package/dist/utils/ErrorRecoveryGuide.js +579 -0
- package/dist/utils/ErrorRecoveryGuide.js.map +1 -0
- package/dist/utils/Helpers.d.ts +453 -0
- package/dist/utils/Helpers.d.ts.map +1 -0
- package/dist/utils/Helpers.js +623 -0
- package/dist/utils/Helpers.js.map +1 -0
- package/dist/utils/IPFSClient.d.ts +113 -0
- package/dist/utils/IPFSClient.d.ts.map +1 -1
- package/dist/utils/IPFSClient.js +128 -7
- package/dist/utils/IPFSClient.js.map +1 -1
- package/dist/utils/Logger.d.ts +195 -0
- package/dist/utils/Logger.d.ts.map +1 -0
- package/dist/utils/Logger.js +382 -0
- package/dist/utils/Logger.js.map +1 -0
- package/dist/utils/NonceManager.d.ts +234 -1
- package/dist/utils/NonceManager.d.ts.map +1 -1
- package/dist/utils/NonceManager.js +372 -7
- package/dist/utils/NonceManager.js.map +1 -1
- package/dist/utils/RateLimiter.d.ts +253 -0
- package/dist/utils/RateLimiter.d.ts.map +1 -0
- package/dist/utils/RateLimiter.js +424 -0
- package/dist/utils/RateLimiter.js.map +1 -0
- package/dist/utils/ReceivedNonceTracker.d.ts +175 -0
- package/dist/utils/ReceivedNonceTracker.d.ts.map +1 -1
- package/dist/utils/ReceivedNonceTracker.js +261 -5
- package/dist/utils/ReceivedNonceTracker.js.map +1 -1
- package/dist/utils/SDKLifecycle.d.ts +156 -0
- package/dist/utils/SDKLifecycle.d.ts.map +1 -0
- package/dist/utils/SDKLifecycle.js +347 -0
- package/dist/utils/SDKLifecycle.js.map +1 -0
- package/dist/utils/SecureNonce.d.ts +57 -0
- package/dist/utils/SecureNonce.d.ts.map +1 -0
- package/dist/utils/SecureNonce.js +80 -0
- package/dist/utils/SecureNonce.js.map +1 -0
- package/dist/utils/Semaphore.d.ts +123 -0
- package/dist/utils/Semaphore.d.ts.map +1 -0
- package/dist/utils/Semaphore.js +247 -0
- package/dist/utils/Semaphore.js.map +1 -0
- package/dist/utils/UsedAttestationTracker.d.ts +167 -0
- package/dist/utils/UsedAttestationTracker.d.ts.map +1 -0
- package/dist/utils/UsedAttestationTracker.js +309 -0
- package/dist/utils/UsedAttestationTracker.js.map +1 -0
- package/dist/utils/canonicalJson.d.ts +22 -0
- package/dist/utils/canonicalJson.d.ts.map +1 -1
- package/dist/utils/canonicalJson.js +26 -3
- package/dist/utils/canonicalJson.js.map +1 -1
- package/dist/utils/computeTypeHash.d.ts +14 -0
- package/dist/utils/computeTypeHash.d.ts.map +1 -1
- package/dist/utils/computeTypeHash.js +19 -2
- package/dist/utils/computeTypeHash.js.map +1 -1
- package/dist/utils/fsSafe.d.ts +14 -0
- package/dist/utils/fsSafe.d.ts.map +1 -0
- package/dist/utils/fsSafe.js +89 -0
- package/dist/utils/fsSafe.js.map +1 -0
- package/dist/utils/index.d.ts +15 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +51 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/security.d.ts +147 -0
- package/dist/utils/security.d.ts.map +1 -0
- package/dist/utils/security.js +391 -0
- package/dist/utils/security.js.map +1 -0
- package/dist/utils/validation.d.ts +40 -0
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +184 -7
- package/dist/utils/validation.js.map +1 -1
- package/package.json +54 -37
- package/src/ACTPClient.ts +692 -178
- package/src/abi/AgentRegistry.json +782 -0
- package/src/abi/EscrowVault.json +106 -38
- package/src/abi/IdentityRegistry.json +316 -0
- package/src/adapters/BaseAdapter.ts +473 -0
- package/src/adapters/BeginnerAdapter.ts +232 -0
- package/src/adapters/IntermediateAdapter.ts +316 -0
- package/src/adapters/index.ts +25 -0
- package/src/builders/DeliveryProofBuilder.ts +3 -2
- package/src/cli/commands/balance.ts +110 -0
- package/src/cli/commands/batch.ts +487 -0
- package/src/cli/commands/config.ts +231 -0
- package/src/cli/commands/init.ts +161 -0
- package/src/cli/commands/mint.ts +116 -0
- package/src/cli/commands/pay.ts +113 -0
- package/src/cli/commands/simulate.ts +345 -0
- package/src/cli/commands/time.ts +303 -0
- package/src/cli/commands/tx.ts +448 -0
- package/src/cli/commands/watch.ts +211 -0
- package/src/cli/index.ts +116 -0
- package/src/cli/utils/client.ts +249 -0
- package/src/cli/utils/config.ts +282 -0
- package/src/cli/utils/output.ts +465 -0
- package/src/config/networks.ts +32 -9
- package/src/errors/index.ts +298 -1
- package/src/index.ts +207 -71
- package/src/level0/Provider.ts +117 -0
- package/src/level0/ServiceDirectory.ts +131 -0
- package/src/level0/index.ts +10 -0
- package/src/level0/provide.ts +131 -0
- package/src/level0/request.ts +494 -0
- package/src/level1/Agent.ts +1432 -0
- package/src/level1/index.ts +10 -0
- package/src/level1/pricing/PriceCalculator.ts +255 -0
- package/src/level1/pricing/PricingStrategy.ts +198 -0
- package/src/level1/types/Job.ts +179 -0
- package/src/level1/types/Options.ts +291 -0
- package/src/level1/types/index.ts +8 -0
- package/src/protocol/ACTPKernel.ts +175 -23
- package/src/protocol/AgentRegistry.ts +559 -0
- package/src/protocol/DIDManager.ts +629 -0
- package/src/protocol/DIDResolver.ts +554 -0
- package/src/protocol/EASHelper.ts +230 -46
- package/src/protocol/EscrowVault.ts +68 -50
- package/src/protocol/EventMonitor.ts +44 -15
- package/src/protocol/MessageSigner.ts +193 -13
- package/src/protocol/ProofGenerator.ts +223 -4
- package/src/runtime/BlockchainRuntime.ts +993 -0
- package/src/runtime/IACTPRuntime.ts +284 -0
- package/src/runtime/MockRuntime.ts +1244 -0
- package/src/runtime/MockStateManager.ts +576 -0
- package/src/runtime/index.ts +25 -0
- package/src/runtime/types/MockState.ts +227 -0
- package/src/types/agent.ts +79 -0
- package/src/types/did.ts +223 -0
- package/src/types/escrow.ts +12 -11
- package/src/types/index.ts +5 -1
- package/src/types/state.ts +12 -3
- package/src/types/transaction.ts +4 -1
- package/src/utils/ErrorRecoveryGuide.ts +675 -0
- package/src/utils/Helpers.ts +688 -0
- package/src/utils/IPFSClient.ts +122 -5
- package/src/utils/Logger.ts +484 -0
- package/src/utils/NonceManager.ts +305 -8
- package/src/utils/RateLimiter.ts +534 -0
- package/src/utils/ReceivedNonceTracker.ts +170 -0
- package/src/utils/SDKLifecycle.ts +416 -0
- package/src/utils/SecureNonce.ts +78 -0
- package/src/utils/Semaphore.ts +276 -0
- package/src/utils/UsedAttestationTracker.ts +387 -0
- package/src/utils/fsSafe.ts +75 -0
- package/src/utils/index.ts +80 -0
- package/src/utils/security.ts +418 -0
- package/src/utils/validation.ts +164 -0
- package/src/__tests__/ProofGenerator.test.ts +0 -124
- package/src/__tests__/QuoteBuilder.test.ts +0 -516
- package/src/__tests__/StateMachine.test.ts +0 -82
- package/src/__tests__/builders/DeliveryProofBuilder.test.ts +0 -581
- package/src/__tests__/integration/ACTPClient.test.ts +0 -263
- package/src/__tests__/integration.test.ts +0 -289
- package/src/__tests__/protocol/EASHelper.test.ts +0 -472
- package/src/__tests__/protocol/EventMonitor.test.ts +0 -382
- package/src/__tests__/security/ACTPKernel.security.test.ts +0 -1167
- package/src/__tests__/security/EscrowVault.security.test.ts +0 -570
- package/src/__tests__/security/MessageSigner.security.test.ts +0 -286
- package/src/__tests__/security/NonceReplay.security.test.ts +0 -501
- package/src/__tests__/security/validation.security.test.ts +0 -376
- package/src/__tests__/utils/IPFSClient.test.ts +0 -262
- package/src/__tests__/utils/NonceManager.test.ts +0 -205
- package/src/__tests__/utils/canonicalJson.test.ts +0 -153
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for Basic and Standard APIs
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { JobHandler, Job } from './Job';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Wallet configuration options
|
|
11
|
+
*/
|
|
12
|
+
export type WalletOption =
|
|
13
|
+
| 'auto' // SDK generates managed wallet
|
|
14
|
+
| 'connect' // Browser wallet popup (future)
|
|
15
|
+
| string // Private key directly
|
|
16
|
+
| { privateKey: string }; // Private key in object form
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Network options
|
|
20
|
+
*/
|
|
21
|
+
export type NetworkOption = 'mock' | 'testnet' | 'mainnet';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Options for provide() function (Basic API)
|
|
25
|
+
*/
|
|
26
|
+
export interface ProvideOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Wallet configuration
|
|
29
|
+
*
|
|
30
|
+
* - 'auto': SDK generates and manages a wallet automatically
|
|
31
|
+
* - 'connect': Open browser wallet connection (MetaMask, etc.) - FUTURE
|
|
32
|
+
* - string: Private key (0x-prefixed hex)
|
|
33
|
+
* - object: { privateKey: string }
|
|
34
|
+
*
|
|
35
|
+
* @default 'auto'
|
|
36
|
+
*/
|
|
37
|
+
wallet?: WalletOption;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Job filtering criteria
|
|
41
|
+
*
|
|
42
|
+
* Only accept jobs matching these filters.
|
|
43
|
+
*/
|
|
44
|
+
filter?: {
|
|
45
|
+
/**
|
|
46
|
+
* Minimum budget in USDC
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* filter: { minBudget: 5 } // Only accept jobs with budget >= $5
|
|
50
|
+
*/
|
|
51
|
+
minBudget?: number;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Maximum budget in USDC
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* filter: { maxBudget: 100 } // Only accept jobs with budget <= $100
|
|
58
|
+
*/
|
|
59
|
+
maxBudget?: number;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Auto-accept policy
|
|
64
|
+
*
|
|
65
|
+
* - true: Automatically accept all jobs matching filter
|
|
66
|
+
* - false: Require manual acceptance
|
|
67
|
+
* - function: Custom logic to decide whether to accept
|
|
68
|
+
*
|
|
69
|
+
* @default true
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* // Auto-accept if budget >= 10
|
|
74
|
+
* autoAccept: (job) => job.budget >= 10
|
|
75
|
+
*
|
|
76
|
+
* // Auto-accept high-priority jobs
|
|
77
|
+
* autoAccept: (job) => job.metadata?.priority === 'high'
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
autoAccept?: boolean | ((job: Job) => boolean | Promise<boolean>);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Network to operate on
|
|
84
|
+
*
|
|
85
|
+
* @default 'mock'
|
|
86
|
+
*/
|
|
87
|
+
network?: NetworkOption;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* RPC URL for blockchain connection (required for testnet/mainnet)
|
|
91
|
+
*
|
|
92
|
+
* If not provided, defaults to public RPC from network config:
|
|
93
|
+
* - testnet: https://sepolia.base.org
|
|
94
|
+
* - mainnet: https://mainnet.base.org
|
|
95
|
+
*
|
|
96
|
+
* For production, consider using a dedicated RPC provider (Alchemy, Infura, etc.)
|
|
97
|
+
* for better reliability and rate limits.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* rpcUrl: 'https://base-sepolia.g.alchemy.com/v2/YOUR_API_KEY'
|
|
101
|
+
*/
|
|
102
|
+
rpcUrl?: string;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* State directory for mock mode
|
|
106
|
+
*
|
|
107
|
+
* Where to store mock state file.
|
|
108
|
+
* Only used when network is 'mock'.
|
|
109
|
+
*
|
|
110
|
+
* @default process.cwd()
|
|
111
|
+
*/
|
|
112
|
+
stateDirectory?: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Request status updates
|
|
117
|
+
*/
|
|
118
|
+
export interface RequestStatus {
|
|
119
|
+
/**
|
|
120
|
+
* Current state of the request
|
|
121
|
+
*/
|
|
122
|
+
state: 'initiated' | 'quoted' | 'committed' | 'in_progress' | 'delivered' | 'settled' | 'disputed' | 'cancelled';
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Progress percentage (0-100) if provider is reporting progress
|
|
126
|
+
*/
|
|
127
|
+
progress?: number;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Progress message if available
|
|
131
|
+
*/
|
|
132
|
+
message?: string;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Estimated time to completion (seconds)
|
|
136
|
+
*/
|
|
137
|
+
eta?: number;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Options for request() function (Basic API)
|
|
142
|
+
*/
|
|
143
|
+
export interface RequestOptions {
|
|
144
|
+
/**
|
|
145
|
+
* Input data to send to the service
|
|
146
|
+
*/
|
|
147
|
+
input: any;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Budget in USDC (decimal format)
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* budget: 10 // $10.00
|
|
154
|
+
*/
|
|
155
|
+
budget: number;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Wallet configuration (same as ProvideOptions)
|
|
159
|
+
*
|
|
160
|
+
* @default 'auto'
|
|
161
|
+
*/
|
|
162
|
+
wallet?: WalletOption;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Network to operate on
|
|
166
|
+
*
|
|
167
|
+
* @default 'mock'
|
|
168
|
+
*/
|
|
169
|
+
network?: NetworkOption;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Timeout in milliseconds
|
|
173
|
+
*
|
|
174
|
+
* @default 300000 (5 minutes)
|
|
175
|
+
*/
|
|
176
|
+
timeout?: number;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Deadline for job completion
|
|
180
|
+
*
|
|
181
|
+
* Can be a timestamp (seconds) or Date object.
|
|
182
|
+
* If not specified, defaults to now + timeout.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* deadline: Math.floor(Date.now() / 1000) + 3600 // 1 hour from now
|
|
186
|
+
* deadline: new Date('2025-12-14T12:00:00Z')
|
|
187
|
+
*/
|
|
188
|
+
deadline?: number | Date;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Provider selection strategy
|
|
192
|
+
*
|
|
193
|
+
* - string: Specific provider address
|
|
194
|
+
* - 'any': First available provider
|
|
195
|
+
* - 'best': Provider with highest reputation
|
|
196
|
+
* - 'cheapest': Provider with lowest price
|
|
197
|
+
*
|
|
198
|
+
* @default 'any'
|
|
199
|
+
*/
|
|
200
|
+
provider?: string | 'any' | 'best' | 'cheapest';
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Progress callback
|
|
204
|
+
*
|
|
205
|
+
* Called when provider reports progress updates.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```typescript
|
|
209
|
+
* onProgress: (status) => {
|
|
210
|
+
* console.log(`${status.state}: ${status.progress}% - ${status.message}`);
|
|
211
|
+
* }
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
onProgress?: (status: RequestStatus) => void;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* State directory for mock mode
|
|
218
|
+
*
|
|
219
|
+
* @default process.cwd()
|
|
220
|
+
*/
|
|
221
|
+
stateDirectory?: string;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* RPC URL for blockchain connection (required for testnet/mainnet)
|
|
225
|
+
*
|
|
226
|
+
* If not provided, defaults to public RPC from network config:
|
|
227
|
+
* - testnet: https://sepolia.base.org
|
|
228
|
+
* - mainnet: https://mainnet.base.org
|
|
229
|
+
*
|
|
230
|
+
* For production, consider using a dedicated RPC provider (Alchemy, Infura, etc.)
|
|
231
|
+
* for better reliability and rate limits.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* rpcUrl: 'https://base-sepolia.g.alchemy.com/v2/YOUR_API_KEY'
|
|
235
|
+
*/
|
|
236
|
+
rpcUrl?: string;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Dispute window duration in seconds
|
|
240
|
+
*
|
|
241
|
+
* Time after delivery during which requester can dispute.
|
|
242
|
+
*
|
|
243
|
+
* @default 172800 (2 days)
|
|
244
|
+
*/
|
|
245
|
+
disputeWindow?: number;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Result of request() function
|
|
250
|
+
*/
|
|
251
|
+
export interface RequestResult {
|
|
252
|
+
/**
|
|
253
|
+
* The result returned by the provider's handler
|
|
254
|
+
*/
|
|
255
|
+
result: any;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Transaction metadata
|
|
259
|
+
*/
|
|
260
|
+
transaction: {
|
|
261
|
+
/**
|
|
262
|
+
* Transaction ID (ACTP protocol)
|
|
263
|
+
*/
|
|
264
|
+
id: string;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Provider address
|
|
268
|
+
*/
|
|
269
|
+
provider: string;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Amount paid (USDC)
|
|
273
|
+
*/
|
|
274
|
+
amount: number;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Platform fee (USDC)
|
|
278
|
+
*/
|
|
279
|
+
fee: number;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Job duration (milliseconds)
|
|
283
|
+
*/
|
|
284
|
+
duration: number;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Delivery proof hash
|
|
288
|
+
*/
|
|
289
|
+
proof: string;
|
|
290
|
+
};
|
|
291
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard API Types - Job, Options, and related interfaces
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export { Job, JobHandler, JobContext } from './Job';
|
|
8
|
+
export { ProvideOptions, RequestOptions, RequestResult, RequestStatus, WalletOption, NetworkOption } from './Options';
|
|
@@ -54,6 +54,18 @@ export class ACTPKernel {
|
|
|
54
54
|
return this.address;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Get the underlying ethers Contract instance.
|
|
59
|
+
*
|
|
60
|
+
* SECURITY FIX (C-3): Provides public access to contract for EventMonitor
|
|
61
|
+
* instead of accessing private field via bracket notation.
|
|
62
|
+
*
|
|
63
|
+
* @returns ethers Contract instance
|
|
64
|
+
*/
|
|
65
|
+
getContract(): Contract {
|
|
66
|
+
return this.contract;
|
|
67
|
+
}
|
|
68
|
+
|
|
57
69
|
/**
|
|
58
70
|
* Get gas buffer multiplier based on operation complexity
|
|
59
71
|
* V6 Security Enhancement: Operation-specific gas buffers
|
|
@@ -76,12 +88,63 @@ export class ACTPKernel {
|
|
|
76
88
|
/**
|
|
77
89
|
* Build transaction options with gas settings and estimated gas
|
|
78
90
|
* V6 Enhancement: Dynamic buffer based on operation type
|
|
91
|
+
*
|
|
92
|
+
* SECURITY FIX (C-3): Gas estimation manipulation attack protection
|
|
93
|
+
* - Enforces operation-specific minimum gas floors (not global 100k)
|
|
94
|
+
* - Validates gas limit doesn't exceed block gas limit (DoS prevention)
|
|
95
|
+
* - Uses safe BigInt arithmetic with overflow detection
|
|
96
|
+
* - Prevents floating-point arithmetic (uses BPS - basis points)
|
|
79
97
|
*/
|
|
80
98
|
private buildTxOptions(estimatedGas: bigint, operation: string = 'default'): any {
|
|
99
|
+
// SECURITY FIX (C-3): Operation-specific minimum gas floors
|
|
100
|
+
// Malicious contracts could return artificially low gas estimates to cause txs to fail
|
|
101
|
+
const MIN_GAS_FLOORS: Record<string, bigint> = {
|
|
102
|
+
'createTransaction': 120000n, // Create + event emission
|
|
103
|
+
'transitionState': 80000n, // State update + event
|
|
104
|
+
'releaseEscrow': 220000n, // Multi-recipient disbursement + events
|
|
105
|
+
'raiseDispute': 100000n, // Large proof data encoding
|
|
106
|
+
'resolveDispute': 250000n, // Complex multi-party settlement
|
|
107
|
+
'cancelTransaction': 60000n, // Simple state change
|
|
108
|
+
'anchorAttestation': 80000n, // Attestation storage
|
|
109
|
+
'default': 100000n // Conservative fallback
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const minFloor = MIN_GAS_FLOORS[operation] || MIN_GAS_FLOORS['default'];
|
|
113
|
+
const safeEstimate = estimatedGas > minFloor ? estimatedGas : minFloor;
|
|
114
|
+
|
|
81
115
|
const bufferMultiplier = this.getGasBufferMultiplier(operation);
|
|
82
116
|
|
|
117
|
+
// SECURITY FIX (C-3): Safe BigInt arithmetic using BPS (basis points)
|
|
118
|
+
// Multiply by (bufferMultiplier * 10000) and divide by 10000
|
|
119
|
+
// Example: 1.15x = (115 * 10000) / 10000 = 11500 / 10000
|
|
120
|
+
// This avoids floating-point precision issues entirely
|
|
121
|
+
const bufferNumerator = BigInt(Math.floor(bufferMultiplier * 10000));
|
|
122
|
+
const bufferDenominator = 10000n;
|
|
123
|
+
const gasLimit = (safeEstimate * bufferNumerator) / bufferDenominator;
|
|
124
|
+
|
|
125
|
+
// SECURITY FIX (C-3): Overflow detection
|
|
126
|
+
// After multiplication and division, result MUST be >= original estimate
|
|
127
|
+
if (gasLimit < safeEstimate) {
|
|
128
|
+
throw new Error(
|
|
129
|
+
`Gas calculation overflow detected for operation "${operation}". ` +
|
|
130
|
+
`Estimate: ${safeEstimate}, Buffer: ${bufferMultiplier}x, Result: ${gasLimit}. ` +
|
|
131
|
+
`This indicates an arithmetic overflow - please report this bug.`
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// SECURITY FIX (C-3): Block gas limit check (Base L2 = 30M gas)
|
|
136
|
+
// Prevents DoS by requesting excessive gas that can never be included
|
|
137
|
+
const MAX_BLOCK_GAS_LIMIT = 30_000_000n;
|
|
138
|
+
if (gasLimit > MAX_BLOCK_GAS_LIMIT) {
|
|
139
|
+
throw new Error(
|
|
140
|
+
`Gas limit ${gasLimit} exceeds maximum block gas limit ${MAX_BLOCK_GAS_LIMIT} for operation "${operation}". ` +
|
|
141
|
+
`This transaction cannot be executed on-chain. ` +
|
|
142
|
+
`Estimated gas: ${estimatedGas}, Min floor: ${minFloor}, Buffer: ${bufferMultiplier}x.`
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
83
146
|
const options: any = {
|
|
84
|
-
gasLimit
|
|
147
|
+
gasLimit
|
|
85
148
|
};
|
|
86
149
|
|
|
87
150
|
if (this.gasSettings?.maxFeePerGas) {
|
|
@@ -153,7 +216,13 @@ export class ACTPKernel {
|
|
|
153
216
|
}
|
|
154
217
|
|
|
155
218
|
// Extract transactionId from TransactionCreated event
|
|
156
|
-
// Event signature: TransactionCreated(bytes32 indexed transactionId, ...)
|
|
219
|
+
// Event signature: TransactionCreated(bytes32 indexed transactionId, address indexed requester, address indexed provider, ...)
|
|
220
|
+
//
|
|
221
|
+
// DOCUMENTATION (CRITICAL-3): Note parameter order difference:
|
|
222
|
+
// - Function: createTransaction(provider, requester, ...) - provider is first
|
|
223
|
+
// - Event: TransactionCreated(txId, requester, provider, ...) - requester is first after txId
|
|
224
|
+
// This is INTENTIONAL - function names main actor (provider), event logs initiator first (requester)
|
|
225
|
+
// SDK correctly uses named args (parsedLog.args.transactionId) to avoid confusion
|
|
157
226
|
for (const log of receipt.logs) {
|
|
158
227
|
try {
|
|
159
228
|
const parsedLog = this.contract.interface.parseLog({
|
|
@@ -162,6 +231,7 @@ export class ACTPKernel {
|
|
|
162
231
|
});
|
|
163
232
|
|
|
164
233
|
if (parsedLog && parsedLog.name === 'TransactionCreated') {
|
|
234
|
+
// Use named arg for clarity (avoids index confusion with swapped provider/requester)
|
|
165
235
|
return parsedLog.args.transactionId || parsedLog.args[0];
|
|
166
236
|
}
|
|
167
237
|
} catch (e) {
|
|
@@ -336,28 +406,33 @@ export class ACTPKernel {
|
|
|
336
406
|
|
|
337
407
|
/**
|
|
338
408
|
* Release milestone payment
|
|
409
|
+
*
|
|
410
|
+
* SECURITY FIX (CRITICAL-2): Contract ABI has only 2 params (txId, amount), not 3.
|
|
411
|
+
* The milestoneId is NOT part of the current ACTPKernel V1 contract.
|
|
412
|
+
* Per ABI: releaseMilestone(bytes32 transactionId, uint256 amount)
|
|
413
|
+
*
|
|
414
|
+
* @param txId - Transaction ID (bytes32)
|
|
415
|
+
* @param amount - Amount to release (uint256)
|
|
416
|
+
* @deprecated milestoneId parameter - removed as contract doesn't support it
|
|
339
417
|
*/
|
|
340
418
|
async releaseMilestone(
|
|
341
419
|
txId: string,
|
|
342
|
-
milestoneId: number,
|
|
343
420
|
amount: bigint
|
|
344
421
|
): Promise<void> {
|
|
345
422
|
// Input validation
|
|
346
423
|
validateTxId(txId, 'txId');
|
|
347
424
|
validateAmount(amount, 'amount');
|
|
348
|
-
if (milestoneId < 0) {
|
|
349
|
-
throw new ValidationError('milestoneId', 'Milestone ID cannot be negative');
|
|
350
|
-
}
|
|
351
425
|
|
|
352
426
|
try {
|
|
353
427
|
// ethers v6: use getFunction()
|
|
354
428
|
const releaseMilestoneFunc = this.contract.getFunction('releaseMilestone');
|
|
355
429
|
|
|
430
|
+
// SECURITY FIX (CRITICAL-2): Contract only takes 2 params (txId, amount)
|
|
356
431
|
// Estimate gas with safety buffer (30% for escrow release operations)
|
|
357
|
-
const estimatedGas = await releaseMilestoneFunc.estimateGas(txId,
|
|
432
|
+
const estimatedGas = await releaseMilestoneFunc.estimateGas(txId, amount);
|
|
358
433
|
const txOptions = this.buildTxOptions(estimatedGas, 'releaseEscrow');
|
|
359
434
|
|
|
360
|
-
const tx = await releaseMilestoneFunc(txId,
|
|
435
|
+
const tx = await releaseMilestoneFunc(txId, amount, txOptions);
|
|
361
436
|
|
|
362
437
|
await tx.wait(2); // Wait for 2 confirmations (Base L2 reorg safety)
|
|
363
438
|
} catch (error: any) {
|
|
@@ -368,19 +443,66 @@ export class ACTPKernel {
|
|
|
368
443
|
/**
|
|
369
444
|
* Release full escrow (settle transaction)
|
|
370
445
|
*
|
|
371
|
-
* SECURITY WARNING (
|
|
372
|
-
*
|
|
446
|
+
* ⚠️ CRITICAL SECURITY WARNING (C-2): Attestation UID Validation Bypass
|
|
447
|
+
*
|
|
448
|
+
* **DO NOT call this method directly from your application code!**
|
|
449
|
+
*
|
|
450
|
+
* ACTPKernel V1 contract accepts any attestationUID without validation.
|
|
451
|
+
* A malicious provider can:
|
|
452
|
+
* - Submit an attestation from a different transaction
|
|
453
|
+
* - Re-use an old attestation (replay attack)
|
|
454
|
+
* - Submit a forged attestation with fake delivery proof
|
|
455
|
+
*
|
|
456
|
+
* **REQUIRED: Use secure wrapper methods instead:**
|
|
457
|
+
*
|
|
458
|
+
* 1. **BeginnerAdapter.completePayment()** (recommended for most users)
|
|
459
|
+
* - Automatically verifies attestation before release
|
|
460
|
+
* - Validates attestation belongs to this transaction
|
|
461
|
+
* - Checks attestation hasn't been used before
|
|
462
|
+
* - Handles all state transitions
|
|
463
|
+
*
|
|
464
|
+
* 2. **IntermediateAdapter.releaseEscrow()** (for more control)
|
|
465
|
+
* - Explicitly requires attestation verification
|
|
466
|
+
* - Throws error if attestation invalid or missing
|
|
467
|
+
* - Allows custom verification logic
|
|
468
|
+
*
|
|
469
|
+
* 3. **Manual verification** (advanced users only):
|
|
470
|
+
* ```typescript
|
|
471
|
+
* // Step 1: Get transaction details
|
|
472
|
+
* const tx = await kernel.getTransaction(txId);
|
|
473
|
+
*
|
|
474
|
+
* // Step 2: Verify attestation if EAS is configured
|
|
475
|
+
* if (easHelper && tx.attestationUID && tx.attestationUID !== '0x0...0') {
|
|
476
|
+
* const isValid = await easHelper.verifyDeliveryAttestation(
|
|
477
|
+
* tx.attestationUID,
|
|
478
|
+
* tx.requester
|
|
479
|
+
* );
|
|
480
|
+
* if (!isValid) {
|
|
481
|
+
* throw new Error('Invalid or fraudulent delivery attestation');
|
|
482
|
+
* }
|
|
483
|
+
* }
|
|
484
|
+
*
|
|
485
|
+
* // Step 3: Only now is it safe to release
|
|
486
|
+
* await kernel.releaseEscrow(txId);
|
|
487
|
+
* ```
|
|
373
488
|
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
489
|
+
* **Why this matters:**
|
|
490
|
+
* - Without verification, you risk paying for work never delivered
|
|
491
|
+
* - Provider can steal funds by re-using attestations from other transactions
|
|
492
|
+
* - No on-chain enforcement (contract V1 limitation, fixed in V2)
|
|
377
493
|
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
494
|
+
* **For testnet/mainnet deployments:**
|
|
495
|
+
* - MUST configure easConfig in ACTPClient
|
|
496
|
+
* - MUST use wrapper methods (Beginner/Intermediate adapters)
|
|
497
|
+
* - NEVER call this method directly unless attestation verified
|
|
380
498
|
*
|
|
381
499
|
* @param txId - Transaction ID to settle
|
|
382
500
|
* @throws {ValidationError} If txId is invalid
|
|
383
501
|
* @throws {TransactionRevertedError} If contract reverts
|
|
502
|
+
*
|
|
503
|
+
* @see {@link BeginnerAdapter.completePayment} Recommended method with built-in verification
|
|
504
|
+
* @see {@link IntermediateAdapter.releaseEscrow} Explicit verification method
|
|
505
|
+
* @see {@link EASHelper.verifyDeliveryAttestation} Manual verification helper
|
|
384
506
|
*/
|
|
385
507
|
async releaseEscrow(txId: string): Promise<void> {
|
|
386
508
|
// Input validation
|
|
@@ -406,7 +528,21 @@ export class ACTPKernel {
|
|
|
406
528
|
* Get transaction by ID
|
|
407
529
|
*/
|
|
408
530
|
async getTransaction(txId: string): Promise<Transaction> {
|
|
409
|
-
|
|
531
|
+
let txData: any;
|
|
532
|
+
try {
|
|
533
|
+
txData = await this.contract.getTransaction(txId);
|
|
534
|
+
} catch (error: any) {
|
|
535
|
+
const reason = error?.reason || error?.shortMessage || error?.message || '';
|
|
536
|
+
|
|
537
|
+
// Deployed kernel reverts on missing transactions (e.g., "Tx missing")
|
|
538
|
+
if (typeof reason === 'string' && reason.toLowerCase().includes('tx missing')) {
|
|
539
|
+
throw new TransactionNotFoundError(txId);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
throw new Error(
|
|
543
|
+
`Failed to fetch transaction ${txId}: ${typeof reason === 'string' ? reason : String(reason)}`
|
|
544
|
+
);
|
|
545
|
+
}
|
|
410
546
|
|
|
411
547
|
// Check if transaction exists (createdAt !== 0)
|
|
412
548
|
if (txData.createdAt === 0 || txData.createdAt === 0n) {
|
|
@@ -420,28 +556,44 @@ export class ACTPKernel {
|
|
|
420
556
|
amount: txData.amount,
|
|
421
557
|
state: (typeof txData.state === 'bigint' ? Number(txData.state) : txData.state) as State,
|
|
422
558
|
createdAt: typeof txData.createdAt === 'bigint' ? Number(txData.createdAt) : txData.createdAt,
|
|
559
|
+
updatedAt: typeof txData.updatedAt === 'bigint' ? Number(txData.updatedAt) : txData.updatedAt,
|
|
423
560
|
deadline: typeof txData.deadline === 'bigint' ? Number(txData.deadline) : txData.deadline,
|
|
424
561
|
disputeWindow: typeof txData.disputeWindow === 'bigint' ? Number(txData.disputeWindow) : txData.disputeWindow,
|
|
425
562
|
escrowContract: txData.escrowContract,
|
|
426
563
|
escrowId: txData.escrowId,
|
|
564
|
+
serviceHash: txData.serviceHash,
|
|
565
|
+
attestationUID: txData.attestationUID,
|
|
427
566
|
// Use metadata field (quote hash for QUOTED state) if available, fallback to serviceHash
|
|
428
|
-
metadata: txData.metadata || txData.serviceHash
|
|
567
|
+
metadata: txData.metadata || txData.serviceHash,
|
|
568
|
+
platformFeeBpsLocked:
|
|
569
|
+
typeof txData.platformFeeBpsLocked === 'bigint'
|
|
570
|
+
? Number(txData.platformFeeBpsLocked)
|
|
571
|
+
: txData.platformFeeBpsLocked
|
|
429
572
|
};
|
|
430
573
|
}
|
|
431
574
|
|
|
432
575
|
/**
|
|
433
576
|
* Get economic parameters (fee structure)
|
|
434
|
-
*
|
|
577
|
+
*
|
|
578
|
+
* SECURITY FIX (CRITICAL-4): Contract doesn't have getEconomicParams() function.
|
|
579
|
+
* Must call individual getters: platformFeeBps(), requesterPenaltyBps(), feeRecipient()
|
|
580
|
+
* Per ACTPKernel.json ABI lines 576-586, 619-630, 351-361
|
|
435
581
|
*/
|
|
436
582
|
async getEconomicParams(): Promise<EconomicParams> {
|
|
437
|
-
|
|
583
|
+
// SECURITY FIX (CRITICAL-4): Call individual view functions in parallel
|
|
584
|
+
// Contract ABI has: platformFeeBps(), requesterPenaltyBps(), feeRecipient()
|
|
585
|
+
// NOT a combined getEconomicParams() function
|
|
586
|
+
const [platformFeeBps, requesterPenaltyBps, feeRecipient] = await Promise.all([
|
|
587
|
+
this.contract.platformFeeBps(),
|
|
588
|
+
this.contract.requesterPenaltyBps(),
|
|
589
|
+
this.contract.feeRecipient()
|
|
590
|
+
]);
|
|
438
591
|
|
|
439
|
-
// Contract returns: (platformFeeBps, requesterPenaltyBps, feeRecipient)
|
|
440
592
|
return {
|
|
441
|
-
baseFeeNumerator: Number(
|
|
593
|
+
baseFeeNumerator: Number(platformFeeBps),
|
|
442
594
|
baseFeeDenominator: 10000, // BPS is always out of 10000
|
|
443
|
-
feeRecipient:
|
|
444
|
-
requesterPenaltyBps: Number(
|
|
595
|
+
feeRecipient: feeRecipient,
|
|
596
|
+
requesterPenaltyBps: Number(requesterPenaltyBps),
|
|
445
597
|
providerPenaltyBps: 0 // Not in current contract ABI, will be added in future version
|
|
446
598
|
};
|
|
447
599
|
}
|