Skip to content

Commit

Permalink
Merge pull request #37 from Once-Upon/benguyen0214/ou-1757-rely-on-vi…
Browse files Browse the repository at this point in the history
…em-in-utility-repo-for-transformers-asset

Rely on viem in utility repo for transformers asset
  • Loading branch information
pcowgill authored Mar 19, 2024
2 parents a0223b3 + 1bf6ff1 commit a9f300c
Show file tree
Hide file tree
Showing 5 changed files with 416 additions and 216 deletions.
197 changes: 197 additions & 0 deletions src/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,170 @@ export const CRYPTO_PUNKS_ADDRESSES = [
'0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb', // CRYPTOPUNKS_NEW
];

export const ERC721_TRANSFER_EVENT = [
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'address',
name: 'from',
type: 'address',
},
{
indexed: true,
internalType: 'address',
name: 'to',
type: 'address',
},
{
indexed: true,
internalType: 'uint256',
name: 'tokenId',
type: 'uint256',
},
],
name: 'Transfer',
type: 'event',
},
] as const;

export const ERC20_TRANSFER_EVENT = [
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'address',
name: 'from',
type: 'address',
},
{
indexed: true,
internalType: 'address',
name: 'to',
type: 'address',
},
{
indexed: false,
internalType: 'uint256',
name: 'value',
type: 'uint256',
},
],
name: 'Transfer',
type: 'event',
},
] as const;

export const ERC1155_TRANSFER_EVENT = [
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'address',
name: 'operator',
type: 'address',
},
{
indexed: true,
internalType: 'address',
name: 'from',
type: 'address',
},
{
indexed: true,
internalType: 'address',
name: 'to',
type: 'address',
},
{
indexed: false,
internalType: 'uint256',
name: 'id',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'value',
type: 'uint256',
},
],
name: 'TransferSingle',
type: 'event',
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'address',
name: 'operator',
type: 'address',
},
{
indexed: true,
internalType: 'address',
name: 'from',
type: 'address',
},
{
indexed: true,
internalType: 'address',
name: 'to',
type: 'address',
},
{
indexed: false,
internalType: 'uint256[]',
name: 'ids',
type: 'uint256[]',
},
{
indexed: false,
internalType: 'uint256[]',
name: 'values',
type: 'uint256[]',
},
],
name: 'TransferBatch',
type: 'event',
},
] as const;

export const WETH_EVENTS = [
{
anonymous: false,
inputs: [
{ indexed: true, name: 'dst', type: 'address' },
{ indexed: false, name: 'wad', type: 'uint256' },
],
name: 'Deposit',
type: 'event',
},
{
anonymous: false,
inputs: [
{ indexed: true, name: 'src', type: 'address' },
{ indexed: false, name: 'wad', type: 'uint256' },
],
name: 'Withdrawal',
type: 'event',
},
{
anonymous: false,
inputs: [
{ indexed: true, name: 'src', type: 'address' },
{ indexed: true, name: 'dst', type: 'address' },
{ indexed: false, name: 'wad', type: 'uint256' },
],
name: 'Transfer',
type: 'event',
},
] as const;

export const ERC721_TRANSFER_EVENT_1 = [
{
anonymous: false,
Expand Down Expand Up @@ -470,6 +634,39 @@ export const ERC721_TRANSFER_EVENT_2 = [
},
] as const;

export const CRYPTO_PUNKS_TRANSFER_EVENTS = [
{
anonymous: false,
inputs: [
{ indexed: true, name: 'from', type: 'address' },
{ indexed: true, name: 'to', type: 'address' },
{ indexed: false, name: 'punkIndex', type: 'uint256' },
],
name: 'PunkTransfer',
type: 'event',
},
{
anonymous: false,
inputs: [
{ indexed: true, name: 'punkIndex', type: 'uint256' },
{ indexed: false, name: 'value', type: 'uint256' },
{ indexed: true, name: 'fromAddress', type: 'address' },
{ indexed: true, name: 'toAddress', type: 'address' },
],
name: 'PunkBought',
type: 'event',
},
{
anonymous: false,
inputs: [
{ indexed: true, name: 'to', type: 'address' },
{ indexed: false, name: 'punkIndex', type: 'uint256' },
],
name: 'Assign',
type: 'event',
},
] as const;

export const PROXY_IMPLEMENTATION_METHOD_SIGNATURES = [
'implementation()',
'IMPL()',
Expand Down
20 changes: 19 additions & 1 deletion src/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
GOVERNOR_METHODS,
SAFE_METHODS,
} from './constants';
import { RawBlock, StdObj } from '../types';
import { EventLogTopics, RawBlock, StdObj } from '../types';
import { Abi, Hex, decodeEventLog } from 'viem';

export const makeTransform = (
children: Record<string, (block: RawBlock) => RawBlock>,
Expand Down Expand Up @@ -186,3 +187,20 @@ export function loadBlockFixture(
const block = normalizeBlock(rawBlock);
return block;
}

export function decodeLog<TAbi extends Abi>(
abi: TAbi,
data: Hex,
topics: EventLogTopics,
) {
try {
const result = decodeEventLog({
abi,
data,
topics,
});
return result;
} catch (err) {
return null;
}
}
Loading

0 comments on commit a9f300c

Please sign in to comment.