Skip to content

Commit

Permalink
fix: remove no used code and fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
bradleySuira committed Jul 31, 2024
1 parent 375028c commit 106639c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
17 changes: 1 addition & 16 deletions frontend/src/utils/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { getAccountFromPrivatekey } from './accounts'
import {
createWalletClient,
http,
recoverTransactionAddress,
serializeTransaction as _serializeTransaction,
type TransactionSerializedLegacy
serializeTransaction as _serializeTransaction
} from 'viem'
import { mainnet } from 'viem/chains'

Expand All @@ -18,19 +16,6 @@ export async function signTransaction(privateKey: `0x${string}`, data: any) {
return account.signTransaction({ ...data, type: 'legacy' })
}

export async function getSignedTransactionAddress(
signedTransaction:
| `0x02${string}`
| `0x01${string}`
| `0x03${string}`
| TransactionSerializedLegacy
) {
return await recoverTransactionAddress({
serializedTransaction: signedTransaction
})
}


export async function serializeTransaction (data: any) {
return _serializeTransaction({
...data,
Expand Down
6 changes: 4 additions & 2 deletions frontend/test/unit/services/signTransaction.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { recoverTransactionAddress } from 'viem'
import {
signTransaction,
getPrivateKey,
getAccountFromPrivatekey,
getSignedTransactionAddress
} from '../../../src/utils'
import { describe, expect, it, vi, afterEach, beforeEach } from 'vitest'

Expand All @@ -26,7 +26,9 @@ describe('SignTransaction', () => {
it('it should sign a transaction and verify', async () => {
const signedTransaction = await signTransaction(privateKey, data)
const account = getAccountFromPrivatekey(privateKey)
const txAddress = await getSignedTransactionAddress(signedTransaction)
const txAddress = await recoverTransactionAddress({
serializedTransaction: signedTransaction
})
expect(txAddress).to.deep.equal(account.address)
})
})
Expand Down

0 comments on commit 106639c

Please sign in to comment.