Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete signMessage decoding #567

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
ContractRegistry,
InputType,
Intents,
MessageInput,
PERMIT2_ADDRESS,
TransactionStatus,
WalletType
Expand Down Expand Up @@ -269,20 +268,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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought raw and typed data would also be removed. Maybe I misunderstood something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to remove them. Problem is that changes rego evaluation, because rego uses the result of intent decoding for typed Data. So I'm gonna do it after I merged regal PR. I could have done it for raw here, but I'd rather just limit this PR to signMessage because it's the scope of the bug. Then I'll do the two others in a subsequent one once regal is merged


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