Skip to content

Commit

Permalink
delete signMessage decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Ptroger committed Oct 23, 2024
1 parent 3a72c9c commit 60cd4f7
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,20 +269,6 @@ describe('decode', () => {
})
})
describe('message and typed data input', () => {
it('decodes message', () => {
const message = 'Hello, world!'
const prefixedMessage = `\x19Ethereum Signed Message:\n${message.length}${message}`
const input: MessageInput = {
type: InputType.MESSAGE,
payload: prefixedMessage
}

const decoded = decode({ input })
expect(decoded).toEqual({
type: Intents.SIGN_MESSAGE,
message
})
})
it('decodes typed data', () => {
const decoded = decode({
input: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { Intent, TypedDataIntent } from '../intent.types'
import { MethodsMapping, SUPPORTED_METHODS } from '../supported-methods'
import { isSupportedMethodId } from '../typeguards'
import {
decodeMessage,
decodePermit,
decodePermit2,
decodeTypedData,
Expand Down Expand Up @@ -143,8 +142,6 @@ const decode = ({ input, config = defaultConfig }: { input: DecodeInput; config?
}
case InputType.TYPED_DATA:
return decodeTypedDataInput(input)
case InputType.MESSAGE:
return decodeMessage(input)
case InputType.RAW:
return {
type: Intents.SIGN_RAW,
Expand Down
8 changes: 1 addition & 7 deletions packages/transaction-request-intent/src/lib/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ export type Raw = {
algorithm: Alg
}

export type MessageInput = {
type: InputType.MESSAGE
payload: string
}

export type RawInput = {
type: InputType.RAW
raw: Raw
Expand Down Expand Up @@ -83,7 +78,7 @@ export type Config = {
transactionRegistry?: TransactionRegistry
supportedMethods?: MethodsMapping
}
export type DecodeInput = TransactionInput | MessageInput | RawInput | TypedDataInput
export type DecodeInput = TransactionInput | RawInput | TypedDataInput

type DecodeSuccess = {
success: true
Expand All @@ -103,7 +98,6 @@ export type SafeDecodeOutput = DecodeSuccess | DecodeError

export enum InputType {
TRANSACTION_REQUEST = 'transactionRequest',
MESSAGE = 'message',
TYPED_DATA = 'typedData',
RAW = 'raw'
}
Expand Down
11 changes: 0 additions & 11 deletions packages/transaction-request-intent/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
ContractRegistry,
ContractRegistryInput,
Intents,
MessageInput,
Misc,
NULL_METHOD_ID,
NativeTransferInput,
Expand Down Expand Up @@ -184,16 +183,6 @@ export const decodeTypedData = (typedData: Eip712TypedData): SignTypedData => ({
})
})

export const decodeMessage = (message: MessageInput): SignMessage => {
if (!message.payload.startsWith(presignMessagePrefix)) {
throw new DecoderError({ message: 'Invalid message prefix', status: 400 })
}
return {
type: Intents.SIGN_MESSAGE,
message: message.payload.slice(presignMessagePrefix.length + 2)
}
}

export const decodePermit = (typedData: Eip712TypedData): Permit | null => {
const { chainId, verifyingContract } = typedData.domain
if (!isPermit(typedData.message) || !chainId || !verifyingContract) {
Expand Down

0 comments on commit 60cd4f7

Please sign in to comment.