|
1 | 1 | import { assertType, describe, expect, test } from 'vitest' |
2 | 2 |
|
| 3 | +import { waitForTransactionReceipt } from '../../actions/public/waitForTransactionReceipt.js' |
| 4 | +import { base } from '../../chains/index.js' |
| 5 | +import { createClient } from '../../clients/createClient.js' |
| 6 | +import { http } from '../../clients/transports/http.js' |
3 | 7 | import { getAddress } from '../address/getAddress.js' |
4 | 8 | import { toEventSelector } from '../hash/toEventSelector.js' |
5 | | - |
6 | 9 | import { decodeEventLog } from './decodeEventLog.js' |
7 | 10 |
|
8 | 11 | test('Transfer()', () => { |
@@ -193,7 +196,7 @@ test('unnamed args: mixed ordering of indexed args', () => { |
193 | 196 | ], |
194 | 197 | data: '0x0000000000000000000000000000000000000000000000000000000000000001', |
195 | 198 | topics: [ |
196 | | - '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', |
| 199 | + '0x138dbc8474f748db86063dcef24cef1495bc73385a946f8d691128085e5ebec2', |
197 | 200 | '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac', |
198 | 201 | '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac', |
199 | 202 | ], |
@@ -908,6 +911,69 @@ describe('GitHub repros', () => { |
908 | 911 | ) |
909 | 912 | }) |
910 | 913 | }) |
| 914 | + |
| 915 | + test('https://github.com/wevm/viem/issues/3705', async () => { |
| 916 | + const client = createClient({ |
| 917 | + chain: base, |
| 918 | + transport: http(), |
| 919 | + }) |
| 920 | + |
| 921 | + const receipt = await waitForTransactionReceipt(client, { |
| 922 | + hash: '0xbee3f576c43a29d3c924cd46ff1ff42489eceae5e8e31afdbba8f982c8291a76', |
| 923 | + }) |
| 924 | + |
| 925 | + const decoded = receipt.logs |
| 926 | + .map((log) => { |
| 927 | + try { |
| 928 | + return decodeEventLog({ |
| 929 | + ...log, |
| 930 | + abi: [ |
| 931 | + { |
| 932 | + type: 'event', |
| 933 | + name: 'PetRegistered', |
| 934 | + inputs: [ |
| 935 | + { |
| 936 | + name: 'petId', |
| 937 | + type: 'uint256', |
| 938 | + indexed: true, |
| 939 | + internalType: 'uint256', |
| 940 | + }, |
| 941 | + { |
| 942 | + name: 'user', |
| 943 | + type: 'address', |
| 944 | + indexed: true, |
| 945 | + internalType: 'address', |
| 946 | + }, |
| 947 | + ], |
| 948 | + anonymous: false, |
| 949 | + }, |
| 950 | + ], |
| 951 | + }) |
| 952 | + } catch { |
| 953 | + return null |
| 954 | + } |
| 955 | + }) |
| 956 | + .filter((log) => log?.eventName === 'PetRegistered') |
| 957 | + |
| 958 | + expect(decoded).toMatchInlineSnapshot(` |
| 959 | + [ |
| 960 | + { |
| 961 | + "args": { |
| 962 | + "petId": 75574n, |
| 963 | + "user": "0x03998b821AB247677a034762CA7F99fACF227975", |
| 964 | + }, |
| 965 | + "eventName": "PetRegistered", |
| 966 | + }, |
| 967 | + { |
| 968 | + "args": { |
| 969 | + "petId": 75575n, |
| 970 | + "user": "0x03998b821AB247677a034762CA7F99fACF227975", |
| 971 | + }, |
| 972 | + "eventName": "PetRegistered", |
| 973 | + }, |
| 974 | + ] |
| 975 | + `) |
| 976 | + }) |
911 | 977 | }) |
912 | 978 |
|
913 | 979 | test("errors: event doesn't exist", () => { |
|
0 commit comments