Skip to content

Commit

Permalink
Remove unnecessary createMultiMsgTransactionPayload fn
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianBorst committed Aug 17, 2023
1 parent 97be69e commit dc95d9f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 32 deletions.
4 changes: 2 additions & 2 deletions packages/transactions/src/messages/bank/send.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createMsgSend as protoCreateMsgSend } from '@althea-net/proto'
import { createMsgSend } from '@althea-net/eip712'
import { createMultiMsgTransactionPayload, TxContext, wrapTypeToArray } from '../base'
import { createTransactionPayload, TxContext, wrapTypeToArray } from '../base'
import { generateTypes, MSG_SEND_TYPES } from '@althea-net/eip712'

export const createEIP712MsgSend = (context: TxContext, params: MsgSendParams[]) => {
Expand Down Expand Up @@ -55,5 +55,5 @@ export const createTxMsgSend = (context: TxContext, params: MsgSendParams | MsgS
const typedData = createEIP712MsgSend(context, multiparams)
const cosmosMsg = createCosmosMsgSend(context, multiparams)

return createMultiMsgTransactionPayload(context, typedData, cosmosMsg)
return createTransactionPayload(context, typedData, cosmosMsg)
}
40 changes: 10 additions & 30 deletions packages/transactions/src/messages/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,22 @@ export const createCosmosPayload = (
}

/**
* Creates a signable transaction with SignDirect,
* LegacyAmino, and EIP-712 components.
* Creates a signable transaction with SignDirect, LegacyAmino, and EIP-712 components.
* Supports multiple Msgs of the same type (must be in typedData AND cosmosMessages)
*
* @param context - Transaction Context
* @param typedData - EIP-712 Typed Data
* @param cosmosMessage - Cosmos SDK Message to sign
* @returns Signable Payload
*
* @param cosmosMessages - Cosmos SDK Message(s) to sign
* @returns Signable Payload with EIP712 types, Sign Direct + Legacy Amino
*/
export const createTransactionPayload = (
context: TxContext,
typedData: EIP712TypedData,
cosmosMessage: any, // TODO: re-export Protobuf Message type from /proto
cosmosMessages: any | any[], // TODO: re-export Protobuf Message type from /proto
): TxPayload => {
const eip712Payload = createLegacyEIP712Payload(context, typedData)

const cosmosPayload = createCosmosPayload(context, cosmosMessage)
const cosmosPayload = createCosmosPayload(context, cosmosMessages)

return {
signDirect: cosmosPayload.signDirect,
Expand All @@ -145,32 +144,13 @@ export const createTransactionPayload = (
}

/**
* Creates a transaction payload for multiple messages, see createTransactionPayload
* Note only works for messages of the same type, multi-type signing requires a chain upgrade
* in which case newCreateTransacitonPayload might do the job
* Creates an EIP712-compatible transaction payload using the new multi-msg type version of
* EIP712 (NOT YET SUPPORTED BY ALTHEA-L1, requires a feature backport)
*
* @param context - Transaction Context
* @param typedData - EIP-712 Typed Data with multiple messages of the same type
* @param cosmosMessage - Cosmos SDK Messages to sign (all of the same type)
* @returns Signable Payload
*
* @param messages - Protobuf-encoded message(s)
* @returns Signable Payload with EIP712 types, Sign Direct + Legacy Amino
*/
export const createMultiMsgTransactionPayload = (
context: TxContext,
typedData: EIP712TypedData,
cosmosMessages: any, // TODO: re-export Protobuf Message type from /proto
): TxPayload => {
const eip712Payload = createLegacyEIP712Payload(context, typedData)

const cosmosPayload = createCosmosPayload(context, cosmosMessages)

return {
signDirect: cosmosPayload.signDirect,
legacyAmino: cosmosPayload.legacyAmino,
eipToSign: eip712Payload,
}
}

export const newCreateTransactionPayload = (
context: TxContext,
messages: MessageGenerated | MessageGenerated[],
Expand Down

0 comments on commit dc95d9f

Please sign in to comment.