This is a pretty complicated and ethers.js seems to handle it perfectly!
Note that I have some long lines here... with the data URI I don't think it really matters, and with the test declarations I figured they were more readable on one line. Can change either if preferred.
Depends on D7045