From 535f2b86d0e48261d981f3be63bb7c5f35104092 Mon Sep 17 00:00:00 2001 From: Dani Somoza Date: Mon, 2 Dec 2024 12:40:12 +0100 Subject: [PATCH] feat: add SignatureType type (#1061) --- guides/integrating-the-safe-core-sdk.md | 2 +- .../src/types/safeTransactionServiceTypes.ts | 5 +++-- .../tests/e2e/offChainSignatures.test.ts | 4 ++-- .../src/packs/safe-4337/testing-utils/fixtures.ts | 3 ++- packages/types-kit/src/types.ts | 13 +++++++++++-- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/guides/integrating-the-safe-core-sdk.md b/guides/integrating-the-safe-core-sdk.md index 03927ebe5..d96eeca33 100644 --- a/guides/integrating-the-safe-core-sdk.md +++ b/guides/integrating-the-safe-core-sdk.md @@ -291,7 +291,7 @@ type SafeMultisigTransactionResponse = { transactionHash?: string confirmationType?: string signature: string - signatureType?: string + signatureType?: SignatureType }, // ... ] diff --git a/packages/api-kit/src/types/safeTransactionServiceTypes.ts b/packages/api-kit/src/types/safeTransactionServiceTypes.ts index 5b75d0147..6a044b7ad 100644 --- a/packages/api-kit/src/types/safeTransactionServiceTypes.ts +++ b/packages/api-kit/src/types/safeTransactionServiceTypes.ts @@ -4,7 +4,8 @@ import { SafeTransactionData, UserOperation, SafeOperationResponse, - ListResponse + ListResponse, + SignatureType } from '@safe-global/types-kit' export type ListOptions = { @@ -231,7 +232,7 @@ export type SafeMessageConfirmation = { readonly modified: string readonly owner: string readonly signature: string - readonly signatureType: string + readonly signatureType: SignatureType } export type SafeMessage = { diff --git a/packages/protocol-kit/tests/e2e/offChainSignatures.test.ts b/packages/protocol-kit/tests/e2e/offChainSignatures.test.ts index aedf90d3e..c1f02b86d 100644 --- a/packages/protocol-kit/tests/e2e/offChainSignatures.test.ts +++ b/packages/protocol-kit/tests/e2e/offChainSignatures.test.ts @@ -311,7 +311,7 @@ describe('Off-chain signatures', () => { transactionHash: '', confirmationType: '', signature: '0x111111', - signatureType: '' + signatureType: 'EOA' }, { owner: '0x2222222222222222222222222222222222222222', @@ -319,7 +319,7 @@ describe('Off-chain signatures', () => { transactionHash: '', confirmationType: '', signature: '0x222222', - signatureType: '' + signatureType: 'EOA' } ], trusted: true, diff --git a/packages/relay-kit/src/packs/safe-4337/testing-utils/fixtures.ts b/packages/relay-kit/src/packs/safe-4337/testing-utils/fixtures.ts index 706238353..b2304d729 100644 --- a/packages/relay-kit/src/packs/safe-4337/testing-utils/fixtures.ts +++ b/packages/relay-kit/src/packs/safe-4337/testing-utils/fixtures.ts @@ -1,3 +1,4 @@ +import { SignatureTypes } from '@safe-global/types-kit' import { ENTRYPOINT_ADDRESS_V06, ENTRYPOINT_ADDRESS_V07 } from '../constants' export const OWNER_1 = '0xFfAC5578BE8AC1B2B9D13b34cAf4A074B96B8A1b' @@ -109,7 +110,7 @@ export const SAFE_OPERATION_RESPONSE = { owner: '0x3059EfD1BCe33be41eeEfd5fb6D520d7fEd54E43', signature: '0xcb28e74375889e400a4d8aca46b8c59e1cf8825e373c26fa99c2fd7c078080e64fe30eaf1125257bdfe0b358b5caef68aa0420478145f52decc8e74c979d43ab1d', - signatureType: 'EOA' + signatureType: SignatureTypes.EOA } ], preparedSignature: diff --git a/packages/types-kit/src/types.ts b/packages/types-kit/src/types.ts index 839e9635a..cec7c4ca5 100644 --- a/packages/types-kit/src/types.ts +++ b/packages/types-kit/src/types.ts @@ -188,13 +188,22 @@ export interface EIP712TypedData { primaryType?: string } +export const SignatureTypes = { + CONTRACT_SIGNATURE: 'CONTRACT_SIGNATURE', + EOA: 'EOA', + APPROVED_HASH: 'APPROVED_HASH', + ETH_SIGN: 'ETH_SIGN' +} as const + +export type SignatureType = (typeof SignatureTypes)[keyof typeof SignatureTypes] + export type SafeMultisigConfirmationResponse = { readonly owner: string readonly submissionDate: string readonly transactionHash?: string readonly confirmationType?: string readonly signature: string - readonly signatureType?: string + readonly signatureType: SignatureType } export type ListResponse = { @@ -313,7 +322,7 @@ export type SafeOperationConfirmation = { readonly modified: string readonly owner: string readonly signature: string - readonly signatureType: string + readonly signatureType: SignatureType } export type UserOperationResponse = {