-
-
Notifications
You must be signed in to change notification settings - Fork 821
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: added assertion to check for existence of a signature on `topics…
…` for `decodeEventLog` (#205) * fix: added assertion to check for existence of event signature on topics * fix: log type * tests: update snapshots
- Loading branch information
Showing
9 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"viem": patch | ||
--- | ||
|
||
Added an assertion to check for existence of an event signature on `topics` for `decodeEventLog` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ import { | |
AbiDecodingDataSizeInvalidError, | ||
AbiEncodingArrayLengthMismatchError, | ||
AbiEncodingLengthMismatchError, | ||
AbiEventSignatureEmptyTopicsError, | ||
DecodeLogTopicsMismatch, | ||
InvalidAbiDecodingTypeError, | ||
InvalidAbiEncodingTypeError, | ||
|
@@ -61,6 +62,17 @@ test('AbiEncodingLengthMismatchError', () => { | |
`) | ||
}) | ||
|
||
test('AbiEventSignatureEmptyTopicsError', () => { | ||
expect( | ||
new AbiEventSignatureEmptyTopicsError({ docsPath: '/test' }), | ||
).toMatchInlineSnapshot(` | ||
[AbiEventSignatureEmptyTopicsError: Cannot extract event signature from empty topics. | ||
Docs: https://viem.sh/test.html | ||
Version: [email protected]] | ||
`) | ||
}) | ||
|
||
describe('DecodeLogTopicsMismatch', () => { | ||
test('default', () => { | ||
expect( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -522,3 +522,29 @@ test("errors: event doesn't exist", () => { | |
Version: [email protected]" | ||
`) | ||
}) | ||
|
||
test('errors: no topics', () => { | ||
expect(() => | ||
decodeEventLog({ | ||
abi: [ | ||
{ | ||
inputs: [ | ||
{ | ||
indexed: true, | ||
name: 'message', | ||
type: 'string', | ||
}, | ||
], | ||
name: 'Bar', | ||
type: 'event', | ||
}, | ||
], | ||
topics: [], | ||
}), | ||
).toThrowErrorMatchingInlineSnapshot(` | ||
"Cannot extract event signature from empty topics. | ||
Docs: https://viem.sh/docs/contract/decodeEventLog.html | ||
Version: [email protected]" | ||
`) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36fa97a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
viem-playground – ./playgrounds/browser
viem-playground-wagmi-dev.vercel.app
viem-playground.vercel.app
viem-playground-git-main-wagmi-dev.vercel.app
36fa97a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
viem – ./site
viem.vercel.app
www.viem.sh
viem-git-main-wagmi-dev.vercel.app
viem-wagmi-dev.vercel.app
viem-site.vercel.app
viem.sh