@fhevm/sdk 0.13.2 → 0.14.0-13
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/_cjs/core/_version.js +1 -1
- package/_cjs/core/_version.js.map +1 -1
- package/_cjs/core/actions/base/canUseUnifiedDecryptionPermit.js +11 -0
- package/_cjs/core/actions/base/canUseUnifiedDecryptionPermit.js.map +1 -0
- package/_cjs/core/actions/base/createUnsignedUnifiedDecryptionPermitEip712.js +0 -4
- package/_cjs/core/actions/base/createUnsignedUnifiedDecryptionPermitEip712.js.map +1 -1
- package/_cjs/core/actions/base/index.js +7 -1
- package/_cjs/core/actions/base/index.js.map +1 -1
- package/_cjs/core/actions/base/signUnifiedDecryptionPermit.js +10 -0
- package/_cjs/core/actions/base/signUnifiedDecryptionPermit.js.map +1 -0
- package/_cjs/core/actions/host/resolveChainId.js +3 -1
- package/_cjs/core/actions/host/resolveChainId.js.map +1 -1
- package/_cjs/core/clients/decorators/base.js +2 -0
- package/_cjs/core/clients/decorators/base.js.map +1 -1
- package/_cjs/core/errors/Erc1271Error.js +48 -0
- package/_cjs/core/errors/Erc1271Error.js.map +1 -0
- package/_cjs/core/frozenContext/fhevmClientFrozenContext-p.js.map +1 -1
- package/_cjs/core/frozenContext/resolveFhevmClientFrozenContext-p.js +11 -1
- package/_cjs/core/frozenContext/resolveFhevmClientFrozenContext-p.js.map +1 -1
- package/_cjs/core/host-contracts/readKmsSignersContext-p.js +0 -7
- package/_cjs/core/host-contracts/readKmsSignersContext-p.js.map +1 -1
- package/_cjs/core/key/FheEncryptionKeyCache-p.js +3 -0
- package/_cjs/core/key/FheEncryptionKeyCache-p.js.map +1 -1
- package/_cjs/core/key/fetchFheEncryptionKey.js +13 -1
- package/_cjs/core/key/fetchFheEncryptionKey.js.map +1 -1
- package/_cjs/core/kms/SignedDecryptionPermit-p.js +1 -27
- package/_cjs/core/kms/SignedDecryptionPermit-p.js.map +1 -1
- package/_cjs/core/kms/SignedDecryptionPermitV2-p.js +22 -14
- package/_cjs/core/kms/SignedDecryptionPermitV2-p.js.map +1 -1
- package/_cjs/core/kms/decryptValuesFromPairs.js +5 -14
- package/_cjs/core/kms/decryptValuesFromPairs.js.map +1 -1
- package/_cjs/core/kms/fetchKmsSigncryptedSharesV2-p.js +8 -0
- package/_cjs/core/kms/fetchKmsSigncryptedSharesV2-p.js.map +1 -1
- package/_cjs/core/modules/decrypt/module/api-p.js +1 -1
- package/_cjs/core/modules/decrypt/module/api-p.js.map +1 -1
- package/_cjs/core/modules/decrypt/module/init-p.js +7 -1
- package/_cjs/core/modules/decrypt/module/init-p.js.map +1 -1
- package/_cjs/core/modules/encrypt/module/init-p.js +14 -2
- package/_cjs/core/modules/encrypt/module/init-p.js.map +1 -1
- package/_cjs/core/modules/relayer/cleartext/mock.js +5 -0
- package/_cjs/core/modules/relayer/cleartext/mock.js.map +1 -1
- package/_cjs/core/modules/relayer/module/RelayerAsyncRequest.js +20 -0
- package/_cjs/core/modules/relayer/module/RelayerAsyncRequest.js.map +1 -1
- package/_cjs/core/modules/relayer/module/fetchCoprocessorSignatures.js +1 -0
- package/_cjs/core/modules/relayer/module/fetchCoprocessorSignatures.js.map +1 -1
- package/_cjs/core/modules/relayer/module/fetchDelegatedUserDecryptV1.js +1 -0
- package/_cjs/core/modules/relayer/module/fetchDelegatedUserDecryptV1.js.map +1 -1
- package/_cjs/core/modules/relayer/module/fetchFeatures.js +35 -0
- package/_cjs/core/modules/relayer/module/fetchFeatures.js.map +1 -0
- package/_cjs/core/modules/relayer/module/fetchPublicDecrypt.js +1 -0
- package/_cjs/core/modules/relayer/module/fetchPublicDecrypt.js.map +1 -1
- package/_cjs/core/modules/relayer/module/fetchUserDecryptV1.js +1 -0
- package/_cjs/core/modules/relayer/module/fetchUserDecryptV1.js.map +1 -1
- package/_cjs/core/modules/relayer/module/fetchUserDecryptV2.js +1 -0
- package/_cjs/core/modules/relayer/module/fetchUserDecryptV2.js.map +1 -1
- package/_cjs/core/modules/relayer/module/index.js +2 -0
- package/_cjs/core/modules/relayer/module/index.js.map +1 -1
- package/_cjs/core/relayerFeatures/ensureRelayerFeatures-p.js +25 -0
- package/_cjs/core/relayerFeatures/ensureRelayerFeatures-p.js.map +1 -0
- package/_cjs/core/relayerFeatures/resolveRelayerFeatures-p.js +7 -0
- package/_cjs/core/relayerFeatures/resolveRelayerFeatures-p.js.map +1 -0
- package/_cjs/core/runtime/CoreFhevm-p.js +58 -2
- package/_cjs/core/runtime/CoreFhevm-p.js.map +1 -1
- package/_cjs/core/runtime/HyperWasmSolver-p.js +44 -4
- package/_cjs/core/runtime/HyperWasmSolver-p.js.map +1 -1
- package/_cjs/core/runtime/ProtocolVersionResolver-p.js +10 -4
- package/_cjs/core/runtime/ProtocolVersionResolver-p.js.map +1 -1
- package/_cjs/core/runtime/initFhevmDecryptRuntime-p.js +1 -1
- package/_cjs/core/runtime/initFhevmDecryptRuntime-p.js.map +1 -1
- package/_cjs/core/runtime/initFhevmRuntime-p.js +1 -1
- package/_cjs/core/runtime/initFhevmRuntime-p.js.map +1 -1
- package/_cjs/core/runtime/sdkProtocolApiVersion.js +1 -1
- package/_cjs/core/runtime/sdkProtocolApiVersion.js.map +1 -1
- package/_cjs/core/utils-p/decrypt/verifyErc1271UserDecrypt-p.js +73 -0
- package/_cjs/core/utils-p/decrypt/verifyErc1271UserDecrypt-p.js.map +1 -0
- package/_cjs/ethers/internal/ethereum-ct.js +2 -11
- package/_cjs/ethers/internal/ethereum-ct.js.map +1 -1
- package/_cjs/ethers/internal/ethereum.js +33 -0
- package/_cjs/ethers/internal/ethereum.js.map +1 -1
- package/_cjs/ethers/internal/utils.js +17 -0
- package/_cjs/ethers/internal/utils.js.map +1 -1
- package/_cjs/viem/internal/ethereum-ct.js +2 -8
- package/_cjs/viem/internal/ethereum-ct.js.map +1 -1
- package/_cjs/viem/internal/ethereum.js +34 -4
- package/_cjs/viem/internal/ethereum.js.map +1 -1
- package/_cjs/wasm/tfhe/loadTfheLib.js.map +1 -1
- package/_cjs/wasm/tkms/KmsLibApi.d.ts +1 -1
- package/_cjs/wasm/tkms/loadKmsLib.js +13 -4
- package/_cjs/wasm/tkms/loadKmsLib.js.map +3 -3
- package/_cjs/wasm/tkms/v0.14.0-1/kms_lib.d.ts +598 -0
- package/_cjs/wasm/tkms/v0.14.0-1/kms_lib.js +1887 -0
- package/_cjs/wasm/tkms/v0.14.0-1/kms_lib.js.map +7 -0
- package/_cjs/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm +0 -0
- package/_cjs/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm.base64.d.ts +3 -0
- package/_cjs/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm.base64.js +35 -0
- package/_cjs/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm.base64.js.map +7 -0
- package/_esm/core/_version.js +1 -1
- package/_esm/core/_version.js.map +1 -1
- package/_esm/core/actions/base/canUseUnifiedDecryptionPermit.js +21 -0
- package/_esm/core/actions/base/canUseUnifiedDecryptionPermit.js.map +1 -0
- package/_esm/core/actions/base/createUnsignedUnifiedDecryptionPermitEip712.js +0 -4
- package/_esm/core/actions/base/createUnsignedUnifiedDecryptionPermitEip712.js.map +1 -1
- package/_esm/core/actions/base/index.js +9 -2
- package/_esm/core/actions/base/index.js.map +1 -1
- package/_esm/core/actions/base/signUnifiedDecryptionPermit.js +7 -0
- package/_esm/core/actions/base/signUnifiedDecryptionPermit.js.map +1 -0
- package/_esm/core/actions/host/resolveChainId.js +3 -1
- package/_esm/core/actions/host/resolveChainId.js.map +1 -1
- package/_esm/core/clients/decorators/base.js +2 -0
- package/_esm/core/clients/decorators/base.js.map +1 -1
- package/_esm/core/errors/Erc1271Error.js +45 -0
- package/_esm/core/errors/Erc1271Error.js.map +1 -0
- package/_esm/core/frozenContext/fhevmClientFrozenContext-p.js.map +1 -1
- package/_esm/core/frozenContext/resolveFhevmClientFrozenContext-p.js +12 -1
- package/_esm/core/frozenContext/resolveFhevmClientFrozenContext-p.js.map +1 -1
- package/_esm/core/host-contracts/readKmsSignersContext-p.js +9 -40
- package/_esm/core/host-contracts/readKmsSignersContext-p.js.map +1 -1
- package/_esm/core/key/FheEncryptionKeyCache-p.js +3 -0
- package/_esm/core/key/FheEncryptionKeyCache-p.js.map +1 -1
- package/_esm/core/key/fetchFheEncryptionKey.js +13 -1
- package/_esm/core/key/fetchFheEncryptionKey.js.map +1 -1
- package/_esm/core/kms/SignedDecryptionPermit-p.js +6 -47
- package/_esm/core/kms/SignedDecryptionPermit-p.js.map +1 -1
- package/_esm/core/kms/SignedDecryptionPermitV2-p.js +35 -21
- package/_esm/core/kms/SignedDecryptionPermitV2-p.js.map +1 -1
- package/_esm/core/kms/decryptValuesFromPairs.js +14 -32
- package/_esm/core/kms/decryptValuesFromPairs.js.map +1 -1
- package/_esm/core/kms/fetchKmsSigncryptedSharesV2-p.js +11 -0
- package/_esm/core/kms/fetchKmsSigncryptedSharesV2-p.js.map +1 -1
- package/_esm/core/modules/decrypt/module/api-p.js +5 -3
- package/_esm/core/modules/decrypt/module/api-p.js.map +1 -1
- package/_esm/core/modules/decrypt/module/init-p.js +7 -1
- package/_esm/core/modules/decrypt/module/init-p.js.map +1 -1
- package/_esm/core/modules/encrypt/module/init-p.js +14 -2
- package/_esm/core/modules/encrypt/module/init-p.js.map +1 -1
- package/_esm/core/modules/relayer/cleartext/mock.js +5 -0
- package/_esm/core/modules/relayer/cleartext/mock.js.map +1 -1
- package/_esm/core/modules/relayer/module/RelayerAsyncRequest.js +20 -0
- package/_esm/core/modules/relayer/module/RelayerAsyncRequest.js.map +1 -1
- package/_esm/core/modules/relayer/module/fetchCoprocessorSignatures.js +1 -0
- package/_esm/core/modules/relayer/module/fetchCoprocessorSignatures.js.map +1 -1
- package/_esm/core/modules/relayer/module/fetchDelegatedUserDecryptV1.js +1 -0
- package/_esm/core/modules/relayer/module/fetchDelegatedUserDecryptV1.js.map +1 -1
- package/_esm/core/modules/relayer/module/fetchFeatures.js +68 -0
- package/_esm/core/modules/relayer/module/fetchFeatures.js.map +1 -0
- package/_esm/core/modules/relayer/module/fetchPublicDecrypt.js +1 -0
- package/_esm/core/modules/relayer/module/fetchPublicDecrypt.js.map +1 -1
- package/_esm/core/modules/relayer/module/fetchUserDecryptV1.js +1 -0
- package/_esm/core/modules/relayer/module/fetchUserDecryptV1.js.map +1 -1
- package/_esm/core/modules/relayer/module/fetchUserDecryptV2.js +1 -0
- package/_esm/core/modules/relayer/module/fetchUserDecryptV2.js.map +1 -1
- package/_esm/core/modules/relayer/module/index.js +2 -0
- package/_esm/core/modules/relayer/module/index.js.map +1 -1
- package/_esm/core/relayerFeatures/ensureRelayerFeatures-p.js +61 -0
- package/_esm/core/relayerFeatures/ensureRelayerFeatures-p.js.map +1 -0
- package/_esm/core/relayerFeatures/resolveRelayerFeatures-p.js +15 -0
- package/_esm/core/relayerFeatures/resolveRelayerFeatures-p.js.map +1 -0
- package/_esm/core/runtime/CoreFhevm-p.js +61 -2
- package/_esm/core/runtime/CoreFhevm-p.js.map +1 -1
- package/_esm/core/runtime/HyperWasmSolver-p.js +51 -6
- package/_esm/core/runtime/HyperWasmSolver-p.js.map +1 -1
- package/_esm/core/runtime/ProtocolVersionResolver-p.js +10 -4
- package/_esm/core/runtime/ProtocolVersionResolver-p.js.map +1 -1
- package/_esm/core/runtime/initFhevmDecryptRuntime-p.js +1 -1
- package/_esm/core/runtime/initFhevmDecryptRuntime-p.js.map +1 -1
- package/_esm/core/runtime/initFhevmRuntime-p.js +1 -1
- package/_esm/core/runtime/initFhevmRuntime-p.js.map +1 -1
- package/_esm/core/runtime/sdkProtocolApiVersion.js +8 -9
- package/_esm/core/runtime/sdkProtocolApiVersion.js.map +1 -1
- package/_esm/core/utils-p/decrypt/verifyErc1271UserDecrypt-p.js +118 -0
- package/_esm/core/utils-p/decrypt/verifyErc1271UserDecrypt-p.js.map +1 -0
- package/_esm/ethers/internal/ethereum-ct.js +4 -13
- package/_esm/ethers/internal/ethereum-ct.js.map +1 -1
- package/_esm/ethers/internal/ethereum.js +45 -2
- package/_esm/ethers/internal/ethereum.js.map +1 -1
- package/_esm/ethers/internal/utils.js +20 -0
- package/_esm/ethers/internal/utils.js.map +1 -1
- package/_esm/viem/internal/ethereum-ct.js +5 -11
- package/_esm/viem/internal/ethereum-ct.js.map +1 -1
- package/_esm/viem/internal/ethereum.js +37 -0
- package/_esm/viem/internal/ethereum.js.map +1 -1
- package/_esm/wasm/tkms/KmsLibApi.d.ts +1 -1
- package/_esm/wasm/tkms/loadKmsLib.js +11 -2
- package/_esm/wasm/tkms/v0.14.0-1/kms_lib.d.ts +598 -0
- package/_esm/wasm/tkms/v0.14.0-1/kms_lib.js +2055 -0
- package/_esm/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm +0 -0
- package/_esm/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm.base64.d.ts +3 -0
- package/_esm/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm.base64.js +7 -0
- package/_types/core/_version.d.ts.map +1 -1
- package/_types/core/actions/base/canUseUnifiedDecryptionPermit.d.ts +23 -0
- package/_types/core/actions/base/canUseUnifiedDecryptionPermit.d.ts.map +1 -0
- package/_types/core/actions/base/createUnsignedUnifiedDecryptionPermitEip712.d.ts.map +1 -1
- package/_types/core/actions/base/index.d.ts +3 -0
- package/_types/core/actions/base/index.d.ts.map +1 -1
- package/_types/core/actions/base/signUnifiedDecryptionPermit.d.ts +17 -0
- package/_types/core/actions/base/signUnifiedDecryptionPermit.d.ts.map +1 -0
- package/_types/core/actions/host/resolveChainId.d.ts.map +1 -1
- package/_types/core/clients/decorators/base.d.ts +14 -0
- package/_types/core/clients/decorators/base.d.ts.map +1 -1
- package/_types/core/errors/Erc1271Error.d.ts +46 -0
- package/_types/core/errors/Erc1271Error.d.ts.map +1 -0
- package/_types/core/frozenContext/fhevmClientFrozenContext-p.d.ts.map +1 -1
- package/_types/core/frozenContext/resolveFhevmClientFrozenContext-p.d.ts.map +1 -1
- package/_types/core/host-contracts/readKmsSignersContext-p.d.ts +9 -14
- package/_types/core/host-contracts/readKmsSignersContext-p.d.ts.map +1 -1
- package/_types/core/key/FheEncryptionKeyCache-p.d.ts.map +1 -1
- package/_types/core/key/fetchFheEncryptionKey.d.ts.map +1 -1
- package/_types/core/kms/SignedDecryptionPermit-p.d.ts.map +1 -1
- package/_types/core/kms/SignedDecryptionPermitV2-p.d.ts.map +1 -1
- package/_types/core/kms/decryptValuesFromPairs.d.ts.map +1 -1
- package/_types/core/kms/fetchKmsSigncryptedSharesV2-p.d.ts.map +1 -1
- package/_types/core/modules/decrypt/module/api-p.d.ts.map +1 -1
- package/_types/core/modules/decrypt/module/init-p.d.ts.map +1 -1
- package/_types/core/modules/encrypt/module/init-p.d.ts.map +1 -1
- package/_types/core/modules/ethereum/types.d.ts +47 -2
- package/_types/core/modules/ethereum/types.d.ts.map +1 -1
- package/_types/core/modules/relayer/cleartext/mock.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/RelayerAsyncRequest.d.ts +3 -0
- package/_types/core/modules/relayer/module/RelayerAsyncRequest.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/fetchCoprocessorSignatures.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/fetchDelegatedUserDecryptV1.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/fetchFeatures.d.ts +26 -0
- package/_types/core/modules/relayer/module/fetchFeatures.d.ts.map +1 -0
- package/_types/core/modules/relayer/module/fetchPublicDecrypt.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/fetchUserDecryptV1.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/fetchUserDecryptV2.d.ts.map +1 -1
- package/_types/core/modules/relayer/module/index.d.ts.map +1 -1
- package/_types/core/modules/relayer/types.d.ts +14 -2
- package/_types/core/modules/relayer/types.d.ts.map +1 -1
- package/_types/core/relayerFeatures/ensureRelayerFeatures-p.d.ts +55 -0
- package/_types/core/relayerFeatures/ensureRelayerFeatures-p.d.ts.map +1 -0
- package/_types/core/relayerFeatures/resolveRelayerFeatures-p.d.ts +39 -0
- package/_types/core/relayerFeatures/resolveRelayerFeatures-p.d.ts.map +1 -0
- package/_types/core/runtime/CoreFhevm-p.d.ts +5 -0
- package/_types/core/runtime/CoreFhevm-p.d.ts.map +1 -1
- package/_types/core/runtime/HyperWasmSolver-p.d.ts +1 -0
- package/_types/core/runtime/HyperWasmSolver-p.d.ts.map +1 -1
- package/_types/core/runtime/ProtocolVersionResolver-p.d.ts.map +1 -1
- package/_types/core/runtime/sdkProtocolApiVersion.d.ts +7 -8
- package/_types/core/runtime/sdkProtocolApiVersion.d.ts.map +1 -1
- package/_types/core/types/kms-p.d.ts +2 -2
- package/_types/core/types/kms-p.d.ts.map +1 -1
- package/_types/core/types/relayer-p.d.ts +1 -1
- package/_types/core/types/relayer-p.d.ts.map +1 -1
- package/_types/core/types/signedDecryptionPermit.d.ts +10 -3
- package/_types/core/types/signedDecryptionPermit.d.ts.map +1 -1
- package/_types/core/utils-p/decrypt/verifyErc1271UserDecrypt-p.d.ts +49 -0
- package/_types/core/utils-p/decrypt/verifyErc1271UserDecrypt-p.d.ts.map +1 -0
- package/_types/ethers/internal/ethereum-ct.d.ts.map +1 -1
- package/_types/ethers/internal/ethereum.d.ts +3 -1
- package/_types/ethers/internal/ethereum.d.ts.map +1 -1
- package/_types/ethers/internal/utils.d.ts +5 -0
- package/_types/ethers/internal/utils.d.ts.map +1 -1
- package/_types/viem/internal/ethereum-ct.d.ts.map +1 -1
- package/_types/viem/internal/ethereum.d.ts +3 -1
- package/_types/viem/internal/ethereum.d.ts.map +1 -1
- package/_types/wasm/tkms/KmsLibApi.d.ts +1 -1
- package/_types/wasm/tkms/v0.14.0-1/kms_lib.d.ts +598 -0
- package/_types/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm.base64.d.ts +3 -0
- package/core/_version.ts +1 -1
- package/core/actions/base/canUseUnifiedDecryptionPermit.ts +38 -0
- package/core/actions/base/createUnsignedUnifiedDecryptionPermitEip712.ts +0 -6
- package/core/actions/base/index.ts +24 -2
- package/core/actions/base/signUnifiedDecryptionPermit.ts +27 -0
- package/core/actions/host/resolveChainId.ts +3 -1
- package/core/clients/decorators/base.ts +21 -0
- package/core/errors/Erc1271Error.ts +85 -0
- package/core/frozenContext/fhevmClientFrozenContext-p.ts +1 -0
- package/core/frozenContext/resolveFhevmClientFrozenContext-p.ts +21 -8
- package/core/host-contracts/readKmsSignersContext-p.ts +9 -45
- package/core/key/FheEncryptionKeyCache-p.ts +6 -0
- package/core/key/fetchFheEncryptionKey.ts +17 -1
- package/core/kms/SignedDecryptionPermit-p.ts +6 -60
- package/core/kms/SignedDecryptionPermitV2-p.ts +54 -41
- package/core/kms/decryptValuesFromPairs.ts +14 -33
- package/core/kms/fetchKmsSigncryptedSharesV2-p.ts +15 -0
- package/core/modules/decrypt/module/api-p.ts +5 -3
- package/core/modules/decrypt/module/init-p.ts +6 -1
- package/core/modules/encrypt/module/init-p.ts +15 -2
- package/core/modules/ethereum/types.ts +55 -1
- package/core/modules/relayer/cleartext/mock.ts +11 -0
- package/core/modules/relayer/module/RelayerAsyncRequest.ts +55 -0
- package/core/modules/relayer/module/fetchCoprocessorSignatures.ts +1 -0
- package/core/modules/relayer/module/fetchDelegatedUserDecryptV1.ts +1 -0
- package/core/modules/relayer/module/fetchFeatures.ts +75 -0
- package/core/modules/relayer/module/fetchPublicDecrypt.ts +1 -0
- package/core/modules/relayer/module/fetchUserDecryptV1.ts +1 -0
- package/core/modules/relayer/module/fetchUserDecryptV2.ts +1 -0
- package/core/modules/relayer/module/index.ts +2 -0
- package/core/modules/relayer/types.ts +26 -2
- package/core/relayerFeatures/ensureRelayerFeatures-p.ts +84 -0
- package/core/relayerFeatures/resolveRelayerFeatures-p.ts +47 -0
- package/core/runtime/CoreFhevm-p.ts +71 -0
- package/core/runtime/HyperWasmSolver-p.ts +57 -8
- package/core/runtime/ProtocolVersionResolver-p.ts +12 -4
- package/core/runtime/initFhevmDecryptRuntime-p.ts +1 -1
- package/core/runtime/initFhevmRuntime-p.ts +1 -1
- package/core/runtime/sdkProtocolApiVersion.ts +8 -9
- package/core/types/kms-p.ts +2 -2
- package/core/types/relayer-p.ts +4 -2
- package/core/types/signedDecryptionPermit.ts +10 -3
- package/core/utils-p/decrypt/verifyErc1271UserDecrypt-p.ts +164 -0
- package/ethers/internal/ethereum-ct.ts +5 -15
- package/ethers/internal/ethereum.ts +58 -3
- package/ethers/internal/utils.ts +27 -0
- package/package.json +2 -2
- package/viem/internal/ethereum-ct.ts +6 -14
- package/viem/internal/ethereum.ts +48 -1
- package/wasm/tkms/KmsLibApi.d.ts +1 -1
- package/wasm/tkms/loadKmsLib.js +11 -2
- package/wasm/tkms/v0.14.0-1/kms_lib.d.ts +598 -0
- package/wasm/tkms/v0.14.0-1/kms_lib.js +2055 -0
- package/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm +0 -0
- package/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm.base64.d.ts +3 -0
- package/wasm/tkms/v0.14.0-1/kms_lib_bg.wasm.base64.js +7 -0
- package/_cjs/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.js +0 -30
- package/_cjs/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.js.map +0 -1
- package/_esm/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.js +0 -27
- package/_esm/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.js.map +0 -1
- package/_types/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.d.ts +0 -14
- package/_types/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.d.ts.map +0 -1
- package/core/utils-p/decrypt/verifyKmsUserDecryptEip712V2.ts +0 -43
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import type { SignedDecryptionPermit, SignedDecryptionPermitV2 } from '../types/signedDecryptionPermit.js';
|
|
2
2
|
import type { KmsUserDecryptEip712V2 } from '../types/kms.js';
|
|
3
|
-
import type {
|
|
4
|
-
import type { FhevmChain } from '../types/fhevmChain.js';
|
|
5
|
-
import type { FhevmRuntime } from '../types/coreFhevmRuntime.js';
|
|
3
|
+
import type { BytesHex, ChecksummedAddress, Uint8Number } from '../types/primitives.js';
|
|
6
4
|
import type { KmsSignDecryptionPermitContext, KmsSignDecryptionPermitParameters } from './SignedDecryptionPermit-p.js';
|
|
7
5
|
import type { KmsExtraData } from '../types/kms-p.js';
|
|
8
6
|
import type { FhevmClientFrozenContext } from '../types/fhevmClientFrozenContext-p.js';
|
|
9
7
|
import { assertRecordNonNullableProperty } from '../base/record.js';
|
|
10
|
-
import {
|
|
8
|
+
import { assertRecordBytesHexProperty } from '../base/bytes.js';
|
|
11
9
|
import { addressToChecksummedAddress, assertIsAddress, assertRecordAddressProperty } from '../base/address.js';
|
|
12
10
|
import { assertRecordStringProperty } from '../base/string.js';
|
|
13
11
|
import { assertIsTransportKeyPair, type TransportKeyPair } from './TransportKeyPair-p.js';
|
|
14
12
|
import { readCurrentKmsSignersContext } from '../host-contracts/readKmsSignersContext-p.js';
|
|
15
13
|
import { kmsSignersContextToExtraData } from '../host-contracts/KmsSignersContext-p.js';
|
|
16
14
|
import { assertIsKmsUserDecryptEip712V2, createKmsUserDecryptEip712V2 } from './createKmsUserDecryptEip712V2.js';
|
|
17
|
-
import {
|
|
15
|
+
import { verifyErc1271UserDecrypt } from '../utils-p/decrypt/verifyErc1271UserDecrypt-p.js';
|
|
18
16
|
import { assert } from '../base/errors/InternalError.js';
|
|
19
17
|
import { EXTRA_DATA_V2 } from './kmsExtraData-p.js';
|
|
20
18
|
import { assertIsUintNumber } from '../base/uint.js';
|
|
@@ -30,7 +28,7 @@ const MAX_USER_DECRYPT_CONTRACT_ADDRESSES = 10 as Uint8Number;
|
|
|
30
28
|
|
|
31
29
|
class SignedDecryptionPermitV2Impl implements SignedDecryptionPermitV2 {
|
|
32
30
|
readonly #eip712: KmsUserDecryptEip712V2;
|
|
33
|
-
readonly #signature:
|
|
31
|
+
readonly #signature: BytesHex;
|
|
34
32
|
readonly #signerAddress: ChecksummedAddress;
|
|
35
33
|
readonly #delegatorAddress: ChecksummedAddress | undefined;
|
|
36
34
|
|
|
@@ -38,7 +36,7 @@ class SignedDecryptionPermitV2Impl implements SignedDecryptionPermitV2 {
|
|
|
38
36
|
privateToken: symbol,
|
|
39
37
|
parameters: {
|
|
40
38
|
readonly eip712: KmsUserDecryptEip712V2;
|
|
41
|
-
readonly signature:
|
|
39
|
+
readonly signature: BytesHex;
|
|
42
40
|
readonly signerAddress: ChecksummedAddress;
|
|
43
41
|
readonly delegatorAddress?: ChecksummedAddress | undefined;
|
|
44
42
|
},
|
|
@@ -56,7 +54,7 @@ class SignedDecryptionPermitV2Impl implements SignedDecryptionPermitV2 {
|
|
|
56
54
|
return this.#eip712;
|
|
57
55
|
}
|
|
58
56
|
|
|
59
|
-
public get signature():
|
|
57
|
+
public get signature(): BytesHex {
|
|
60
58
|
return this.#signature;
|
|
61
59
|
}
|
|
62
60
|
|
|
@@ -95,6 +93,44 @@ export function isSignedDecryptionPermitV2(value: unknown): value is SignedDecry
|
|
|
95
93
|
return value instanceof SignedDecryptionPermitV2Impl;
|
|
96
94
|
}
|
|
97
95
|
|
|
96
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
97
|
+
// _createSignedDecryptionPermitV2
|
|
98
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
99
|
+
|
|
100
|
+
async function _createSignedDecryptionPermitV2(
|
|
101
|
+
context: KmsSignDecryptionPermitContext,
|
|
102
|
+
parameters: {
|
|
103
|
+
readonly signerAddress: ChecksummedAddress;
|
|
104
|
+
readonly eip712: KmsUserDecryptEip712V2;
|
|
105
|
+
readonly signature: BytesHex;
|
|
106
|
+
readonly delegatorAddress?: ChecksummedAddress | undefined;
|
|
107
|
+
},
|
|
108
|
+
): Promise<SignedDecryptionPermitV2> {
|
|
109
|
+
const { eip712, signature } = parameters;
|
|
110
|
+
|
|
111
|
+
// Enforced here (the choke point shared by signDecryptionPermitV2 and
|
|
112
|
+
// parseSignedDecryptionPermitV2). The message field is a validated uint256
|
|
113
|
+
// string, so `BigInt` is safe; a uint can only be non-positive when it is 0.
|
|
114
|
+
if (BigInt(eip712.message.durationSeconds) <= 0n) {
|
|
115
|
+
throw new RangeError(`durationSeconds must be positive, got ${eip712.message.durationSeconds}`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (eip712.message.allowedContracts.length > MAX_USER_DECRYPT_CONTRACT_ADDRESSES) {
|
|
119
|
+
throw Error(`allowedContracts max length of ${MAX_USER_DECRYPT_CONTRACT_ADDRESSES} exceeded`);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Precautionary local check against `eip712.message.userAddress`; auto-detects
|
|
123
|
+
// EOA vs ERC-1271 (a normal EOA permit stays on the no-RPC fast path). The KMS
|
|
124
|
+
// remains authoritative — see `verifyErc1271UserDecrypt` for the full contract.
|
|
125
|
+
await verifyErc1271UserDecrypt(context, {
|
|
126
|
+
userAddress: eip712.message.userAddress,
|
|
127
|
+
eip712,
|
|
128
|
+
signature,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
return new SignedDecryptionPermitV2Impl(PRIVATE_TOKEN, parameters);
|
|
132
|
+
}
|
|
133
|
+
|
|
98
134
|
////////////////////////////////////////////////////////////////////////////////
|
|
99
135
|
// signDecryptionPermitV2
|
|
100
136
|
////////////////////////////////////////////////////////////////////////////////
|
|
@@ -153,7 +189,11 @@ export async function parseSignedDecryptionPermitV2(
|
|
|
153
189
|
const options = {};
|
|
154
190
|
|
|
155
191
|
assertRecordNonNullableProperty(permit, 'eip712', permitName, options);
|
|
156
|
-
|
|
192
|
+
|
|
193
|
+
// Accept a variable-length signature: a 65-byte EOA signature, a concatenated
|
|
194
|
+
// multisig ERC-1271 blob, or the empty `0x` pre-approved-hash flow. The verify
|
|
195
|
+
// step below auto-detects EOA vs ERC-1271 against `eip712.message.userAddress`.
|
|
196
|
+
assertRecordBytesHexProperty(permit, 'signature', permitName, options);
|
|
157
197
|
assertRecordAddressProperty(permit, 'signerAddress', permitName, options);
|
|
158
198
|
|
|
159
199
|
const eip712 = permit.eip712;
|
|
@@ -175,7 +215,11 @@ export async function parseSignedDecryptionPermitV2(
|
|
|
175
215
|
);
|
|
176
216
|
}
|
|
177
217
|
|
|
178
|
-
return await _createSignedDecryptionPermitV2(context, {
|
|
218
|
+
return await _createSignedDecryptionPermitV2(context, {
|
|
219
|
+
signature: permit.signature,
|
|
220
|
+
eip712,
|
|
221
|
+
signerAddress,
|
|
222
|
+
});
|
|
179
223
|
}
|
|
180
224
|
|
|
181
225
|
////////////////////////////////////////////////////////////////////////////////
|
|
@@ -269,37 +313,6 @@ export async function createUnsignedDecryptionPermitEip712V2(
|
|
|
269
313
|
return eip712;
|
|
270
314
|
}
|
|
271
315
|
|
|
272
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
273
|
-
// _createSignedDecryptionPermitV2
|
|
274
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
275
|
-
|
|
276
|
-
async function _createSignedDecryptionPermitV2(
|
|
277
|
-
context: { readonly chain: FhevmChain; readonly runtime: FhevmRuntime },
|
|
278
|
-
parameters: {
|
|
279
|
-
readonly signerAddress: ChecksummedAddress;
|
|
280
|
-
readonly eip712: KmsUserDecryptEip712V2;
|
|
281
|
-
readonly signature: Bytes65Hex;
|
|
282
|
-
readonly delegatorAddress?: ChecksummedAddress | undefined;
|
|
283
|
-
},
|
|
284
|
-
): Promise<SignedDecryptionPermitV2> {
|
|
285
|
-
const { signerAddress, eip712, signature } = parameters;
|
|
286
|
-
|
|
287
|
-
// Enforced here (the choke point shared by signDecryptionPermitV2 and
|
|
288
|
-
// parseSignedDecryptionPermitV2). The message field is a validated uint256
|
|
289
|
-
// string, so `BigInt` is safe; a uint can only be non-positive when it is 0.
|
|
290
|
-
if (BigInt(eip712.message.durationSeconds) <= 0n) {
|
|
291
|
-
throw new RangeError(`durationSeconds must be positive, got ${eip712.message.durationSeconds}`);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
if (eip712.message.allowedContracts.length > MAX_USER_DECRYPT_CONTRACT_ADDRESSES) {
|
|
295
|
-
throw Error(`allowedContracts max length of ${MAX_USER_DECRYPT_CONTRACT_ADDRESSES} exceeded`);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
await verifyKmsUserDecryptEip712V2(context, { signer: signerAddress, message: eip712.message, signature });
|
|
299
|
-
|
|
300
|
-
return new SignedDecryptionPermitV2Impl(PRIVATE_TOKEN, parameters);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
316
|
////////////////////////////////////////////////////////////////////////////////
|
|
304
317
|
// _assertKmsEip712V2DeadlineValidity
|
|
305
318
|
////////////////////////////////////////////////////////////////////////////////
|
|
@@ -9,7 +9,6 @@ import type { RelayerDelegatedUserDecryptOptions, RelayerUserDecryptOptions } fr
|
|
|
9
9
|
import type { SignedDecryptionPermit } from '../types/signedDecryptionPermit.js';
|
|
10
10
|
import type { TransportKeyPair } from './TransportKeyPair-p.js';
|
|
11
11
|
import type { FhevmClientFrozenContext } from '../types/fhevmClientFrozenContext-p.js';
|
|
12
|
-
import { SDK_PROTOCOL_API_MAJOR_VERSION, SDK_PROTOCOL_API_MINOR_VERSION } from '../runtime/sdkProtocolApiVersion.js';
|
|
13
12
|
import { decryptKmsSigncryptedShares } from './decryptKmsSigncryptedShares-p.js';
|
|
14
13
|
import { fetchKmsSigncryptedSharesV1 } from './fetchKmsSigncryptedSharesV1-p.js';
|
|
15
14
|
import { fetchKmsSigncryptedSharesV2 } from './fetchKmsSigncryptedSharesV2-p.js';
|
|
@@ -47,40 +46,22 @@ export async function decryptValuesFromPairs(fhevm: Context, parameters: Paramet
|
|
|
47
46
|
|
|
48
47
|
let kmsSigncryptedShares: KmsSigncryptedShares;
|
|
49
48
|
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (parameters.signedPermit.version > 1) {
|
|
61
|
-
throw new Error(
|
|
62
|
-
`Unsupported permit version ${parameters.signedPermit.version}: this SDK uses protocol API v0.13.x, which only supports V1 decryption permits. V2 permits require an SDK using protocol API v0.14.0 or later.`,
|
|
63
|
-
);
|
|
64
|
-
}
|
|
49
|
+
// Route on the permit's OWN version, never the resolved protocol version. A signed
|
|
50
|
+
// permit is a self-describing artifact: its version fixes the EIP-712 message shape,
|
|
51
|
+
// so only the matching route can read it and reach the matching relayer endpoint.
|
|
52
|
+
// Keying off protocol version instead is indirect and breaks the moment the two
|
|
53
|
+
// diverge (e.g. a v1 permit used against a chain that now resolves to a newer
|
|
54
|
+
// protocol) — the artifact you are consuming is the source of truth, not the context.
|
|
55
|
+
//
|
|
56
|
+
// v1: message.contractAddresses -> fetchKmsSigncryptedSharesV1 -> POST v2/user-decrypt
|
|
57
|
+
// v2: message.userAddress + allowedContracts -> fetchKmsSigncryptedSharesV2 -> POST v3/user-decrypt
|
|
58
|
+
if (parameters.signedPermit.version === 1) {
|
|
65
59
|
kmsSigncryptedShares = await fetchKmsSigncryptedSharesV1(fhevm, parameters);
|
|
66
60
|
} else {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// diverge (e.g. a v1 permit used against a chain that now resolves to a newer
|
|
72
|
-
// protocol) — the artifact you are consuming is the source of truth, not the context.
|
|
73
|
-
//
|
|
74
|
-
// v1: message.contractAddresses -> fetchKmsSigncryptedSharesV1 -> POST v2/user-decrypt
|
|
75
|
-
// v2: message.userAddress + allowedContracts -> fetchKmsSigncryptedSharesV2 -> POST v3/user-decrypt
|
|
76
|
-
if (parameters.signedPermit.version === 1) {
|
|
77
|
-
kmsSigncryptedShares = await fetchKmsSigncryptedSharesV1(fhevm, parameters);
|
|
78
|
-
} else {
|
|
79
|
-
kmsSigncryptedShares = await fetchKmsSigncryptedSharesV2(fhevm, {
|
|
80
|
-
...parameters,
|
|
81
|
-
options: parameters.options as RelayerUserDecryptOptions | undefined,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
61
|
+
kmsSigncryptedShares = await fetchKmsSigncryptedSharesV2(fhevm, {
|
|
62
|
+
...parameters,
|
|
63
|
+
options: parameters.options as RelayerUserDecryptOptions | undefined,
|
|
64
|
+
});
|
|
84
65
|
}
|
|
85
66
|
|
|
86
67
|
// Using the `KmsSigncryptedShares` decrypt and reconstruct clear values
|
|
@@ -17,6 +17,7 @@ import { checkPersistAllowed } from '../host-contracts/checkPersistAllowed.js';
|
|
|
17
17
|
import { checkDelegation } from '../host-contracts/checkDelegation.js';
|
|
18
18
|
import { createKmsEip712Domain } from './createKmsEip712Domain.js';
|
|
19
19
|
import { EXTRA_DATA_V2, createKmsExtraDataFromBytesHex } from './kmsExtraData-p.js';
|
|
20
|
+
import { ensureRelayerFeatures } from '../relayerFeatures/ensureRelayerFeatures-p.js';
|
|
20
21
|
|
|
21
22
|
////////////////////////////////////////////////////////////////////////////////
|
|
22
23
|
|
|
@@ -48,6 +49,20 @@ type ReturnType = KmsSigncryptedShares;
|
|
|
48
49
|
|
|
49
50
|
export async function fetchKmsSigncryptedSharesV2(context: Context, parameters: Parameters): Promise<ReturnType> {
|
|
50
51
|
const { options, pairs, fhevmContext } = parameters;
|
|
52
|
+
|
|
53
|
+
// The v3 / unified user-decrypt route only exists on relayers that advertise it. Guard here — not
|
|
54
|
+
// only at callers — so any direct caller of this V2 path is protected too. Resolved once per client
|
|
55
|
+
// (cached), using the same effective auth this function uses for the actual relayer request.
|
|
56
|
+
const features = await ensureRelayerFeatures(context, {
|
|
57
|
+
auth: options?.auth ?? context.runtime.config.auth,
|
|
58
|
+
});
|
|
59
|
+
if (!features.relayerSupportsV3UserDecryptRoute) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
'The relayer does not support unified (V2) decryption permits. Call `canUseUnifiedDecryptionPermit` up ' +
|
|
62
|
+
'front to check support, and use a legacy (V1) decryption permit against this relayer instead.',
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
51
66
|
const signedPermit = parameters.signedPermit as SignedDecryptionPermitV2;
|
|
52
67
|
|
|
53
68
|
const tkmsVersion = fhevmContext.tkmsVersion;
|
|
@@ -31,7 +31,7 @@ import { uint32ToBytes32 } from '../../../base/uint.js';
|
|
|
31
31
|
import { createClearValue } from '../../../handle/ClearValue.js';
|
|
32
32
|
import { bytesToClearValueType } from '../../../handle/FheType.js';
|
|
33
33
|
import { remove0x } from '../../../base/string.js';
|
|
34
|
-
import { bytesToHexLarge } from '../../../base/bytes.js';
|
|
34
|
+
import { bytesToHexLarge, isBytes65Hex } from '../../../base/bytes.js';
|
|
35
35
|
import { WasmScope } from '../../../base/wasmScope.js';
|
|
36
36
|
import { initTkmsModule } from './init-p.js';
|
|
37
37
|
import { getMetadata, getShares } from '../../../kms/KmsSigncryptedShares-p.js';
|
|
@@ -379,8 +379,10 @@ export async function decryptAndReconstruct(
|
|
|
379
379
|
);
|
|
380
380
|
|
|
381
381
|
const requestWasmArg = {
|
|
382
|
-
//
|
|
383
|
-
|
|
382
|
+
// The tkms request parser accepts only a strict 65-byte ECDSA signature
|
|
383
|
+
// here and documents the field as optional — ERC-1271 permits (multisig
|
|
384
|
+
// blobs, empty approved-hash signatures) must omit it.
|
|
385
|
+
signature: isBytes65Hex(metadata.eip712Signature) ? remove0x(metadata.eip712Signature) : undefined,
|
|
384
386
|
client_address: clientAddress,
|
|
385
387
|
enc_key: remove0x(publicEncKeyMlKem512WasmBytesHex),
|
|
386
388
|
ciphertext_handles: metadata.handles.map((h) => h.bytes32HexNo0x),
|
|
@@ -247,7 +247,12 @@ async function _initTkmsModule(cfg: ResolvedTkmsModuleConfig): Promise<KmsLibApi
|
|
|
247
247
|
|
|
248
248
|
const input: TkmsLibInitAsyncParameters = { module_or_path: wasmModule };
|
|
249
249
|
|
|
250
|
-
|
|
250
|
+
try {
|
|
251
|
+
await kmsLib.initAsync(input);
|
|
252
|
+
} catch (e) {
|
|
253
|
+
cfg.logger?.error?.(`Failed to instantiate tkms WASM module (version=${cfg.version}).`, e);
|
|
254
|
+
throw e;
|
|
255
|
+
}
|
|
251
256
|
|
|
252
257
|
// Note: init_panic_hook is not exposed by kms_lib
|
|
253
258
|
const wasmInfo = kmsLib.getWasmInfo();
|
|
@@ -597,7 +597,12 @@ async function _initTfheModule(cfg: ResolvedTfheModuleConfig): Promise<TfheLibAp
|
|
|
597
597
|
const input: TfheLibInitAsyncParameters = { module_or_path: wasmModule };
|
|
598
598
|
|
|
599
599
|
// 2. Load and instantiate the TFHE WASM binary
|
|
600
|
-
|
|
600
|
+
try {
|
|
601
|
+
await tfheLib.initAsync(input);
|
|
602
|
+
} catch (e) {
|
|
603
|
+
cfg.logger?.error?.(`Failed to instantiate tfhe WASM module (version=${cfg.version}).`, e);
|
|
604
|
+
throw e;
|
|
605
|
+
}
|
|
601
606
|
|
|
602
607
|
// 3. Route WASM panics to console.error instead of silently aborting
|
|
603
608
|
tfheLib.init_panic_hook();
|
|
@@ -605,7 +610,15 @@ async function _initTfheModule(cfg: ResolvedTfheModuleConfig): Promise<TfheLibAp
|
|
|
605
610
|
// 4. Spawn Web Workers for parallel FHE operations (skipped when single-threaded)
|
|
606
611
|
if (!cfg.singleThread) {
|
|
607
612
|
cfg.logger?.debug?.(`initThreadPool(${cfg.numberOfThreads})`);
|
|
608
|
-
|
|
613
|
+
try {
|
|
614
|
+
await tfheLib.initThreadPool(cfg.numberOfThreads);
|
|
615
|
+
} catch (e) {
|
|
616
|
+
cfg.logger?.error?.(
|
|
617
|
+
`Failed to initialize tfhe WASM thread pool (numberOfThreads=${cfg.numberOfThreads}, version=${cfg.version}).`,
|
|
618
|
+
e,
|
|
619
|
+
);
|
|
620
|
+
throw e;
|
|
621
|
+
}
|
|
609
622
|
}
|
|
610
623
|
|
|
611
624
|
const wasmInfo = tfheLib.getWasmInfo();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TrustedValue } from '../../base/trustedValue.js';
|
|
2
|
-
import type { Bytes65Hex, BytesHex, ChecksummedAddress, Uint256 } from '../../types/primitives.js';
|
|
2
|
+
import type { Bytes32Hex, Bytes65Hex, BytesHex, ChecksummedAddress, Uint256 } from '../../types/primitives.js';
|
|
3
3
|
import type { Prettify } from '../../types/utils.js';
|
|
4
4
|
|
|
5
5
|
////////////////////////////////////////////////////////////////////////////////
|
|
@@ -37,6 +37,58 @@ export type RecoverTypedDataAddressModuleFunction = {
|
|
|
37
37
|
recoverTypedDataAddress(parameters: RecoverTypedDataAddressParameters): Promise<RecoverTypedDataAddressReturnType>;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
41
|
+
// hashTypedData
|
|
42
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
43
|
+
|
|
44
|
+
export type HashTypedDataParameters = Readonly<{
|
|
45
|
+
domain: RecoverTypedDataAddressParameters['domain'];
|
|
46
|
+
types: Record<string, Array<{ name: string; type: string }>>;
|
|
47
|
+
primaryType: string;
|
|
48
|
+
message: Record<string, unknown>;
|
|
49
|
+
}>;
|
|
50
|
+
|
|
51
|
+
/** The EIP-712 digest (`bytes32`) that a signer signs. */
|
|
52
|
+
export type HashTypedDataReturnType = Bytes32Hex;
|
|
53
|
+
|
|
54
|
+
export type HashTypedDataModuleFunction = {
|
|
55
|
+
hashTypedData(parameters: HashTypedDataParameters): HashTypedDataReturnType;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
59
|
+
// call (raw eth_call / STATICCALL)
|
|
60
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
61
|
+
|
|
62
|
+
export type EthCallParameters = Readonly<{
|
|
63
|
+
readonly to: ChecksummedAddress;
|
|
64
|
+
readonly data: BytesHex;
|
|
65
|
+
/** Optional gas cap for the call. */
|
|
66
|
+
readonly gas?: bigint | undefined;
|
|
67
|
+
}>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Outcome of a raw `eth_call`.
|
|
71
|
+
*
|
|
72
|
+
* - `{ success: true }` — the node returned (possibly empty) returndata. A no-code
|
|
73
|
+
* address yields empty `0x` data, mirroring EVM `STATICCALL` semantics.
|
|
74
|
+
* - `{ success: false }` — the call reverted cleanly at the EVM level. This is a
|
|
75
|
+
* *definitive* on-chain rejection (distinct from a transport-level failure,
|
|
76
|
+
* which the adapter rethrows so the caller can degrade gracefully).
|
|
77
|
+
*/
|
|
78
|
+
export type EthCallResult =
|
|
79
|
+
| { readonly success: true; readonly data: BytesHex }
|
|
80
|
+
| { readonly success: false; readonly reason: string };
|
|
81
|
+
|
|
82
|
+
export type CallModuleFunction = {
|
|
83
|
+
/**
|
|
84
|
+
* Performs a raw `eth_call` (STATICCALL semantics) and returns the raw
|
|
85
|
+
* returndata. Reverts are surfaced as `{ success: false }`; transport-level
|
|
86
|
+
* errors (network, timeout, rate limit, …) are thrown so callers can decide
|
|
87
|
+
* whether to fail or degrade.
|
|
88
|
+
*/
|
|
89
|
+
call(hostPublicClient: TrustedClient, parameters: EthCallParameters): Promise<EthCallResult>;
|
|
90
|
+
};
|
|
91
|
+
|
|
40
92
|
////////////////////////////////////////////////////////////////////////////////
|
|
41
93
|
// signTypedData
|
|
42
94
|
////////////////////////////////////////////////////////////////////////////////
|
|
@@ -139,8 +191,10 @@ export type ReadContractModuleFunction = {
|
|
|
139
191
|
|
|
140
192
|
export type EthereumModule = Prettify<
|
|
141
193
|
RecoverTypedDataAddressModuleFunction &
|
|
194
|
+
HashTypedDataModuleFunction &
|
|
142
195
|
SignTypedDataModuleFunction &
|
|
143
196
|
ReadContractModuleFunction &
|
|
197
|
+
CallModuleFunction &
|
|
144
198
|
EncodeModuleFunction &
|
|
145
199
|
EncodePackedModuleFunction &
|
|
146
200
|
DecodeModuleFunction &
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { UintNumber } from '../../../types/primitives.js';
|
|
2
2
|
import type {
|
|
3
|
+
FetchFeaturesParameters,
|
|
4
|
+
FetchFeaturesReturnType,
|
|
3
5
|
FetchFheEncryptionKeyBytesParameters,
|
|
4
6
|
FetchFheEncryptionKeyBytesReturnType,
|
|
5
7
|
FetchFheEncryptionKeySourceParameters,
|
|
6
8
|
RelayerClient,
|
|
9
|
+
RelayerClientWithRuntime,
|
|
7
10
|
RelayerModuleFactory,
|
|
8
11
|
} from '../types.js';
|
|
9
12
|
import { createDeadbeefBytes } from '../../../base/bytes.js';
|
|
@@ -49,6 +52,14 @@ export const relayerModule: RelayerModuleFactory = () => {
|
|
|
49
52
|
fetchPublicDecrypt,
|
|
50
53
|
fetchUserDecrypt,
|
|
51
54
|
fetchDelegatedUserDecrypt,
|
|
55
|
+
fetchFeatures: (
|
|
56
|
+
_relayerClient: RelayerClientWithRuntime,
|
|
57
|
+
_parameters: FetchFeaturesParameters,
|
|
58
|
+
): Promise<FetchFeaturesReturnType> => {
|
|
59
|
+
return Promise.resolve({
|
|
60
|
+
relayerSupportsV3UserDecryptRoute: true,
|
|
61
|
+
});
|
|
62
|
+
},
|
|
52
63
|
}),
|
|
53
64
|
});
|
|
54
65
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Auth } from '../../../types/auth.js';
|
|
2
|
+
import type { Logger } from '../../../types/logger.js';
|
|
2
3
|
import type {
|
|
3
4
|
RelayerApiError,
|
|
4
5
|
RelayerAsyncRequestState,
|
|
@@ -110,6 +111,7 @@ type RelayerAsyncRequestParams = {
|
|
|
110
111
|
payload: Record<string, unknown>;
|
|
111
112
|
timeoutInSeconds?: number | undefined;
|
|
112
113
|
throwErrorIfNoRetryAfter?: boolean | undefined;
|
|
114
|
+
logger?: Logger | undefined;
|
|
113
115
|
options?:
|
|
114
116
|
| RelayerInputProofOptions
|
|
115
117
|
| RelayerUserDecryptOptions
|
|
@@ -120,6 +122,7 @@ type RelayerAsyncRequestParams = {
|
|
|
120
122
|
|
|
121
123
|
export class RelayerAsyncRequest {
|
|
122
124
|
private readonly _debug: boolean;
|
|
125
|
+
private readonly _logger: Logger | undefined;
|
|
123
126
|
private _fetchMethod: 'GET' | 'POST' | undefined;
|
|
124
127
|
private _elapsed: number;
|
|
125
128
|
private _jobId: string | undefined;
|
|
@@ -207,6 +210,7 @@ export class RelayerAsyncRequest {
|
|
|
207
210
|
this._url = params.url;
|
|
208
211
|
this._payload = params.payload;
|
|
209
212
|
this._debug = params.options?.debug === true;
|
|
213
|
+
this._logger = params.logger;
|
|
210
214
|
this._fhevmAuth = params.options?.auth;
|
|
211
215
|
this._customHeaders = normalizeHeaders(params.options?.headers);
|
|
212
216
|
this._onProgress = params.options?.onProgress as typeof this._onProgress;
|
|
@@ -600,6 +604,10 @@ export class RelayerAsyncRequest {
|
|
|
600
604
|
|
|
601
605
|
const retryAfterMs = this._getRetryAfterHeaderValueInMs(response);
|
|
602
606
|
|
|
607
|
+
this._logger?.warn?.(
|
|
608
|
+
`[RelayerAsyncRequest] Throttled (429) on ${this._url} (operation=${this._relayerOperation}, retryCount=${this._retryCount}). Retrying in ${retryAfterMs}ms.`,
|
|
609
|
+
);
|
|
610
|
+
|
|
603
611
|
// Async onProgress callback
|
|
604
612
|
this._postAsyncOnProgressCallback({
|
|
605
613
|
type: 'throttled',
|
|
@@ -678,6 +686,10 @@ export class RelayerAsyncRequest {
|
|
|
678
686
|
default: {
|
|
679
687
|
// Use TS compiler + `never` to guarantee the switch integrity
|
|
680
688
|
const throwUnsupportedStatus = (unsupportedStatus: never): never => {
|
|
689
|
+
this._logger?.error?.(
|
|
690
|
+
`[RelayerAsyncRequest] Unsupported POST response status ${String(unsupportedStatus)} on ${this._url} (operation=${this._relayerOperation})`,
|
|
691
|
+
undefined,
|
|
692
|
+
);
|
|
681
693
|
throw new RelayerResponseStatusError({
|
|
682
694
|
fetchMethod: 'POST',
|
|
683
695
|
status: unsupportedStatus,
|
|
@@ -1059,6 +1071,10 @@ export class RelayerAsyncRequest {
|
|
|
1059
1071
|
default: {
|
|
1060
1072
|
// Use TS compiler + `never` to guarantee the switch integrity
|
|
1061
1073
|
const throwUnsupportedStatus = (unsupportedStatus: never): never => {
|
|
1074
|
+
this._logger?.error?.(
|
|
1075
|
+
`[RelayerAsyncRequest] Unsupported GET response status ${String(unsupportedStatus)} on ${this._url} (operation=${this._relayerOperation}, jobId=${this.jobId})`,
|
|
1076
|
+
undefined,
|
|
1077
|
+
);
|
|
1062
1078
|
throw new RelayerResponseStatusError({
|
|
1063
1079
|
fetchMethod: 'GET',
|
|
1064
1080
|
status: unsupportedStatus,
|
|
@@ -1191,6 +1207,10 @@ export class RelayerAsyncRequest {
|
|
|
1191
1207
|
throw fetchError;
|
|
1192
1208
|
}
|
|
1193
1209
|
|
|
1210
|
+
this._logger?.warn?.(
|
|
1211
|
+
`[RelayerAsyncRequest] Fetch to ${this._url} failed (attempt ${attempts}/${this._fetchRetries}, operation=${this._relayerOperation}): ${formatFetchErrorMetaMessages(fetchError).join('. ')}. Retrying.`,
|
|
1212
|
+
);
|
|
1213
|
+
|
|
1194
1214
|
// Wait before retry using state-machine-aware timeout
|
|
1195
1215
|
// This allows cancellation to interrupt the delay
|
|
1196
1216
|
// Skip incrementing _retryCount since fetch retries are separate from polling retries
|
|
@@ -1391,6 +1411,10 @@ export class RelayerAsyncRequest {
|
|
|
1391
1411
|
this._assert(!this._state.canceled, '!this._state.canceled');
|
|
1392
1412
|
}
|
|
1393
1413
|
|
|
1414
|
+
this._logger?.warn?.(
|
|
1415
|
+
`[RelayerAsyncRequest] Request aborted on ${this._url} (reason=${String(signal.reason)}, operation=${this._relayerOperation}, jobId=${this._jobId})`,
|
|
1416
|
+
);
|
|
1417
|
+
|
|
1394
1418
|
this._postAsyncOnProgressCallback({
|
|
1395
1419
|
type: 'abort',
|
|
1396
1420
|
url: this._url,
|
|
@@ -1558,6 +1582,11 @@ export class RelayerAsyncRequest {
|
|
|
1558
1582
|
|
|
1559
1583
|
this._state.timeout = true;
|
|
1560
1584
|
|
|
1585
|
+
this._logger?.error?.(
|
|
1586
|
+
`[RelayerAsyncRequest] Request timed out on ${this._url} (operation=${this._relayerOperation}, jobId=${this._jobId}, retryCount=${this._retryCount}, timeoutMs=${this._requestMaxDurationInMs})`,
|
|
1587
|
+
undefined,
|
|
1588
|
+
);
|
|
1589
|
+
|
|
1561
1590
|
this._postAsyncOnProgressCallback({
|
|
1562
1591
|
type: 'timeout',
|
|
1563
1592
|
url: this._url,
|
|
@@ -1656,6 +1685,10 @@ export class RelayerAsyncRequest {
|
|
|
1656
1685
|
* @throws {RelayerResponseStatusError} Always throws.
|
|
1657
1686
|
*/
|
|
1658
1687
|
private _throwUnexpectedStatusError(status: number, surfacedMessage?: string): never {
|
|
1688
|
+
this._logger?.error?.(
|
|
1689
|
+
`[RelayerAsyncRequest] Unexpected HTTP status ${status} on ${this._url} (operation=${this._relayerOperation}, jobId=${this._jobId})${surfacedMessage !== undefined ? `: ${surfacedMessage}` : ''}`,
|
|
1690
|
+
undefined,
|
|
1691
|
+
);
|
|
1659
1692
|
throw new RelayerResponseStatusError({
|
|
1660
1693
|
fetchMethod: this._fetchMethod as unknown as RelayerFetchMethod,
|
|
1661
1694
|
status,
|
|
@@ -1694,6 +1727,11 @@ export class RelayerAsyncRequest {
|
|
|
1694
1727
|
// Clone
|
|
1695
1728
|
const clonedRelayerApiError = JSON.parse(JSON.stringify(params.relayerApiError)) as RelayerApiError;
|
|
1696
1729
|
|
|
1730
|
+
this._logger?.error?.(
|
|
1731
|
+
`[RelayerAsyncRequest] Relayer API error on ${this._url} (status=${params.status}, operation=${this._relayerOperation}, jobId=${this._jobId}, retryCount=${this._retryCount}): label=${params.relayerApiError.label}, message=${params.relayerApiError.message}`,
|
|
1732
|
+
undefined,
|
|
1733
|
+
);
|
|
1734
|
+
|
|
1697
1735
|
const args: RelayerProgressFailed<RelayerPostOperation> = {
|
|
1698
1736
|
type: 'failed',
|
|
1699
1737
|
url: this._url,
|
|
@@ -1743,6 +1781,10 @@ export class RelayerAsyncRequest {
|
|
|
1743
1781
|
* @throws {RelayerRequestInternalError}
|
|
1744
1782
|
*/
|
|
1745
1783
|
private _throwInternalError(message: string): never {
|
|
1784
|
+
this._logger?.error?.(
|
|
1785
|
+
`[RelayerAsyncRequest] Internal error on ${this._url} (operation=${this._relayerOperation}): ${message}`,
|
|
1786
|
+
undefined,
|
|
1787
|
+
);
|
|
1746
1788
|
throw new RelayerRequestInternalError({
|
|
1747
1789
|
operation: this._relayerOperation,
|
|
1748
1790
|
url: this._url,
|
|
@@ -1758,6 +1800,10 @@ export class RelayerAsyncRequest {
|
|
|
1758
1800
|
*/
|
|
1759
1801
|
private _throwMaxRetryError(params: { fetchMethod: 'GET' | 'POST' }): never {
|
|
1760
1802
|
const elapsed = this._jobIdTimestamp !== undefined ? Date.now() - this._jobIdTimestamp : 0;
|
|
1803
|
+
this._logger?.error?.(
|
|
1804
|
+
`[RelayerAsyncRequest] Max retry count exceeded on ${this._url} (${params.fetchMethod}, operation=${this._relayerOperation}, jobId=${this._jobId}, retryCount=${this._retryCount}, elapsed=${elapsed}ms).`,
|
|
1805
|
+
undefined,
|
|
1806
|
+
);
|
|
1761
1807
|
throw new RelayerMaxRetryError({
|
|
1762
1808
|
operation: this._relayerOperation,
|
|
1763
1809
|
url: this._url,
|
|
@@ -1778,6 +1824,10 @@ export class RelayerAsyncRequest {
|
|
|
1778
1824
|
cause: InvalidPropertyError;
|
|
1779
1825
|
bodyJson: string;
|
|
1780
1826
|
}): never {
|
|
1827
|
+
this._logger?.error?.(
|
|
1828
|
+
`[RelayerAsyncRequest] Unexpected response body on ${this._url} (status=${params.status}, operation=${this._relayerOperation}, jobId=${this._jobId}): ${params.bodyJson}`,
|
|
1829
|
+
params.cause,
|
|
1830
|
+
);
|
|
1781
1831
|
throw new RelayerResponseInvalidBodyError({
|
|
1782
1832
|
...params,
|
|
1783
1833
|
fetchMethod: this._fetchMethod as unknown as RelayerFetchMethod,
|
|
@@ -1795,6 +1845,10 @@ export class RelayerAsyncRequest {
|
|
|
1795
1845
|
* @throws {RelayerFetchError} Always throws.
|
|
1796
1846
|
*/
|
|
1797
1847
|
private _throwFetchError(params: { message: string; cause: unknown }): never {
|
|
1848
|
+
this._logger?.error?.(
|
|
1849
|
+
`[RelayerAsyncRequest] ${params.message} (url=${this._url}, operation=${this._relayerOperation}, jobId=${this._jobId}, retryCount=${this._retryCount})`,
|
|
1850
|
+
params.cause,
|
|
1851
|
+
);
|
|
1798
1852
|
throw new RelayerFetchError({
|
|
1799
1853
|
...params,
|
|
1800
1854
|
elapsed: this._elapsed,
|
|
@@ -1839,5 +1893,6 @@ export class RelayerAsyncRequest {
|
|
|
1839
1893
|
if (this._debug) {
|
|
1840
1894
|
console.log(`[RelayerAsyncRequest]:${functionName}: ${message}`);
|
|
1841
1895
|
}
|
|
1896
|
+
this._logger?.debug?.(`[RelayerAsyncRequest]:${functionName}: ${message}`);
|
|
1842
1897
|
}
|
|
1843
1898
|
}
|
|
@@ -55,6 +55,7 @@ export async function fetchDelegatedUserDecrypt(
|
|
|
55
55
|
url,
|
|
56
56
|
payload: relayerPayload,
|
|
57
57
|
options,
|
|
58
|
+
logger: relayerClient.runtime.config.logger,
|
|
58
59
|
});
|
|
59
60
|
|
|
60
61
|
const result: FetchDelegatedUserDecryptResult = (await request.run()) as FetchDelegatedUserDecryptResult;
|