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

Humanizer: singleton factory #1031

Merged
merged 2 commits into from
Oct 14, 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
5 changes: 5 additions & 0 deletions src/consts/humanizer/humanizerInfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -87489,6 +87489,11 @@
},
"isSC": {},
"logo": "https://raw.githubusercontent.com/MetaMask/contract-metadata/master/images/hoppy.svg"
},
"0xce0042b868300000d44a59004da54a005ffdcf9f": {
"address": "0xce0042b868300000d44a59004da54a005ffdcf9f",
"name": "Contract Factory",
"isSC": {}
}
}
}
2 changes: 2 additions & 0 deletions src/libs/humanizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import legendsModule from './modules/Legends'
import { postProcessing } from './modules/PostProcessing/postProcessModule'
import preProcessHumanizer from './modules/PreProcess'
import privilegeHumanizer from './modules/Privileges'
import singletonFactory from './modules/SingletonFactory'
import { SocketModule } from './modules/Socket'
import sushiSwapModule from './modules/Sushiswap'
import { genericErc20Humanizer, genericErc721Humanizer } from './modules/Tokens'
Expand Down Expand Up @@ -51,6 +52,7 @@ export const humanizerCallModules: HumanizerCallModule[] = [
privilegeHumanizer,
sushiSwapModule,
legendsModule,
singletonFactory,
fallbackHumanizer,
postProcessing
]
Expand Down
3 changes: 3 additions & 0 deletions src/libs/humanizer/modules/SingletonFactory/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { singletonFactory } from './singletonFactory'

export default singletonFactory

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions src/libs/humanizer/modules/SingletonFactory/singletonFactory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { getAddress, Interface } from 'ethers'

import { AccountOp } from '../../../accountOp/accountOp'
import { HumanizerCallModule, IrCall } from '../../interfaces'
import { getAction, getAddressVisualization, getLabel } from '../../utils'

const CONTRACT_FACTORY_ADDRESS = '0xce0042B868300000d44A59004Da54A005ffdcf9f'
export const singletonFactory: HumanizerCallModule = (_: AccountOp, irCalls: IrCall[]) => {
const iface = new Interface(['function deploy(bytes,bytes32)'])
const newCalls = irCalls.map((call) => {
// @TODO fix those upper/lowercase
if (
getAddress(call.to) === CONTRACT_FACTORY_ADDRESS &&
call.data.slice(0, 10) === iface.getFunction('deploy')!.selector
) {
return {
...call,
fullVisualization: [
getAction('Deploy a contract'),
getLabel('via'),
getAddressVisualization(CONTRACT_FACTORY_ADDRESS)
]
}
}
return call
})
return newCalls
}
Loading