@opendatalabs/vana-sdk 0.1.0-alpha.273dc39 → 0.1.0-alpha.276ea01
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/README.md +13 -4
- package/dist/browser.cjs +29 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +2 -0
- package/dist/browser.d.ts +2 -1
- package/dist/browser.js +1 -305
- package/dist/browser.js.map +1 -1
- package/dist/chains/definitions.cjs +92 -0
- package/dist/chains/definitions.cjs.map +1 -0
- package/dist/chains/definitions.d.cts +53 -0
- package/dist/chains/definitions.d.ts +53 -0
- package/dist/chains/definitions.js +64 -0
- package/dist/chains/definitions.js.map +1 -0
- package/dist/chains/index.cjs +37 -0
- package/dist/chains/index.cjs.map +1 -0
- package/dist/chains/index.d.cts +2 -0
- package/dist/chains/index.d.ts +2 -0
- package/dist/chains/index.js +15 -0
- package/dist/chains/index.js.map +1 -0
- package/dist/chains.browser.cjs +6 -65
- package/dist/chains.browser.cjs.map +1 -1
- package/dist/chains.browser.d.cts +2 -53
- package/dist/chains.browser.d.ts +2 -53
- package/dist/chains.browser.js +7 -57
- package/dist/chains.browser.js.map +1 -1
- package/dist/chains.cjs +6 -65
- package/dist/chains.cjs.map +1 -1
- package/dist/chains.d.cts +1 -1
- package/dist/chains.d.ts +1 -1
- package/dist/chains.js +7 -57
- package/dist/chains.js.map +1 -1
- package/dist/chains.node.cjs +6 -65
- package/dist/chains.node.cjs.map +1 -1
- package/dist/chains.node.d.cts +1 -1
- package/dist/chains.node.d.ts +1 -1
- package/dist/chains.node.js +7 -57
- package/dist/chains.node.js.map +1 -1
- package/dist/config/addresses.cjs +325 -0
- package/dist/config/addresses.cjs.map +1 -0
- package/dist/config/addresses.d.cts +380 -0
- package/dist/config/addresses.d.ts +380 -0
- package/dist/config/addresses.js +295 -0
- package/dist/config/addresses.js.map +1 -0
- package/dist/config/chains.cjs +93 -0
- package/dist/config/chains.cjs.map +1 -0
- package/dist/config/chains.d.cts +85 -0
- package/dist/config/chains.d.ts +85 -0
- package/dist/config/chains.js +67 -0
- package/dist/config/chains.js.map +1 -0
- package/dist/config/eventMappings.cjs +114 -0
- package/dist/config/eventMappings.cjs.map +1 -0
- package/dist/config/eventMappings.d.cts +108 -0
- package/dist/config/eventMappings.d.ts +108 -0
- package/dist/config/eventMappings.js +90 -0
- package/dist/config/eventMappings.js.map +1 -0
- package/dist/config/features.cjs +52 -0
- package/dist/config/features.cjs.map +1 -0
- package/dist/config/features.d.cts +64 -0
- package/dist/config/features.d.ts +64 -0
- package/dist/config/features.js +28 -0
- package/dist/config/features.js.map +1 -0
- package/dist/contracts/contractController.cjs +126 -0
- package/dist/contracts/contractController.cjs.map +1 -0
- package/dist/contracts/contractController.d.cts +96 -0
- package/dist/contracts/contractController.d.ts +96 -0
- package/dist/contracts/contractController.js +103 -0
- package/dist/contracts/contractController.js.map +1 -0
- package/dist/controllers/data.cjs +2239 -0
- package/dist/controllers/data.cjs.map +1 -0
- package/dist/controllers/data.d.cts +941 -0
- package/dist/controllers/data.d.ts +941 -0
- package/dist/controllers/data.js +2222 -0
- package/dist/controllers/data.js.map +1 -0
- package/dist/controllers/permissions.cjs +3726 -0
- package/dist/controllers/permissions.cjs.map +1 -0
- package/dist/controllers/permissions.d.cts +25 -0
- package/dist/controllers/permissions.d.ts +25 -0
- package/dist/controllers/permissions.js +3702 -0
- package/dist/controllers/permissions.js.map +1 -0
- package/dist/controllers/protocol.cjs +179 -0
- package/dist/controllers/protocol.cjs.map +1 -0
- package/dist/controllers/protocol.d.cts +167 -0
- package/dist/controllers/protocol.d.ts +167 -0
- package/dist/controllers/protocol.js +162 -0
- package/dist/controllers/protocol.js.map +1 -0
- package/dist/controllers/schemas.cjs +584 -0
- package/dist/controllers/schemas.cjs.map +1 -0
- package/dist/controllers/schemas.d.cts +272 -0
- package/dist/controllers/schemas.d.ts +272 -0
- package/dist/controllers/schemas.js +560 -0
- package/dist/controllers/schemas.js.map +1 -0
- package/dist/controllers/server.cjs +427 -0
- package/dist/controllers/server.cjs.map +1 -0
- package/dist/controllers/server.d.cts +243 -0
- package/dist/controllers/server.d.ts +243 -0
- package/dist/controllers/server.js +408 -0
- package/dist/controllers/server.js.map +1 -0
- package/dist/core/apiClient.cjs +325 -0
- package/dist/core/apiClient.cjs.map +1 -0
- package/dist/core/apiClient.d.cts +165 -0
- package/dist/core/apiClient.d.ts +165 -0
- package/dist/core/apiClient.js +309 -0
- package/dist/core/apiClient.js.map +1 -0
- package/dist/core/client.cjs +70 -0
- package/dist/core/client.cjs.map +1 -0
- package/dist/core/client.d.cts +92 -0
- package/dist/core/client.d.ts +92 -0
- package/dist/core/client.js +47 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/generics.cjs +388 -0
- package/dist/core/generics.cjs.map +1 -0
- package/dist/core/generics.d.cts +120 -0
- package/dist/core/generics.d.ts +120 -0
- package/dist/core/generics.js +366 -0
- package/dist/core/generics.js.map +1 -0
- package/dist/core.cjs +640 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +466 -0
- package/dist/core.d.ts +466 -0
- package/dist/core.js +628 -0
- package/dist/core.js.map +1 -0
- package/dist/crypto/ecies/__tests__/test-vectors.cjs +102 -0
- package/dist/crypto/ecies/__tests__/test-vectors.cjs.map +1 -0
- package/dist/crypto/ecies/__tests__/test-vectors.d.cts +40 -0
- package/dist/crypto/ecies/__tests__/test-vectors.d.ts +40 -0
- package/dist/crypto/ecies/__tests__/test-vectors.js +77 -0
- package/dist/crypto/ecies/__tests__/test-vectors.js.map +1 -0
- package/dist/crypto/ecies/base.cjs +231 -0
- package/dist/crypto/ecies/base.cjs.map +1 -0
- package/dist/crypto/ecies/base.d.cts +143 -0
- package/dist/crypto/ecies/base.d.ts +143 -0
- package/dist/crypto/ecies/base.js +211 -0
- package/dist/crypto/ecies/base.js.map +1 -0
- package/dist/crypto/ecies/browser.cjs +164 -0
- package/dist/crypto/ecies/browser.cjs.map +1 -0
- package/dist/crypto/ecies/browser.d.cts +48 -0
- package/dist/crypto/ecies/browser.d.ts +48 -0
- package/dist/crypto/ecies/browser.js +130 -0
- package/dist/crypto/ecies/browser.js.map +1 -0
- package/dist/crypto/ecies/constants.cjs +131 -0
- package/dist/crypto/ecies/constants.cjs.map +1 -0
- package/dist/crypto/ecies/constants.d.cts +122 -0
- package/dist/crypto/ecies/constants.d.ts +122 -0
- package/dist/crypto/ecies/constants.js +101 -0
- package/dist/crypto/ecies/constants.js.map +1 -0
- package/dist/crypto/ecies/index.cjs +35 -0
- package/dist/crypto/ecies/index.cjs.map +1 -0
- package/dist/crypto/ecies/index.d.cts +1 -0
- package/dist/crypto/ecies/index.d.ts +1 -0
- package/dist/crypto/ecies/index.js +13 -0
- package/dist/crypto/ecies/index.js.map +1 -0
- package/dist/crypto/ecies/interface.cjs +88 -0
- package/dist/crypto/ecies/interface.cjs.map +1 -0
- package/dist/crypto/ecies/interface.d.cts +176 -0
- package/dist/crypto/ecies/interface.d.ts +176 -0
- package/dist/crypto/ecies/interface.js +61 -0
- package/dist/crypto/ecies/interface.js.map +1 -0
- package/dist/crypto/ecies/node.cjs +166 -0
- package/dist/crypto/ecies/node.cjs.map +1 -0
- package/dist/crypto/ecies/node.d.cts +50 -0
- package/dist/crypto/ecies/node.d.ts +50 -0
- package/dist/crypto/ecies/node.js +144 -0
- package/dist/crypto/ecies/node.js.map +1 -0
- package/dist/crypto/ecies/test-vectors/eccrypto-vectors.d.cts +76 -0
- package/dist/crypto/ecies/test-vectors/eccrypto-vectors.d.ts +76 -0
- package/dist/crypto/ecies/test-vectors/eccrypto-vectors.json +72 -0
- package/dist/crypto/ecies/utils.cjs +91 -0
- package/dist/crypto/ecies/utils.cjs.map +1 -0
- package/dist/crypto/ecies/utils.d.cts +67 -0
- package/dist/crypto/ecies/utils.d.ts +67 -0
- package/dist/crypto/ecies/utils.js +60 -0
- package/dist/crypto/ecies/utils.js.map +1 -0
- package/dist/crypto/services/WalletKeyEncryptionService.cjs +128 -0
- package/dist/crypto/services/WalletKeyEncryptionService.cjs.map +1 -0
- package/dist/crypto/services/WalletKeyEncryptionService.d.cts +92 -0
- package/dist/crypto/services/WalletKeyEncryptionService.d.ts +92 -0
- package/dist/crypto/services/WalletKeyEncryptionService.js +112 -0
- package/dist/crypto/services/WalletKeyEncryptionService.js.map +1 -0
- package/dist/diagnostics.cjs +37 -0
- package/dist/diagnostics.cjs.map +1 -0
- package/dist/diagnostics.d.cts +26 -0
- package/dist/diagnostics.d.ts +26 -0
- package/dist/diagnostics.js +13 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/errors.cjs +141 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +350 -0
- package/dist/errors.d.ts +350 -0
- package/dist/errors.js +108 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/abi/ComputeEngineImplementation.cjs +1313 -0
- package/dist/generated/abi/ComputeEngineImplementation.cjs.map +1 -0
- package/dist/generated/abi/ComputeEngineImplementation.d.cts +996 -0
- package/dist/generated/abi/ComputeEngineImplementation.d.ts +996 -0
- package/dist/generated/abi/ComputeEngineImplementation.js +1289 -0
- package/dist/generated/abi/ComputeEngineImplementation.js.map +1 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.cjs +734 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.cjs.map +1 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.cts +545 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.ts +545 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.js +710 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.js.map +1 -0
- package/dist/generated/abi/DATFactoryImplementation.cjs +882 -0
- package/dist/generated/abi/DATFactoryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DATFactoryImplementation.d.cts +661 -0
- package/dist/generated/abi/DATFactoryImplementation.d.ts +661 -0
- package/dist/generated/abi/DATFactoryImplementation.js +858 -0
- package/dist/generated/abi/DATFactoryImplementation.js.map +1 -0
- package/dist/generated/abi/DATImplementation.cjs +934 -0
- package/dist/generated/abi/DATImplementation.cjs.map +1 -0
- package/dist/generated/abi/DATImplementation.d.cts +693 -0
- package/dist/generated/abi/DATImplementation.d.ts +693 -0
- package/dist/generated/abi/DATImplementation.js +910 -0
- package/dist/generated/abi/DATImplementation.js.map +1 -0
- package/dist/generated/abi/DATPausableImplementation.cjs +1523 -0
- package/dist/generated/abi/DATPausableImplementation.cjs.map +1 -0
- package/dist/generated/abi/DATPausableImplementation.d.cts +1145 -0
- package/dist/generated/abi/DATPausableImplementation.d.ts +1145 -0
- package/dist/generated/abi/DATPausableImplementation.js +1499 -0
- package/dist/generated/abi/DATPausableImplementation.js.map +1 -0
- package/dist/generated/abi/DATVotesImplementation.cjs +1460 -0
- package/dist/generated/abi/DATVotesImplementation.cjs.map +1 -0
- package/dist/generated/abi/DATVotesImplementation.d.cts +1095 -0
- package/dist/generated/abi/DATVotesImplementation.d.ts +1095 -0
- package/dist/generated/abi/DATVotesImplementation.js +1436 -0
- package/dist/generated/abi/DATVotesImplementation.js.map +1 -0
- package/dist/generated/abi/DLPPerformanceImplementation.cjs +1160 -0
- package/dist/generated/abi/DLPPerformanceImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPPerformanceImplementation.d.cts +883 -0
- package/dist/generated/abi/DLPPerformanceImplementation.d.ts +883 -0
- package/dist/generated/abi/DLPPerformanceImplementation.js +1136 -0
- package/dist/generated/abi/DLPPerformanceImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRegistryImplementation.cjs +1469 -0
- package/dist/generated/abi/DLPRegistryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRegistryImplementation.d.cts +1123 -0
- package/dist/generated/abi/DLPRegistryImplementation.d.ts +1123 -0
- package/dist/generated/abi/DLPRegistryImplementation.js +1445 -0
- package/dist/generated/abi/DLPRegistryImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.cjs +612 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.cts +452 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.ts +452 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.js +588 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.cjs +948 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.d.cts +714 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.d.ts +714 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.js +924 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.cjs +612 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.cts +452 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.ts +452 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.js +588 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.cjs +939 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.d.cts +706 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.d.ts +706 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.js +915 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRootImplementation.cjs +1644 -0
- package/dist/generated/abi/DLPRootImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRootImplementation.d.cts +1248 -0
- package/dist/generated/abi/DLPRootImplementation.d.ts +1248 -0
- package/dist/generated/abi/DLPRootImplementation.js +1620 -0
- package/dist/generated/abi/DLPRootImplementation.js.map +1 -0
- package/dist/generated/abi/DLPTreasuryImplementation.cjs +612 -0
- package/dist/generated/abi/DLPTreasuryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPTreasuryImplementation.d.cts +452 -0
- package/dist/generated/abi/DLPTreasuryImplementation.d.ts +452 -0
- package/dist/generated/abi/DLPTreasuryImplementation.js +588 -0
- package/dist/generated/abi/DLPTreasuryImplementation.js.map +1 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.cjs +985 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.d.cts +737 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.d.ts +737 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.js +961 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.js.map +1 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs +888 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.d.cts +661 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.d.ts +661 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.js +864 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.js.map +1 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs +1317 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.cts +989 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.ts +989 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.js +1293 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.js.map +1 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.cjs +1438 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.d.cts +1086 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.d.ts +1086 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.js +1414 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.js.map +1 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.cjs +984 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.d.cts +737 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.d.ts +737 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.js +960 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.js.map +1 -0
- package/dist/generated/abi/DataRegistryImplementation.cjs +1328 -0
- package/dist/generated/abi/DataRegistryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataRegistryImplementation.d.cts +1004 -0
- package/dist/generated/abi/DataRegistryImplementation.d.ts +1004 -0
- package/dist/generated/abi/DataRegistryImplementation.js +1304 -0
- package/dist/generated/abi/DataRegistryImplementation.js.map +1 -0
- package/dist/generated/abi/QueryEngineImplementation.cjs +1319 -0
- package/dist/generated/abi/QueryEngineImplementation.cjs.map +1 -0
- package/dist/generated/abi/QueryEngineImplementation.d.cts +1001 -0
- package/dist/generated/abi/QueryEngineImplementation.d.ts +1001 -0
- package/dist/generated/abi/QueryEngineImplementation.js +1295 -0
- package/dist/generated/abi/QueryEngineImplementation.js.map +1 -0
- package/dist/generated/abi/SwapHelperImplementation.cjs +1019 -0
- package/dist/generated/abi/SwapHelperImplementation.cjs.map +1 -0
- package/dist/generated/abi/SwapHelperImplementation.d.cts +764 -0
- package/dist/generated/abi/SwapHelperImplementation.d.ts +764 -0
- package/dist/generated/abi/SwapHelperImplementation.js +995 -0
- package/dist/generated/abi/SwapHelperImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.cts +701 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.ts +701 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.js +912 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.cts +701 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.ts +701 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.js +912 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.cts +701 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.ts +701 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.js +912 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolImplementation.cjs +1313 -0
- package/dist/generated/abi/TeePoolImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolImplementation.d.cts +993 -0
- package/dist/generated/abi/TeePoolImplementation.d.ts +993 -0
- package/dist/generated/abi/TeePoolImplementation.js +1289 -0
- package/dist/generated/abi/TeePoolImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.cts +701 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.ts +701 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.js +912 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.cts +701 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.ts +701 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.js +912 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.cjs +1313 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.d.cts +993 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.d.ts +993 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.js +1289 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.js.map +1 -0
- package/dist/generated/abi/VanaEpochImplementation.cjs +1188 -0
- package/dist/generated/abi/VanaEpochImplementation.cjs.map +1 -0
- package/dist/generated/abi/VanaEpochImplementation.d.cts +900 -0
- package/dist/generated/abi/VanaEpochImplementation.d.ts +900 -0
- package/dist/generated/abi/VanaEpochImplementation.js +1164 -0
- package/dist/generated/abi/VanaEpochImplementation.js.map +1 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.cjs +1234 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.cjs.map +1 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.d.cts +934 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.d.ts +934 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.js +1210 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.js.map +1 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.cjs +921 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.cjs.map +1 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.d.cts +693 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.d.ts +693 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.js +897 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.js.map +1 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.cjs +538 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.cjs.map +1 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.d.cts +394 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.d.ts +394 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.js +514 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.js.map +1 -0
- package/dist/generated/abi/index.cjs +135 -0
- package/dist/generated/abi/index.cjs.map +1 -0
- package/dist/generated/abi/index.d.cts +26516 -0
- package/dist/generated/abi/index.d.ts +26516 -0
- package/dist/generated/abi/index.js +99 -0
- package/dist/generated/abi/index.js.map +1 -0
- package/dist/generated/server/server-exports.cjs +23 -0
- package/dist/generated/server/server-exports.cjs.map +1 -0
- package/dist/generated/server/server-exports.d.cts +21 -0
- package/dist/generated/server/server-exports.d.ts +21 -0
- package/dist/generated/server/server-exports.js +2 -0
- package/dist/generated/server/server-exports.js.map +1 -0
- package/dist/generated/server/server.cjs +17 -0
- package/dist/generated/server/server.cjs.map +1 -0
- package/dist/generated/server/server.d.cts +512 -0
- package/dist/generated/server/server.d.ts +512 -0
- package/dist/generated/server/server.js +1 -0
- package/dist/generated/server/server.js.map +1 -0
- package/dist/generated/subgraph.cjs +675 -0
- package/dist/generated/subgraph.cjs.map +1 -0
- package/dist/generated/subgraph.d.cts +5981 -0
- package/dist/generated/subgraph.d.ts +5981 -0
- package/dist/generated/subgraph.js +644 -0
- package/dist/generated/subgraph.js.map +1 -0
- package/dist/index.browser.cjs +151 -0
- package/dist/index.browser.cjs.map +1 -0
- package/dist/index.browser.d.cts +177 -0
- package/dist/index.browser.d.ts +67 -37276
- package/dist/index.browser.js +64 -46357
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.node.cjs +87 -46843
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.cts +63 -37546
- package/dist/index.node.d.ts +63 -37546
- package/dist/index.node.js +68 -46730
- package/dist/index.node.js.map +1 -1
- package/dist/node.cjs +2 -321
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +2 -1
- package/dist/node.d.ts +2 -1
- package/dist/node.js +1 -307
- package/dist/node.js.map +1 -1
- package/dist/permissions-DNKPu_G0.d.cts +1666 -0
- package/dist/permissions-eo8YeLGf.d.ts +1666 -0
- package/dist/platform/browser-only.cjs +37 -0
- package/dist/platform/browser-only.cjs.map +1 -0
- package/dist/platform/browser-only.d.cts +25 -0
- package/dist/platform/browser-only.d.ts +25 -0
- package/dist/platform/browser-only.js +12 -0
- package/dist/platform/browser-only.js.map +1 -0
- package/dist/platform/browser-safe.cjs +57 -0
- package/dist/platform/browser-safe.cjs.map +1 -0
- package/dist/platform/browser-safe.d.cts +32 -0
- package/dist/platform/browser-safe.d.ts +32 -0
- package/dist/platform/browser-safe.js +31 -0
- package/dist/platform/browser-safe.js.map +1 -0
- package/dist/platform/browser.cjs +329 -0
- package/dist/platform/browser.cjs.map +1 -0
- package/dist/platform/browser.d.cts +74 -0
- package/dist/platform/browser.d.ts +74 -0
- package/dist/platform/browser.js +304 -0
- package/dist/platform/browser.js.map +1 -0
- package/dist/platform/index.cjs +50 -0
- package/dist/platform/index.cjs.map +1 -0
- package/dist/platform/index.d.cts +5 -0
- package/dist/platform/index.d.ts +5 -0
- package/dist/platform/index.js +27 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/interface.cjs +17 -0
- package/dist/platform/interface.cjs.map +1 -0
- package/dist/{node-D9-F9uEP.d.cts → platform/interface.d.cts} +1 -21
- package/dist/{node-D9-F9uEP.d.ts → platform/interface.d.ts} +1 -21
- package/dist/platform/interface.js +1 -0
- package/dist/platform/interface.js.map +1 -0
- package/dist/platform/node.cjs +351 -0
- package/dist/platform/node.cjs.map +1 -0
- package/dist/platform/node.d.cts +27 -0
- package/dist/platform/node.d.ts +27 -0
- package/dist/platform/node.js +327 -0
- package/dist/platform/node.js.map +1 -0
- package/dist/platform/shared/error-utils.cjs +43 -0
- package/dist/platform/shared/error-utils.cjs.map +1 -0
- package/dist/platform/shared/error-utils.d.cts +25 -0
- package/dist/platform/shared/error-utils.d.ts +25 -0
- package/dist/platform/shared/error-utils.js +18 -0
- package/dist/platform/shared/error-utils.js.map +1 -0
- package/dist/platform/shared/pgp-utils.cjs +55 -0
- package/dist/platform/shared/pgp-utils.cjs.map +1 -0
- package/dist/platform/shared/pgp-utils.d.cts +61 -0
- package/dist/platform/shared/pgp-utils.d.ts +61 -0
- package/dist/platform/shared/pgp-utils.js +29 -0
- package/dist/platform/shared/pgp-utils.js.map +1 -0
- package/dist/platform/shared/stream-utils.cjs +49 -0
- package/dist/platform/shared/stream-utils.cjs.map +1 -0
- package/dist/platform/shared/stream-utils.d.cts +16 -0
- package/dist/platform/shared/stream-utils.d.ts +16 -0
- package/dist/platform/shared/stream-utils.js +25 -0
- package/dist/platform/shared/stream-utils.js.map +1 -0
- package/dist/platform/utils.cjs +114 -0
- package/dist/platform/utils.cjs.map +1 -0
- package/dist/platform/utils.d.cts +53 -0
- package/dist/platform/utils.d.ts +53 -0
- package/dist/platform/utils.js +76 -0
- package/dist/platform/utils.js.map +1 -0
- package/dist/platform.browser.cjs +41 -0
- package/dist/platform.browser.cjs.map +1 -0
- package/dist/platform.browser.d.cts +4 -0
- package/dist/platform.browser.d.ts +4 -60
- package/dist/platform.browser.js +10 -379
- package/dist/platform.browser.js.map +1 -1
- package/dist/platform.cjs +14 -708
- package/dist/platform.cjs.map +1 -1
- package/dist/platform.d.cts +5 -2
- package/dist/platform.d.ts +5 -2
- package/dist/platform.js +14 -694
- package/dist/platform.js.map +1 -1
- package/dist/platform.node.cjs +14 -708
- package/dist/platform.node.cjs.map +1 -1
- package/dist/platform.node.d.cts +5 -105
- package/dist/platform.node.d.ts +5 -105
- package/dist/platform.node.js +14 -694
- package/dist/platform.node.js.map +1 -1
- package/dist/schemas/dataSchema.schema.d.cts +88 -0
- package/dist/schemas/dataSchema.schema.d.ts +88 -0
- package/dist/schemas/dataSchema.schema.json +53 -0
- package/dist/schemas/grantFile.schema.d.cts +57 -0
- package/dist/schemas/grantFile.schema.d.ts +57 -0
- package/dist/schemas/grantFile.schema.json +43 -0
- package/dist/server/handler.cjs +101 -0
- package/dist/server/handler.cjs.map +1 -0
- package/dist/server/handler.d.cts +282 -0
- package/dist/server/handler.d.ts +282 -0
- package/dist/server/handler.js +77 -0
- package/dist/server/handler.js.map +1 -0
- package/dist/storage/index.cjs +44 -0
- package/dist/storage/index.cjs.map +1 -0
- package/dist/storage/index.d.cts +10 -0
- package/dist/storage/index.d.ts +10 -0
- package/dist/storage/index.js +15 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/manager.cjs +189 -0
- package/dist/storage/manager.cjs.map +1 -0
- package/dist/storage/manager.d.cts +150 -0
- package/dist/storage/manager.d.ts +150 -0
- package/dist/storage/manager.js +172 -0
- package/dist/storage/manager.js.map +1 -0
- package/dist/storage/providers/callback-storage.cjs +177 -0
- package/dist/storage/providers/callback-storage.cjs.map +1 -0
- package/dist/storage/providers/callback-storage.d.cts +100 -0
- package/dist/storage/providers/callback-storage.d.ts +100 -0
- package/dist/storage/providers/callback-storage.js +155 -0
- package/dist/storage/providers/callback-storage.js.map +1 -0
- package/dist/storage/providers/google-drive.cjs +516 -0
- package/dist/storage/providers/google-drive.cjs.map +1 -0
- package/dist/storage/providers/google-drive.d.cts +156 -0
- package/dist/storage/providers/google-drive.d.ts +156 -0
- package/dist/storage/providers/google-drive.js +497 -0
- package/dist/storage/providers/google-drive.js.map +1 -0
- package/dist/storage/providers/ipfs.cjs +283 -0
- package/dist/storage/providers/ipfs.cjs.map +1 -0
- package/dist/storage/providers/ipfs.d.cts +163 -0
- package/dist/storage/providers/ipfs.d.ts +163 -0
- package/dist/storage/providers/ipfs.js +264 -0
- package/dist/storage/providers/ipfs.js.map +1 -0
- package/dist/storage/providers/pinata.cjs +339 -0
- package/dist/storage/providers/pinata.cjs.map +1 -0
- package/dist/storage/providers/pinata.d.cts +173 -0
- package/dist/storage/providers/pinata.d.ts +173 -0
- package/dist/storage/providers/pinata.js +320 -0
- package/dist/storage/providers/pinata.js.map +1 -0
- package/dist/types/chains.cjs +36 -0
- package/dist/types/chains.cjs.map +1 -0
- package/dist/types/chains.d.cts +34 -0
- package/dist/types/chains.d.ts +34 -0
- package/dist/types/chains.js +11 -0
- package/dist/types/chains.js.map +1 -0
- package/dist/types/config.cjs +41 -0
- package/dist/types/config.cjs.map +1 -0
- package/dist/types/config.d.cts +726 -0
- package/dist/types/config.d.ts +726 -0
- package/dist/types/config.js +15 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/contracts.cjs +17 -0
- package/dist/types/contracts.cjs.map +1 -0
- package/dist/types/contracts.d.cts +68 -0
- package/dist/types/contracts.d.ts +68 -0
- package/dist/types/contracts.js +1 -0
- package/dist/types/contracts.js.map +1 -0
- package/dist/types/data.cjs +17 -0
- package/dist/types/data.cjs.map +1 -0
- package/dist/types/data.d.cts +694 -0
- package/dist/types/data.d.ts +694 -0
- package/dist/types/data.js +1 -0
- package/dist/types/data.js.map +1 -0
- package/dist/types/eccrypto-js.d.cjs +2 -0
- package/dist/types/eccrypto-js.d.cjs.map +1 -0
- package/dist/types/eccrypto-js.d.d.cts +13 -0
- package/dist/types/eccrypto-js.d.d.ts +13 -0
- package/dist/types/eccrypto-js.d.js +1 -0
- package/dist/types/eccrypto-js.d.js.map +1 -0
- package/dist/types/external-apis.cjs +61 -0
- package/dist/types/external-apis.cjs.map +1 -0
- package/dist/types/external-apis.d.cts +186 -0
- package/dist/types/external-apis.d.ts +186 -0
- package/dist/types/external-apis.js +34 -0
- package/dist/types/external-apis.js.map +1 -0
- package/dist/types/generics.cjs +17 -0
- package/dist/types/generics.cjs.map +1 -0
- package/dist/types/generics.d.cts +450 -0
- package/dist/types/generics.d.ts +450 -0
- package/dist/types/generics.js +1 -0
- package/dist/types/generics.js.map +1 -0
- package/dist/types/index.cjs +64 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +34 -0
- package/dist/types/index.d.ts +34 -0
- package/dist/types/index.js +35 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/operations.cjs +65 -0
- package/dist/types/operations.cjs.map +1 -0
- package/dist/types/operations.d.cts +108 -0
- package/dist/types/operations.d.ts +108 -0
- package/dist/types/operations.js +37 -0
- package/dist/types/operations.js.map +1 -0
- package/dist/types/permissions.cjs +17 -0
- package/dist/types/permissions.cjs.map +1 -0
- package/dist/types/permissions.d.cts +957 -0
- package/dist/types/permissions.d.ts +957 -0
- package/dist/types/permissions.js +1 -0
- package/dist/types/permissions.js.map +1 -0
- package/dist/types/personal.cjs +17 -0
- package/dist/types/personal.cjs.map +1 -0
- package/dist/types/personal.d.cts +40 -0
- package/dist/types/personal.d.ts +40 -0
- package/dist/types/personal.js +1 -0
- package/dist/types/personal.js.map +1 -0
- package/dist/types/relayer.cjs +17 -0
- package/dist/types/relayer.cjs.map +1 -0
- package/dist/types/relayer.d.cts +284 -0
- package/dist/types/relayer.d.ts +284 -0
- package/dist/types/relayer.js +1 -0
- package/dist/types/relayer.js.map +1 -0
- package/dist/types/storage.cjs +39 -0
- package/dist/types/storage.cjs.map +1 -0
- package/dist/types/storage.d.cts +131 -0
- package/dist/types/storage.d.ts +131 -0
- package/dist/types/storage.js +18 -0
- package/dist/types/storage.js.map +1 -0
- package/dist/types/transactionResults.cjs +17 -0
- package/dist/types/transactionResults.cjs.map +1 -0
- package/dist/types/transactionResults.d.cts +25 -0
- package/dist/types/transactionResults.d.ts +25 -0
- package/dist/types/transactionResults.js +1 -0
- package/dist/types/transactionResults.js.map +1 -0
- package/dist/types/utils.cjs +17 -0
- package/dist/types/utils.cjs.map +1 -0
- package/dist/types/utils.d.cts +819 -0
- package/dist/types/utils.d.ts +819 -0
- package/dist/types/utils.js +1 -0
- package/dist/types/utils.js.map +1 -0
- package/dist/types.cjs +23 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +66 -0
- package/dist/types.d.ts +66 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/blockchain/registry.cjs +81 -0
- package/dist/utils/blockchain/registry.cjs.map +1 -0
- package/dist/utils/blockchain/registry.d.cts +34 -0
- package/dist/utils/blockchain/registry.d.ts +34 -0
- package/dist/utils/blockchain/registry.js +56 -0
- package/dist/utils/blockchain/registry.js.map +1 -0
- package/dist/utils/crypto-utils.cjs +120 -0
- package/dist/utils/crypto-utils.cjs.map +1 -0
- package/dist/utils/crypto-utils.d.cts +118 -0
- package/dist/utils/crypto-utils.d.ts +118 -0
- package/dist/utils/crypto-utils.js +87 -0
- package/dist/utils/crypto-utils.js.map +1 -0
- package/dist/utils/download.cjs +69 -0
- package/dist/utils/download.cjs.map +1 -0
- package/dist/utils/download.d.cts +41 -0
- package/dist/utils/download.d.ts +41 -0
- package/dist/utils/download.js +45 -0
- package/dist/utils/download.js.map +1 -0
- package/dist/utils/encoding.cjs +66 -0
- package/dist/utils/encoding.cjs.map +1 -0
- package/dist/utils/encoding.d.cts +54 -0
- package/dist/utils/encoding.d.ts +54 -0
- package/dist/utils/encoding.js +39 -0
- package/dist/utils/encoding.js.map +1 -0
- package/dist/utils/encryption.cjs +170 -0
- package/dist/utils/encryption.cjs.map +1 -0
- package/dist/utils/encryption.d.cts +275 -0
- package/dist/utils/encryption.d.ts +275 -0
- package/dist/utils/encryption.js +136 -0
- package/dist/utils/encryption.js.map +1 -0
- package/dist/utils/eventParsing.cjs +111 -0
- package/dist/utils/eventParsing.cjs.map +1 -0
- package/dist/utils/eventParsing.d.cts +60 -0
- package/dist/utils/eventParsing.d.ts +60 -0
- package/dist/utils/eventParsing.js +86 -0
- package/dist/utils/eventParsing.js.map +1 -0
- package/dist/utils/formatters.cjs +53 -0
- package/dist/utils/formatters.cjs.map +1 -0
- package/dist/utils/formatters.d.cts +120 -0
- package/dist/utils/formatters.d.ts +120 -0
- package/dist/utils/formatters.js +26 -0
- package/dist/utils/formatters.js.map +1 -0
- package/dist/utils/grantFiles.cjs +175 -0
- package/dist/utils/grantFiles.cjs.map +1 -0
- package/dist/utils/grantFiles.d.cts +186 -0
- package/dist/utils/grantFiles.d.ts +186 -0
- package/dist/utils/grantFiles.js +137 -0
- package/dist/utils/grantFiles.js.map +1 -0
- package/dist/utils/grantValidation.cjs +243 -0
- package/dist/utils/grantValidation.cjs.map +1 -0
- package/dist/utils/grantValidation.d.cts +150 -0
- package/dist/utils/grantValidation.d.ts +150 -0
- package/dist/utils/grantValidation.js +201 -0
- package/dist/utils/grantValidation.js.map +1 -0
- package/dist/utils/grants.cjs +108 -0
- package/dist/utils/grants.cjs.map +1 -0
- package/dist/utils/grants.d.cts +70 -0
- package/dist/utils/grants.d.ts +70 -0
- package/dist/utils/grants.js +82 -0
- package/dist/utils/grants.js.map +1 -0
- package/dist/utils/ipfs.cjs +130 -0
- package/dist/utils/ipfs.cjs.map +1 -0
- package/dist/utils/ipfs.d.cts +90 -0
- package/dist/utils/ipfs.d.ts +90 -0
- package/dist/utils/ipfs.js +99 -0
- package/dist/utils/ipfs.js.map +1 -0
- package/dist/utils/lazy-import.cjs +40 -0
- package/dist/utils/lazy-import.cjs.map +1 -0
- package/dist/utils/lazy-import.d.cts +20 -0
- package/dist/utils/lazy-import.d.ts +20 -0
- package/dist/utils/lazy-import.js +16 -0
- package/dist/utils/lazy-import.js.map +1 -0
- package/dist/utils/multicall.cjs +231 -0
- package/dist/utils/multicall.cjs.map +1 -0
- package/dist/utils/multicall.d.cts +129 -0
- package/dist/utils/multicall.d.ts +129 -0
- package/dist/utils/multicall.js +206 -0
- package/dist/utils/multicall.js.map +1 -0
- package/dist/utils/schemaValidation.cjs +258 -0
- package/dist/utils/schemaValidation.cjs.map +1 -0
- package/dist/utils/schemaValidation.d.cts +172 -0
- package/dist/utils/schemaValidation.d.ts +172 -0
- package/dist/utils/schemaValidation.js +222 -0
- package/dist/utils/schemaValidation.js.map +1 -0
- package/dist/utils/signatureCache.cjs +187 -0
- package/dist/utils/signatureCache.cjs.map +1 -0
- package/dist/utils/signatureCache.d.cts +134 -0
- package/dist/utils/signatureCache.d.ts +134 -0
- package/dist/utils/signatureCache.js +165 -0
- package/dist/utils/signatureCache.js.map +1 -0
- package/dist/utils/signatureFormatter.cjs +45 -0
- package/dist/utils/signatureFormatter.cjs.map +1 -0
- package/dist/utils/signatureFormatter.d.cts +39 -0
- package/dist/utils/signatureFormatter.d.ts +39 -0
- package/dist/utils/signatureFormatter.js +21 -0
- package/dist/utils/signatureFormatter.js.map +1 -0
- package/dist/utils/transactionParsing.cjs +84 -0
- package/dist/utils/transactionParsing.cjs.map +1 -0
- package/dist/utils/transactionParsing.d.cts +25 -0
- package/dist/utils/transactionParsing.d.ts +25 -0
- package/dist/utils/transactionParsing.js +62 -0
- package/dist/utils/transactionParsing.js.map +1 -0
- package/dist/utils/typedDataConverter.cjs +43 -0
- package/dist/utils/typedDataConverter.cjs.map +1 -0
- package/dist/utils/typedDataConverter.d.cts +13 -0
- package/dist/utils/typedDataConverter.d.ts +13 -0
- package/dist/utils/typedDataConverter.js +19 -0
- package/dist/utils/typedDataConverter.js.map +1 -0
- package/dist/utils/urlResolver.cjs +55 -0
- package/dist/utils/urlResolver.cjs.map +1 -0
- package/dist/utils/urlResolver.d.cts +40 -0
- package/dist/utils/urlResolver.d.ts +40 -0
- package/dist/utils/urlResolver.js +30 -0
- package/dist/utils/urlResolver.js.map +1 -0
- package/package.json +42 -19
- package/dist/browser-DY8XDblx.d.ts +0 -241
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var signatureCache_exports = {};
|
|
20
|
+
__export(signatureCache_exports, {
|
|
21
|
+
SignatureCache: () => SignatureCache,
|
|
22
|
+
withSignatureCache: () => withSignatureCache
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(signatureCache_exports);
|
|
25
|
+
var import_viem = require("viem");
|
|
26
|
+
var import_sha256 = require("@noble/hashes/sha256");
|
|
27
|
+
var import_utils = require("@noble/hashes/utils");
|
|
28
|
+
class SignatureCache {
|
|
29
|
+
static PREFIX = "vana_sig_";
|
|
30
|
+
static DEFAULT_TTL_HOURS = 2;
|
|
31
|
+
/**
|
|
32
|
+
* Get a cached signature if it exists and hasn't expired
|
|
33
|
+
*
|
|
34
|
+
* @param cache - Platform cache adapter instance
|
|
35
|
+
* @param walletAddress - Wallet address that created the signature
|
|
36
|
+
* @param messageHash - Hash of the message that was signed
|
|
37
|
+
* @returns The cached signature if valid, null if expired or not found
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const messageHash = SignatureCache.hashMessage(typedData);
|
|
41
|
+
* const cached = SignatureCache.get(cache, '0x123...', messageHash);
|
|
42
|
+
* if (cached) {
|
|
43
|
+
* console.log('Using cached signature:', cached);
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
static get(cache, walletAddress, messageHash) {
|
|
48
|
+
const key = this.getCacheKey(walletAddress, messageHash);
|
|
49
|
+
try {
|
|
50
|
+
const stored = cache.get(key);
|
|
51
|
+
if (!stored) return null;
|
|
52
|
+
const cached = JSON.parse(stored);
|
|
53
|
+
if (Date.now() > cached.expires) {
|
|
54
|
+
cache.delete(key);
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return cached.signature;
|
|
58
|
+
} catch {
|
|
59
|
+
try {
|
|
60
|
+
cache.delete(key);
|
|
61
|
+
} catch {
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Store a signature in the cache with configurable TTL
|
|
68
|
+
*
|
|
69
|
+
* @param cache - Platform cache adapter instance
|
|
70
|
+
* @param walletAddress - Wallet address that created the signature
|
|
71
|
+
* @param messageHash - Hash of the message that was signed
|
|
72
|
+
* @param signature - The signature to cache
|
|
73
|
+
* @param ttlHours - Time to live in hours (default: 2)
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const signature = await wallet.signTypedData(typedData);
|
|
77
|
+
* const messageHash = SignatureCache.hashMessage(typedData);
|
|
78
|
+
*
|
|
79
|
+
* // Cache for default 2 hours
|
|
80
|
+
* SignatureCache.set(cache, walletAddress, messageHash, signature);
|
|
81
|
+
*
|
|
82
|
+
* // Cache for 24 hours
|
|
83
|
+
* SignatureCache.set(cache, walletAddress, messageHash, signature, 24);
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
static set(cache, walletAddress, messageHash, signature, ttlHours = this.DEFAULT_TTL_HOURS) {
|
|
87
|
+
const key = this.getCacheKey(walletAddress, messageHash);
|
|
88
|
+
const cached = {
|
|
89
|
+
signature,
|
|
90
|
+
expires: Date.now() + ttlHours * 36e5
|
|
91
|
+
// Convert hours to milliseconds
|
|
92
|
+
};
|
|
93
|
+
try {
|
|
94
|
+
cache.set(key, JSON.stringify(cached));
|
|
95
|
+
} catch {
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Clear all cached signatures (useful for testing or explicit cleanup)
|
|
100
|
+
*
|
|
101
|
+
* @param cache - Platform cache adapter instance
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* // Clear all signatures when user logs out
|
|
105
|
+
* SignatureCache.clear(cache);
|
|
106
|
+
*
|
|
107
|
+
* // Clear before running tests
|
|
108
|
+
* beforeEach(() => {
|
|
109
|
+
* SignatureCache.clear(cache);
|
|
110
|
+
* });
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
static clear(cache) {
|
|
114
|
+
try {
|
|
115
|
+
cache.clear();
|
|
116
|
+
} catch {
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
static getCacheKey(walletAddress, messageHash) {
|
|
120
|
+
return `${this.PREFIX}${(0, import_viem.getAddress)(walletAddress)}:${messageHash}`;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Generate a deterministic hash of a message object for cache key generation
|
|
124
|
+
*
|
|
125
|
+
* @remarks
|
|
126
|
+
* Creates a cryptographically secure hash from complex objects including EIP-712 typed data.
|
|
127
|
+
* Uses SHA-256 for collision resistance and deterministic key generation.
|
|
128
|
+
* Handles BigInt serialization and sorts object keys for consistency.
|
|
129
|
+
*
|
|
130
|
+
* @param message - The message object to hash (typically EIP-712 typed data)
|
|
131
|
+
* @returns A hex string hash (SHA-256) suitable for cache keys
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* const typedData = {
|
|
135
|
+
* domain: { name: 'Vana', version: '1' },
|
|
136
|
+
* message: { nonce: 123n, grant: '...' }
|
|
137
|
+
* };
|
|
138
|
+
*
|
|
139
|
+
* const hash = SignatureCache.hashMessage(typedData);
|
|
140
|
+
* // Returns SHA-256 hash like: "a1b2c3d4e5f6..."
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
static hashMessage(message) {
|
|
144
|
+
const jsonString = JSON.stringify(message, this.deterministicReplacer);
|
|
145
|
+
const hashBytes = (0, import_sha256.sha256)(new TextEncoder().encode(jsonString));
|
|
146
|
+
return (0, import_utils.bytesToHex)(hashBytes);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Deterministic JSON replacer that handles BigInt values and sorts object keys
|
|
150
|
+
* This ensures consistent cache key generation for EIP-712 typed data
|
|
151
|
+
*
|
|
152
|
+
* @param _key - The object key being serialized (unused)
|
|
153
|
+
* @param value - The value to serialize
|
|
154
|
+
* @returns The serialized value with sorted keys for objects
|
|
155
|
+
*/
|
|
156
|
+
static deterministicReplacer(_key, value) {
|
|
157
|
+
if (typeof value === "bigint") {
|
|
158
|
+
return `__BIGINT__${value.toString()}`;
|
|
159
|
+
}
|
|
160
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
161
|
+
return Object.keys(value).sort().reduce(
|
|
162
|
+
(sorted, key) => {
|
|
163
|
+
sorted[key] = value[key];
|
|
164
|
+
return sorted;
|
|
165
|
+
},
|
|
166
|
+
{}
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
return value;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async function withSignatureCache(cache, walletAddress, typedData, signFn, ttlHours) {
|
|
173
|
+
const messageHash = SignatureCache.hashMessage(typedData);
|
|
174
|
+
const cached = SignatureCache.get(cache, walletAddress, messageHash);
|
|
175
|
+
if (cached) {
|
|
176
|
+
return cached;
|
|
177
|
+
}
|
|
178
|
+
const signature = await signFn();
|
|
179
|
+
SignatureCache.set(cache, walletAddress, messageHash, signature, ttlHours);
|
|
180
|
+
return signature;
|
|
181
|
+
}
|
|
182
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
183
|
+
0 && (module.exports = {
|
|
184
|
+
SignatureCache,
|
|
185
|
+
withSignatureCache
|
|
186
|
+
});
|
|
187
|
+
//# sourceMappingURL=signatureCache.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/signatureCache.ts"],"sourcesContent":["import { Hash, getAddress } from \"viem\";\nimport type { VanaCacheAdapter } from \"../platform/interface\";\nimport { sha256 } from \"@noble/hashes/sha256\";\nimport { bytesToHex } from \"@noble/hashes/utils\";\n\ninterface CachedSignature {\n signature: Hash;\n expires: number;\n}\n\n/**\n * Simple signature cache using platform cache adapter to avoid repeated signing of identical messages.\n *\n * @remarks\n * This cache significantly improves UX by avoiding repeated wallet signature prompts\n * for identical operations. It's particularly useful for operations that may be\n * retried or called multiple times with the same parameters.\n *\n * Features:\n * - Platform-appropriate storage (sessionStorage in browser, memory in Node.js)\n * - Configurable TTL (default 2 hours)\n * - Automatic cleanup of expired entries\n * - Cache keys based on wallet address + message hash\n *\n * @example\n * ```typescript\n * // Check cache before requesting signature\n * const cached = SignatureCache.get(cache, walletAddress, messageHash);\n * if (cached) {\n * return cached;\n * }\n *\n * // Request signature and cache it\n * const signature = await wallet.signTypedData(typedData);\n * SignatureCache.set(cache, walletAddress, messageHash, signature);\n * ```\n * @category Utilities\n */\nexport class SignatureCache {\n private static readonly PREFIX = \"vana_sig_\";\n private static readonly DEFAULT_TTL_HOURS = 2;\n\n /**\n * Get a cached signature if it exists and hasn't expired\n *\n * @param cache - Platform cache adapter instance\n * @param walletAddress - Wallet address that created the signature\n * @param messageHash - Hash of the message that was signed\n * @returns The cached signature if valid, null if expired or not found\n * @example\n * ```typescript\n * const messageHash = SignatureCache.hashMessage(typedData);\n * const cached = SignatureCache.get(cache, '0x123...', messageHash);\n * if (cached) {\n * console.log('Using cached signature:', cached);\n * }\n * ```\n */\n static get(\n cache: VanaCacheAdapter,\n walletAddress: string,\n messageHash: string,\n ): Hash | null {\n const key = this.getCacheKey(walletAddress, messageHash);\n\n try {\n const stored = cache.get(key);\n if (!stored) return null;\n\n const cached: CachedSignature = JSON.parse(stored);\n\n // Check if expired\n if (Date.now() > cached.expires) {\n cache.delete(key);\n return null;\n }\n\n return cached.signature;\n } catch {\n // Invalid JSON or storage error, clean up\n try {\n cache.delete(key);\n } catch {\n // Ignore cache cleanup errors\n }\n return null;\n }\n }\n\n /**\n * Store a signature in the cache with configurable TTL\n *\n * @param cache - Platform cache adapter instance\n * @param walletAddress - Wallet address that created the signature\n * @param messageHash - Hash of the message that was signed\n * @param signature - The signature to cache\n * @param ttlHours - Time to live in hours (default: 2)\n * @example\n * ```typescript\n * const signature = await wallet.signTypedData(typedData);\n * const messageHash = SignatureCache.hashMessage(typedData);\n *\n * // Cache for default 2 hours\n * SignatureCache.set(cache, walletAddress, messageHash, signature);\n *\n * // Cache for 24 hours\n * SignatureCache.set(cache, walletAddress, messageHash, signature, 24);\n * ```\n */\n static set(\n cache: VanaCacheAdapter,\n walletAddress: string,\n messageHash: string,\n signature: Hash,\n ttlHours: number = this.DEFAULT_TTL_HOURS,\n ): void {\n const key = this.getCacheKey(walletAddress, messageHash);\n const cached: CachedSignature = {\n signature,\n expires: Date.now() + ttlHours * 3600000, // Convert hours to milliseconds\n };\n\n try {\n cache.set(key, JSON.stringify(cached));\n } catch {\n // Storage quota exceeded or other error, ignore silently\n // Better to continue without caching than to fail\n }\n }\n\n /**\n * Clear all cached signatures (useful for testing or explicit cleanup)\n *\n * @param cache - Platform cache adapter instance\n * @example\n * ```typescript\n * // Clear all signatures when user logs out\n * SignatureCache.clear(cache);\n *\n * // Clear before running tests\n * beforeEach(() => {\n * SignatureCache.clear(cache);\n * });\n * ```\n */\n static clear(cache: VanaCacheAdapter): void {\n try {\n cache.clear();\n } catch {\n // Ignore storage errors\n }\n }\n\n private static getCacheKey(\n walletAddress: string,\n messageHash: string,\n ): string {\n return `${this.PREFIX}${getAddress(walletAddress)}:${messageHash}`;\n }\n\n /**\n * Generate a deterministic hash of a message object for cache key generation\n *\n * @remarks\n * Creates a cryptographically secure hash from complex objects including EIP-712 typed data.\n * Uses SHA-256 for collision resistance and deterministic key generation.\n * Handles BigInt serialization and sorts object keys for consistency.\n *\n * @param message - The message object to hash (typically EIP-712 typed data)\n * @returns A hex string hash (SHA-256) suitable for cache keys\n * @example\n * ```typescript\n * const typedData = {\n * domain: { name: 'Vana', version: '1' },\n * message: { nonce: 123n, grant: '...' }\n * };\n *\n * const hash = SignatureCache.hashMessage(typedData);\n * // Returns SHA-256 hash like: \"a1b2c3d4e5f6...\"\n * ```\n */\n static hashMessage(message: object): string {\n // Deterministically stringify the object with sorted keys\n const jsonString = JSON.stringify(message, this.deterministicReplacer);\n\n // Use SHA-256 for cryptographic hashing\n const hashBytes = sha256(new TextEncoder().encode(jsonString));\n return bytesToHex(hashBytes);\n }\n\n /**\n * Deterministic JSON replacer that handles BigInt values and sorts object keys\n * This ensures consistent cache key generation for EIP-712 typed data\n *\n * @param _key - The object key being serialized (unused)\n * @param value - The value to serialize\n * @returns The serialized value with sorted keys for objects\n */\n private static deterministicReplacer(_key: string, value: unknown): unknown {\n if (typeof value === \"bigint\") {\n return `__BIGINT__${value.toString()}`;\n }\n // Sort object keys for deterministic serialization\n if (value !== null && typeof value === \"object\" && !Array.isArray(value)) {\n return Object.keys(value as Record<string, unknown>)\n .sort()\n .reduce(\n (sorted, key) => {\n sorted[key] = (value as Record<string, unknown>)[key];\n return sorted;\n },\n {} as Record<string, unknown>,\n );\n }\n return value;\n }\n}\n\n/**\n * Wrapper function to cache signature operations\n *\n * @param cache - The cache adapter to use for storage\n * @param walletAddress - The wallet address signing the message\n * @param typedData - The EIP-712 typed data being signed\n * @param signFn - Function that performs the actual signing\n * @param ttlHours - Cache TTL in hours (default 2)\n * @returns The signature (cached or newly generated)\n */\nexport async function withSignatureCache(\n cache: VanaCacheAdapter,\n walletAddress: string,\n typedData: Record<string, unknown>,\n signFn: () => Promise<Hash>,\n ttlHours?: number,\n): Promise<Hash> {\n // Create a hash of the typed data for the cache key\n const messageHash = SignatureCache.hashMessage(typedData);\n\n // Try to get from cache first\n const cached = SignatureCache.get(cache, walletAddress, messageHash);\n if (cached) {\n return cached;\n }\n\n // Not in cache, sign and store\n const signature = await signFn();\n SignatureCache.set(cache, walletAddress, messageHash, signature, ttlHours);\n\n return signature;\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Hash } from 'viem';
|
|
2
|
+
import { VanaCacheAdapter } from '../platform/interface.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Simple signature cache using platform cache adapter to avoid repeated signing of identical messages.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* This cache significantly improves UX by avoiding repeated wallet signature prompts
|
|
9
|
+
* for identical operations. It's particularly useful for operations that may be
|
|
10
|
+
* retried or called multiple times with the same parameters.
|
|
11
|
+
*
|
|
12
|
+
* Features:
|
|
13
|
+
* - Platform-appropriate storage (sessionStorage in browser, memory in Node.js)
|
|
14
|
+
* - Configurable TTL (default 2 hours)
|
|
15
|
+
* - Automatic cleanup of expired entries
|
|
16
|
+
* - Cache keys based on wallet address + message hash
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Check cache before requesting signature
|
|
21
|
+
* const cached = SignatureCache.get(cache, walletAddress, messageHash);
|
|
22
|
+
* if (cached) {
|
|
23
|
+
* return cached;
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* // Request signature and cache it
|
|
27
|
+
* const signature = await wallet.signTypedData(typedData);
|
|
28
|
+
* SignatureCache.set(cache, walletAddress, messageHash, signature);
|
|
29
|
+
* ```
|
|
30
|
+
* @category Utilities
|
|
31
|
+
*/
|
|
32
|
+
declare class SignatureCache {
|
|
33
|
+
private static readonly PREFIX;
|
|
34
|
+
private static readonly DEFAULT_TTL_HOURS;
|
|
35
|
+
/**
|
|
36
|
+
* Get a cached signature if it exists and hasn't expired
|
|
37
|
+
*
|
|
38
|
+
* @param cache - Platform cache adapter instance
|
|
39
|
+
* @param walletAddress - Wallet address that created the signature
|
|
40
|
+
* @param messageHash - Hash of the message that was signed
|
|
41
|
+
* @returns The cached signature if valid, null if expired or not found
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const messageHash = SignatureCache.hashMessage(typedData);
|
|
45
|
+
* const cached = SignatureCache.get(cache, '0x123...', messageHash);
|
|
46
|
+
* if (cached) {
|
|
47
|
+
* console.log('Using cached signature:', cached);
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
static get(cache: VanaCacheAdapter, walletAddress: string, messageHash: string): Hash | null;
|
|
52
|
+
/**
|
|
53
|
+
* Store a signature in the cache with configurable TTL
|
|
54
|
+
*
|
|
55
|
+
* @param cache - Platform cache adapter instance
|
|
56
|
+
* @param walletAddress - Wallet address that created the signature
|
|
57
|
+
* @param messageHash - Hash of the message that was signed
|
|
58
|
+
* @param signature - The signature to cache
|
|
59
|
+
* @param ttlHours - Time to live in hours (default: 2)
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const signature = await wallet.signTypedData(typedData);
|
|
63
|
+
* const messageHash = SignatureCache.hashMessage(typedData);
|
|
64
|
+
*
|
|
65
|
+
* // Cache for default 2 hours
|
|
66
|
+
* SignatureCache.set(cache, walletAddress, messageHash, signature);
|
|
67
|
+
*
|
|
68
|
+
* // Cache for 24 hours
|
|
69
|
+
* SignatureCache.set(cache, walletAddress, messageHash, signature, 24);
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
static set(cache: VanaCacheAdapter, walletAddress: string, messageHash: string, signature: Hash, ttlHours?: number): void;
|
|
73
|
+
/**
|
|
74
|
+
* Clear all cached signatures (useful for testing or explicit cleanup)
|
|
75
|
+
*
|
|
76
|
+
* @param cache - Platform cache adapter instance
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* // Clear all signatures when user logs out
|
|
80
|
+
* SignatureCache.clear(cache);
|
|
81
|
+
*
|
|
82
|
+
* // Clear before running tests
|
|
83
|
+
* beforeEach(() => {
|
|
84
|
+
* SignatureCache.clear(cache);
|
|
85
|
+
* });
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
static clear(cache: VanaCacheAdapter): void;
|
|
89
|
+
private static getCacheKey;
|
|
90
|
+
/**
|
|
91
|
+
* Generate a deterministic hash of a message object for cache key generation
|
|
92
|
+
*
|
|
93
|
+
* @remarks
|
|
94
|
+
* Creates a cryptographically secure hash from complex objects including EIP-712 typed data.
|
|
95
|
+
* Uses SHA-256 for collision resistance and deterministic key generation.
|
|
96
|
+
* Handles BigInt serialization and sorts object keys for consistency.
|
|
97
|
+
*
|
|
98
|
+
* @param message - The message object to hash (typically EIP-712 typed data)
|
|
99
|
+
* @returns A hex string hash (SHA-256) suitable for cache keys
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const typedData = {
|
|
103
|
+
* domain: { name: 'Vana', version: '1' },
|
|
104
|
+
* message: { nonce: 123n, grant: '...' }
|
|
105
|
+
* };
|
|
106
|
+
*
|
|
107
|
+
* const hash = SignatureCache.hashMessage(typedData);
|
|
108
|
+
* // Returns SHA-256 hash like: "a1b2c3d4e5f6..."
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
static hashMessage(message: object): string;
|
|
112
|
+
/**
|
|
113
|
+
* Deterministic JSON replacer that handles BigInt values and sorts object keys
|
|
114
|
+
* This ensures consistent cache key generation for EIP-712 typed data
|
|
115
|
+
*
|
|
116
|
+
* @param _key - The object key being serialized (unused)
|
|
117
|
+
* @param value - The value to serialize
|
|
118
|
+
* @returns The serialized value with sorted keys for objects
|
|
119
|
+
*/
|
|
120
|
+
private static deterministicReplacer;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Wrapper function to cache signature operations
|
|
124
|
+
*
|
|
125
|
+
* @param cache - The cache adapter to use for storage
|
|
126
|
+
* @param walletAddress - The wallet address signing the message
|
|
127
|
+
* @param typedData - The EIP-712 typed data being signed
|
|
128
|
+
* @param signFn - Function that performs the actual signing
|
|
129
|
+
* @param ttlHours - Cache TTL in hours (default 2)
|
|
130
|
+
* @returns The signature (cached or newly generated)
|
|
131
|
+
*/
|
|
132
|
+
declare function withSignatureCache(cache: VanaCacheAdapter, walletAddress: string, typedData: Record<string, unknown>, signFn: () => Promise<Hash>, ttlHours?: number): Promise<Hash>;
|
|
133
|
+
|
|
134
|
+
export { SignatureCache, withSignatureCache };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Hash } from 'viem';
|
|
2
|
+
import { VanaCacheAdapter } from '../platform/interface.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Simple signature cache using platform cache adapter to avoid repeated signing of identical messages.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* This cache significantly improves UX by avoiding repeated wallet signature prompts
|
|
9
|
+
* for identical operations. It's particularly useful for operations that may be
|
|
10
|
+
* retried or called multiple times with the same parameters.
|
|
11
|
+
*
|
|
12
|
+
* Features:
|
|
13
|
+
* - Platform-appropriate storage (sessionStorage in browser, memory in Node.js)
|
|
14
|
+
* - Configurable TTL (default 2 hours)
|
|
15
|
+
* - Automatic cleanup of expired entries
|
|
16
|
+
* - Cache keys based on wallet address + message hash
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Check cache before requesting signature
|
|
21
|
+
* const cached = SignatureCache.get(cache, walletAddress, messageHash);
|
|
22
|
+
* if (cached) {
|
|
23
|
+
* return cached;
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* // Request signature and cache it
|
|
27
|
+
* const signature = await wallet.signTypedData(typedData);
|
|
28
|
+
* SignatureCache.set(cache, walletAddress, messageHash, signature);
|
|
29
|
+
* ```
|
|
30
|
+
* @category Utilities
|
|
31
|
+
*/
|
|
32
|
+
declare class SignatureCache {
|
|
33
|
+
private static readonly PREFIX;
|
|
34
|
+
private static readonly DEFAULT_TTL_HOURS;
|
|
35
|
+
/**
|
|
36
|
+
* Get a cached signature if it exists and hasn't expired
|
|
37
|
+
*
|
|
38
|
+
* @param cache - Platform cache adapter instance
|
|
39
|
+
* @param walletAddress - Wallet address that created the signature
|
|
40
|
+
* @param messageHash - Hash of the message that was signed
|
|
41
|
+
* @returns The cached signature if valid, null if expired or not found
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const messageHash = SignatureCache.hashMessage(typedData);
|
|
45
|
+
* const cached = SignatureCache.get(cache, '0x123...', messageHash);
|
|
46
|
+
* if (cached) {
|
|
47
|
+
* console.log('Using cached signature:', cached);
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
static get(cache: VanaCacheAdapter, walletAddress: string, messageHash: string): Hash | null;
|
|
52
|
+
/**
|
|
53
|
+
* Store a signature in the cache with configurable TTL
|
|
54
|
+
*
|
|
55
|
+
* @param cache - Platform cache adapter instance
|
|
56
|
+
* @param walletAddress - Wallet address that created the signature
|
|
57
|
+
* @param messageHash - Hash of the message that was signed
|
|
58
|
+
* @param signature - The signature to cache
|
|
59
|
+
* @param ttlHours - Time to live in hours (default: 2)
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const signature = await wallet.signTypedData(typedData);
|
|
63
|
+
* const messageHash = SignatureCache.hashMessage(typedData);
|
|
64
|
+
*
|
|
65
|
+
* // Cache for default 2 hours
|
|
66
|
+
* SignatureCache.set(cache, walletAddress, messageHash, signature);
|
|
67
|
+
*
|
|
68
|
+
* // Cache for 24 hours
|
|
69
|
+
* SignatureCache.set(cache, walletAddress, messageHash, signature, 24);
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
static set(cache: VanaCacheAdapter, walletAddress: string, messageHash: string, signature: Hash, ttlHours?: number): void;
|
|
73
|
+
/**
|
|
74
|
+
* Clear all cached signatures (useful for testing or explicit cleanup)
|
|
75
|
+
*
|
|
76
|
+
* @param cache - Platform cache adapter instance
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* // Clear all signatures when user logs out
|
|
80
|
+
* SignatureCache.clear(cache);
|
|
81
|
+
*
|
|
82
|
+
* // Clear before running tests
|
|
83
|
+
* beforeEach(() => {
|
|
84
|
+
* SignatureCache.clear(cache);
|
|
85
|
+
* });
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
static clear(cache: VanaCacheAdapter): void;
|
|
89
|
+
private static getCacheKey;
|
|
90
|
+
/**
|
|
91
|
+
* Generate a deterministic hash of a message object for cache key generation
|
|
92
|
+
*
|
|
93
|
+
* @remarks
|
|
94
|
+
* Creates a cryptographically secure hash from complex objects including EIP-712 typed data.
|
|
95
|
+
* Uses SHA-256 for collision resistance and deterministic key generation.
|
|
96
|
+
* Handles BigInt serialization and sorts object keys for consistency.
|
|
97
|
+
*
|
|
98
|
+
* @param message - The message object to hash (typically EIP-712 typed data)
|
|
99
|
+
* @returns A hex string hash (SHA-256) suitable for cache keys
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const typedData = {
|
|
103
|
+
* domain: { name: 'Vana', version: '1' },
|
|
104
|
+
* message: { nonce: 123n, grant: '...' }
|
|
105
|
+
* };
|
|
106
|
+
*
|
|
107
|
+
* const hash = SignatureCache.hashMessage(typedData);
|
|
108
|
+
* // Returns SHA-256 hash like: "a1b2c3d4e5f6..."
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
static hashMessage(message: object): string;
|
|
112
|
+
/**
|
|
113
|
+
* Deterministic JSON replacer that handles BigInt values and sorts object keys
|
|
114
|
+
* This ensures consistent cache key generation for EIP-712 typed data
|
|
115
|
+
*
|
|
116
|
+
* @param _key - The object key being serialized (unused)
|
|
117
|
+
* @param value - The value to serialize
|
|
118
|
+
* @returns The serialized value with sorted keys for objects
|
|
119
|
+
*/
|
|
120
|
+
private static deterministicReplacer;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Wrapper function to cache signature operations
|
|
124
|
+
*
|
|
125
|
+
* @param cache - The cache adapter to use for storage
|
|
126
|
+
* @param walletAddress - The wallet address signing the message
|
|
127
|
+
* @param typedData - The EIP-712 typed data being signed
|
|
128
|
+
* @param signFn - Function that performs the actual signing
|
|
129
|
+
* @param ttlHours - Cache TTL in hours (default 2)
|
|
130
|
+
* @returns The signature (cached or newly generated)
|
|
131
|
+
*/
|
|
132
|
+
declare function withSignatureCache(cache: VanaCacheAdapter, walletAddress: string, typedData: Record<string, unknown>, signFn: () => Promise<Hash>, ttlHours?: number): Promise<Hash>;
|
|
133
|
+
|
|
134
|
+
export { SignatureCache, withSignatureCache };
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
import { getAddress } from "viem";
|
|
5
|
+
import { sha256 } from "@noble/hashes/sha256";
|
|
6
|
+
import { bytesToHex } from "@noble/hashes/utils";
|
|
7
|
+
class SignatureCache {
|
|
8
|
+
/**
|
|
9
|
+
* Get a cached signature if it exists and hasn't expired
|
|
10
|
+
*
|
|
11
|
+
* @param cache - Platform cache adapter instance
|
|
12
|
+
* @param walletAddress - Wallet address that created the signature
|
|
13
|
+
* @param messageHash - Hash of the message that was signed
|
|
14
|
+
* @returns The cached signature if valid, null if expired or not found
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const messageHash = SignatureCache.hashMessage(typedData);
|
|
18
|
+
* const cached = SignatureCache.get(cache, '0x123...', messageHash);
|
|
19
|
+
* if (cached) {
|
|
20
|
+
* console.log('Using cached signature:', cached);
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
static get(cache, walletAddress, messageHash) {
|
|
25
|
+
const key = this.getCacheKey(walletAddress, messageHash);
|
|
26
|
+
try {
|
|
27
|
+
const stored = cache.get(key);
|
|
28
|
+
if (!stored) return null;
|
|
29
|
+
const cached = JSON.parse(stored);
|
|
30
|
+
if (Date.now() > cached.expires) {
|
|
31
|
+
cache.delete(key);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return cached.signature;
|
|
35
|
+
} catch {
|
|
36
|
+
try {
|
|
37
|
+
cache.delete(key);
|
|
38
|
+
} catch {
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Store a signature in the cache with configurable TTL
|
|
45
|
+
*
|
|
46
|
+
* @param cache - Platform cache adapter instance
|
|
47
|
+
* @param walletAddress - Wallet address that created the signature
|
|
48
|
+
* @param messageHash - Hash of the message that was signed
|
|
49
|
+
* @param signature - The signature to cache
|
|
50
|
+
* @param ttlHours - Time to live in hours (default: 2)
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const signature = await wallet.signTypedData(typedData);
|
|
54
|
+
* const messageHash = SignatureCache.hashMessage(typedData);
|
|
55
|
+
*
|
|
56
|
+
* // Cache for default 2 hours
|
|
57
|
+
* SignatureCache.set(cache, walletAddress, messageHash, signature);
|
|
58
|
+
*
|
|
59
|
+
* // Cache for 24 hours
|
|
60
|
+
* SignatureCache.set(cache, walletAddress, messageHash, signature, 24);
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
static set(cache, walletAddress, messageHash, signature, ttlHours = this.DEFAULT_TTL_HOURS) {
|
|
64
|
+
const key = this.getCacheKey(walletAddress, messageHash);
|
|
65
|
+
const cached = {
|
|
66
|
+
signature,
|
|
67
|
+
expires: Date.now() + ttlHours * 36e5
|
|
68
|
+
// Convert hours to milliseconds
|
|
69
|
+
};
|
|
70
|
+
try {
|
|
71
|
+
cache.set(key, JSON.stringify(cached));
|
|
72
|
+
} catch {
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Clear all cached signatures (useful for testing or explicit cleanup)
|
|
77
|
+
*
|
|
78
|
+
* @param cache - Platform cache adapter instance
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* // Clear all signatures when user logs out
|
|
82
|
+
* SignatureCache.clear(cache);
|
|
83
|
+
*
|
|
84
|
+
* // Clear before running tests
|
|
85
|
+
* beforeEach(() => {
|
|
86
|
+
* SignatureCache.clear(cache);
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
static clear(cache) {
|
|
91
|
+
try {
|
|
92
|
+
cache.clear();
|
|
93
|
+
} catch {
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
static getCacheKey(walletAddress, messageHash) {
|
|
97
|
+
return `${this.PREFIX}${getAddress(walletAddress)}:${messageHash}`;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Generate a deterministic hash of a message object for cache key generation
|
|
101
|
+
*
|
|
102
|
+
* @remarks
|
|
103
|
+
* Creates a cryptographically secure hash from complex objects including EIP-712 typed data.
|
|
104
|
+
* Uses SHA-256 for collision resistance and deterministic key generation.
|
|
105
|
+
* Handles BigInt serialization and sorts object keys for consistency.
|
|
106
|
+
*
|
|
107
|
+
* @param message - The message object to hash (typically EIP-712 typed data)
|
|
108
|
+
* @returns A hex string hash (SHA-256) suitable for cache keys
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const typedData = {
|
|
112
|
+
* domain: { name: 'Vana', version: '1' },
|
|
113
|
+
* message: { nonce: 123n, grant: '...' }
|
|
114
|
+
* };
|
|
115
|
+
*
|
|
116
|
+
* const hash = SignatureCache.hashMessage(typedData);
|
|
117
|
+
* // Returns SHA-256 hash like: "a1b2c3d4e5f6..."
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
static hashMessage(message) {
|
|
121
|
+
const jsonString = JSON.stringify(message, this.deterministicReplacer);
|
|
122
|
+
const hashBytes = sha256(new TextEncoder().encode(jsonString));
|
|
123
|
+
return bytesToHex(hashBytes);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Deterministic JSON replacer that handles BigInt values and sorts object keys
|
|
127
|
+
* This ensures consistent cache key generation for EIP-712 typed data
|
|
128
|
+
*
|
|
129
|
+
* @param _key - The object key being serialized (unused)
|
|
130
|
+
* @param value - The value to serialize
|
|
131
|
+
* @returns The serialized value with sorted keys for objects
|
|
132
|
+
*/
|
|
133
|
+
static deterministicReplacer(_key, value) {
|
|
134
|
+
if (typeof value === "bigint") {
|
|
135
|
+
return `__BIGINT__${value.toString()}`;
|
|
136
|
+
}
|
|
137
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
138
|
+
return Object.keys(value).sort().reduce(
|
|
139
|
+
(sorted, key) => {
|
|
140
|
+
sorted[key] = value[key];
|
|
141
|
+
return sorted;
|
|
142
|
+
},
|
|
143
|
+
{}
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
return value;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
__publicField(SignatureCache, "PREFIX", "vana_sig_");
|
|
150
|
+
__publicField(SignatureCache, "DEFAULT_TTL_HOURS", 2);
|
|
151
|
+
async function withSignatureCache(cache, walletAddress, typedData, signFn, ttlHours) {
|
|
152
|
+
const messageHash = SignatureCache.hashMessage(typedData);
|
|
153
|
+
const cached = SignatureCache.get(cache, walletAddress, messageHash);
|
|
154
|
+
if (cached) {
|
|
155
|
+
return cached;
|
|
156
|
+
}
|
|
157
|
+
const signature = await signFn();
|
|
158
|
+
SignatureCache.set(cache, walletAddress, messageHash, signature, ttlHours);
|
|
159
|
+
return signature;
|
|
160
|
+
}
|
|
161
|
+
export {
|
|
162
|
+
SignatureCache,
|
|
163
|
+
withSignatureCache
|
|
164
|
+
};
|
|
165
|
+
//# sourceMappingURL=signatureCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/signatureCache.ts"],"sourcesContent":["import { Hash, getAddress } from \"viem\";\nimport type { VanaCacheAdapter } from \"../platform/interface\";\nimport { sha256 } from \"@noble/hashes/sha256\";\nimport { bytesToHex } from \"@noble/hashes/utils\";\n\ninterface CachedSignature {\n signature: Hash;\n expires: number;\n}\n\n/**\n * Simple signature cache using platform cache adapter to avoid repeated signing of identical messages.\n *\n * @remarks\n * This cache significantly improves UX by avoiding repeated wallet signature prompts\n * for identical operations. It's particularly useful for operations that may be\n * retried or called multiple times with the same parameters.\n *\n * Features:\n * - Platform-appropriate storage (sessionStorage in browser, memory in Node.js)\n * - Configurable TTL (default 2 hours)\n * - Automatic cleanup of expired entries\n * - Cache keys based on wallet address + message hash\n *\n * @example\n * ```typescript\n * // Check cache before requesting signature\n * const cached = SignatureCache.get(cache, walletAddress, messageHash);\n * if (cached) {\n * return cached;\n * }\n *\n * // Request signature and cache it\n * const signature = await wallet.signTypedData(typedData);\n * SignatureCache.set(cache, walletAddress, messageHash, signature);\n * ```\n * @category Utilities\n */\nexport class SignatureCache {\n private static readonly PREFIX = \"vana_sig_\";\n private static readonly DEFAULT_TTL_HOURS = 2;\n\n /**\n * Get a cached signature if it exists and hasn't expired\n *\n * @param cache - Platform cache adapter instance\n * @param walletAddress - Wallet address that created the signature\n * @param messageHash - Hash of the message that was signed\n * @returns The cached signature if valid, null if expired or not found\n * @example\n * ```typescript\n * const messageHash = SignatureCache.hashMessage(typedData);\n * const cached = SignatureCache.get(cache, '0x123...', messageHash);\n * if (cached) {\n * console.log('Using cached signature:', cached);\n * }\n * ```\n */\n static get(\n cache: VanaCacheAdapter,\n walletAddress: string,\n messageHash: string,\n ): Hash | null {\n const key = this.getCacheKey(walletAddress, messageHash);\n\n try {\n const stored = cache.get(key);\n if (!stored) return null;\n\n const cached: CachedSignature = JSON.parse(stored);\n\n // Check if expired\n if (Date.now() > cached.expires) {\n cache.delete(key);\n return null;\n }\n\n return cached.signature;\n } catch {\n // Invalid JSON or storage error, clean up\n try {\n cache.delete(key);\n } catch {\n // Ignore cache cleanup errors\n }\n return null;\n }\n }\n\n /**\n * Store a signature in the cache with configurable TTL\n *\n * @param cache - Platform cache adapter instance\n * @param walletAddress - Wallet address that created the signature\n * @param messageHash - Hash of the message that was signed\n * @param signature - The signature to cache\n * @param ttlHours - Time to live in hours (default: 2)\n * @example\n * ```typescript\n * const signature = await wallet.signTypedData(typedData);\n * const messageHash = SignatureCache.hashMessage(typedData);\n *\n * // Cache for default 2 hours\n * SignatureCache.set(cache, walletAddress, messageHash, signature);\n *\n * // Cache for 24 hours\n * SignatureCache.set(cache, walletAddress, messageHash, signature, 24);\n * ```\n */\n static set(\n cache: VanaCacheAdapter,\n walletAddress: string,\n messageHash: string,\n signature: Hash,\n ttlHours: number = this.DEFAULT_TTL_HOURS,\n ): void {\n const key = this.getCacheKey(walletAddress, messageHash);\n const cached: CachedSignature = {\n signature,\n expires: Date.now() + ttlHours * 3600000, // Convert hours to milliseconds\n };\n\n try {\n cache.set(key, JSON.stringify(cached));\n } catch {\n // Storage quota exceeded or other error, ignore silently\n // Better to continue without caching than to fail\n }\n }\n\n /**\n * Clear all cached signatures (useful for testing or explicit cleanup)\n *\n * @param cache - Platform cache adapter instance\n * @example\n * ```typescript\n * // Clear all signatures when user logs out\n * SignatureCache.clear(cache);\n *\n * // Clear before running tests\n * beforeEach(() => {\n * SignatureCache.clear(cache);\n * });\n * ```\n */\n static clear(cache: VanaCacheAdapter): void {\n try {\n cache.clear();\n } catch {\n // Ignore storage errors\n }\n }\n\n private static getCacheKey(\n walletAddress: string,\n messageHash: string,\n ): string {\n return `${this.PREFIX}${getAddress(walletAddress)}:${messageHash}`;\n }\n\n /**\n * Generate a deterministic hash of a message object for cache key generation\n *\n * @remarks\n * Creates a cryptographically secure hash from complex objects including EIP-712 typed data.\n * Uses SHA-256 for collision resistance and deterministic key generation.\n * Handles BigInt serialization and sorts object keys for consistency.\n *\n * @param message - The message object to hash (typically EIP-712 typed data)\n * @returns A hex string hash (SHA-256) suitable for cache keys\n * @example\n * ```typescript\n * const typedData = {\n * domain: { name: 'Vana', version: '1' },\n * message: { nonce: 123n, grant: '...' }\n * };\n *\n * const hash = SignatureCache.hashMessage(typedData);\n * // Returns SHA-256 hash like: \"a1b2c3d4e5f6...\"\n * ```\n */\n static hashMessage(message: object): string {\n // Deterministically stringify the object with sorted keys\n const jsonString = JSON.stringify(message, this.deterministicReplacer);\n\n // Use SHA-256 for cryptographic hashing\n const hashBytes = sha256(new TextEncoder().encode(jsonString));\n return bytesToHex(hashBytes);\n }\n\n /**\n * Deterministic JSON replacer that handles BigInt values and sorts object keys\n * This ensures consistent cache key generation for EIP-712 typed data\n *\n * @param _key - The object key being serialized (unused)\n * @param value - The value to serialize\n * @returns The serialized value with sorted keys for objects\n */\n private static deterministicReplacer(_key: string, value: unknown): unknown {\n if (typeof value === \"bigint\") {\n return `__BIGINT__${value.toString()}`;\n }\n // Sort object keys for deterministic serialization\n if (value !== null && typeof value === \"object\" && !Array.isArray(value)) {\n return Object.keys(value as Record<string, unknown>)\n .sort()\n .reduce(\n (sorted, key) => {\n sorted[key] = (value as Record<string, unknown>)[key];\n return sorted;\n },\n {} as Record<string, unknown>,\n );\n }\n return value;\n }\n}\n\n/**\n * Wrapper function to cache signature operations\n *\n * @param cache - The cache adapter to use for storage\n * @param walletAddress - The wallet address signing the message\n * @param typedData - The EIP-712 typed data being signed\n * @param signFn - Function that performs the actual signing\n * @param ttlHours - Cache TTL in hours (default 2)\n * @returns The signature (cached or newly generated)\n */\nexport async function withSignatureCache(\n cache: VanaCacheAdapter,\n walletAddress: string,\n typedData: Record<string, unknown>,\n signFn: () => Promise<Hash>,\n ttlHours?: number,\n): Promise<Hash> {\n // Create a hash of the typed data for the cache key\n const messageHash = SignatureCache.hashMessage(typedData);\n\n // Try to get from cache first\n const cached = SignatureCache.get(cache, walletAddress, messageHash);\n if (cached) {\n return cached;\n }\n\n // Not in cache, sign and store\n const signature = await signFn();\n SignatureCache.set(cache, walletAddress, messageHash, signature, ttlHours);\n\n return signature;\n}\n"],"mappings":"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","names":[]}
|